documentation.d.ts 3.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549
  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. readonly 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 readonly 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 LogLevels: 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 readonly 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. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  482. /**
  483. * Returns client's state
  484. */
  485. readonly readyState: number;
  486. /**
  487. * Returns client's status
  488. */
  489. readonly status: number;
  490. /**
  491. * Returns client's status as a text
  492. */
  493. readonly statusText: string;
  494. /**
  495. * Returns client's response
  496. */
  497. readonly response: any;
  498. /**
  499. * Returns client's response url
  500. */
  501. readonly responseURL: string;
  502. /**
  503. * Returns client's response as text
  504. */
  505. readonly responseText: string;
  506. /**
  507. * Gets or sets the expected response type
  508. */
  509. responseType: XMLHttpRequestResponseType;
  510. /** @hidden */
  511. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  512. /** @hidden */
  513. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  514. /**
  515. * Cancels any network activity
  516. */
  517. abort(): void;
  518. /**
  519. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  520. * @param body defines an optional request body
  521. */
  522. send(body?: Document | BodyInit | null): void;
  523. /**
  524. * Sets the request method, request URL
  525. * @param method defines the method to use (GET, POST, etc..)
  526. * @param url defines the url to connect with
  527. */
  528. open(method: string, url: string): void;
  529. /**
  530. * Sets the value of a request header.
  531. * @param name The name of the header whose value is to be set
  532. * @param value The value to set as the body of the header
  533. */
  534. setRequestHeader(name: string, value: string): void;
  535. /**
  536. * Get the string containing the text of a particular header's value.
  537. * @param name The name of the header
  538. * @returns The string containing the text of the given header name
  539. */
  540. getResponseHeader(name: string): Nullable<string>;
  541. }
  542. }
  543. declare module BABYLON {
  544. /**
  545. * File request interface
  546. */
  547. export interface IFileRequest {
  548. /**
  549. * Raised when the request is complete (success or error).
  550. */
  551. onCompleteObservable: Observable<IFileRequest>;
  552. /**
  553. * Aborts the request for a file.
  554. */
  555. abort: () => void;
  556. }
  557. }
  558. declare module BABYLON {
  559. /**
  560. * Define options used to create a render target texture
  561. */
  562. export class RenderTargetCreationOptions {
  563. /**
  564. * Specifies is mipmaps must be generated
  565. */
  566. generateMipMaps?: boolean;
  567. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  568. generateDepthBuffer?: boolean;
  569. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  570. generateStencilBuffer?: boolean;
  571. /** Defines texture type (int by default) */
  572. type?: number;
  573. /** Defines sampling mode (trilinear by default) */
  574. samplingMode?: number;
  575. /** Defines format (RGBA by default) */
  576. format?: number;
  577. }
  578. }
  579. declare module BABYLON {
  580. /**
  581. * @hidden
  582. **/
  583. export class _TimeToken {
  584. _startTimeQuery: Nullable<WebGLQuery>;
  585. _endTimeQuery: Nullable<WebGLQuery>;
  586. _timeElapsedQuery: Nullable<WebGLQuery>;
  587. _timeElapsedQueryEnded: boolean;
  588. }
  589. }
  590. declare module BABYLON {
  591. /** Defines the cross module used constants to avoid circular dependncies */
  592. export class Constants {
  593. /** Defines that alpha blending is disabled */
  594. static readonly ALPHA_DISABLE: number;
  595. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  596. static readonly ALPHA_ADD: number;
  597. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  598. static readonly ALPHA_COMBINE: number;
  599. /** Defines that alpha blending to DEST - SRC * DEST */
  600. static readonly ALPHA_SUBTRACT: number;
  601. /** Defines that alpha blending to SRC * DEST */
  602. static readonly ALPHA_MULTIPLY: number;
  603. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  604. static readonly ALPHA_MAXIMIZED: number;
  605. /** Defines that alpha blending to SRC + DEST */
  606. static readonly ALPHA_ONEONE: number;
  607. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  608. static readonly ALPHA_PREMULTIPLIED: number;
  609. /**
  610. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  611. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  612. */
  613. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  614. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  615. static readonly ALPHA_INTERPOLATE: number;
  616. /**
  617. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  618. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_SCREENMODE: number;
  621. /**
  622. * Defines that alpha blending to SRC + DST
  623. * Alpha will be set to SRC ALPHA + DST ALPHA
  624. */
  625. static readonly ALPHA_ONEONE_ONEONE: number;
  626. /**
  627. * Defines that alpha blending to SRC * DST ALPHA + DST
  628. * Alpha will be set to 0
  629. */
  630. static readonly ALPHA_ALPHATOCOLOR: number;
  631. /**
  632. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  633. */
  634. static readonly ALPHA_REVERSEONEMINUS: number;
  635. /**
  636. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  637. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  638. */
  639. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  640. /**
  641. * Defines that alpha blending to SRC + DST
  642. * Alpha will be set to SRC ALPHA
  643. */
  644. static readonly ALPHA_ONEONE_ONEZERO: number;
  645. /** Defines that alpha blending equation a SUM */
  646. static readonly ALPHA_EQUATION_ADD: number;
  647. /** Defines that alpha blending equation a SUBSTRACTION */
  648. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  649. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  650. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  651. /** Defines that alpha blending equation a MAX operation */
  652. static readonly ALPHA_EQUATION_MAX: number;
  653. /** Defines that alpha blending equation a MIN operation */
  654. static readonly ALPHA_EQUATION_MIN: number;
  655. /**
  656. * Defines that alpha blending equation a DARKEN operation:
  657. * It takes the min of the src and sums the alpha channels.
  658. */
  659. static readonly ALPHA_EQUATION_DARKEN: number;
  660. /** Defines that the ressource is not delayed*/
  661. static readonly DELAYLOADSTATE_NONE: number;
  662. /** Defines that the ressource was successfully delay loaded */
  663. static readonly DELAYLOADSTATE_LOADED: number;
  664. /** Defines that the ressource is currently delay loading */
  665. static readonly DELAYLOADSTATE_LOADING: number;
  666. /** Defines that the ressource is delayed and has not started loading */
  667. static readonly DELAYLOADSTATE_NOTLOADED: number;
  668. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  669. static readonly NEVER: number;
  670. /** 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 */
  671. static readonly ALWAYS: number;
  672. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  673. static readonly LESS: number;
  674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  675. static readonly EQUAL: number;
  676. /** 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 */
  677. static readonly LEQUAL: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  679. static readonly GREATER: number;
  680. /** 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 */
  681. static readonly GEQUAL: number;
  682. /** 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 */
  683. static readonly NOTEQUAL: number;
  684. /** Passed to stencilOperation to specify that stencil value must be kept */
  685. static readonly KEEP: number;
  686. /** Passed to stencilOperation to specify that stencil value must be replaced */
  687. static readonly REPLACE: number;
  688. /** Passed to stencilOperation to specify that stencil value must be incremented */
  689. static readonly INCR: number;
  690. /** Passed to stencilOperation to specify that stencil value must be decremented */
  691. static readonly DECR: number;
  692. /** Passed to stencilOperation to specify that stencil value must be inverted */
  693. static readonly INVERT: number;
  694. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  695. static readonly INCR_WRAP: number;
  696. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  697. static readonly DECR_WRAP: number;
  698. /** Texture is not repeating outside of 0..1 UVs */
  699. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  700. /** Texture is repeating outside of 0..1 UVs */
  701. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  702. /** Texture is repeating and mirrored */
  703. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  704. /** ALPHA */
  705. static readonly TEXTUREFORMAT_ALPHA: number;
  706. /** LUMINANCE */
  707. static readonly TEXTUREFORMAT_LUMINANCE: number;
  708. /** LUMINANCE_ALPHA */
  709. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  710. /** RGB */
  711. static readonly TEXTUREFORMAT_RGB: number;
  712. /** RGBA */
  713. static readonly TEXTUREFORMAT_RGBA: number;
  714. /** RED */
  715. static readonly TEXTUREFORMAT_RED: number;
  716. /** RED (2nd reference) */
  717. static readonly TEXTUREFORMAT_R: number;
  718. /** RG */
  719. static readonly TEXTUREFORMAT_RG: number;
  720. /** RED_INTEGER */
  721. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  722. /** RED_INTEGER (2nd reference) */
  723. static readonly TEXTUREFORMAT_R_INTEGER: number;
  724. /** RG_INTEGER */
  725. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  726. /** RGB_INTEGER */
  727. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  728. /** RGBA_INTEGER */
  729. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  730. /** UNSIGNED_BYTE */
  731. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  732. /** UNSIGNED_BYTE (2nd reference) */
  733. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  734. /** FLOAT */
  735. static readonly TEXTURETYPE_FLOAT: number;
  736. /** HALF_FLOAT */
  737. static readonly TEXTURETYPE_HALF_FLOAT: number;
  738. /** BYTE */
  739. static readonly TEXTURETYPE_BYTE: number;
  740. /** SHORT */
  741. static readonly TEXTURETYPE_SHORT: number;
  742. /** UNSIGNED_SHORT */
  743. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  744. /** INT */
  745. static readonly TEXTURETYPE_INT: number;
  746. /** UNSIGNED_INT */
  747. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  748. /** UNSIGNED_SHORT_4_4_4_4 */
  749. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  750. /** UNSIGNED_SHORT_5_5_5_1 */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  752. /** UNSIGNED_SHORT_5_6_5 */
  753. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  754. /** UNSIGNED_INT_2_10_10_10_REV */
  755. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  756. /** UNSIGNED_INT_24_8 */
  757. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  758. /** UNSIGNED_INT_10F_11F_11F_REV */
  759. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  760. /** UNSIGNED_INT_5_9_9_9_REV */
  761. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  762. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  763. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  764. /** nearest is mag = nearest and min = nearest and mip = nearest */
  765. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  766. /** Bilinear is mag = linear and min = linear and mip = nearest */
  767. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  768. /** Trilinear is mag = linear and min = linear and mip = linear */
  769. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  770. /** nearest is mag = nearest and min = nearest and mip = linear */
  771. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  772. /** Bilinear is mag = linear and min = linear and mip = nearest */
  773. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  774. /** Trilinear is mag = linear and min = linear and mip = linear */
  775. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  776. /** mag = nearest and min = nearest and mip = nearest */
  777. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  778. /** mag = nearest and min = linear and mip = nearest */
  779. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  780. /** mag = nearest and min = linear and mip = linear */
  781. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  782. /** mag = nearest and min = linear and mip = none */
  783. static readonly TEXTURE_NEAREST_LINEAR: number;
  784. /** mag = nearest and min = nearest and mip = none */
  785. static readonly TEXTURE_NEAREST_NEAREST: number;
  786. /** mag = linear and min = nearest and mip = nearest */
  787. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  788. /** mag = linear and min = nearest and mip = linear */
  789. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  790. /** mag = linear and min = linear and mip = none */
  791. static readonly TEXTURE_LINEAR_LINEAR: number;
  792. /** mag = linear and min = nearest and mip = none */
  793. static readonly TEXTURE_LINEAR_NEAREST: number;
  794. /** Explicit coordinates mode */
  795. static readonly TEXTURE_EXPLICIT_MODE: number;
  796. /** Spherical coordinates mode */
  797. static readonly TEXTURE_SPHERICAL_MODE: number;
  798. /** Planar coordinates mode */
  799. static readonly TEXTURE_PLANAR_MODE: number;
  800. /** Cubic coordinates mode */
  801. static readonly TEXTURE_CUBIC_MODE: number;
  802. /** Projection coordinates mode */
  803. static readonly TEXTURE_PROJECTION_MODE: number;
  804. /** Skybox coordinates mode */
  805. static readonly TEXTURE_SKYBOX_MODE: number;
  806. /** Inverse Cubic coordinates mode */
  807. static readonly TEXTURE_INVCUBIC_MODE: number;
  808. /** Equirectangular coordinates mode */
  809. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  810. /** Equirectangular Fixed coordinates mode */
  811. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  812. /** Equirectangular Fixed Mirrored coordinates mode */
  813. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  814. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  815. static readonly SCALEMODE_FLOOR: number;
  816. /** Defines that texture rescaling will look for the nearest power of 2 size */
  817. static readonly SCALEMODE_NEAREST: number;
  818. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  819. static readonly SCALEMODE_CEILING: number;
  820. /**
  821. * The dirty texture flag value
  822. */
  823. static readonly MATERIAL_TextureDirtyFlag: number;
  824. /**
  825. * The dirty light flag value
  826. */
  827. static readonly MATERIAL_LightDirtyFlag: number;
  828. /**
  829. * The dirty fresnel flag value
  830. */
  831. static readonly MATERIAL_FresnelDirtyFlag: number;
  832. /**
  833. * The dirty attribute flag value
  834. */
  835. static readonly MATERIAL_AttributesDirtyFlag: number;
  836. /**
  837. * The dirty misc flag value
  838. */
  839. static readonly MATERIAL_MiscDirtyFlag: number;
  840. /**
  841. * The all dirty flag value
  842. */
  843. static readonly MATERIAL_AllDirtyFlag: number;
  844. /**
  845. * Returns the triangle fill mode
  846. */
  847. static readonly MATERIAL_TriangleFillMode: number;
  848. /**
  849. * Returns the wireframe mode
  850. */
  851. static readonly MATERIAL_WireFrameFillMode: number;
  852. /**
  853. * Returns the point fill mode
  854. */
  855. static readonly MATERIAL_PointFillMode: number;
  856. /**
  857. * Returns the point list draw mode
  858. */
  859. static readonly MATERIAL_PointListDrawMode: number;
  860. /**
  861. * Returns the line list draw mode
  862. */
  863. static readonly MATERIAL_LineListDrawMode: number;
  864. /**
  865. * Returns the line loop draw mode
  866. */
  867. static readonly MATERIAL_LineLoopDrawMode: number;
  868. /**
  869. * Returns the line strip draw mode
  870. */
  871. static readonly MATERIAL_LineStripDrawMode: number;
  872. /**
  873. * Returns the triangle strip draw mode
  874. */
  875. static readonly MATERIAL_TriangleStripDrawMode: number;
  876. /**
  877. * Returns the triangle fan draw mode
  878. */
  879. static readonly MATERIAL_TriangleFanDrawMode: number;
  880. /**
  881. * Stores the clock-wise side orientation
  882. */
  883. static readonly MATERIAL_ClockWiseSideOrientation: number;
  884. /**
  885. * Stores the counter clock-wise side orientation
  886. */
  887. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  888. /**
  889. * Nothing
  890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  891. */
  892. static readonly ACTION_NothingTrigger: number;
  893. /**
  894. * On pick
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_OnPickTrigger: number;
  898. /**
  899. * On left pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnLeftPickTrigger: number;
  903. /**
  904. * On right pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnRightPickTrigger: number;
  908. /**
  909. * On center pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnCenterPickTrigger: number;
  913. /**
  914. * On pick down
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickDownTrigger: number;
  918. /**
  919. * On double pick
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnDoublePickTrigger: number;
  923. /**
  924. * On pick up
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickUpTrigger: number;
  928. /**
  929. * On pick out.
  930. * This trigger will only be raised if you also declared a OnPickDown
  931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickOutTrigger: number;
  934. /**
  935. * On long press
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnLongPressTrigger: number;
  939. /**
  940. * On pointer over
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPointerOverTrigger: number;
  944. /**
  945. * On pointer out
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOutTrigger: number;
  949. /**
  950. * On every frame
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnEveryFrameTrigger: number;
  954. /**
  955. * On intersection enter
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnIntersectionEnterTrigger: number;
  959. /**
  960. * On intersection exit
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionExitTrigger: number;
  964. /**
  965. * On key down
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnKeyDownTrigger: number;
  969. /**
  970. * On key up
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyUpTrigger: number;
  974. /**
  975. * Billboard mode will only apply to Y axis
  976. */
  977. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  978. /**
  979. * Billboard mode will apply to all axes
  980. */
  981. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  982. /**
  983. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  984. */
  985. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  986. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  987. * Test order :
  988. * Is the bounding sphere outside the frustum ?
  989. * If not, are the bounding box vertices outside the frustum ?
  990. * It not, then the cullable object is in the frustum.
  991. */
  992. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  993. /** Culling strategy : Bounding Sphere Only.
  994. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  995. * It's also less accurate than the standard because some not visible objects can still be selected.
  996. * Test : is the bounding sphere outside the frustum ?
  997. * If not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1000. /** Culling strategy : Optimistic Inclusion.
  1001. * This in an inclusion test first, then the standard exclusion test.
  1002. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1003. * 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.
  1004. * Anyway, it's as accurate as the standard strategy.
  1005. * Test :
  1006. * Is the cullable object bounding sphere center in the frustum ?
  1007. * If not, apply the default culling strategy.
  1008. */
  1009. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1010. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1011. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1012. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1013. * 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.
  1014. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1015. * Test :
  1016. * Is the cullable object bounding sphere center in the frustum ?
  1017. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1020. /**
  1021. * No logging while loading
  1022. */
  1023. static readonly SCENELOADER_NO_LOGGING: number;
  1024. /**
  1025. * Minimal logging while loading
  1026. */
  1027. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1028. /**
  1029. * Summary logging while loading
  1030. */
  1031. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1032. /**
  1033. * Detailled logging while loading
  1034. */
  1035. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1036. }
  1037. }
  1038. declare module BABYLON {
  1039. /**
  1040. * This represents the required contract to create a new type of texture loader.
  1041. */
  1042. export interface IInternalTextureLoader {
  1043. /**
  1044. * Defines wether the loader supports cascade loading the different faces.
  1045. */
  1046. supportCascades: boolean;
  1047. /**
  1048. * This returns if the loader support the current file information.
  1049. * @param extension defines the file extension of the file being loaded
  1050. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1051. * @param fallback defines the fallback internal texture if any
  1052. * @param isBase64 defines whether the texture is encoded as a base64
  1053. * @param isBuffer defines whether the texture data are stored as a buffer
  1054. * @returns true if the loader can load the specified file
  1055. */
  1056. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1057. /**
  1058. * Transform the url before loading if required.
  1059. * @param rootUrl the url of the texture
  1060. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1061. * @returns the transformed texture
  1062. */
  1063. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1064. /**
  1065. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the fallback texture
  1069. */
  1070. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1071. /**
  1072. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1073. * @param data contains the texture data
  1074. * @param texture defines the BabylonJS internal texture
  1075. * @param createPolynomials will be true if polynomials have been requested
  1076. * @param onLoad defines the callback to trigger once the texture is ready
  1077. * @param onError defines the callback to trigger in case of error
  1078. */
  1079. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1080. /**
  1081. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1082. * @param data contains the texture data
  1083. * @param texture defines the BabylonJS internal texture
  1084. * @param callback defines the method to call once ready to upload
  1085. */
  1086. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1087. }
  1088. }
  1089. declare module BABYLON {
  1090. /**
  1091. * Class used to store and describe the pipeline context associated with an effect
  1092. */
  1093. export interface IPipelineContext {
  1094. /**
  1095. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1096. */
  1097. isAsync: boolean;
  1098. /**
  1099. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1100. */
  1101. isReady: boolean;
  1102. /** @hidden */
  1103. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1104. }
  1105. }
  1106. declare module BABYLON {
  1107. /**
  1108. * Class used to store gfx data (like WebGLBuffer)
  1109. */
  1110. export class DataBuffer {
  1111. /**
  1112. * Gets or sets the number of objects referencing this buffer
  1113. */
  1114. references: number;
  1115. /** Gets or sets the size of the underlying buffer */
  1116. capacity: number;
  1117. /**
  1118. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1119. */
  1120. is32Bits: boolean;
  1121. /**
  1122. * Gets the underlying buffer
  1123. */
  1124. readonly underlyingResource: any;
  1125. }
  1126. }
  1127. declare module BABYLON {
  1128. /** @hidden */
  1129. export interface IShaderProcessor {
  1130. attributeProcessor?: (attribute: string) => string;
  1131. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1132. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1133. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1134. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1135. lineProcessor?: (line: string, isFragment: boolean) => string;
  1136. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1137. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1138. }
  1139. }
  1140. declare module BABYLON {
  1141. /** @hidden */
  1142. export interface ProcessingOptions {
  1143. defines: string[];
  1144. indexParameters: any;
  1145. isFragment: boolean;
  1146. shouldUseHighPrecisionShader: boolean;
  1147. supportsUniformBuffers: boolean;
  1148. shadersRepository: string;
  1149. includesShadersStore: {
  1150. [key: string]: string;
  1151. };
  1152. processor?: IShaderProcessor;
  1153. version: string;
  1154. platformName: string;
  1155. lookForClosingBracketForUniformBuffer?: boolean;
  1156. }
  1157. }
  1158. declare module BABYLON {
  1159. /** @hidden */
  1160. export class ShaderCodeNode {
  1161. line: string;
  1162. children: ShaderCodeNode[];
  1163. additionalDefineKey?: string;
  1164. additionalDefineValue?: string;
  1165. isValid(preprocessors: {
  1166. [key: string]: string;
  1167. }): boolean;
  1168. process(preprocessors: {
  1169. [key: string]: string;
  1170. }, options: ProcessingOptions): string;
  1171. }
  1172. }
  1173. declare module BABYLON {
  1174. /** @hidden */
  1175. export class ShaderCodeCursor {
  1176. private _lines;
  1177. lineIndex: number;
  1178. readonly currentLine: string;
  1179. readonly canRead: boolean;
  1180. lines: string[];
  1181. }
  1182. }
  1183. declare module BABYLON {
  1184. /** @hidden */
  1185. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1186. process(preprocessors: {
  1187. [key: string]: string;
  1188. }, options: ProcessingOptions): string;
  1189. }
  1190. }
  1191. declare module BABYLON {
  1192. /** @hidden */
  1193. export class ShaderDefineExpression {
  1194. isTrue(preprocessors: {
  1195. [key: string]: string;
  1196. }): boolean;
  1197. }
  1198. }
  1199. declare module BABYLON {
  1200. /** @hidden */
  1201. export class ShaderCodeTestNode extends ShaderCodeNode {
  1202. testExpression: ShaderDefineExpression;
  1203. isValid(preprocessors: {
  1204. [key: string]: string;
  1205. }): boolean;
  1206. }
  1207. }
  1208. declare module BABYLON {
  1209. /** @hidden */
  1210. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1211. define: string;
  1212. not: boolean;
  1213. constructor(define: string, not?: boolean);
  1214. isTrue(preprocessors: {
  1215. [key: string]: string;
  1216. }): boolean;
  1217. }
  1218. }
  1219. declare module BABYLON {
  1220. /** @hidden */
  1221. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1222. leftOperand: ShaderDefineExpression;
  1223. rightOperand: ShaderDefineExpression;
  1224. isTrue(preprocessors: {
  1225. [key: string]: string;
  1226. }): boolean;
  1227. }
  1228. }
  1229. declare module BABYLON {
  1230. /** @hidden */
  1231. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1232. leftOperand: ShaderDefineExpression;
  1233. rightOperand: ShaderDefineExpression;
  1234. isTrue(preprocessors: {
  1235. [key: string]: string;
  1236. }): boolean;
  1237. }
  1238. }
  1239. declare module BABYLON {
  1240. /** @hidden */
  1241. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1242. define: string;
  1243. operand: string;
  1244. testValue: string;
  1245. constructor(define: string, operand: string, testValue: string);
  1246. isTrue(preprocessors: {
  1247. [key: string]: string;
  1248. }): boolean;
  1249. }
  1250. }
  1251. declare module BABYLON {
  1252. /**
  1253. * Class used to enable access to offline support
  1254. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1255. */
  1256. export interface IOfflineProvider {
  1257. /**
  1258. * Gets a boolean indicating if scene must be saved in the database
  1259. */
  1260. enableSceneOffline: boolean;
  1261. /**
  1262. * Gets a boolean indicating if textures must be saved in the database
  1263. */
  1264. enableTexturesOffline: boolean;
  1265. /**
  1266. * Open the offline support and make it available
  1267. * @param successCallback defines the callback to call on success
  1268. * @param errorCallback defines the callback to call on error
  1269. */
  1270. open(successCallback: () => void, errorCallback: () => void): void;
  1271. /**
  1272. * Loads an image from the offline support
  1273. * @param url defines the url to load from
  1274. * @param image defines the target DOM image
  1275. */
  1276. loadImage(url: string, image: HTMLImageElement): void;
  1277. /**
  1278. * Loads a file from offline support
  1279. * @param url defines the URL to load from
  1280. * @param sceneLoaded defines a callback to call on success
  1281. * @param progressCallBack defines a callback to call when progress changed
  1282. * @param errorCallback defines a callback to call on error
  1283. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1284. */
  1285. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1286. }
  1287. }
  1288. declare module BABYLON {
  1289. /**
  1290. * Class used to help managing file picking and drag'n'drop
  1291. * File Storage
  1292. */
  1293. export class FilesInputStore {
  1294. /**
  1295. * List of files ready to be loaded
  1296. */
  1297. static FilesToLoad: {
  1298. [key: string]: File;
  1299. };
  1300. }
  1301. }
  1302. declare module BABYLON {
  1303. /**
  1304. * Class used to define a retry strategy when error happens while loading assets
  1305. */
  1306. export class RetryStrategy {
  1307. /**
  1308. * Function used to defines an exponential back off strategy
  1309. * @param maxRetries defines the maximum number of retries (3 by default)
  1310. * @param baseInterval defines the interval between retries
  1311. * @returns the strategy function to use
  1312. */
  1313. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1314. }
  1315. }
  1316. declare module BABYLON {
  1317. /**
  1318. * @ignore
  1319. * Application error to support additional information when loading a file
  1320. */
  1321. export abstract class BaseError extends Error {
  1322. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1323. }
  1324. }
  1325. declare module BABYLON {
  1326. /** @ignore */
  1327. export class LoadFileError extends BaseError {
  1328. request?: WebRequest;
  1329. file?: File;
  1330. /**
  1331. * Creates a new LoadFileError
  1332. * @param message defines the message of the error
  1333. * @param request defines the optional web request
  1334. * @param file defines the optional file
  1335. */
  1336. constructor(message: string, object?: WebRequest | File);
  1337. }
  1338. /** @ignore */
  1339. export class RequestFileError extends BaseError {
  1340. request: WebRequest;
  1341. /**
  1342. * Creates a new LoadFileError
  1343. * @param message defines the message of the error
  1344. * @param request defines the optional web request
  1345. */
  1346. constructor(message: string, request: WebRequest);
  1347. }
  1348. /** @ignore */
  1349. export class ReadFileError extends BaseError {
  1350. file: File;
  1351. /**
  1352. * Creates a new ReadFileError
  1353. * @param message defines the message of the error
  1354. * @param file defines the optional file
  1355. */
  1356. constructor(message: string, file: File);
  1357. }
  1358. /**
  1359. * @hidden
  1360. */
  1361. export class FileTools {
  1362. /**
  1363. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1364. */
  1365. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1366. /**
  1367. * Gets or sets the base URL to use to load assets
  1368. */
  1369. static BaseUrl: string;
  1370. /**
  1371. * Default behaviour for cors in the application.
  1372. * It can be a string if the expected behavior is identical in the entire app.
  1373. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1374. */
  1375. static CorsBehavior: string | ((url: string | string[]) => string);
  1376. /**
  1377. * Gets or sets a function used to pre-process url before using them to load assets
  1378. */
  1379. static PreprocessUrl: (url: string) => string;
  1380. /**
  1381. * Removes unwanted characters from an url
  1382. * @param url defines the url to clean
  1383. * @returns the cleaned url
  1384. */
  1385. private static _CleanUrl;
  1386. /**
  1387. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1388. * @param url define the url we are trying
  1389. * @param element define the dom element where to configure the cors policy
  1390. */
  1391. static SetCorsBehavior(url: string | string[], element: {
  1392. crossOrigin: string | null;
  1393. }): void;
  1394. /**
  1395. * Loads an image as an HTMLImageElement.
  1396. * @param input url string, ArrayBuffer, or Blob to load
  1397. * @param onLoad callback called when the image successfully loads
  1398. * @param onError callback called when the image fails to load
  1399. * @param offlineProvider offline provider for caching
  1400. * @param mimeType optional mime type
  1401. * @returns the HTMLImageElement of the loaded image
  1402. */
  1403. 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>;
  1404. /**
  1405. * Reads a file from a File object
  1406. * @param file defines the file to load
  1407. * @param onSuccess defines the callback to call when data is loaded
  1408. * @param onProgress defines the callback to call during loading process
  1409. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1410. * @param onError defines the callback to call when an error occurs
  1411. * @returns a file request object
  1412. */
  1413. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1414. /**
  1415. * Loads a file from a url
  1416. * @param url url to load
  1417. * @param onSuccess callback called when the file successfully loads
  1418. * @param onProgress callback called while file is loading (if the server supports this mode)
  1419. * @param offlineProvider defines the offline provider for caching
  1420. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1421. * @param onError callback called when the file fails to load
  1422. * @returns a file request object
  1423. */
  1424. 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;
  1425. /**
  1426. * Loads a file
  1427. * @param url url to load
  1428. * @param onSuccess callback called when the file successfully loads
  1429. * @param onProgress callback called while file is loading (if the server supports this mode)
  1430. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1431. * @param onError callback called when the file fails to load
  1432. * @param onOpened callback called when the web request is opened
  1433. * @returns a file request object
  1434. */
  1435. 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;
  1436. /**
  1437. * Checks if the loaded document was accessed via `file:`-Protocol.
  1438. * @returns boolean
  1439. */
  1440. static IsFileURL(): boolean;
  1441. }
  1442. }
  1443. declare module BABYLON {
  1444. /** @hidden */
  1445. export class ShaderProcessor {
  1446. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1447. private static _ProcessPrecision;
  1448. private static _ExtractOperation;
  1449. private static _BuildSubExpression;
  1450. private static _BuildExpression;
  1451. private static _MoveCursorWithinIf;
  1452. private static _MoveCursor;
  1453. private static _EvaluatePreProcessors;
  1454. private static _PreparePreProcessors;
  1455. private static _ProcessShaderConversion;
  1456. private static _ProcessIncludes;
  1457. }
  1458. }
  1459. declare module BABYLON {
  1460. /**
  1461. * @hidden
  1462. */
  1463. export interface IColor4Like {
  1464. r: float;
  1465. g: float;
  1466. b: float;
  1467. a: float;
  1468. }
  1469. /**
  1470. * @hidden
  1471. */
  1472. export interface IColor3Like {
  1473. r: float;
  1474. g: float;
  1475. b: float;
  1476. }
  1477. /**
  1478. * @hidden
  1479. */
  1480. export interface IVector4Like {
  1481. x: float;
  1482. y: float;
  1483. z: float;
  1484. w: float;
  1485. }
  1486. /**
  1487. * @hidden
  1488. */
  1489. export interface IVector3Like {
  1490. x: float;
  1491. y: float;
  1492. z: float;
  1493. }
  1494. /**
  1495. * @hidden
  1496. */
  1497. export interface IVector2Like {
  1498. x: float;
  1499. y: float;
  1500. }
  1501. /**
  1502. * @hidden
  1503. */
  1504. export interface IMatrixLike {
  1505. toArray(): DeepImmutable<Float32Array>;
  1506. updateFlag: int;
  1507. }
  1508. /**
  1509. * @hidden
  1510. */
  1511. export interface IViewportLike {
  1512. x: float;
  1513. y: float;
  1514. width: float;
  1515. height: float;
  1516. }
  1517. /**
  1518. * @hidden
  1519. */
  1520. export interface IPlaneLike {
  1521. normal: IVector3Like;
  1522. d: float;
  1523. normalize(): void;
  1524. }
  1525. }
  1526. declare module BABYLON {
  1527. /**
  1528. * Interface used to define common properties for effect fallbacks
  1529. */
  1530. export interface IEffectFallbacks {
  1531. /**
  1532. * Removes the defines that should be removed when falling back.
  1533. * @param currentDefines defines the current define statements for the shader.
  1534. * @param effect defines the current effect we try to compile
  1535. * @returns The resulting defines with defines of the current rank removed.
  1536. */
  1537. reduce(currentDefines: string, effect: Effect): string;
  1538. /**
  1539. * Removes the fallback from the bound mesh.
  1540. */
  1541. unBindMesh(): void;
  1542. /**
  1543. * Checks to see if more fallbacks are still availible.
  1544. */
  1545. hasMoreFallbacks: boolean;
  1546. }
  1547. }
  1548. declare module BABYLON {
  1549. /**
  1550. * Class used to evalaute queries containing `and` and `or` operators
  1551. */
  1552. export class AndOrNotEvaluator {
  1553. /**
  1554. * Evaluate a query
  1555. * @param query defines the query to evaluate
  1556. * @param evaluateCallback defines the callback used to filter result
  1557. * @returns true if the query matches
  1558. */
  1559. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1560. private static _HandleParenthesisContent;
  1561. private static _SimplifyNegation;
  1562. }
  1563. }
  1564. declare module BABYLON {
  1565. /**
  1566. * Class used to store custom tags
  1567. */
  1568. export class Tags {
  1569. /**
  1570. * Adds support for tags on the given object
  1571. * @param obj defines the object to use
  1572. */
  1573. static EnableFor(obj: any): void;
  1574. /**
  1575. * Removes tags support
  1576. * @param obj defines the object to use
  1577. */
  1578. static DisableFor(obj: any): void;
  1579. /**
  1580. * Gets a boolean indicating if the given object has tags
  1581. * @param obj defines the object to use
  1582. * @returns a boolean
  1583. */
  1584. static HasTags(obj: any): boolean;
  1585. /**
  1586. * Gets the tags available on a given object
  1587. * @param obj defines the object to use
  1588. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1589. * @returns the tags
  1590. */
  1591. static GetTags(obj: any, asString?: boolean): any;
  1592. /**
  1593. * Adds tags to an object
  1594. * @param obj defines the object to use
  1595. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1596. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1597. */
  1598. static AddTagsTo(obj: any, tagsString: string): void;
  1599. /**
  1600. * @hidden
  1601. */
  1602. static _AddTagTo(obj: any, tag: string): void;
  1603. /**
  1604. * Removes specific tags from a specific object
  1605. * @param obj defines the object to use
  1606. * @param tagsString defines the tags to remove
  1607. */
  1608. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1609. /**
  1610. * @hidden
  1611. */
  1612. static _RemoveTagFrom(obj: any, tag: string): void;
  1613. /**
  1614. * Defines if tags hosted on an object match a given query
  1615. * @param obj defines the object to use
  1616. * @param tagsQuery defines the tag query
  1617. * @returns a boolean
  1618. */
  1619. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1620. }
  1621. }
  1622. declare module BABYLON {
  1623. /**
  1624. * Scalar computation library
  1625. */
  1626. export class Scalar {
  1627. /**
  1628. * Two pi constants convenient for computation.
  1629. */
  1630. static TwoPi: number;
  1631. /**
  1632. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1633. * @param a number
  1634. * @param b number
  1635. * @param epsilon (default = 1.401298E-45)
  1636. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1637. */
  1638. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1639. /**
  1640. * Returns a string : the upper case translation of the number i to hexadecimal.
  1641. * @param i number
  1642. * @returns the upper case translation of the number i to hexadecimal.
  1643. */
  1644. static ToHex(i: number): string;
  1645. /**
  1646. * Returns -1 if value is negative and +1 is value is positive.
  1647. * @param value the value
  1648. * @returns the value itself if it's equal to zero.
  1649. */
  1650. static Sign(value: number): number;
  1651. /**
  1652. * Returns the value itself if it's between min and max.
  1653. * Returns min if the value is lower than min.
  1654. * Returns max if the value is greater than max.
  1655. * @param value the value to clmap
  1656. * @param min the min value to clamp to (default: 0)
  1657. * @param max the max value to clamp to (default: 1)
  1658. * @returns the clamped value
  1659. */
  1660. static Clamp(value: number, min?: number, max?: number): number;
  1661. /**
  1662. * the log2 of value.
  1663. * @param value the value to compute log2 of
  1664. * @returns the log2 of value.
  1665. */
  1666. static Log2(value: number): number;
  1667. /**
  1668. * Loops the value, so that it is never larger than length and never smaller than 0.
  1669. *
  1670. * This is similar to the modulo operator but it works with floating point numbers.
  1671. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1672. * With t = 5 and length = 2.5, the result would be 0.0.
  1673. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1674. * @param value the value
  1675. * @param length the length
  1676. * @returns the looped value
  1677. */
  1678. static Repeat(value: number, length: number): number;
  1679. /**
  1680. * Normalize the value between 0.0 and 1.0 using min and max values
  1681. * @param value value to normalize
  1682. * @param min max to normalize between
  1683. * @param max min to normalize between
  1684. * @returns the normalized value
  1685. */
  1686. static Normalize(value: number, min: number, max: number): number;
  1687. /**
  1688. * Denormalize the value from 0.0 and 1.0 using min and max values
  1689. * @param normalized value to denormalize
  1690. * @param min max to denormalize between
  1691. * @param max min to denormalize between
  1692. * @returns the denormalized value
  1693. */
  1694. static Denormalize(normalized: number, min: number, max: number): number;
  1695. /**
  1696. * Calculates the shortest difference between two given angles given in degrees.
  1697. * @param current current angle in degrees
  1698. * @param target target angle in degrees
  1699. * @returns the delta
  1700. */
  1701. static DeltaAngle(current: number, target: number): number;
  1702. /**
  1703. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1704. * @param tx value
  1705. * @param length length
  1706. * @returns The returned value will move back and forth between 0 and length
  1707. */
  1708. static PingPong(tx: number, length: number): number;
  1709. /**
  1710. * Interpolates between min and max with smoothing at the limits.
  1711. *
  1712. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1713. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1714. * @param from from
  1715. * @param to to
  1716. * @param tx value
  1717. * @returns the smooth stepped value
  1718. */
  1719. static SmoothStep(from: number, to: number, tx: number): number;
  1720. /**
  1721. * Moves a value current towards target.
  1722. *
  1723. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1724. * Negative values of maxDelta pushes the value away from target.
  1725. * @param current current value
  1726. * @param target target value
  1727. * @param maxDelta max distance to move
  1728. * @returns resulting value
  1729. */
  1730. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1731. /**
  1732. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1733. *
  1734. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1735. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1736. * @param current current value
  1737. * @param target target value
  1738. * @param maxDelta max distance to move
  1739. * @returns resulting angle
  1740. */
  1741. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1742. /**
  1743. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1744. * @param start start value
  1745. * @param end target value
  1746. * @param amount amount to lerp between
  1747. * @returns the lerped value
  1748. */
  1749. static Lerp(start: number, end: number, amount: number): number;
  1750. /**
  1751. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1752. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1753. * @param start start value
  1754. * @param end target value
  1755. * @param amount amount to lerp between
  1756. * @returns the lerped value
  1757. */
  1758. static LerpAngle(start: number, end: number, amount: number): number;
  1759. /**
  1760. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1761. * @param a start value
  1762. * @param b target value
  1763. * @param value value between a and b
  1764. * @returns the inverseLerp value
  1765. */
  1766. static InverseLerp(a: number, b: number, value: number): number;
  1767. /**
  1768. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1769. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1770. * @param value1 spline value
  1771. * @param tangent1 spline value
  1772. * @param value2 spline value
  1773. * @param tangent2 spline value
  1774. * @param amount input value
  1775. * @returns hermite result
  1776. */
  1777. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1778. /**
  1779. * Returns a random float number between and min and max values
  1780. * @param min min value of random
  1781. * @param max max value of random
  1782. * @returns random value
  1783. */
  1784. static RandomRange(min: number, max: number): number;
  1785. /**
  1786. * This function returns percentage of a number in a given range.
  1787. *
  1788. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1789. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1790. * @param number to convert to percentage
  1791. * @param min min range
  1792. * @param max max range
  1793. * @returns the percentage
  1794. */
  1795. static RangeToPercent(number: number, min: number, max: number): number;
  1796. /**
  1797. * This function returns number that corresponds to the percentage in a given range.
  1798. *
  1799. * PercentToRange(0.34,0,100) will return 34.
  1800. * @param percent to convert to number
  1801. * @param min min range
  1802. * @param max max range
  1803. * @returns the number
  1804. */
  1805. static PercentToRange(percent: number, min: number, max: number): number;
  1806. /**
  1807. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1808. * @param angle The angle to normalize in radian.
  1809. * @return The converted angle.
  1810. */
  1811. static NormalizeRadians(angle: number): number;
  1812. }
  1813. }
  1814. declare module BABYLON {
  1815. /**
  1816. * Constant used to convert a value to gamma space
  1817. * @ignorenaming
  1818. */
  1819. export const ToGammaSpace: number;
  1820. /**
  1821. * Constant used to convert a value to linear space
  1822. * @ignorenaming
  1823. */
  1824. export const ToLinearSpace = 2.2;
  1825. /**
  1826. * Constant used to define the minimal number value in Babylon.js
  1827. * @ignorenaming
  1828. */
  1829. let Epsilon: number;
  1830. }
  1831. declare module BABYLON {
  1832. /**
  1833. * Class used to represent a viewport on screen
  1834. */
  1835. export class Viewport {
  1836. /** viewport left coordinate */
  1837. x: number;
  1838. /** viewport top coordinate */
  1839. y: number;
  1840. /**viewport width */
  1841. width: number;
  1842. /** viewport height */
  1843. height: number;
  1844. /**
  1845. * Creates a Viewport object located at (x, y) and sized (width, height)
  1846. * @param x defines viewport left coordinate
  1847. * @param y defines viewport top coordinate
  1848. * @param width defines the viewport width
  1849. * @param height defines the viewport height
  1850. */
  1851. constructor(
  1852. /** viewport left coordinate */
  1853. x: number,
  1854. /** viewport top coordinate */
  1855. y: number,
  1856. /**viewport width */
  1857. width: number,
  1858. /** viewport height */
  1859. height: number);
  1860. /**
  1861. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1862. * @param renderWidth defines the rendering width
  1863. * @param renderHeight defines the rendering height
  1864. * @returns a new Viewport
  1865. */
  1866. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1867. /**
  1868. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1869. * @param renderWidth defines the rendering width
  1870. * @param renderHeight defines the rendering height
  1871. * @param ref defines the target viewport
  1872. * @returns the current viewport
  1873. */
  1874. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1875. /**
  1876. * Returns a new Viewport copied from the current one
  1877. * @returns a new Viewport
  1878. */
  1879. clone(): Viewport;
  1880. }
  1881. }
  1882. declare module BABYLON {
  1883. /**
  1884. * Class containing a set of static utilities functions for arrays.
  1885. */
  1886. export class ArrayTools {
  1887. /**
  1888. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1889. * @param size the number of element to construct and put in the array
  1890. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1891. * @returns a new array filled with new objects
  1892. */
  1893. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1894. }
  1895. }
  1896. declare module BABYLON {
  1897. /**
  1898. * Class representing a vector containing 2 coordinates
  1899. */
  1900. export class Vector2 {
  1901. /** defines the first coordinate */
  1902. x: number;
  1903. /** defines the second coordinate */
  1904. y: number;
  1905. /**
  1906. * Creates a new Vector2 from the given x and y coordinates
  1907. * @param x defines the first coordinate
  1908. * @param y defines the second coordinate
  1909. */
  1910. constructor(
  1911. /** defines the first coordinate */
  1912. x?: number,
  1913. /** defines the second coordinate */
  1914. y?: number);
  1915. /**
  1916. * Gets a string with the Vector2 coordinates
  1917. * @returns a string with the Vector2 coordinates
  1918. */
  1919. toString(): string;
  1920. /**
  1921. * Gets class name
  1922. * @returns the string "Vector2"
  1923. */
  1924. getClassName(): string;
  1925. /**
  1926. * Gets current vector hash code
  1927. * @returns the Vector2 hash code as a number
  1928. */
  1929. getHashCode(): number;
  1930. /**
  1931. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1932. * @param array defines the source array
  1933. * @param index defines the offset in source array
  1934. * @returns the current Vector2
  1935. */
  1936. toArray(array: FloatArray, index?: number): Vector2;
  1937. /**
  1938. * Copy the current vector to an array
  1939. * @returns a new array with 2 elements: the Vector2 coordinates.
  1940. */
  1941. asArray(): number[];
  1942. /**
  1943. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1944. * @param source defines the source Vector2
  1945. * @returns the current updated Vector2
  1946. */
  1947. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1948. /**
  1949. * Sets the Vector2 coordinates with the given floats
  1950. * @param x defines the first coordinate
  1951. * @param y defines the second coordinate
  1952. * @returns the current updated Vector2
  1953. */
  1954. copyFromFloats(x: number, y: number): Vector2;
  1955. /**
  1956. * Sets the Vector2 coordinates with the given floats
  1957. * @param x defines the first coordinate
  1958. * @param y defines the second coordinate
  1959. * @returns the current updated Vector2
  1960. */
  1961. set(x: number, y: number): Vector2;
  1962. /**
  1963. * Add another vector with the current one
  1964. * @param otherVector defines the other vector
  1965. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1966. */
  1967. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1968. /**
  1969. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1970. * @param otherVector defines the other vector
  1971. * @param result defines the target vector
  1972. * @returns the unmodified current Vector2
  1973. */
  1974. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1975. /**
  1976. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1977. * @param otherVector defines the other vector
  1978. * @returns the current updated Vector2
  1979. */
  1980. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1981. /**
  1982. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1983. * @param otherVector defines the other vector
  1984. * @returns a new Vector2
  1985. */
  1986. addVector3(otherVector: Vector3): Vector2;
  1987. /**
  1988. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1989. * @param otherVector defines the other vector
  1990. * @returns a new Vector2
  1991. */
  1992. subtract(otherVector: Vector2): Vector2;
  1993. /**
  1994. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1995. * @param otherVector defines the other vector
  1996. * @param result defines the target vector
  1997. * @returns the unmodified current Vector2
  1998. */
  1999. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2000. /**
  2001. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2002. * @param otherVector defines the other vector
  2003. * @returns the current updated Vector2
  2004. */
  2005. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2006. /**
  2007. * Multiplies in place the current Vector2 coordinates by the given ones
  2008. * @param otherVector defines the other vector
  2009. * @returns the current updated Vector2
  2010. */
  2011. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2012. /**
  2013. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2014. * @param otherVector defines the other vector
  2015. * @returns a new Vector2
  2016. */
  2017. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2018. /**
  2019. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2020. * @param otherVector defines the other vector
  2021. * @param result defines the target vector
  2022. * @returns the unmodified current Vector2
  2023. */
  2024. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2025. /**
  2026. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2027. * @param x defines the first coordinate
  2028. * @param y defines the second coordinate
  2029. * @returns a new Vector2
  2030. */
  2031. multiplyByFloats(x: number, y: number): Vector2;
  2032. /**
  2033. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2034. * @param otherVector defines the other vector
  2035. * @returns a new Vector2
  2036. */
  2037. divide(otherVector: Vector2): Vector2;
  2038. /**
  2039. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2040. * @param otherVector defines the other vector
  2041. * @param result defines the target vector
  2042. * @returns the unmodified current Vector2
  2043. */
  2044. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2045. /**
  2046. * Divides the current Vector2 coordinates by the given ones
  2047. * @param otherVector defines the other vector
  2048. * @returns the current updated Vector2
  2049. */
  2050. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2051. /**
  2052. * Gets a new Vector2 with current Vector2 negated coordinates
  2053. * @returns a new Vector2
  2054. */
  2055. negate(): Vector2;
  2056. /**
  2057. * Multiply the Vector2 coordinates by scale
  2058. * @param scale defines the scaling factor
  2059. * @returns the current updated Vector2
  2060. */
  2061. scaleInPlace(scale: number): Vector2;
  2062. /**
  2063. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2064. * @param scale defines the scaling factor
  2065. * @returns a new Vector2
  2066. */
  2067. scale(scale: number): Vector2;
  2068. /**
  2069. * Scale the current Vector2 values by a factor to a given Vector2
  2070. * @param scale defines the scale factor
  2071. * @param result defines the Vector2 object where to store the result
  2072. * @returns the unmodified current Vector2
  2073. */
  2074. scaleToRef(scale: number, result: Vector2): Vector2;
  2075. /**
  2076. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2077. * @param scale defines the scale factor
  2078. * @param result defines the Vector2 object where to store the result
  2079. * @returns the unmodified current Vector2
  2080. */
  2081. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2082. /**
  2083. * Gets a boolean if two vectors are equals
  2084. * @param otherVector defines the other vector
  2085. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2086. */
  2087. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2088. /**
  2089. * Gets a boolean if two vectors are equals (using an epsilon value)
  2090. * @param otherVector defines the other vector
  2091. * @param epsilon defines the minimal distance to consider equality
  2092. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2093. */
  2094. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2095. /**
  2096. * Gets a new Vector2 from current Vector2 floored values
  2097. * @returns a new Vector2
  2098. */
  2099. floor(): Vector2;
  2100. /**
  2101. * Gets a new Vector2 from current Vector2 floored values
  2102. * @returns a new Vector2
  2103. */
  2104. fract(): Vector2;
  2105. /**
  2106. * Gets the length of the vector
  2107. * @returns the vector length (float)
  2108. */
  2109. length(): number;
  2110. /**
  2111. * Gets the vector squared length
  2112. * @returns the vector squared length (float)
  2113. */
  2114. lengthSquared(): number;
  2115. /**
  2116. * Normalize the vector
  2117. * @returns the current updated Vector2
  2118. */
  2119. normalize(): Vector2;
  2120. /**
  2121. * Gets a new Vector2 copied from the Vector2
  2122. * @returns a new Vector2
  2123. */
  2124. clone(): Vector2;
  2125. /**
  2126. * Gets a new Vector2(0, 0)
  2127. * @returns a new Vector2
  2128. */
  2129. static Zero(): Vector2;
  2130. /**
  2131. * Gets a new Vector2(1, 1)
  2132. * @returns a new Vector2
  2133. */
  2134. static One(): Vector2;
  2135. /**
  2136. * Gets a new Vector2 set from the given index element of the given array
  2137. * @param array defines the data source
  2138. * @param offset defines the offset in the data source
  2139. * @returns a new Vector2
  2140. */
  2141. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2142. /**
  2143. * Sets "result" from the given index element of the given array
  2144. * @param array defines the data source
  2145. * @param offset defines the offset in the data source
  2146. * @param result defines the target vector
  2147. */
  2148. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2149. /**
  2150. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2151. * @param value1 defines 1st point of control
  2152. * @param value2 defines 2nd point of control
  2153. * @param value3 defines 3rd point of control
  2154. * @param value4 defines 4th point of control
  2155. * @param amount defines the interpolation factor
  2156. * @returns a new Vector2
  2157. */
  2158. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2159. /**
  2160. * 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".
  2161. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2162. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2163. * @param value defines the value to clamp
  2164. * @param min defines the lower limit
  2165. * @param max defines the upper limit
  2166. * @returns a new Vector2
  2167. */
  2168. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2171. * @param value1 defines the 1st control point
  2172. * @param tangent1 defines the outgoing tangent
  2173. * @param value2 defines the 2nd control point
  2174. * @param tangent2 defines the incoming tangent
  2175. * @param amount defines the interpolation factor
  2176. * @returns a new Vector2
  2177. */
  2178. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2179. /**
  2180. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2181. * @param start defines the start vector
  2182. * @param end defines the end vector
  2183. * @param amount defines the interpolation factor
  2184. * @returns a new Vector2
  2185. */
  2186. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2187. /**
  2188. * Gets the dot product of the vector "left" and the vector "right"
  2189. * @param left defines first vector
  2190. * @param right defines second vector
  2191. * @returns the dot product (float)
  2192. */
  2193. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2194. /**
  2195. * Returns a new Vector2 equal to the normalized given vector
  2196. * @param vector defines the vector to normalize
  2197. * @returns a new Vector2
  2198. */
  2199. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2200. /**
  2201. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2202. * @param left defines 1st vector
  2203. * @param right defines 2nd vector
  2204. * @returns a new Vector2
  2205. */
  2206. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2207. /**
  2208. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2209. * @param left defines 1st vector
  2210. * @param right defines 2nd vector
  2211. * @returns a new Vector2
  2212. */
  2213. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2214. /**
  2215. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2216. * @param vector defines the vector to transform
  2217. * @param transformation defines the matrix to apply
  2218. * @returns a new Vector2
  2219. */
  2220. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2221. /**
  2222. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2223. * @param vector defines the vector to transform
  2224. * @param transformation defines the matrix to apply
  2225. * @param result defines the target vector
  2226. */
  2227. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2228. /**
  2229. * Determines if a given vector is included in a triangle
  2230. * @param p defines the vector to test
  2231. * @param p0 defines 1st triangle point
  2232. * @param p1 defines 2nd triangle point
  2233. * @param p2 defines 3rd triangle point
  2234. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2235. */
  2236. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2237. /**
  2238. * Gets the distance between the vectors "value1" and "value2"
  2239. * @param value1 defines first vector
  2240. * @param value2 defines second vector
  2241. * @returns the distance between vectors
  2242. */
  2243. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2244. /**
  2245. * Returns the squared distance between the vectors "value1" and "value2"
  2246. * @param value1 defines first vector
  2247. * @param value2 defines second vector
  2248. * @returns the squared distance between vectors
  2249. */
  2250. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2251. /**
  2252. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2253. * @param value1 defines first vector
  2254. * @param value2 defines second vector
  2255. * @returns a new Vector2
  2256. */
  2257. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2258. /**
  2259. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2260. * @param p defines the middle point
  2261. * @param segA defines one point of the segment
  2262. * @param segB defines the other point of the segment
  2263. * @returns the shortest distance
  2264. */
  2265. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2266. }
  2267. /**
  2268. * Class used to store (x,y,z) vector representation
  2269. * A Vector3 is the main object used in 3D geometry
  2270. * It can represent etiher the coordinates of a point the space, either a direction
  2271. * Reminder: js uses a left handed forward facing system
  2272. */
  2273. export class Vector3 {
  2274. /**
  2275. * Defines the first coordinates (on X axis)
  2276. */
  2277. x: number;
  2278. /**
  2279. * Defines the second coordinates (on Y axis)
  2280. */
  2281. y: number;
  2282. /**
  2283. * Defines the third coordinates (on Z axis)
  2284. */
  2285. z: number;
  2286. private static _UpReadOnly;
  2287. private static _ZeroReadOnly;
  2288. /**
  2289. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2290. * @param x defines the first coordinates (on X axis)
  2291. * @param y defines the second coordinates (on Y axis)
  2292. * @param z defines the third coordinates (on Z axis)
  2293. */
  2294. constructor(
  2295. /**
  2296. * Defines the first coordinates (on X axis)
  2297. */
  2298. x?: number,
  2299. /**
  2300. * Defines the second coordinates (on Y axis)
  2301. */
  2302. y?: number,
  2303. /**
  2304. * Defines the third coordinates (on Z axis)
  2305. */
  2306. z?: number);
  2307. /**
  2308. * Creates a string representation of the Vector3
  2309. * @returns a string with the Vector3 coordinates.
  2310. */
  2311. toString(): string;
  2312. /**
  2313. * Gets the class name
  2314. * @returns the string "Vector3"
  2315. */
  2316. getClassName(): string;
  2317. /**
  2318. * Creates the Vector3 hash code
  2319. * @returns a number which tends to be unique between Vector3 instances
  2320. */
  2321. getHashCode(): number;
  2322. /**
  2323. * Creates an array containing three elements : the coordinates of the Vector3
  2324. * @returns a new array of numbers
  2325. */
  2326. asArray(): number[];
  2327. /**
  2328. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2329. * @param array defines the destination array
  2330. * @param index defines the offset in the destination array
  2331. * @returns the current Vector3
  2332. */
  2333. toArray(array: FloatArray, index?: number): Vector3;
  2334. /**
  2335. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2336. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2337. */
  2338. toQuaternion(): Quaternion;
  2339. /**
  2340. * Adds the given vector to the current Vector3
  2341. * @param otherVector defines the second operand
  2342. * @returns the current updated Vector3
  2343. */
  2344. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2345. /**
  2346. * Adds the given coordinates to the current Vector3
  2347. * @param x defines the x coordinate of the operand
  2348. * @param y defines the y coordinate of the operand
  2349. * @param z defines the z coordinate of the operand
  2350. * @returns the current updated Vector3
  2351. */
  2352. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2353. /**
  2354. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2355. * @param otherVector defines the second operand
  2356. * @returns the resulting Vector3
  2357. */
  2358. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2359. /**
  2360. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2361. * @param otherVector defines the second operand
  2362. * @param result defines the Vector3 object where to store the result
  2363. * @returns the current Vector3
  2364. */
  2365. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2366. /**
  2367. * Subtract the given vector from the current Vector3
  2368. * @param otherVector defines the second operand
  2369. * @returns the current updated Vector3
  2370. */
  2371. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2372. /**
  2373. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2374. * @param otherVector defines the second operand
  2375. * @returns the resulting Vector3
  2376. */
  2377. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2378. /**
  2379. * Subtracts the given vector from the current Vector3 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. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2385. /**
  2386. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2387. * @param x defines the x coordinate of the operand
  2388. * @param y defines the y coordinate of the operand
  2389. * @param z defines the z coordinate of the operand
  2390. * @returns the resulting Vector3
  2391. */
  2392. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2393. /**
  2394. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2395. * @param x defines the x coordinate of the operand
  2396. * @param y defines the y coordinate of the operand
  2397. * @param z defines the z coordinate of the operand
  2398. * @param result defines the Vector3 object where to store the result
  2399. * @returns the current Vector3
  2400. */
  2401. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2402. /**
  2403. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2404. * @returns a new Vector3
  2405. */
  2406. negate(): Vector3;
  2407. /**
  2408. * Multiplies the Vector3 coordinates by the float "scale"
  2409. * @param scale defines the multiplier factor
  2410. * @returns the current updated Vector3
  2411. */
  2412. scaleInPlace(scale: number): Vector3;
  2413. /**
  2414. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2415. * @param scale defines the multiplier factor
  2416. * @returns a new Vector3
  2417. */
  2418. scale(scale: number): Vector3;
  2419. /**
  2420. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2421. * @param scale defines the multiplier factor
  2422. * @param result defines the Vector3 object where to store the result
  2423. * @returns the current Vector3
  2424. */
  2425. scaleToRef(scale: number, result: Vector3): Vector3;
  2426. /**
  2427. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2428. * @param scale defines the scale factor
  2429. * @param result defines the Vector3 object where to store the result
  2430. * @returns the unmodified current Vector3
  2431. */
  2432. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2433. /**
  2434. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2435. * @param otherVector defines the second operand
  2436. * @returns true if both vectors are equals
  2437. */
  2438. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2439. /**
  2440. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2441. * @param otherVector defines the second operand
  2442. * @param epsilon defines the minimal distance to define values as equals
  2443. * @returns true if both vectors are distant less than epsilon
  2444. */
  2445. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2446. /**
  2447. * Returns true if the current Vector3 coordinates equals the given floats
  2448. * @param x defines the x coordinate of the operand
  2449. * @param y defines the y coordinate of the operand
  2450. * @param z defines the z coordinate of the operand
  2451. * @returns true if both vectors are equals
  2452. */
  2453. equalsToFloats(x: number, y: number, z: number): boolean;
  2454. /**
  2455. * Multiplies the current Vector3 coordinates by the given ones
  2456. * @param otherVector defines the second operand
  2457. * @returns the current updated Vector3
  2458. */
  2459. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2460. /**
  2461. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2462. * @param otherVector defines the second operand
  2463. * @returns the new Vector3
  2464. */
  2465. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2466. /**
  2467. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2468. * @param otherVector defines the second operand
  2469. * @param result defines the Vector3 object where to store the result
  2470. * @returns the current Vector3
  2471. */
  2472. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2473. /**
  2474. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2475. * @param x defines the x coordinate of the operand
  2476. * @param y defines the y coordinate of the operand
  2477. * @param z defines the z coordinate of the operand
  2478. * @returns the new Vector3
  2479. */
  2480. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2481. /**
  2482. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2483. * @param otherVector defines the second operand
  2484. * @returns the new Vector3
  2485. */
  2486. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2487. /**
  2488. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2489. * @param otherVector defines the second operand
  2490. * @param result defines the Vector3 object where to store the result
  2491. * @returns the current Vector3
  2492. */
  2493. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2494. /**
  2495. * Divides the current Vector3 coordinates by the given ones.
  2496. * @param otherVector defines the second operand
  2497. * @returns the current updated Vector3
  2498. */
  2499. divideInPlace(otherVector: Vector3): Vector3;
  2500. /**
  2501. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2502. * @param other defines the second operand
  2503. * @returns the current updated Vector3
  2504. */
  2505. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2506. /**
  2507. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2508. * @param other defines the second operand
  2509. * @returns the current updated Vector3
  2510. */
  2511. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2512. /**
  2513. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2514. * @param x defines the x coordinate of the operand
  2515. * @param y defines the y coordinate of the operand
  2516. * @param z defines the z coordinate of the operand
  2517. * @returns the current updated Vector3
  2518. */
  2519. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2520. /**
  2521. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2522. * @param x defines the x coordinate of the operand
  2523. * @param y defines the y coordinate of the operand
  2524. * @param z defines the z coordinate of the operand
  2525. * @returns the current updated Vector3
  2526. */
  2527. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2528. /**
  2529. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2530. * Check if is non uniform within a certain amount of decimal places to account for this
  2531. * @param epsilon the amount the values can differ
  2532. * @returns if the the vector is non uniform to a certain number of decimal places
  2533. */
  2534. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2535. /**
  2536. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2537. */
  2538. readonly isNonUniform: boolean;
  2539. /**
  2540. * Gets a new Vector3 from current Vector3 floored values
  2541. * @returns a new Vector3
  2542. */
  2543. floor(): Vector3;
  2544. /**
  2545. * Gets a new Vector3 from current Vector3 floored values
  2546. * @returns a new Vector3
  2547. */
  2548. fract(): Vector3;
  2549. /**
  2550. * Gets the length of the Vector3
  2551. * @returns the length of the Vector3
  2552. */
  2553. length(): number;
  2554. /**
  2555. * Gets the squared length of the Vector3
  2556. * @returns squared length of the Vector3
  2557. */
  2558. lengthSquared(): number;
  2559. /**
  2560. * Normalize the current Vector3.
  2561. * Please note that this is an in place operation.
  2562. * @returns the current updated Vector3
  2563. */
  2564. normalize(): Vector3;
  2565. /**
  2566. * Reorders the x y z properties of the vector in place
  2567. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2568. * @returns the current updated vector
  2569. */
  2570. reorderInPlace(order: string): this;
  2571. /**
  2572. * Rotates the vector around 0,0,0 by a quaternion
  2573. * @param quaternion the rotation quaternion
  2574. * @param result vector to store the result
  2575. * @returns the resulting vector
  2576. */
  2577. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2578. /**
  2579. * Rotates a vector around a given point
  2580. * @param quaternion the rotation quaternion
  2581. * @param point the point to rotate around
  2582. * @param result vector to store the result
  2583. * @returns the resulting vector
  2584. */
  2585. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2586. /**
  2587. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2588. * The cross product is then orthogonal to both current and "other"
  2589. * @param other defines the right operand
  2590. * @returns the cross product
  2591. */
  2592. cross(other: Vector3): Vector3;
  2593. /**
  2594. * Normalize the current Vector3 with the given input length.
  2595. * Please note that this is an in place operation.
  2596. * @param len the length of the vector
  2597. * @returns the current updated Vector3
  2598. */
  2599. normalizeFromLength(len: number): Vector3;
  2600. /**
  2601. * Normalize the current Vector3 to a new vector
  2602. * @returns the new Vector3
  2603. */
  2604. normalizeToNew(): Vector3;
  2605. /**
  2606. * Normalize the current Vector3 to the reference
  2607. * @param reference define the Vector3 to update
  2608. * @returns the updated Vector3
  2609. */
  2610. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2611. /**
  2612. * Creates a new Vector3 copied from the current Vector3
  2613. * @returns the new Vector3
  2614. */
  2615. clone(): Vector3;
  2616. /**
  2617. * Copies the given vector coordinates to the current Vector3 ones
  2618. * @param source defines the source Vector3
  2619. * @returns the current updated Vector3
  2620. */
  2621. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2622. /**
  2623. * Copies the given floats to the current Vector3 coordinates
  2624. * @param x defines the x coordinate of the operand
  2625. * @param y defines the y coordinate of the operand
  2626. * @param z defines the z coordinate of the operand
  2627. * @returns the current updated Vector3
  2628. */
  2629. copyFromFloats(x: number, y: number, z: number): Vector3;
  2630. /**
  2631. * Copies the given floats to the current Vector3 coordinates
  2632. * @param x defines the x coordinate of the operand
  2633. * @param y defines the y coordinate of the operand
  2634. * @param z defines the z coordinate of the operand
  2635. * @returns the current updated Vector3
  2636. */
  2637. set(x: number, y: number, z: number): Vector3;
  2638. /**
  2639. * Copies the given float to the current Vector3 coordinates
  2640. * @param v defines the x, y and z coordinates of the operand
  2641. * @returns the current updated Vector3
  2642. */
  2643. setAll(v: number): Vector3;
  2644. /**
  2645. * Get the clip factor between two vectors
  2646. * @param vector0 defines the first operand
  2647. * @param vector1 defines the second operand
  2648. * @param axis defines the axis to use
  2649. * @param size defines the size along the axis
  2650. * @returns the clip factor
  2651. */
  2652. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2653. /**
  2654. * Get angle between two vectors
  2655. * @param vector0 angle between vector0 and vector1
  2656. * @param vector1 angle between vector0 and vector1
  2657. * @param normal direction of the normal
  2658. * @return the angle between vector0 and vector1
  2659. */
  2660. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2661. /**
  2662. * Returns a new Vector3 set from the index "offset" of the given array
  2663. * @param array defines the source array
  2664. * @param offset defines the offset in the source array
  2665. * @returns the new Vector3
  2666. */
  2667. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2668. /**
  2669. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2670. * @param array defines the source array
  2671. * @param offset defines the offset in the source array
  2672. * @returns the new Vector3
  2673. * @deprecated Please use FromArray instead.
  2674. */
  2675. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2676. /**
  2677. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2678. * @param array defines the source array
  2679. * @param offset defines the offset in the source array
  2680. * @param result defines the Vector3 where to store the result
  2681. */
  2682. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2683. /**
  2684. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2685. * @param array defines the source array
  2686. * @param offset defines the offset in the source array
  2687. * @param result defines the Vector3 where to store the result
  2688. * @deprecated Please use FromArrayToRef instead.
  2689. */
  2690. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2691. /**
  2692. * Sets the given vector "result" with the given floats.
  2693. * @param x defines the x coordinate of the source
  2694. * @param y defines the y coordinate of the source
  2695. * @param z defines the z coordinate of the source
  2696. * @param result defines the Vector3 where to store the result
  2697. */
  2698. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2699. /**
  2700. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2701. * @returns a new empty Vector3
  2702. */
  2703. static Zero(): Vector3;
  2704. /**
  2705. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2706. * @returns a new unit Vector3
  2707. */
  2708. static One(): Vector3;
  2709. /**
  2710. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2711. * @returns a new up Vector3
  2712. */
  2713. static Up(): Vector3;
  2714. /**
  2715. * Gets a up Vector3 that must not be updated
  2716. */
  2717. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2718. /**
  2719. * Gets a zero Vector3 that must not be updated
  2720. */
  2721. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2722. /**
  2723. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2724. * @returns a new down Vector3
  2725. */
  2726. static Down(): Vector3;
  2727. /**
  2728. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2729. * @returns a new forward Vector3
  2730. */
  2731. static Forward(): Vector3;
  2732. /**
  2733. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2734. * @returns a new forward Vector3
  2735. */
  2736. static Backward(): Vector3;
  2737. /**
  2738. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2739. * @returns a new right Vector3
  2740. */
  2741. static Right(): Vector3;
  2742. /**
  2743. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2744. * @returns a new left Vector3
  2745. */
  2746. static Left(): Vector3;
  2747. /**
  2748. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2749. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2750. * @param vector defines the Vector3 to transform
  2751. * @param transformation defines the transformation matrix
  2752. * @returns the transformed Vector3
  2753. */
  2754. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2755. /**
  2756. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2757. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2758. * @param vector defines the Vector3 to transform
  2759. * @param transformation defines the transformation matrix
  2760. * @param result defines the Vector3 where to store the result
  2761. */
  2762. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2763. /**
  2764. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2765. * This method computes tranformed coordinates only, not transformed direction vectors
  2766. * @param x define the x coordinate of the source vector
  2767. * @param y define the y coordinate of the source vector
  2768. * @param z define the z coordinate of the source vector
  2769. * @param transformation defines the transformation matrix
  2770. * @param result defines the Vector3 where to store the result
  2771. */
  2772. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2773. /**
  2774. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2775. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2776. * @param vector defines the Vector3 to transform
  2777. * @param transformation defines the transformation matrix
  2778. * @returns the new Vector3
  2779. */
  2780. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2781. /**
  2782. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2783. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2784. * @param vector defines the Vector3 to transform
  2785. * @param transformation defines the transformation matrix
  2786. * @param result defines the Vector3 where to store the result
  2787. */
  2788. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2789. /**
  2790. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2791. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2792. * @param x define the x coordinate of the source vector
  2793. * @param y define the y coordinate of the source vector
  2794. * @param z define the z coordinate of the source vector
  2795. * @param transformation defines the transformation matrix
  2796. * @param result defines the Vector3 where to store the result
  2797. */
  2798. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2799. /**
  2800. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2801. * @param value1 defines the first control point
  2802. * @param value2 defines the second control point
  2803. * @param value3 defines the third control point
  2804. * @param value4 defines the fourth control point
  2805. * @param amount defines the amount on the spline to use
  2806. * @returns the new Vector3
  2807. */
  2808. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2809. /**
  2810. * 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"
  2811. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2812. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2813. * @param value defines the current value
  2814. * @param min defines the lower range value
  2815. * @param max defines the upper range value
  2816. * @returns the new Vector3
  2817. */
  2818. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2819. /**
  2820. * 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"
  2821. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2822. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2823. * @param value defines the current value
  2824. * @param min defines the lower range value
  2825. * @param max defines the upper range value
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2829. /**
  2830. * Checks if a given vector is inside a specific range
  2831. * @param v defines the vector to test
  2832. * @param min defines the minimum range
  2833. * @param max defines the maximum range
  2834. */
  2835. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2836. /**
  2837. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2838. * @param value1 defines the first control point
  2839. * @param tangent1 defines the first tangent vector
  2840. * @param value2 defines the second control point
  2841. * @param tangent2 defines the second tangent vector
  2842. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2843. * @returns the new Vector3
  2844. */
  2845. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2846. /**
  2847. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2848. * @param start defines the start value
  2849. * @param end defines the end value
  2850. * @param amount max defines amount between both (between 0 and 1)
  2851. * @returns the new Vector3
  2852. */
  2853. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2854. /**
  2855. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2856. * @param start defines the start value
  2857. * @param end defines the end value
  2858. * @param amount max defines amount between both (between 0 and 1)
  2859. * @param result defines the Vector3 where to store the result
  2860. */
  2861. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2862. /**
  2863. * Returns the dot product (float) between the vectors "left" and "right"
  2864. * @param left defines the left operand
  2865. * @param right defines the right operand
  2866. * @returns the dot product
  2867. */
  2868. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2869. /**
  2870. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2871. * The cross product is then orthogonal to both "left" and "right"
  2872. * @param left defines the left operand
  2873. * @param right defines the right operand
  2874. * @returns the cross product
  2875. */
  2876. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2877. /**
  2878. * Sets the given vector "result" with the cross product of "left" and "right"
  2879. * The cross product is then orthogonal to both "left" and "right"
  2880. * @param left defines the left operand
  2881. * @param right defines the right operand
  2882. * @param result defines the Vector3 where to store the result
  2883. */
  2884. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2885. /**
  2886. * Returns a new Vector3 as the normalization of the given vector
  2887. * @param vector defines the Vector3 to normalize
  2888. * @returns the new Vector3
  2889. */
  2890. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2891. /**
  2892. * Sets the given vector "result" with the normalization of the given first vector
  2893. * @param vector defines the Vector3 to normalize
  2894. * @param result defines the Vector3 where to store the result
  2895. */
  2896. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2897. /**
  2898. * Project a Vector3 onto screen space
  2899. * @param vector defines the Vector3 to project
  2900. * @param world defines the world matrix to use
  2901. * @param transform defines the transform (view x projection) matrix to use
  2902. * @param viewport defines the screen viewport to use
  2903. * @returns the new Vector3
  2904. */
  2905. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2906. /** @hidden */
  2907. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2908. /**
  2909. * Unproject from screen space to object space
  2910. * @param source defines the screen space Vector3 to use
  2911. * @param viewportWidth defines the current width of the viewport
  2912. * @param viewportHeight defines the current height of the viewport
  2913. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2914. * @param transform defines the transform (view x projection) matrix to use
  2915. * @returns the new Vector3
  2916. */
  2917. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2918. /**
  2919. * Unproject from screen space to object space
  2920. * @param source defines the screen space Vector3 to use
  2921. * @param viewportWidth defines the current width of the viewport
  2922. * @param viewportHeight defines the current height of the viewport
  2923. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2924. * @param view defines the view matrix to use
  2925. * @param projection defines the projection matrix to use
  2926. * @returns the new Vector3
  2927. */
  2928. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2929. /**
  2930. * Unproject from screen space to object space
  2931. * @param source defines the screen space Vector3 to use
  2932. * @param viewportWidth defines the current width of the viewport
  2933. * @param viewportHeight defines the current height of the viewport
  2934. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2935. * @param view defines the view matrix to use
  2936. * @param projection defines the projection matrix to use
  2937. * @param result defines the Vector3 where to store the result
  2938. */
  2939. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2940. /**
  2941. * Unproject from screen space to object space
  2942. * @param sourceX defines the screen space x coordinate to use
  2943. * @param sourceY defines the screen space y coordinate to use
  2944. * @param sourceZ defines the screen space z coordinate 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. * @param result defines the Vector3 where to store the result
  2951. */
  2952. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2953. /**
  2954. * Gets the minimal coordinate values between two Vector3
  2955. * @param left defines the first operand
  2956. * @param right defines the second operand
  2957. * @returns the new Vector3
  2958. */
  2959. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2960. /**
  2961. * Gets the maximal coordinate values between two Vector3
  2962. * @param left defines the first operand
  2963. * @param right defines the second operand
  2964. * @returns the new Vector3
  2965. */
  2966. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2967. /**
  2968. * Returns the distance between the vectors "value1" and "value2"
  2969. * @param value1 defines the first operand
  2970. * @param value2 defines the second operand
  2971. * @returns the distance
  2972. */
  2973. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2974. /**
  2975. * Returns the squared distance between the vectors "value1" and "value2"
  2976. * @param value1 defines the first operand
  2977. * @param value2 defines the second operand
  2978. * @returns the squared distance
  2979. */
  2980. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2981. /**
  2982. * Returns a new Vector3 located at the center between "value1" and "value2"
  2983. * @param value1 defines the first operand
  2984. * @param value2 defines the second operand
  2985. * @returns the new Vector3
  2986. */
  2987. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2988. /**
  2989. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2990. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2991. * to something in order to rotate it from its local system to the given target system
  2992. * Note: axis1, axis2 and axis3 are normalized during this operation
  2993. * @param axis1 defines the first axis
  2994. * @param axis2 defines the second axis
  2995. * @param axis3 defines the third axis
  2996. * @returns a new Vector3
  2997. */
  2998. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2999. /**
  3000. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3001. * @param axis1 defines the first axis
  3002. * @param axis2 defines the second axis
  3003. * @param axis3 defines the third axis
  3004. * @param ref defines the Vector3 where to store the result
  3005. */
  3006. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3007. }
  3008. /**
  3009. * Vector4 class created for EulerAngle class conversion to Quaternion
  3010. */
  3011. export class Vector4 {
  3012. /** x value of the vector */
  3013. x: number;
  3014. /** y value of the vector */
  3015. y: number;
  3016. /** z value of the vector */
  3017. z: number;
  3018. /** w value of the vector */
  3019. w: number;
  3020. /**
  3021. * Creates a Vector4 object from the given floats.
  3022. * @param x x value of the vector
  3023. * @param y y value of the vector
  3024. * @param z z value of the vector
  3025. * @param w w value of the vector
  3026. */
  3027. constructor(
  3028. /** x value of the vector */
  3029. x: number,
  3030. /** y value of the vector */
  3031. y: number,
  3032. /** z value of the vector */
  3033. z: number,
  3034. /** w value of the vector */
  3035. w: number);
  3036. /**
  3037. * Returns the string with the Vector4 coordinates.
  3038. * @returns a string containing all the vector values
  3039. */
  3040. toString(): string;
  3041. /**
  3042. * Returns the string "Vector4".
  3043. * @returns "Vector4"
  3044. */
  3045. getClassName(): string;
  3046. /**
  3047. * Returns the Vector4 hash code.
  3048. * @returns a unique hash code
  3049. */
  3050. getHashCode(): number;
  3051. /**
  3052. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3053. * @returns the resulting array
  3054. */
  3055. asArray(): number[];
  3056. /**
  3057. * Populates the given array from the given index with the Vector4 coordinates.
  3058. * @param array array to populate
  3059. * @param index index of the array to start at (default: 0)
  3060. * @returns the Vector4.
  3061. */
  3062. toArray(array: FloatArray, index?: number): Vector4;
  3063. /**
  3064. * Adds the given vector to the current Vector4.
  3065. * @param otherVector the vector to add
  3066. * @returns the updated Vector4.
  3067. */
  3068. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3069. /**
  3070. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3071. * @param otherVector the vector to add
  3072. * @returns the resulting vector
  3073. */
  3074. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3075. /**
  3076. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3077. * @param otherVector the vector to add
  3078. * @param result the vector to store the result
  3079. * @returns the current Vector4.
  3080. */
  3081. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3082. /**
  3083. * Subtract in place the given vector from the current Vector4.
  3084. * @param otherVector the vector to subtract
  3085. * @returns the updated Vector4.
  3086. */
  3087. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3088. /**
  3089. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3090. * @param otherVector the vector to add
  3091. * @returns the new vector with the result
  3092. */
  3093. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3094. /**
  3095. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3096. * @param otherVector the vector to subtract
  3097. * @param result the vector to store the result
  3098. * @returns the current Vector4.
  3099. */
  3100. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3101. /**
  3102. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3103. */
  3104. /**
  3105. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3106. * @param x value to subtract
  3107. * @param y value to subtract
  3108. * @param z value to subtract
  3109. * @param w value to subtract
  3110. * @returns new vector containing the result
  3111. */
  3112. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3113. /**
  3114. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3115. * @param x value to subtract
  3116. * @param y value to subtract
  3117. * @param z value to subtract
  3118. * @param w value to subtract
  3119. * @param result the vector to store the result in
  3120. * @returns the current Vector4.
  3121. */
  3122. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3123. /**
  3124. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3125. * @returns a new vector with the negated values
  3126. */
  3127. negate(): Vector4;
  3128. /**
  3129. * Multiplies the current Vector4 coordinates by scale (float).
  3130. * @param scale the number to scale with
  3131. * @returns the updated Vector4.
  3132. */
  3133. scaleInPlace(scale: number): Vector4;
  3134. /**
  3135. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3136. * @param scale the number to scale with
  3137. * @returns a new vector with the result
  3138. */
  3139. scale(scale: number): Vector4;
  3140. /**
  3141. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3142. * @param scale the number to scale with
  3143. * @param result a vector to store the result in
  3144. * @returns the current Vector4.
  3145. */
  3146. scaleToRef(scale: number, result: Vector4): Vector4;
  3147. /**
  3148. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3149. * @param scale defines the scale factor
  3150. * @param result defines the Vector4 object where to store the result
  3151. * @returns the unmodified current Vector4
  3152. */
  3153. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3154. /**
  3155. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3156. * @param otherVector the vector to compare against
  3157. * @returns true if they are equal
  3158. */
  3159. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3160. /**
  3161. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3162. * @param otherVector vector to compare against
  3163. * @param epsilon (Default: very small number)
  3164. * @returns true if they are equal
  3165. */
  3166. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3167. /**
  3168. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3169. * @param x x value to compare against
  3170. * @param y y value to compare against
  3171. * @param z z value to compare against
  3172. * @param w w value to compare against
  3173. * @returns true if equal
  3174. */
  3175. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3176. /**
  3177. * Multiplies in place the current Vector4 by the given one.
  3178. * @param otherVector vector to multiple with
  3179. * @returns the updated Vector4.
  3180. */
  3181. multiplyInPlace(otherVector: Vector4): Vector4;
  3182. /**
  3183. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3184. * @param otherVector vector to multiple with
  3185. * @returns resulting new vector
  3186. */
  3187. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3188. /**
  3189. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3190. * @param otherVector vector to multiple with
  3191. * @param result vector to store the result
  3192. * @returns the current Vector4.
  3193. */
  3194. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3195. /**
  3196. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3197. * @param x x value multiply with
  3198. * @param y y value multiply with
  3199. * @param z z value multiply with
  3200. * @param w w value multiply with
  3201. * @returns resulting new vector
  3202. */
  3203. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3204. /**
  3205. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3206. * @param otherVector vector to devide with
  3207. * @returns resulting new vector
  3208. */
  3209. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3210. /**
  3211. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3212. * @param otherVector vector to devide with
  3213. * @param result vector to store the result
  3214. * @returns the current Vector4.
  3215. */
  3216. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3217. /**
  3218. * Divides the current Vector3 coordinates by the given ones.
  3219. * @param otherVector vector to devide with
  3220. * @returns the updated Vector3.
  3221. */
  3222. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3223. /**
  3224. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3225. * @param other defines the second operand
  3226. * @returns the current updated Vector4
  3227. */
  3228. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3229. /**
  3230. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3231. * @param other defines the second operand
  3232. * @returns the current updated Vector4
  3233. */
  3234. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3235. /**
  3236. * Gets a new Vector4 from current Vector4 floored values
  3237. * @returns a new Vector4
  3238. */
  3239. floor(): Vector4;
  3240. /**
  3241. * Gets a new Vector4 from current Vector3 floored values
  3242. * @returns a new Vector4
  3243. */
  3244. fract(): Vector4;
  3245. /**
  3246. * Returns the Vector4 length (float).
  3247. * @returns the length
  3248. */
  3249. length(): number;
  3250. /**
  3251. * Returns the Vector4 squared length (float).
  3252. * @returns the length squared
  3253. */
  3254. lengthSquared(): number;
  3255. /**
  3256. * Normalizes in place the Vector4.
  3257. * @returns the updated Vector4.
  3258. */
  3259. normalize(): Vector4;
  3260. /**
  3261. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3262. * @returns this converted to a new vector3
  3263. */
  3264. toVector3(): Vector3;
  3265. /**
  3266. * Returns a new Vector4 copied from the current one.
  3267. * @returns the new cloned vector
  3268. */
  3269. clone(): Vector4;
  3270. /**
  3271. * Updates the current Vector4 with the given one coordinates.
  3272. * @param source the source vector to copy from
  3273. * @returns the updated Vector4.
  3274. */
  3275. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3276. /**
  3277. * Updates the current Vector4 coordinates with the given floats.
  3278. * @param x float to copy from
  3279. * @param y float to copy from
  3280. * @param z float to copy from
  3281. * @param w float to copy from
  3282. * @returns the updated Vector4.
  3283. */
  3284. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3285. /**
  3286. * Updates the current Vector4 coordinates with the given floats.
  3287. * @param x float to set from
  3288. * @param y float to set from
  3289. * @param z float to set from
  3290. * @param w float to set from
  3291. * @returns the updated Vector4.
  3292. */
  3293. set(x: number, y: number, z: number, w: number): Vector4;
  3294. /**
  3295. * Copies the given float to the current Vector3 coordinates
  3296. * @param v defines the x, y, z and w coordinates of the operand
  3297. * @returns the current updated Vector3
  3298. */
  3299. setAll(v: number): Vector4;
  3300. /**
  3301. * Returns a new Vector4 set from the starting index of the given array.
  3302. * @param array the array to pull values from
  3303. * @param offset the offset into the array to start at
  3304. * @returns the new vector
  3305. */
  3306. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3307. /**
  3308. * Updates the given vector "result" from the starting index of the given array.
  3309. * @param array the array to pull values from
  3310. * @param offset the offset into the array to start at
  3311. * @param result the vector to store the result in
  3312. */
  3313. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3314. /**
  3315. * Updates the given vector "result" from the starting index of the given Float32Array.
  3316. * @param array the array to pull values from
  3317. * @param offset the offset into the array to start at
  3318. * @param result the vector to store the result in
  3319. */
  3320. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3321. /**
  3322. * Updates the given vector "result" coordinates from the given floats.
  3323. * @param x float to set from
  3324. * @param y float to set from
  3325. * @param z float to set from
  3326. * @param w float to set from
  3327. * @param result the vector to the floats in
  3328. */
  3329. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3330. /**
  3331. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3332. * @returns the new vector
  3333. */
  3334. static Zero(): Vector4;
  3335. /**
  3336. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3337. * @returns the new vector
  3338. */
  3339. static One(): Vector4;
  3340. /**
  3341. * Returns a new normalized Vector4 from the given one.
  3342. * @param vector the vector to normalize
  3343. * @returns the vector
  3344. */
  3345. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3346. /**
  3347. * Updates the given vector "result" from the normalization of the given one.
  3348. * @param vector the vector to normalize
  3349. * @param result the vector to store the result in
  3350. */
  3351. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3352. /**
  3353. * Returns a vector with the minimum values from the left and right vectors
  3354. * @param left left vector to minimize
  3355. * @param right right vector to minimize
  3356. * @returns a new vector with the minimum of the left and right vector values
  3357. */
  3358. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3359. /**
  3360. * Returns a vector with the maximum values from the left and right vectors
  3361. * @param left left vector to maximize
  3362. * @param right right vector to maximize
  3363. * @returns a new vector with the maximum of the left and right vector values
  3364. */
  3365. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3366. /**
  3367. * Returns the distance (float) between the vectors "value1" and "value2".
  3368. * @param value1 value to calulate the distance between
  3369. * @param value2 value to calulate the distance between
  3370. * @return the distance between the two vectors
  3371. */
  3372. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3373. /**
  3374. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3375. * @param value1 value to calulate the distance between
  3376. * @param value2 value to calulate the distance between
  3377. * @return the distance between the two vectors squared
  3378. */
  3379. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3380. /**
  3381. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3382. * @param value1 value to calulate the center between
  3383. * @param value2 value to calulate the center between
  3384. * @return the center between the two vectors
  3385. */
  3386. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3387. /**
  3388. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3389. * This methods computes transformed normalized direction vectors only.
  3390. * @param vector the vector to transform
  3391. * @param transformation the transformation matrix to apply
  3392. * @returns the new vector
  3393. */
  3394. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3395. /**
  3396. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3397. * This methods computes transformed normalized direction vectors only.
  3398. * @param vector the vector to transform
  3399. * @param transformation the transformation matrix to apply
  3400. * @param result the vector to store the result in
  3401. */
  3402. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3403. /**
  3404. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3405. * This methods computes transformed normalized direction vectors only.
  3406. * @param x value to transform
  3407. * @param y value to transform
  3408. * @param z value to transform
  3409. * @param w value to transform
  3410. * @param transformation the transformation matrix to apply
  3411. * @param result the vector to store the results in
  3412. */
  3413. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3414. /**
  3415. * Creates a new Vector4 from a Vector3
  3416. * @param source defines the source data
  3417. * @param w defines the 4th component (default is 0)
  3418. * @returns a new Vector4
  3419. */
  3420. static FromVector3(source: Vector3, w?: number): Vector4;
  3421. }
  3422. /**
  3423. * Class used to store quaternion data
  3424. * @see https://en.wikipedia.org/wiki/Quaternion
  3425. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3426. */
  3427. export class Quaternion {
  3428. /** defines the first component (0 by default) */
  3429. x: number;
  3430. /** defines the second component (0 by default) */
  3431. y: number;
  3432. /** defines the third component (0 by default) */
  3433. z: number;
  3434. /** defines the fourth component (1.0 by default) */
  3435. w: number;
  3436. /**
  3437. * Creates a new Quaternion from the given floats
  3438. * @param x defines the first component (0 by default)
  3439. * @param y defines the second component (0 by default)
  3440. * @param z defines the third component (0 by default)
  3441. * @param w defines the fourth component (1.0 by default)
  3442. */
  3443. constructor(
  3444. /** defines the first component (0 by default) */
  3445. x?: number,
  3446. /** defines the second component (0 by default) */
  3447. y?: number,
  3448. /** defines the third component (0 by default) */
  3449. z?: number,
  3450. /** defines the fourth component (1.0 by default) */
  3451. w?: number);
  3452. /**
  3453. * Gets a string representation for the current quaternion
  3454. * @returns a string with the Quaternion coordinates
  3455. */
  3456. toString(): string;
  3457. /**
  3458. * Gets the class name of the quaternion
  3459. * @returns the string "Quaternion"
  3460. */
  3461. getClassName(): string;
  3462. /**
  3463. * Gets a hash code for this quaternion
  3464. * @returns the quaternion hash code
  3465. */
  3466. getHashCode(): number;
  3467. /**
  3468. * Copy the quaternion to an array
  3469. * @returns a new array populated with 4 elements from the quaternion coordinates
  3470. */
  3471. asArray(): number[];
  3472. /**
  3473. * Check if two quaternions are equals
  3474. * @param otherQuaternion defines the second operand
  3475. * @return true if the current quaternion and the given one coordinates are strictly equals
  3476. */
  3477. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3478. /**
  3479. * Clone the current quaternion
  3480. * @returns a new quaternion copied from the current one
  3481. */
  3482. clone(): Quaternion;
  3483. /**
  3484. * Copy a quaternion to the current one
  3485. * @param other defines the other quaternion
  3486. * @returns the updated current quaternion
  3487. */
  3488. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3489. /**
  3490. * Updates the current quaternion with the given float coordinates
  3491. * @param x defines the x coordinate
  3492. * @param y defines the y coordinate
  3493. * @param z defines the z coordinate
  3494. * @param w defines the w coordinate
  3495. * @returns the updated current quaternion
  3496. */
  3497. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3498. /**
  3499. * Updates the current quaternion from the given float coordinates
  3500. * @param x defines the x coordinate
  3501. * @param y defines the y coordinate
  3502. * @param z defines the z coordinate
  3503. * @param w defines the w coordinate
  3504. * @returns the updated current quaternion
  3505. */
  3506. set(x: number, y: number, z: number, w: number): Quaternion;
  3507. /**
  3508. * Adds two quaternions
  3509. * @param other defines the second operand
  3510. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3511. */
  3512. add(other: DeepImmutable<Quaternion>): Quaternion;
  3513. /**
  3514. * Add a quaternion to the current one
  3515. * @param other defines the quaternion to add
  3516. * @returns the current quaternion
  3517. */
  3518. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3519. /**
  3520. * Subtract two quaternions
  3521. * @param other defines the second operand
  3522. * @returns a new quaternion as the subtraction result of the given one from the current one
  3523. */
  3524. subtract(other: Quaternion): Quaternion;
  3525. /**
  3526. * Multiplies the current quaternion by a scale factor
  3527. * @param value defines the scale factor
  3528. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3529. */
  3530. scale(value: number): Quaternion;
  3531. /**
  3532. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3533. * @param scale defines the scale factor
  3534. * @param result defines the Quaternion object where to store the result
  3535. * @returns the unmodified current quaternion
  3536. */
  3537. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3538. /**
  3539. * Multiplies in place the current quaternion by a scale factor
  3540. * @param value defines the scale factor
  3541. * @returns the current modified quaternion
  3542. */
  3543. scaleInPlace(value: number): Quaternion;
  3544. /**
  3545. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3546. * @param scale defines the scale factor
  3547. * @param result defines the Quaternion object where to store the result
  3548. * @returns the unmodified current quaternion
  3549. */
  3550. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3551. /**
  3552. * Multiplies two quaternions
  3553. * @param q1 defines the second operand
  3554. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3555. */
  3556. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3557. /**
  3558. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3559. * @param q1 defines the second operand
  3560. * @param result defines the target quaternion
  3561. * @returns the current quaternion
  3562. */
  3563. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3564. /**
  3565. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3566. * @param q1 defines the second operand
  3567. * @returns the currentupdated quaternion
  3568. */
  3569. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3570. /**
  3571. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3572. * @param ref defines the target quaternion
  3573. * @returns the current quaternion
  3574. */
  3575. conjugateToRef(ref: Quaternion): Quaternion;
  3576. /**
  3577. * Conjugates in place (1-q) the current quaternion
  3578. * @returns the current updated quaternion
  3579. */
  3580. conjugateInPlace(): Quaternion;
  3581. /**
  3582. * Conjugates in place (1-q) the current quaternion
  3583. * @returns a new quaternion
  3584. */
  3585. conjugate(): Quaternion;
  3586. /**
  3587. * Gets length of current quaternion
  3588. * @returns the quaternion length (float)
  3589. */
  3590. length(): number;
  3591. /**
  3592. * Normalize in place the current quaternion
  3593. * @returns the current updated quaternion
  3594. */
  3595. normalize(): Quaternion;
  3596. /**
  3597. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3598. * @param order is a reserved parameter and is ignore for now
  3599. * @returns a new Vector3 containing the Euler angles
  3600. */
  3601. toEulerAngles(order?: string): Vector3;
  3602. /**
  3603. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3604. * @param result defines the vector which will be filled with the Euler angles
  3605. * @param order is a reserved parameter and is ignore for now
  3606. * @returns the current unchanged quaternion
  3607. */
  3608. toEulerAnglesToRef(result: Vector3): Quaternion;
  3609. /**
  3610. * Updates the given rotation matrix with the current quaternion values
  3611. * @param result defines the target matrix
  3612. * @returns the current unchanged quaternion
  3613. */
  3614. toRotationMatrix(result: Matrix): Quaternion;
  3615. /**
  3616. * Updates the current quaternion from the given rotation matrix values
  3617. * @param matrix defines the source matrix
  3618. * @returns the current updated quaternion
  3619. */
  3620. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3621. /**
  3622. * Creates a new quaternion from a rotation matrix
  3623. * @param matrix defines the source matrix
  3624. * @returns a new quaternion created from the given rotation matrix values
  3625. */
  3626. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3627. /**
  3628. * Updates the given quaternion with the given rotation matrix values
  3629. * @param matrix defines the source matrix
  3630. * @param result defines the target quaternion
  3631. */
  3632. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3633. /**
  3634. * Returns the dot product (float) between the quaternions "left" and "right"
  3635. * @param left defines the left operand
  3636. * @param right defines the right operand
  3637. * @returns the dot product
  3638. */
  3639. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3640. /**
  3641. * Checks if the two quaternions are close to each other
  3642. * @param quat0 defines the first quaternion to check
  3643. * @param quat1 defines the second quaternion to check
  3644. * @returns true if the two quaternions are close to each other
  3645. */
  3646. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3647. /**
  3648. * Creates an empty quaternion
  3649. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3650. */
  3651. static Zero(): Quaternion;
  3652. /**
  3653. * Inverse a given quaternion
  3654. * @param q defines the source quaternion
  3655. * @returns a new quaternion as the inverted current quaternion
  3656. */
  3657. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3658. /**
  3659. * Inverse a given quaternion
  3660. * @param q defines the source quaternion
  3661. * @param result the quaternion the result will be stored in
  3662. * @returns the result quaternion
  3663. */
  3664. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3665. /**
  3666. * Creates an identity quaternion
  3667. * @returns the identity quaternion
  3668. */
  3669. static Identity(): Quaternion;
  3670. /**
  3671. * Gets a boolean indicating if the given quaternion is identity
  3672. * @param quaternion defines the quaternion to check
  3673. * @returns true if the quaternion is identity
  3674. */
  3675. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3676. /**
  3677. * Creates a quaternion from a rotation around an axis
  3678. * @param axis defines the axis to use
  3679. * @param angle defines the angle to use
  3680. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3681. */
  3682. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3683. /**
  3684. * Creates a rotation around an axis and stores it into the given quaternion
  3685. * @param axis defines the axis to use
  3686. * @param angle defines the angle to use
  3687. * @param result defines the target quaternion
  3688. * @returns the target quaternion
  3689. */
  3690. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3691. /**
  3692. * Creates a new quaternion from data stored into an array
  3693. * @param array defines the data source
  3694. * @param offset defines the offset in the source array where the data starts
  3695. * @returns a new quaternion
  3696. */
  3697. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3698. /**
  3699. * Create a quaternion from Euler rotation angles
  3700. * @param x Pitch
  3701. * @param y Yaw
  3702. * @param z Roll
  3703. * @returns the new Quaternion
  3704. */
  3705. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3706. /**
  3707. * Updates a quaternion from Euler rotation angles
  3708. * @param x Pitch
  3709. * @param y Yaw
  3710. * @param z Roll
  3711. * @param result the quaternion to store the result
  3712. * @returns the updated quaternion
  3713. */
  3714. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3715. /**
  3716. * Create a quaternion from Euler rotation vector
  3717. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3718. * @returns the new Quaternion
  3719. */
  3720. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3721. /**
  3722. * Updates a quaternion from Euler rotation vector
  3723. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3724. * @param result the quaternion to store the result
  3725. * @returns the updated quaternion
  3726. */
  3727. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3728. /**
  3729. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3730. * @param yaw defines the rotation around Y axis
  3731. * @param pitch defines the rotation around X axis
  3732. * @param roll defines the rotation around Z axis
  3733. * @returns the new quaternion
  3734. */
  3735. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3736. /**
  3737. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3738. * @param yaw defines the rotation around Y axis
  3739. * @param pitch defines the rotation around X axis
  3740. * @param roll defines the rotation around Z axis
  3741. * @param result defines the target quaternion
  3742. */
  3743. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3744. /**
  3745. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3746. * @param alpha defines the rotation around first axis
  3747. * @param beta defines the rotation around second axis
  3748. * @param gamma defines the rotation around third axis
  3749. * @returns the new quaternion
  3750. */
  3751. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3752. /**
  3753. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3754. * @param alpha defines the rotation around first axis
  3755. * @param beta defines the rotation around second axis
  3756. * @param gamma defines the rotation around third axis
  3757. * @param result defines the target quaternion
  3758. */
  3759. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3760. /**
  3761. * 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)
  3762. * @param axis1 defines the first axis
  3763. * @param axis2 defines the second axis
  3764. * @param axis3 defines the third axis
  3765. * @returns the new quaternion
  3766. */
  3767. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3768. /**
  3769. * 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
  3770. * @param axis1 defines the first axis
  3771. * @param axis2 defines the second axis
  3772. * @param axis3 defines the third axis
  3773. * @param ref defines the target quaternion
  3774. */
  3775. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3776. /**
  3777. * Interpolates between two quaternions
  3778. * @param left defines first quaternion
  3779. * @param right defines second quaternion
  3780. * @param amount defines the gradient to use
  3781. * @returns the new interpolated quaternion
  3782. */
  3783. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3784. /**
  3785. * Interpolates between two quaternions and stores it into a target quaternion
  3786. * @param left defines first quaternion
  3787. * @param right defines second quaternion
  3788. * @param amount defines the gradient to use
  3789. * @param result defines the target quaternion
  3790. */
  3791. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3792. /**
  3793. * Interpolate between two quaternions using Hermite interpolation
  3794. * @param value1 defines first quaternion
  3795. * @param tangent1 defines the incoming tangent
  3796. * @param value2 defines second quaternion
  3797. * @param tangent2 defines the outgoing tangent
  3798. * @param amount defines the target quaternion
  3799. * @returns the new interpolated quaternion
  3800. */
  3801. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3802. }
  3803. /**
  3804. * Class used to store matrix data (4x4)
  3805. */
  3806. export class Matrix {
  3807. private static _updateFlagSeed;
  3808. private static _identityReadOnly;
  3809. private _isIdentity;
  3810. private _isIdentityDirty;
  3811. private _isIdentity3x2;
  3812. private _isIdentity3x2Dirty;
  3813. /**
  3814. * Gets the update flag of the matrix which is an unique number for the matrix.
  3815. * It will be incremented every time the matrix data change.
  3816. * You can use it to speed the comparison between two versions of the same matrix.
  3817. */
  3818. updateFlag: number;
  3819. private readonly _m;
  3820. /**
  3821. * Gets the internal data of the matrix
  3822. */
  3823. readonly m: DeepImmutable<Float32Array>;
  3824. /** @hidden */
  3825. _markAsUpdated(): void;
  3826. /** @hidden */
  3827. private _updateIdentityStatus;
  3828. /**
  3829. * Creates an empty matrix (filled with zeros)
  3830. */
  3831. constructor();
  3832. /**
  3833. * Check if the current matrix is identity
  3834. * @returns true is the matrix is the identity matrix
  3835. */
  3836. isIdentity(): boolean;
  3837. /**
  3838. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3839. * @returns true is the matrix is the identity matrix
  3840. */
  3841. isIdentityAs3x2(): boolean;
  3842. /**
  3843. * Gets the determinant of the matrix
  3844. * @returns the matrix determinant
  3845. */
  3846. determinant(): number;
  3847. /**
  3848. * Returns the matrix as a Float32Array
  3849. * @returns the matrix underlying array
  3850. */
  3851. toArray(): DeepImmutable<Float32Array>;
  3852. /**
  3853. * Returns the matrix as a Float32Array
  3854. * @returns the matrix underlying array.
  3855. */
  3856. asArray(): DeepImmutable<Float32Array>;
  3857. /**
  3858. * Inverts the current matrix in place
  3859. * @returns the current inverted matrix
  3860. */
  3861. invert(): Matrix;
  3862. /**
  3863. * Sets all the matrix elements to zero
  3864. * @returns the current matrix
  3865. */
  3866. reset(): Matrix;
  3867. /**
  3868. * Adds the current matrix with a second one
  3869. * @param other defines the matrix to add
  3870. * @returns a new matrix as the addition of the current matrix and the given one
  3871. */
  3872. add(other: DeepImmutable<Matrix>): Matrix;
  3873. /**
  3874. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3875. * @param other defines the matrix to add
  3876. * @param result defines the target matrix
  3877. * @returns the current matrix
  3878. */
  3879. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3880. /**
  3881. * Adds in place the given matrix to the current matrix
  3882. * @param other defines the second operand
  3883. * @returns the current updated matrix
  3884. */
  3885. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3886. /**
  3887. * Sets the given matrix to the current inverted Matrix
  3888. * @param other defines the target matrix
  3889. * @returns the unmodified current matrix
  3890. */
  3891. invertToRef(other: Matrix): Matrix;
  3892. /**
  3893. * add a value at the specified position in the current Matrix
  3894. * @param index the index of the value within the matrix. between 0 and 15.
  3895. * @param value the value to be added
  3896. * @returns the current updated matrix
  3897. */
  3898. addAtIndex(index: number, value: number): Matrix;
  3899. /**
  3900. * mutiply the specified position in the current Matrix by a value
  3901. * @param index the index of the value within the matrix. between 0 and 15.
  3902. * @param value the value to be added
  3903. * @returns the current updated matrix
  3904. */
  3905. multiplyAtIndex(index: number, value: number): Matrix;
  3906. /**
  3907. * Inserts the translation vector (using 3 floats) in the current matrix
  3908. * @param x defines the 1st component of the translation
  3909. * @param y defines the 2nd component of the translation
  3910. * @param z defines the 3rd component of the translation
  3911. * @returns the current updated matrix
  3912. */
  3913. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3914. /**
  3915. * Adds the translation vector (using 3 floats) in the current matrix
  3916. * @param x defines the 1st component of the translation
  3917. * @param y defines the 2nd component of the translation
  3918. * @param z defines the 3rd component of the translation
  3919. * @returns the current updated matrix
  3920. */
  3921. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3922. /**
  3923. * Inserts the translation vector in the current matrix
  3924. * @param vector3 defines the translation to insert
  3925. * @returns the current updated matrix
  3926. */
  3927. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3928. /**
  3929. * Gets the translation value of the current matrix
  3930. * @returns a new Vector3 as the extracted translation from the matrix
  3931. */
  3932. getTranslation(): Vector3;
  3933. /**
  3934. * Fill a Vector3 with the extracted translation from the matrix
  3935. * @param result defines the Vector3 where to store the translation
  3936. * @returns the current matrix
  3937. */
  3938. getTranslationToRef(result: Vector3): Matrix;
  3939. /**
  3940. * Remove rotation and scaling part from the matrix
  3941. * @returns the updated matrix
  3942. */
  3943. removeRotationAndScaling(): Matrix;
  3944. /**
  3945. * Multiply two matrices
  3946. * @param other defines the second operand
  3947. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3948. */
  3949. multiply(other: DeepImmutable<Matrix>): Matrix;
  3950. /**
  3951. * Copy the current matrix from the given one
  3952. * @param other defines the source matrix
  3953. * @returns the current updated matrix
  3954. */
  3955. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3956. /**
  3957. * Populates the given array from the starting index with the current matrix values
  3958. * @param array defines the target array
  3959. * @param offset defines the offset in the target array where to start storing values
  3960. * @returns the current matrix
  3961. */
  3962. copyToArray(array: Float32Array, offset?: number): Matrix;
  3963. /**
  3964. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3965. * @param other defines the second operand
  3966. * @param result defines the matrix where to store the multiplication
  3967. * @returns the current matrix
  3968. */
  3969. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3970. /**
  3971. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3972. * @param other defines the second operand
  3973. * @param result defines the array where to store the multiplication
  3974. * @param offset defines the offset in the target array where to start storing values
  3975. * @returns the current matrix
  3976. */
  3977. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3978. /**
  3979. * Check equality between this matrix and a second one
  3980. * @param value defines the second matrix to compare
  3981. * @returns true is the current matrix and the given one values are strictly equal
  3982. */
  3983. equals(value: DeepImmutable<Matrix>): boolean;
  3984. /**
  3985. * Clone the current matrix
  3986. * @returns a new matrix from the current matrix
  3987. */
  3988. clone(): Matrix;
  3989. /**
  3990. * Returns the name of the current matrix class
  3991. * @returns the string "Matrix"
  3992. */
  3993. getClassName(): string;
  3994. /**
  3995. * Gets the hash code of the current matrix
  3996. * @returns the hash code
  3997. */
  3998. getHashCode(): number;
  3999. /**
  4000. * Decomposes the current Matrix into a translation, rotation and scaling components
  4001. * @param scale defines the scale vector3 given as a reference to update
  4002. * @param rotation defines the rotation quaternion given as a reference to update
  4003. * @param translation defines the translation vector3 given as a reference to update
  4004. * @returns true if operation was successful
  4005. */
  4006. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4007. /**
  4008. * Gets specific row of the matrix
  4009. * @param index defines the number of the row to get
  4010. * @returns the index-th row of the current matrix as a new Vector4
  4011. */
  4012. getRow(index: number): Nullable<Vector4>;
  4013. /**
  4014. * Sets the index-th row of the current matrix to the vector4 values
  4015. * @param index defines the number of the row to set
  4016. * @param row defines the target vector4
  4017. * @returns the updated current matrix
  4018. */
  4019. setRow(index: number, row: Vector4): Matrix;
  4020. /**
  4021. * Compute the transpose of the matrix
  4022. * @returns the new transposed matrix
  4023. */
  4024. transpose(): Matrix;
  4025. /**
  4026. * Compute the transpose of the matrix and store it in a given matrix
  4027. * @param result defines the target matrix
  4028. * @returns the current matrix
  4029. */
  4030. transposeToRef(result: Matrix): Matrix;
  4031. /**
  4032. * Sets the index-th row of the current matrix with the given 4 x float values
  4033. * @param index defines the row index
  4034. * @param x defines the x component to set
  4035. * @param y defines the y component to set
  4036. * @param z defines the z component to set
  4037. * @param w defines the w component to set
  4038. * @returns the updated current matrix
  4039. */
  4040. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4041. /**
  4042. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4043. * @param scale defines the scale factor
  4044. * @returns a new matrix
  4045. */
  4046. scale(scale: number): Matrix;
  4047. /**
  4048. * Scale the current matrix values by a factor to a given result matrix
  4049. * @param scale defines the scale factor
  4050. * @param result defines the matrix to store the result
  4051. * @returns the current matrix
  4052. */
  4053. scaleToRef(scale: number, result: Matrix): Matrix;
  4054. /**
  4055. * Scale the current matrix values by a factor and add the result to a given matrix
  4056. * @param scale defines the scale factor
  4057. * @param result defines the Matrix to store the result
  4058. * @returns the current matrix
  4059. */
  4060. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4061. /**
  4062. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4063. * @param ref matrix to store the result
  4064. */
  4065. toNormalMatrix(ref: Matrix): void;
  4066. /**
  4067. * Gets only rotation part of the current matrix
  4068. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4069. */
  4070. getRotationMatrix(): Matrix;
  4071. /**
  4072. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4073. * @param result defines the target matrix to store data to
  4074. * @returns the current matrix
  4075. */
  4076. getRotationMatrixToRef(result: Matrix): Matrix;
  4077. /**
  4078. * Toggles model matrix from being right handed to left handed in place and vice versa
  4079. */
  4080. toggleModelMatrixHandInPlace(): void;
  4081. /**
  4082. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4083. */
  4084. toggleProjectionMatrixHandInPlace(): void;
  4085. /**
  4086. * Creates a matrix from an array
  4087. * @param array defines the source array
  4088. * @param offset defines an offset in the source array
  4089. * @returns a new Matrix set from the starting index of the given array
  4090. */
  4091. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4092. /**
  4093. * Copy the content of an array into a given matrix
  4094. * @param array defines the source array
  4095. * @param offset defines an offset in the source array
  4096. * @param result defines the target matrix
  4097. */
  4098. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4099. /**
  4100. * Stores an array into a matrix after having multiplied each component by a given factor
  4101. * @param array defines the source array
  4102. * @param offset defines the offset in the source array
  4103. * @param scale defines the scaling factor
  4104. * @param result defines the target matrix
  4105. */
  4106. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4107. /**
  4108. * Gets an identity matrix that must not be updated
  4109. */
  4110. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4111. /**
  4112. * Stores a list of values (16) inside a given matrix
  4113. * @param initialM11 defines 1st value of 1st row
  4114. * @param initialM12 defines 2nd value of 1st row
  4115. * @param initialM13 defines 3rd value of 1st row
  4116. * @param initialM14 defines 4th value of 1st row
  4117. * @param initialM21 defines 1st value of 2nd row
  4118. * @param initialM22 defines 2nd value of 2nd row
  4119. * @param initialM23 defines 3rd value of 2nd row
  4120. * @param initialM24 defines 4th value of 2nd row
  4121. * @param initialM31 defines 1st value of 3rd row
  4122. * @param initialM32 defines 2nd value of 3rd row
  4123. * @param initialM33 defines 3rd value of 3rd row
  4124. * @param initialM34 defines 4th value of 3rd row
  4125. * @param initialM41 defines 1st value of 4th row
  4126. * @param initialM42 defines 2nd value of 4th row
  4127. * @param initialM43 defines 3rd value of 4th row
  4128. * @param initialM44 defines 4th value of 4th row
  4129. * @param result defines the target matrix
  4130. */
  4131. 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;
  4132. /**
  4133. * Creates new matrix from a list of values (16)
  4134. * @param initialM11 defines 1st value of 1st row
  4135. * @param initialM12 defines 2nd value of 1st row
  4136. * @param initialM13 defines 3rd value of 1st row
  4137. * @param initialM14 defines 4th value of 1st row
  4138. * @param initialM21 defines 1st value of 2nd row
  4139. * @param initialM22 defines 2nd value of 2nd row
  4140. * @param initialM23 defines 3rd value of 2nd row
  4141. * @param initialM24 defines 4th value of 2nd row
  4142. * @param initialM31 defines 1st value of 3rd row
  4143. * @param initialM32 defines 2nd value of 3rd row
  4144. * @param initialM33 defines 3rd value of 3rd row
  4145. * @param initialM34 defines 4th value of 3rd row
  4146. * @param initialM41 defines 1st value of 4th row
  4147. * @param initialM42 defines 2nd value of 4th row
  4148. * @param initialM43 defines 3rd value of 4th row
  4149. * @param initialM44 defines 4th value of 4th row
  4150. * @returns the new matrix
  4151. */
  4152. 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;
  4153. /**
  4154. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4155. * @param scale defines the scale vector3
  4156. * @param rotation defines the rotation quaternion
  4157. * @param translation defines the translation vector3
  4158. * @returns a new matrix
  4159. */
  4160. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4161. /**
  4162. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4163. * @param scale defines the scale vector3
  4164. * @param rotation defines the rotation quaternion
  4165. * @param translation defines the translation vector3
  4166. * @param result defines the target matrix
  4167. */
  4168. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4169. /**
  4170. * Creates a new identity matrix
  4171. * @returns a new identity matrix
  4172. */
  4173. static Identity(): Matrix;
  4174. /**
  4175. * Creates a new identity matrix and stores the result in a given matrix
  4176. * @param result defines the target matrix
  4177. */
  4178. static IdentityToRef(result: Matrix): void;
  4179. /**
  4180. * Creates a new zero matrix
  4181. * @returns a new zero matrix
  4182. */
  4183. static Zero(): Matrix;
  4184. /**
  4185. * Creates a new rotation matrix for "angle" radians around the X axis
  4186. * @param angle defines the angle (in radians) to use
  4187. * @return the new matrix
  4188. */
  4189. static RotationX(angle: number): Matrix;
  4190. /**
  4191. * Creates a new matrix as the invert of a given matrix
  4192. * @param source defines the source matrix
  4193. * @returns the new matrix
  4194. */
  4195. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4196. /**
  4197. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4198. * @param angle defines the angle (in radians) to use
  4199. * @param result defines the target matrix
  4200. */
  4201. static RotationXToRef(angle: number, result: Matrix): void;
  4202. /**
  4203. * Creates a new rotation matrix for "angle" radians around the Y axis
  4204. * @param angle defines the angle (in radians) to use
  4205. * @return the new matrix
  4206. */
  4207. static RotationY(angle: number): Matrix;
  4208. /**
  4209. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4210. * @param angle defines the angle (in radians) to use
  4211. * @param result defines the target matrix
  4212. */
  4213. static RotationYToRef(angle: number, result: Matrix): void;
  4214. /**
  4215. * Creates a new rotation matrix for "angle" radians around the Z axis
  4216. * @param angle defines the angle (in radians) to use
  4217. * @return the new matrix
  4218. */
  4219. static RotationZ(angle: number): Matrix;
  4220. /**
  4221. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4222. * @param angle defines the angle (in radians) to use
  4223. * @param result defines the target matrix
  4224. */
  4225. static RotationZToRef(angle: number, result: Matrix): void;
  4226. /**
  4227. * Creates a new rotation matrix for "angle" radians around the given axis
  4228. * @param axis defines the axis to use
  4229. * @param angle defines the angle (in radians) to use
  4230. * @return the new matrix
  4231. */
  4232. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4233. /**
  4234. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4235. * @param axis defines the axis to use
  4236. * @param angle defines the angle (in radians) to use
  4237. * @param result defines the target matrix
  4238. */
  4239. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4240. /**
  4241. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4242. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4243. * @param from defines the vector to align
  4244. * @param to defines the vector to align to
  4245. * @param result defines the target matrix
  4246. */
  4247. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4248. /**
  4249. * Creates a rotation matrix
  4250. * @param yaw defines the yaw angle in radians (Y axis)
  4251. * @param pitch defines the pitch angle in radians (X axis)
  4252. * @param roll defines the roll angle in radians (X axis)
  4253. * @returns the new rotation matrix
  4254. */
  4255. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4256. /**
  4257. * Creates a rotation matrix and stores it in a given matrix
  4258. * @param yaw defines the yaw angle in radians (Y axis)
  4259. * @param pitch defines the pitch angle in radians (X axis)
  4260. * @param roll defines the roll angle in radians (X axis)
  4261. * @param result defines the target matrix
  4262. */
  4263. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4264. /**
  4265. * Creates a scaling matrix
  4266. * @param x defines the scale factor on X axis
  4267. * @param y defines the scale factor on Y axis
  4268. * @param z defines the scale factor on Z axis
  4269. * @returns the new matrix
  4270. */
  4271. static Scaling(x: number, y: number, z: number): Matrix;
  4272. /**
  4273. * Creates a scaling matrix and stores it in a given matrix
  4274. * @param x defines the scale factor on X axis
  4275. * @param y defines the scale factor on Y axis
  4276. * @param z defines the scale factor on Z axis
  4277. * @param result defines the target matrix
  4278. */
  4279. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4280. /**
  4281. * Creates a translation matrix
  4282. * @param x defines the translation on X axis
  4283. * @param y defines the translation on Y axis
  4284. * @param z defines the translationon Z axis
  4285. * @returns the new matrix
  4286. */
  4287. static Translation(x: number, y: number, z: number): Matrix;
  4288. /**
  4289. * Creates a translation matrix and stores it in a given matrix
  4290. * @param x defines the translation on X axis
  4291. * @param y defines the translation on Y axis
  4292. * @param z defines the translationon Z axis
  4293. * @param result defines the target matrix
  4294. */
  4295. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4296. /**
  4297. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4298. * @param startValue defines the start value
  4299. * @param endValue defines the end value
  4300. * @param gradient defines the gradient factor
  4301. * @returns the new matrix
  4302. */
  4303. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4304. /**
  4305. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4306. * @param startValue defines the start value
  4307. * @param endValue defines the end value
  4308. * @param gradient defines the gradient factor
  4309. * @param result defines the Matrix object where to store data
  4310. */
  4311. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4312. /**
  4313. * Builds a new matrix whose values are computed by:
  4314. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4315. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4316. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4317. * @param startValue defines the first matrix
  4318. * @param endValue defines the second matrix
  4319. * @param gradient defines the gradient between the two matrices
  4320. * @returns the new matrix
  4321. */
  4322. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4323. /**
  4324. * Update a matrix to values which are computed by:
  4325. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4326. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4327. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4328. * @param startValue defines the first matrix
  4329. * @param endValue defines the second matrix
  4330. * @param gradient defines the gradient between the two matrices
  4331. * @param result defines the target matrix
  4332. */
  4333. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4334. /**
  4335. * 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"
  4336. * This function works in left handed mode
  4337. * @param eye defines the final position of the entity
  4338. * @param target defines where the entity should look at
  4339. * @param up defines the up vector for the entity
  4340. * @returns the new matrix
  4341. */
  4342. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4343. /**
  4344. * 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".
  4345. * This function works in left handed mode
  4346. * @param eye defines the final position of the entity
  4347. * @param target defines where the entity should look at
  4348. * @param up defines the up vector for the entity
  4349. * @param result defines the target matrix
  4350. */
  4351. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4352. /**
  4353. * 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"
  4354. * This function works in right handed mode
  4355. * @param eye defines the final position of the entity
  4356. * @param target defines where the entity should look at
  4357. * @param up defines the up vector for the entity
  4358. * @returns the new matrix
  4359. */
  4360. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4361. /**
  4362. * 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".
  4363. * This function works in right handed mode
  4364. * @param eye defines the final position of the entity
  4365. * @param target defines where the entity should look at
  4366. * @param up defines the up vector for the entity
  4367. * @param result defines the target matrix
  4368. */
  4369. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4370. /**
  4371. * Create a left-handed orthographic projection matrix
  4372. * @param width defines the viewport width
  4373. * @param height defines the viewport height
  4374. * @param znear defines the near clip plane
  4375. * @param zfar defines the far clip plane
  4376. * @returns a new matrix as a left-handed orthographic projection matrix
  4377. */
  4378. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4379. /**
  4380. * Store a left-handed orthographic projection to a given matrix
  4381. * @param width defines the viewport width
  4382. * @param height defines the viewport height
  4383. * @param znear defines the near clip plane
  4384. * @param zfar defines the far clip plane
  4385. * @param result defines the target matrix
  4386. */
  4387. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4388. /**
  4389. * Create a left-handed orthographic projection matrix
  4390. * @param left defines the viewport left coordinate
  4391. * @param right defines the viewport right coordinate
  4392. * @param bottom defines the viewport bottom coordinate
  4393. * @param top defines the viewport top coordinate
  4394. * @param znear defines the near clip plane
  4395. * @param zfar defines the far clip plane
  4396. * @returns a new matrix as a left-handed orthographic projection matrix
  4397. */
  4398. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4399. /**
  4400. * Stores a left-handed orthographic projection into a given matrix
  4401. * @param left defines the viewport left coordinate
  4402. * @param right defines the viewport right coordinate
  4403. * @param bottom defines the viewport bottom coordinate
  4404. * @param top defines the viewport top coordinate
  4405. * @param znear defines the near clip plane
  4406. * @param zfar defines the far clip plane
  4407. * @param result defines the target matrix
  4408. */
  4409. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4410. /**
  4411. * Creates a right-handed orthographic projection matrix
  4412. * @param left defines the viewport left coordinate
  4413. * @param right defines the viewport right coordinate
  4414. * @param bottom defines the viewport bottom coordinate
  4415. * @param top defines the viewport top coordinate
  4416. * @param znear defines the near clip plane
  4417. * @param zfar defines the far clip plane
  4418. * @returns a new matrix as a right-handed orthographic projection matrix
  4419. */
  4420. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4421. /**
  4422. * Stores a right-handed orthographic projection into a given matrix
  4423. * @param left defines the viewport left coordinate
  4424. * @param right defines the viewport right coordinate
  4425. * @param bottom defines the viewport bottom coordinate
  4426. * @param top defines the viewport top coordinate
  4427. * @param znear defines the near clip plane
  4428. * @param zfar defines the far clip plane
  4429. * @param result defines the target matrix
  4430. */
  4431. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4432. /**
  4433. * Creates a left-handed perspective projection matrix
  4434. * @param width defines the viewport width
  4435. * @param height defines the viewport height
  4436. * @param znear defines the near clip plane
  4437. * @param zfar defines the far clip plane
  4438. * @returns a new matrix as a left-handed perspective projection matrix
  4439. */
  4440. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4441. /**
  4442. * Creates a left-handed perspective projection matrix
  4443. * @param fov defines the horizontal field of view
  4444. * @param aspect defines the aspect ratio
  4445. * @param znear defines the near clip plane
  4446. * @param zfar defines the far clip plane
  4447. * @returns a new matrix as a left-handed perspective projection matrix
  4448. */
  4449. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4450. /**
  4451. * Stores a left-handed perspective projection into a given matrix
  4452. * @param fov defines the horizontal field of view
  4453. * @param aspect defines the aspect ratio
  4454. * @param znear defines the near clip plane
  4455. * @param zfar defines the far clip plane
  4456. * @param result defines the target matrix
  4457. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4458. */
  4459. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4460. /**
  4461. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4462. * @param fov defines the horizontal field of view
  4463. * @param aspect defines the aspect ratio
  4464. * @param znear defines the near clip plane
  4465. * @param zfar not used as infinity is used as far clip
  4466. * @param result defines the target matrix
  4467. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4468. */
  4469. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4470. /**
  4471. * Creates a right-handed perspective projection matrix
  4472. * @param fov defines the horizontal field of view
  4473. * @param aspect defines the aspect ratio
  4474. * @param znear defines the near clip plane
  4475. * @param zfar defines the far clip plane
  4476. * @returns a new matrix as a right-handed perspective projection matrix
  4477. */
  4478. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4479. /**
  4480. * Stores a right-handed perspective projection into a given matrix
  4481. * @param fov defines the horizontal field of view
  4482. * @param aspect defines the aspect ratio
  4483. * @param znear defines the near clip plane
  4484. * @param zfar defines the far clip plane
  4485. * @param result defines the target matrix
  4486. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4487. */
  4488. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4489. /**
  4490. * Stores a right-handed perspective projection into a given matrix
  4491. * @param fov defines the horizontal field of view
  4492. * @param aspect defines the aspect ratio
  4493. * @param znear defines the near clip plane
  4494. * @param zfar not used as infinity is used as far clip
  4495. * @param result defines the target matrix
  4496. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4497. */
  4498. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4499. /**
  4500. * Stores a perspective projection for WebVR info a given matrix
  4501. * @param fov defines the field of view
  4502. * @param znear defines the near clip plane
  4503. * @param zfar defines the far clip plane
  4504. * @param result defines the target matrix
  4505. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4506. */
  4507. static PerspectiveFovWebVRToRef(fov: {
  4508. upDegrees: number;
  4509. downDegrees: number;
  4510. leftDegrees: number;
  4511. rightDegrees: number;
  4512. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4513. /**
  4514. * Computes a complete transformation matrix
  4515. * @param viewport defines the viewport to use
  4516. * @param world defines the world matrix
  4517. * @param view defines the view matrix
  4518. * @param projection defines the projection matrix
  4519. * @param zmin defines the near clip plane
  4520. * @param zmax defines the far clip plane
  4521. * @returns the transformation matrix
  4522. */
  4523. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4524. /**
  4525. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4526. * @param matrix defines the matrix to use
  4527. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4528. */
  4529. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4530. /**
  4531. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4532. * @param matrix defines the matrix to use
  4533. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4534. */
  4535. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4536. /**
  4537. * Compute the transpose of a given matrix
  4538. * @param matrix defines the matrix to transpose
  4539. * @returns the new matrix
  4540. */
  4541. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4542. /**
  4543. * Compute the transpose of a matrix and store it in a target matrix
  4544. * @param matrix defines the matrix to transpose
  4545. * @param result defines the target matrix
  4546. */
  4547. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4548. /**
  4549. * Computes a reflection matrix from a plane
  4550. * @param plane defines the reflection plane
  4551. * @returns a new matrix
  4552. */
  4553. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4554. /**
  4555. * Computes a reflection matrix from a plane
  4556. * @param plane defines the reflection plane
  4557. * @param result defines the target matrix
  4558. */
  4559. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4560. /**
  4561. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4562. * @param xaxis defines the value of the 1st axis
  4563. * @param yaxis defines the value of the 2nd axis
  4564. * @param zaxis defines the value of the 3rd axis
  4565. * @param result defines the target matrix
  4566. */
  4567. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4568. /**
  4569. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4570. * @param quat defines the quaternion to use
  4571. * @param result defines the target matrix
  4572. */
  4573. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4574. }
  4575. /**
  4576. * @hidden
  4577. */
  4578. export class TmpVectors {
  4579. static Vector2: Vector2[];
  4580. static Vector3: Vector3[];
  4581. static Vector4: Vector4[];
  4582. static Quaternion: Quaternion[];
  4583. static Matrix: Matrix[];
  4584. }
  4585. }
  4586. declare module BABYLON {
  4587. /**
  4588. * Defines potential orientation for back face culling
  4589. */
  4590. export enum Orientation {
  4591. /**
  4592. * Clockwise
  4593. */
  4594. CW = 0,
  4595. /** Counter clockwise */
  4596. CCW = 1
  4597. }
  4598. /** Class used to represent a Bezier curve */
  4599. export class BezierCurve {
  4600. /**
  4601. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4602. * @param t defines the time
  4603. * @param x1 defines the left coordinate on X axis
  4604. * @param y1 defines the left coordinate on Y axis
  4605. * @param x2 defines the right coordinate on X axis
  4606. * @param y2 defines the right coordinate on Y axis
  4607. * @returns the interpolated value
  4608. */
  4609. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4610. }
  4611. /**
  4612. * Defines angle representation
  4613. */
  4614. export class Angle {
  4615. private _radians;
  4616. /**
  4617. * Creates an Angle object of "radians" radians (float).
  4618. * @param radians the angle in radians
  4619. */
  4620. constructor(radians: number);
  4621. /**
  4622. * Get value in degrees
  4623. * @returns the Angle value in degrees (float)
  4624. */
  4625. degrees(): number;
  4626. /**
  4627. * Get value in radians
  4628. * @returns the Angle value in radians (float)
  4629. */
  4630. radians(): number;
  4631. /**
  4632. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4633. * @param a defines first vector
  4634. * @param b defines second vector
  4635. * @returns a new Angle
  4636. */
  4637. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4638. /**
  4639. * Gets a new Angle object from the given float in radians
  4640. * @param radians defines the angle value in radians
  4641. * @returns a new Angle
  4642. */
  4643. static FromRadians(radians: number): Angle;
  4644. /**
  4645. * Gets a new Angle object from the given float in degrees
  4646. * @param degrees defines the angle value in degrees
  4647. * @returns a new Angle
  4648. */
  4649. static FromDegrees(degrees: number): Angle;
  4650. }
  4651. /**
  4652. * This represents an arc in a 2d space.
  4653. */
  4654. export class Arc2 {
  4655. /** Defines the start point of the arc */
  4656. startPoint: Vector2;
  4657. /** Defines the mid point of the arc */
  4658. midPoint: Vector2;
  4659. /** Defines the end point of the arc */
  4660. endPoint: Vector2;
  4661. /**
  4662. * Defines the center point of the arc.
  4663. */
  4664. centerPoint: Vector2;
  4665. /**
  4666. * Defines the radius of the arc.
  4667. */
  4668. radius: number;
  4669. /**
  4670. * Defines the angle of the arc (from mid point to end point).
  4671. */
  4672. angle: Angle;
  4673. /**
  4674. * Defines the start angle of the arc (from start point to middle point).
  4675. */
  4676. startAngle: Angle;
  4677. /**
  4678. * Defines the orientation of the arc (clock wise/counter clock wise).
  4679. */
  4680. orientation: Orientation;
  4681. /**
  4682. * Creates an Arc object from the three given points : start, middle and end.
  4683. * @param startPoint Defines the start point of the arc
  4684. * @param midPoint Defines the midlle point of the arc
  4685. * @param endPoint Defines the end point of the arc
  4686. */
  4687. constructor(
  4688. /** Defines the start point of the arc */
  4689. startPoint: Vector2,
  4690. /** Defines the mid point of the arc */
  4691. midPoint: Vector2,
  4692. /** Defines the end point of the arc */
  4693. endPoint: Vector2);
  4694. }
  4695. /**
  4696. * Represents a 2D path made up of multiple 2D points
  4697. */
  4698. export class Path2 {
  4699. private _points;
  4700. private _length;
  4701. /**
  4702. * If the path start and end point are the same
  4703. */
  4704. closed: boolean;
  4705. /**
  4706. * Creates a Path2 object from the starting 2D coordinates x and y.
  4707. * @param x the starting points x value
  4708. * @param y the starting points y value
  4709. */
  4710. constructor(x: number, y: number);
  4711. /**
  4712. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4713. * @param x the added points x value
  4714. * @param y the added points y value
  4715. * @returns the updated Path2.
  4716. */
  4717. addLineTo(x: number, y: number): Path2;
  4718. /**
  4719. * 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.
  4720. * @param midX middle point x value
  4721. * @param midY middle point y value
  4722. * @param endX end point x value
  4723. * @param endY end point y value
  4724. * @param numberOfSegments (default: 36)
  4725. * @returns the updated Path2.
  4726. */
  4727. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4728. /**
  4729. * Closes the Path2.
  4730. * @returns the Path2.
  4731. */
  4732. close(): Path2;
  4733. /**
  4734. * Gets the sum of the distance between each sequential point in the path
  4735. * @returns the Path2 total length (float).
  4736. */
  4737. length(): number;
  4738. /**
  4739. * Gets the points which construct the path
  4740. * @returns the Path2 internal array of points.
  4741. */
  4742. getPoints(): Vector2[];
  4743. /**
  4744. * Retreives the point at the distance aways from the starting point
  4745. * @param normalizedLengthPosition the length along the path to retreive the point from
  4746. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4747. */
  4748. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4749. /**
  4750. * Creates a new path starting from an x and y position
  4751. * @param x starting x value
  4752. * @param y starting y value
  4753. * @returns a new Path2 starting at the coordinates (x, y).
  4754. */
  4755. static StartingAt(x: number, y: number): Path2;
  4756. }
  4757. /**
  4758. * Represents a 3D path made up of multiple 3D points
  4759. */
  4760. export class Path3D {
  4761. /**
  4762. * an array of Vector3, the curve axis of the Path3D
  4763. */
  4764. path: Vector3[];
  4765. private _curve;
  4766. private _distances;
  4767. private _tangents;
  4768. private _normals;
  4769. private _binormals;
  4770. private _raw;
  4771. private _alignTangentsWithPath;
  4772. private readonly _pointAtData;
  4773. /**
  4774. * new Path3D(path, normal, raw)
  4775. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4776. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4777. * @param path an array of Vector3, the curve axis of the Path3D
  4778. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4779. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4780. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4781. */
  4782. constructor(
  4783. /**
  4784. * an array of Vector3, the curve axis of the Path3D
  4785. */
  4786. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4787. /**
  4788. * Returns the Path3D array of successive Vector3 designing its curve.
  4789. * @returns the Path3D array of successive Vector3 designing its curve.
  4790. */
  4791. getCurve(): Vector3[];
  4792. /**
  4793. * Returns the Path3D array of successive Vector3 designing its curve.
  4794. * @returns the Path3D array of successive Vector3 designing its curve.
  4795. */
  4796. getPoints(): Vector3[];
  4797. /**
  4798. * @returns the computed length (float) of the path.
  4799. */
  4800. length(): number;
  4801. /**
  4802. * Returns an array populated with tangent vectors on each Path3D curve point.
  4803. * @returns an array populated with tangent vectors on each Path3D curve point.
  4804. */
  4805. getTangents(): Vector3[];
  4806. /**
  4807. * Returns an array populated with normal vectors on each Path3D curve point.
  4808. * @returns an array populated with normal vectors on each Path3D curve point.
  4809. */
  4810. getNormals(): Vector3[];
  4811. /**
  4812. * Returns an array populated with binormal vectors on each Path3D curve point.
  4813. * @returns an array populated with binormal vectors on each Path3D curve point.
  4814. */
  4815. getBinormals(): Vector3[];
  4816. /**
  4817. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4818. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4819. */
  4820. getDistances(): number[];
  4821. /**
  4822. * Returns an interpolated point along this path
  4823. * @param position the position of the point along this path, from 0.0 to 1.0
  4824. * @returns a new Vector3 as the point
  4825. */
  4826. getPointAt(position: number): Vector3;
  4827. /**
  4828. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4829. * @param position the position of the point along this path, from 0.0 to 1.0
  4830. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4831. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4832. */
  4833. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4834. /**
  4835. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4836. * @param position the position of the point along this path, from 0.0 to 1.0
  4837. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4838. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4839. */
  4840. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4841. /**
  4842. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4843. * @param position the position of the point along this path, from 0.0 to 1.0
  4844. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4845. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4846. */
  4847. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4848. /**
  4849. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4850. * @param position the position of the point along this path, from 0.0 to 1.0
  4851. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4852. */
  4853. getDistanceAt(position: number): number;
  4854. /**
  4855. * Returns the array index of the previous point of an interpolated point along this path
  4856. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4857. * @returns the array index
  4858. */
  4859. getPreviousPointIndexAt(position: number): number;
  4860. /**
  4861. * 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)
  4862. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4863. * @returns the sub position
  4864. */
  4865. getSubPositionAt(position: number): number;
  4866. /**
  4867. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4868. * @param target the vector of which to get the closest position to
  4869. * @returns the position of the closest virtual point on this path to the target vector
  4870. */
  4871. getClosestPositionTo(target: Vector3): number;
  4872. /**
  4873. * Returns a sub path (slice) of this path
  4874. * @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
  4875. * @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
  4876. * @returns a sub path (slice) of this path
  4877. */
  4878. slice(start?: number, end?: number): Path3D;
  4879. /**
  4880. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4881. * @param path path which all values are copied into the curves points
  4882. * @param firstNormal which should be projected onto the curve
  4883. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4884. * @returns the same object updated.
  4885. */
  4886. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4887. private _compute;
  4888. private _getFirstNonNullVector;
  4889. private _getLastNonNullVector;
  4890. private _normalVector;
  4891. /**
  4892. * Updates the point at data for an interpolated point along this curve
  4893. * @param position the position of the point along this curve, from 0.0 to 1.0
  4894. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4895. * @returns the (updated) point at data
  4896. */
  4897. private _updatePointAtData;
  4898. /**
  4899. * Updates the point at data from the specified parameters
  4900. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4901. * @param point the interpolated point
  4902. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4903. */
  4904. private _setPointAtData;
  4905. /**
  4906. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4907. */
  4908. private _updateInterpolationMatrix;
  4909. }
  4910. /**
  4911. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4912. * A Curve3 is designed from a series of successive Vector3.
  4913. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4914. */
  4915. export class Curve3 {
  4916. private _points;
  4917. private _length;
  4918. /**
  4919. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4920. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4921. * @param v1 (Vector3) the control point
  4922. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4923. * @param nbPoints (integer) the wanted number of points in the curve
  4924. * @returns the created Curve3
  4925. */
  4926. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4927. /**
  4928. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4929. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4930. * @param v1 (Vector3) the first control point
  4931. * @param v2 (Vector3) the second control point
  4932. * @param v3 (Vector3) the end point of the Cubic Bezier
  4933. * @param nbPoints (integer) the wanted number of points in the curve
  4934. * @returns the created Curve3
  4935. */
  4936. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4937. /**
  4938. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4939. * @param p1 (Vector3) the origin point of the Hermite Spline
  4940. * @param t1 (Vector3) the tangent vector at the origin point
  4941. * @param p2 (Vector3) the end point of the Hermite Spline
  4942. * @param t2 (Vector3) the tangent vector at the end point
  4943. * @param nbPoints (integer) the wanted number of points in the curve
  4944. * @returns the created Curve3
  4945. */
  4946. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4947. /**
  4948. * Returns a Curve3 object along a CatmullRom Spline curve :
  4949. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4950. * @param nbPoints (integer) the wanted number of points between each curve control points
  4951. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4952. * @returns the created Curve3
  4953. */
  4954. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4955. /**
  4956. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4957. * A Curve3 is designed from a series of successive Vector3.
  4958. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4959. * @param points points which make up the curve
  4960. */
  4961. constructor(points: Vector3[]);
  4962. /**
  4963. * @returns the Curve3 stored array of successive Vector3
  4964. */
  4965. getPoints(): Vector3[];
  4966. /**
  4967. * @returns the computed length (float) of the curve.
  4968. */
  4969. length(): number;
  4970. /**
  4971. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4972. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4973. * curveA and curveB keep unchanged.
  4974. * @param curve the curve to continue from this curve
  4975. * @returns the newly constructed curve
  4976. */
  4977. continue(curve: DeepImmutable<Curve3>): Curve3;
  4978. private _computeLength;
  4979. }
  4980. }
  4981. declare module BABYLON {
  4982. /**
  4983. * This represents the main contract an easing function should follow.
  4984. * Easing functions are used throughout the animation system.
  4985. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4986. */
  4987. export interface IEasingFunction {
  4988. /**
  4989. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4990. * of the easing function.
  4991. * The link below provides some of the most common examples of easing functions.
  4992. * @see https://easings.net/
  4993. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4994. * @returns the corresponding value on the curve defined by the easing function
  4995. */
  4996. ease(gradient: number): number;
  4997. }
  4998. /**
  4999. * Base class used for every default easing function.
  5000. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5001. */
  5002. export class EasingFunction implements IEasingFunction {
  5003. /**
  5004. * Interpolation follows the mathematical formula associated with the easing function.
  5005. */
  5006. static readonly EASINGMODE_EASEIN: number;
  5007. /**
  5008. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5009. */
  5010. static readonly EASINGMODE_EASEOUT: number;
  5011. /**
  5012. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5013. */
  5014. static readonly EASINGMODE_EASEINOUT: number;
  5015. private _easingMode;
  5016. /**
  5017. * Sets the easing mode of the current function.
  5018. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5019. */
  5020. setEasingMode(easingMode: number): void;
  5021. /**
  5022. * Gets the current easing mode.
  5023. * @returns the easing mode
  5024. */
  5025. getEasingMode(): number;
  5026. /**
  5027. * @hidden
  5028. */
  5029. easeInCore(gradient: number): number;
  5030. /**
  5031. * Given an input gradient between 0 and 1, this returns the corresponding value
  5032. * of the easing function.
  5033. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5034. * @returns the corresponding value on the curve defined by the easing function
  5035. */
  5036. ease(gradient: number): number;
  5037. }
  5038. /**
  5039. * Easing function with a circle shape (see link below).
  5040. * @see https://easings.net/#easeInCirc
  5041. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5042. */
  5043. export class CircleEase extends EasingFunction implements IEasingFunction {
  5044. /** @hidden */
  5045. easeInCore(gradient: number): number;
  5046. }
  5047. /**
  5048. * Easing function with a ease back shape (see link below).
  5049. * @see https://easings.net/#easeInBack
  5050. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5051. */
  5052. export class BackEase extends EasingFunction implements IEasingFunction {
  5053. /** Defines the amplitude of the function */
  5054. amplitude: number;
  5055. /**
  5056. * Instantiates a back ease easing
  5057. * @see https://easings.net/#easeInBack
  5058. * @param amplitude Defines the amplitude of the function
  5059. */
  5060. constructor(
  5061. /** Defines the amplitude of the function */
  5062. amplitude?: number);
  5063. /** @hidden */
  5064. easeInCore(gradient: number): number;
  5065. }
  5066. /**
  5067. * Easing function with a bouncing shape (see link below).
  5068. * @see https://easings.net/#easeInBounce
  5069. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5070. */
  5071. export class BounceEase extends EasingFunction implements IEasingFunction {
  5072. /** Defines the number of bounces */
  5073. bounces: number;
  5074. /** Defines the amplitude of the bounce */
  5075. bounciness: number;
  5076. /**
  5077. * Instantiates a bounce easing
  5078. * @see https://easings.net/#easeInBounce
  5079. * @param bounces Defines the number of bounces
  5080. * @param bounciness Defines the amplitude of the bounce
  5081. */
  5082. constructor(
  5083. /** Defines the number of bounces */
  5084. bounces?: number,
  5085. /** Defines the amplitude of the bounce */
  5086. bounciness?: number);
  5087. /** @hidden */
  5088. easeInCore(gradient: number): number;
  5089. }
  5090. /**
  5091. * Easing function with a power of 3 shape (see link below).
  5092. * @see https://easings.net/#easeInCubic
  5093. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5094. */
  5095. export class CubicEase extends EasingFunction implements IEasingFunction {
  5096. /** @hidden */
  5097. easeInCore(gradient: number): number;
  5098. }
  5099. /**
  5100. * Easing function with an elastic shape (see link below).
  5101. * @see https://easings.net/#easeInElastic
  5102. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5103. */
  5104. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5105. /** Defines the number of oscillations*/
  5106. oscillations: number;
  5107. /** Defines the amplitude of the oscillations*/
  5108. springiness: number;
  5109. /**
  5110. * Instantiates an elastic easing function
  5111. * @see https://easings.net/#easeInElastic
  5112. * @param oscillations Defines the number of oscillations
  5113. * @param springiness Defines the amplitude of the oscillations
  5114. */
  5115. constructor(
  5116. /** Defines the number of oscillations*/
  5117. oscillations?: number,
  5118. /** Defines the amplitude of the oscillations*/
  5119. springiness?: number);
  5120. /** @hidden */
  5121. easeInCore(gradient: number): number;
  5122. }
  5123. /**
  5124. * Easing function with an exponential shape (see link below).
  5125. * @see https://easings.net/#easeInExpo
  5126. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5127. */
  5128. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5129. /** Defines the exponent of the function */
  5130. exponent: number;
  5131. /**
  5132. * Instantiates an exponential easing function
  5133. * @see https://easings.net/#easeInExpo
  5134. * @param exponent Defines the exponent of the function
  5135. */
  5136. constructor(
  5137. /** Defines the exponent of the function */
  5138. exponent?: number);
  5139. /** @hidden */
  5140. easeInCore(gradient: number): number;
  5141. }
  5142. /**
  5143. * Easing function with a power shape (see link below).
  5144. * @see https://easings.net/#easeInQuad
  5145. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5146. */
  5147. export class PowerEase extends EasingFunction implements IEasingFunction {
  5148. /** Defines the power of the function */
  5149. power: number;
  5150. /**
  5151. * Instantiates an power base easing function
  5152. * @see https://easings.net/#easeInQuad
  5153. * @param power Defines the power of the function
  5154. */
  5155. constructor(
  5156. /** Defines the power of the function */
  5157. power?: number);
  5158. /** @hidden */
  5159. easeInCore(gradient: number): number;
  5160. }
  5161. /**
  5162. * Easing function with a power of 2 shape (see link below).
  5163. * @see https://easings.net/#easeInQuad
  5164. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5165. */
  5166. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5167. /** @hidden */
  5168. easeInCore(gradient: number): number;
  5169. }
  5170. /**
  5171. * Easing function with a power of 4 shape (see link below).
  5172. * @see https://easings.net/#easeInQuart
  5173. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5174. */
  5175. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5176. /** @hidden */
  5177. easeInCore(gradient: number): number;
  5178. }
  5179. /**
  5180. * Easing function with a power of 5 shape (see link below).
  5181. * @see https://easings.net/#easeInQuint
  5182. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5183. */
  5184. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5185. /** @hidden */
  5186. easeInCore(gradient: number): number;
  5187. }
  5188. /**
  5189. * Easing function with a sin shape (see link below).
  5190. * @see https://easings.net/#easeInSine
  5191. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5192. */
  5193. export class SineEase extends EasingFunction implements IEasingFunction {
  5194. /** @hidden */
  5195. easeInCore(gradient: number): number;
  5196. }
  5197. /**
  5198. * Easing function with a bezier shape (see link below).
  5199. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5200. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5201. */
  5202. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5203. /** Defines the x component of the start tangent in the bezier curve */
  5204. x1: number;
  5205. /** Defines the y component of the start tangent in the bezier curve */
  5206. y1: number;
  5207. /** Defines the x component of the end tangent in the bezier curve */
  5208. x2: number;
  5209. /** Defines the y component of the end tangent in the bezier curve */
  5210. y2: number;
  5211. /**
  5212. * Instantiates a bezier function
  5213. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5214. * @param x1 Defines the x component of the start tangent in the bezier curve
  5215. * @param y1 Defines the y component of the start tangent in the bezier curve
  5216. * @param x2 Defines the x component of the end tangent in the bezier curve
  5217. * @param y2 Defines the y component of the end tangent in the bezier curve
  5218. */
  5219. constructor(
  5220. /** Defines the x component of the start tangent in the bezier curve */
  5221. x1?: number,
  5222. /** Defines the y component of the start tangent in the bezier curve */
  5223. y1?: number,
  5224. /** Defines the x component of the end tangent in the bezier curve */
  5225. x2?: number,
  5226. /** Defines the y component of the end tangent in the bezier curve */
  5227. y2?: number);
  5228. /** @hidden */
  5229. easeInCore(gradient: number): number;
  5230. }
  5231. }
  5232. declare module BABYLON {
  5233. /**
  5234. * Class used to hold a RBG color
  5235. */
  5236. export class Color3 {
  5237. /**
  5238. * Defines the red component (between 0 and 1, default is 0)
  5239. */
  5240. r: number;
  5241. /**
  5242. * Defines the green component (between 0 and 1, default is 0)
  5243. */
  5244. g: number;
  5245. /**
  5246. * Defines the blue component (between 0 and 1, default is 0)
  5247. */
  5248. b: number;
  5249. /**
  5250. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5251. * @param r defines the red component (between 0 and 1, default is 0)
  5252. * @param g defines the green component (between 0 and 1, default is 0)
  5253. * @param b defines the blue component (between 0 and 1, default is 0)
  5254. */
  5255. constructor(
  5256. /**
  5257. * Defines the red component (between 0 and 1, default is 0)
  5258. */
  5259. r?: number,
  5260. /**
  5261. * Defines the green component (between 0 and 1, default is 0)
  5262. */
  5263. g?: number,
  5264. /**
  5265. * Defines the blue component (between 0 and 1, default is 0)
  5266. */
  5267. b?: number);
  5268. /**
  5269. * Creates a string with the Color3 current values
  5270. * @returns the string representation of the Color3 object
  5271. */
  5272. toString(): string;
  5273. /**
  5274. * Returns the string "Color3"
  5275. * @returns "Color3"
  5276. */
  5277. getClassName(): string;
  5278. /**
  5279. * Compute the Color3 hash code
  5280. * @returns an unique number that can be used to hash Color3 objects
  5281. */
  5282. getHashCode(): number;
  5283. /**
  5284. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5285. * @param array defines the array where to store the r,g,b components
  5286. * @param index defines an optional index in the target array to define where to start storing values
  5287. * @returns the current Color3 object
  5288. */
  5289. toArray(array: FloatArray, index?: number): Color3;
  5290. /**
  5291. * Returns a new Color4 object from the current Color3 and the given alpha
  5292. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5293. * @returns a new Color4 object
  5294. */
  5295. toColor4(alpha?: number): Color4;
  5296. /**
  5297. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5298. * @returns the new array
  5299. */
  5300. asArray(): number[];
  5301. /**
  5302. * Returns the luminance value
  5303. * @returns a float value
  5304. */
  5305. toLuminance(): number;
  5306. /**
  5307. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5308. * @param otherColor defines the second operand
  5309. * @returns the new Color3 object
  5310. */
  5311. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5312. /**
  5313. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5314. * @param otherColor defines the second operand
  5315. * @param result defines the Color3 object where to store the result
  5316. * @returns the current Color3
  5317. */
  5318. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5319. /**
  5320. * Determines equality between Color3 objects
  5321. * @param otherColor defines the second operand
  5322. * @returns true if the rgb values are equal to the given ones
  5323. */
  5324. equals(otherColor: DeepImmutable<Color3>): boolean;
  5325. /**
  5326. * Determines equality between the current Color3 object and a set of r,b,g values
  5327. * @param r defines the red component to check
  5328. * @param g defines the green component to check
  5329. * @param b defines the blue component to check
  5330. * @returns true if the rgb values are equal to the given ones
  5331. */
  5332. equalsFloats(r: number, g: number, b: number): boolean;
  5333. /**
  5334. * Multiplies in place each rgb value by scale
  5335. * @param scale defines the scaling factor
  5336. * @returns the updated Color3
  5337. */
  5338. scale(scale: number): Color3;
  5339. /**
  5340. * Multiplies the rgb values by scale and stores the result into "result"
  5341. * @param scale defines the scaling factor
  5342. * @param result defines the Color3 object where to store the result
  5343. * @returns the unmodified current Color3
  5344. */
  5345. scaleToRef(scale: number, result: Color3): Color3;
  5346. /**
  5347. * Scale the current Color3 values by a factor and add the result to a given Color3
  5348. * @param scale defines the scale factor
  5349. * @param result defines color to store the result into
  5350. * @returns the unmodified current Color3
  5351. */
  5352. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5353. /**
  5354. * Clamps the rgb values by the min and max values and stores the result into "result"
  5355. * @param min defines minimum clamping value (default is 0)
  5356. * @param max defines maximum clamping value (default is 1)
  5357. * @param result defines color to store the result into
  5358. * @returns the original Color3
  5359. */
  5360. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5361. /**
  5362. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5363. * @param otherColor defines the second operand
  5364. * @returns the new Color3
  5365. */
  5366. add(otherColor: DeepImmutable<Color3>): Color3;
  5367. /**
  5368. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5369. * @param otherColor defines the second operand
  5370. * @param result defines Color3 object to store the result into
  5371. * @returns the unmodified current Color3
  5372. */
  5373. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5374. /**
  5375. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5376. * @param otherColor defines the second operand
  5377. * @returns the new Color3
  5378. */
  5379. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5380. /**
  5381. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5382. * @param otherColor defines the second operand
  5383. * @param result defines Color3 object to store the result into
  5384. * @returns the unmodified current Color3
  5385. */
  5386. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5387. /**
  5388. * Copy the current object
  5389. * @returns a new Color3 copied the current one
  5390. */
  5391. clone(): Color3;
  5392. /**
  5393. * Copies the rgb values from the source in the current Color3
  5394. * @param source defines the source Color3 object
  5395. * @returns the updated Color3 object
  5396. */
  5397. copyFrom(source: DeepImmutable<Color3>): Color3;
  5398. /**
  5399. * Updates the Color3 rgb values from the given floats
  5400. * @param r defines the red component to read from
  5401. * @param g defines the green component to read from
  5402. * @param b defines the blue component to read from
  5403. * @returns the current Color3 object
  5404. */
  5405. copyFromFloats(r: number, g: number, b: number): Color3;
  5406. /**
  5407. * Updates the Color3 rgb values from the given floats
  5408. * @param r defines the red component to read from
  5409. * @param g defines the green component to read from
  5410. * @param b defines the blue component to read from
  5411. * @returns the current Color3 object
  5412. */
  5413. set(r: number, g: number, b: number): Color3;
  5414. /**
  5415. * Compute the Color3 hexadecimal code as a string
  5416. * @returns a string containing the hexadecimal representation of the Color3 object
  5417. */
  5418. toHexString(): string;
  5419. /**
  5420. * Computes a new Color3 converted from the current one to linear space
  5421. * @returns a new Color3 object
  5422. */
  5423. toLinearSpace(): Color3;
  5424. /**
  5425. * Converts current color in rgb space to HSV values
  5426. * @returns a new color3 representing the HSV values
  5427. */
  5428. toHSV(): Color3;
  5429. /**
  5430. * Converts current color in rgb space to HSV values
  5431. * @param result defines the Color3 where to store the HSV values
  5432. */
  5433. toHSVToRef(result: Color3): void;
  5434. /**
  5435. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5436. * @param convertedColor defines the Color3 object where to store the linear space version
  5437. * @returns the unmodified Color3
  5438. */
  5439. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5440. /**
  5441. * Computes a new Color3 converted from the current one to gamma space
  5442. * @returns a new Color3 object
  5443. */
  5444. toGammaSpace(): Color3;
  5445. /**
  5446. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5447. * @param convertedColor defines the Color3 object where to store the gamma space version
  5448. * @returns the unmodified Color3
  5449. */
  5450. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5451. private static _BlackReadOnly;
  5452. /**
  5453. * Convert Hue, saturation and value to a Color3 (RGB)
  5454. * @param hue defines the hue
  5455. * @param saturation defines the saturation
  5456. * @param value defines the value
  5457. * @param result defines the Color3 where to store the RGB values
  5458. */
  5459. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5460. /**
  5461. * Creates a new Color3 from the string containing valid hexadecimal values
  5462. * @param hex defines a string containing valid hexadecimal values
  5463. * @returns a new Color3 object
  5464. */
  5465. static FromHexString(hex: string): Color3;
  5466. /**
  5467. * Creates a new Color3 from the starting index of the given array
  5468. * @param array defines the source array
  5469. * @param offset defines an offset in the source array
  5470. * @returns a new Color3 object
  5471. */
  5472. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5473. /**
  5474. * Creates a new Color3 from integer values (< 256)
  5475. * @param r defines the red component to read from (value between 0 and 255)
  5476. * @param g defines the green component to read from (value between 0 and 255)
  5477. * @param b defines the blue component to read from (value between 0 and 255)
  5478. * @returns a new Color3 object
  5479. */
  5480. static FromInts(r: number, g: number, b: number): Color3;
  5481. /**
  5482. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5483. * @param start defines the start Color3 value
  5484. * @param end defines the end Color3 value
  5485. * @param amount defines the gradient value between start and end
  5486. * @returns a new Color3 object
  5487. */
  5488. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5489. /**
  5490. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5491. * @param left defines the start value
  5492. * @param right defines the end value
  5493. * @param amount defines the gradient factor
  5494. * @param result defines the Color3 object where to store the result
  5495. */
  5496. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5497. /**
  5498. * Returns a Color3 value containing a red color
  5499. * @returns a new Color3 object
  5500. */
  5501. static Red(): Color3;
  5502. /**
  5503. * Returns a Color3 value containing a green color
  5504. * @returns a new Color3 object
  5505. */
  5506. static Green(): Color3;
  5507. /**
  5508. * Returns a Color3 value containing a blue color
  5509. * @returns a new Color3 object
  5510. */
  5511. static Blue(): Color3;
  5512. /**
  5513. * Returns a Color3 value containing a black color
  5514. * @returns a new Color3 object
  5515. */
  5516. static Black(): Color3;
  5517. /**
  5518. * Gets a Color3 value containing a black color that must not be updated
  5519. */
  5520. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5521. /**
  5522. * Returns a Color3 value containing a white color
  5523. * @returns a new Color3 object
  5524. */
  5525. static White(): Color3;
  5526. /**
  5527. * Returns a Color3 value containing a purple color
  5528. * @returns a new Color3 object
  5529. */
  5530. static Purple(): Color3;
  5531. /**
  5532. * Returns a Color3 value containing a magenta color
  5533. * @returns a new Color3 object
  5534. */
  5535. static Magenta(): Color3;
  5536. /**
  5537. * Returns a Color3 value containing a yellow color
  5538. * @returns a new Color3 object
  5539. */
  5540. static Yellow(): Color3;
  5541. /**
  5542. * Returns a Color3 value containing a gray color
  5543. * @returns a new Color3 object
  5544. */
  5545. static Gray(): Color3;
  5546. /**
  5547. * Returns a Color3 value containing a teal color
  5548. * @returns a new Color3 object
  5549. */
  5550. static Teal(): Color3;
  5551. /**
  5552. * Returns a Color3 value containing a random color
  5553. * @returns a new Color3 object
  5554. */
  5555. static Random(): Color3;
  5556. }
  5557. /**
  5558. * Class used to hold a RBGA color
  5559. */
  5560. export class Color4 {
  5561. /**
  5562. * Defines the red component (between 0 and 1, default is 0)
  5563. */
  5564. r: number;
  5565. /**
  5566. * Defines the green component (between 0 and 1, default is 0)
  5567. */
  5568. g: number;
  5569. /**
  5570. * Defines the blue component (between 0 and 1, default is 0)
  5571. */
  5572. b: number;
  5573. /**
  5574. * Defines the alpha component (between 0 and 1, default is 1)
  5575. */
  5576. a: number;
  5577. /**
  5578. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5579. * @param r defines the red component (between 0 and 1, default is 0)
  5580. * @param g defines the green component (between 0 and 1, default is 0)
  5581. * @param b defines the blue component (between 0 and 1, default is 0)
  5582. * @param a defines the alpha component (between 0 and 1, default is 1)
  5583. */
  5584. constructor(
  5585. /**
  5586. * Defines the red component (between 0 and 1, default is 0)
  5587. */
  5588. r?: number,
  5589. /**
  5590. * Defines the green component (between 0 and 1, default is 0)
  5591. */
  5592. g?: number,
  5593. /**
  5594. * Defines the blue component (between 0 and 1, default is 0)
  5595. */
  5596. b?: number,
  5597. /**
  5598. * Defines the alpha component (between 0 and 1, default is 1)
  5599. */
  5600. a?: number);
  5601. /**
  5602. * Adds in place the given Color4 values to the current Color4 object
  5603. * @param right defines the second operand
  5604. * @returns the current updated Color4 object
  5605. */
  5606. addInPlace(right: DeepImmutable<Color4>): Color4;
  5607. /**
  5608. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5609. * @returns the new array
  5610. */
  5611. asArray(): number[];
  5612. /**
  5613. * Stores from the starting index in the given array the Color4 successive values
  5614. * @param array defines the array where to store the r,g,b components
  5615. * @param index defines an optional index in the target array to define where to start storing values
  5616. * @returns the current Color4 object
  5617. */
  5618. toArray(array: number[], index?: number): Color4;
  5619. /**
  5620. * Determines equality between Color4 objects
  5621. * @param otherColor defines the second operand
  5622. * @returns true if the rgba values are equal to the given ones
  5623. */
  5624. equals(otherColor: DeepImmutable<Color4>): boolean;
  5625. /**
  5626. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5627. * @param right defines the second operand
  5628. * @returns a new Color4 object
  5629. */
  5630. add(right: DeepImmutable<Color4>): Color4;
  5631. /**
  5632. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5633. * @param right defines the second operand
  5634. * @returns a new Color4 object
  5635. */
  5636. subtract(right: DeepImmutable<Color4>): Color4;
  5637. /**
  5638. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5639. * @param right defines the second operand
  5640. * @param result defines the Color4 object where to store the result
  5641. * @returns the current Color4 object
  5642. */
  5643. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5644. /**
  5645. * Creates a new Color4 with the current Color4 values multiplied by scale
  5646. * @param scale defines the scaling factor to apply
  5647. * @returns a new Color4 object
  5648. */
  5649. scale(scale: number): Color4;
  5650. /**
  5651. * Multiplies the current Color4 values by scale and stores the result in "result"
  5652. * @param scale defines the scaling factor to apply
  5653. * @param result defines the Color4 object where to store the result
  5654. * @returns the current unmodified Color4
  5655. */
  5656. scaleToRef(scale: number, result: Color4): Color4;
  5657. /**
  5658. * Scale the current Color4 values by a factor and add the result to a given Color4
  5659. * @param scale defines the scale factor
  5660. * @param result defines the Color4 object where to store the result
  5661. * @returns the unmodified current Color4
  5662. */
  5663. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5664. /**
  5665. * Clamps the rgb values by the min and max values and stores the result into "result"
  5666. * @param min defines minimum clamping value (default is 0)
  5667. * @param max defines maximum clamping value (default is 1)
  5668. * @param result defines color to store the result into.
  5669. * @returns the cuurent Color4
  5670. */
  5671. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5672. /**
  5673. * Multipy an Color4 value by another and return a new Color4 object
  5674. * @param color defines the Color4 value to multiply by
  5675. * @returns a new Color4 object
  5676. */
  5677. multiply(color: Color4): Color4;
  5678. /**
  5679. * Multipy a Color4 value by another and push the result in a reference value
  5680. * @param color defines the Color4 value to multiply by
  5681. * @param result defines the Color4 to fill the result in
  5682. * @returns the result Color4
  5683. */
  5684. multiplyToRef(color: Color4, result: Color4): Color4;
  5685. /**
  5686. * Creates a string with the Color4 current values
  5687. * @returns the string representation of the Color4 object
  5688. */
  5689. toString(): string;
  5690. /**
  5691. * Returns the string "Color4"
  5692. * @returns "Color4"
  5693. */
  5694. getClassName(): string;
  5695. /**
  5696. * Compute the Color4 hash code
  5697. * @returns an unique number that can be used to hash Color4 objects
  5698. */
  5699. getHashCode(): number;
  5700. /**
  5701. * Creates a new Color4 copied from the current one
  5702. * @returns a new Color4 object
  5703. */
  5704. clone(): Color4;
  5705. /**
  5706. * Copies the given Color4 values into the current one
  5707. * @param source defines the source Color4 object
  5708. * @returns the current updated Color4 object
  5709. */
  5710. copyFrom(source: Color4): Color4;
  5711. /**
  5712. * Copies the given float values into the current one
  5713. * @param r defines the red component to read from
  5714. * @param g defines the green component to read from
  5715. * @param b defines the blue component to read from
  5716. * @param a defines the alpha component to read from
  5717. * @returns the current updated Color4 object
  5718. */
  5719. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5720. /**
  5721. * Copies the given float values into the current one
  5722. * @param r defines the red component to read from
  5723. * @param g defines the green component to read from
  5724. * @param b defines the blue component to read from
  5725. * @param a defines the alpha component to read from
  5726. * @returns the current updated Color4 object
  5727. */
  5728. set(r: number, g: number, b: number, a: number): Color4;
  5729. /**
  5730. * Compute the Color4 hexadecimal code as a string
  5731. * @returns a string containing the hexadecimal representation of the Color4 object
  5732. */
  5733. toHexString(): string;
  5734. /**
  5735. * Computes a new Color4 converted from the current one to linear space
  5736. * @returns a new Color4 object
  5737. */
  5738. toLinearSpace(): Color4;
  5739. /**
  5740. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5741. * @param convertedColor defines the Color4 object where to store the linear space version
  5742. * @returns the unmodified Color4
  5743. */
  5744. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5745. /**
  5746. * Computes a new Color4 converted from the current one to gamma space
  5747. * @returns a new Color4 object
  5748. */
  5749. toGammaSpace(): Color4;
  5750. /**
  5751. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5752. * @param convertedColor defines the Color4 object where to store the gamma space version
  5753. * @returns the unmodified Color4
  5754. */
  5755. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5756. /**
  5757. * Creates a new Color4 from the string containing valid hexadecimal values
  5758. * @param hex defines a string containing valid hexadecimal values
  5759. * @returns a new Color4 object
  5760. */
  5761. static FromHexString(hex: string): Color4;
  5762. /**
  5763. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5764. * @param left defines the start value
  5765. * @param right defines the end value
  5766. * @param amount defines the gradient factor
  5767. * @returns a new Color4 object
  5768. */
  5769. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5770. /**
  5771. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5772. * @param left defines the start value
  5773. * @param right defines the end value
  5774. * @param amount defines the gradient factor
  5775. * @param result defines the Color4 object where to store data
  5776. */
  5777. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5778. /**
  5779. * Creates a new Color4 from a Color3 and an alpha value
  5780. * @param color3 defines the source Color3 to read from
  5781. * @param alpha defines the alpha component (1.0 by default)
  5782. * @returns a new Color4 object
  5783. */
  5784. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5785. /**
  5786. * Creates a new Color4 from the starting index element of the given array
  5787. * @param array defines the source array to read from
  5788. * @param offset defines the offset in the source array
  5789. * @returns a new Color4 object
  5790. */
  5791. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5792. /**
  5793. * Creates a new Color3 from integer values (< 256)
  5794. * @param r defines the red component to read from (value between 0 and 255)
  5795. * @param g defines the green component to read from (value between 0 and 255)
  5796. * @param b defines the blue component to read from (value between 0 and 255)
  5797. * @param a defines the alpha component to read from (value between 0 and 255)
  5798. * @returns a new Color3 object
  5799. */
  5800. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5801. /**
  5802. * Check the content of a given array and convert it to an array containing RGBA data
  5803. * If the original array was already containing count * 4 values then it is returned directly
  5804. * @param colors defines the array to check
  5805. * @param count defines the number of RGBA data to expect
  5806. * @returns an array containing count * 4 values (RGBA)
  5807. */
  5808. static CheckColors4(colors: number[], count: number): number[];
  5809. }
  5810. /**
  5811. * @hidden
  5812. */
  5813. export class TmpColors {
  5814. static Color3: Color3[];
  5815. static Color4: Color4[];
  5816. }
  5817. }
  5818. declare module BABYLON {
  5819. /**
  5820. * Defines an interface which represents an animation key frame
  5821. */
  5822. export interface IAnimationKey {
  5823. /**
  5824. * Frame of the key frame
  5825. */
  5826. frame: number;
  5827. /**
  5828. * Value at the specifies key frame
  5829. */
  5830. value: any;
  5831. /**
  5832. * The input tangent for the cubic hermite spline
  5833. */
  5834. inTangent?: any;
  5835. /**
  5836. * The output tangent for the cubic hermite spline
  5837. */
  5838. outTangent?: any;
  5839. /**
  5840. * The animation interpolation type
  5841. */
  5842. interpolation?: AnimationKeyInterpolation;
  5843. }
  5844. /**
  5845. * Enum for the animation key frame interpolation type
  5846. */
  5847. export enum AnimationKeyInterpolation {
  5848. /**
  5849. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5850. */
  5851. STEP = 1
  5852. }
  5853. }
  5854. declare module BABYLON {
  5855. /**
  5856. * Represents the range of an animation
  5857. */
  5858. export class AnimationRange {
  5859. /**The name of the animation range**/
  5860. name: string;
  5861. /**The starting frame of the animation */
  5862. from: number;
  5863. /**The ending frame of the animation*/
  5864. to: number;
  5865. /**
  5866. * Initializes the range of an animation
  5867. * @param name The name of the animation range
  5868. * @param from The starting frame of the animation
  5869. * @param to The ending frame of the animation
  5870. */
  5871. constructor(
  5872. /**The name of the animation range**/
  5873. name: string,
  5874. /**The starting frame of the animation */
  5875. from: number,
  5876. /**The ending frame of the animation*/
  5877. to: number);
  5878. /**
  5879. * Makes a copy of the animation range
  5880. * @returns A copy of the animation range
  5881. */
  5882. clone(): AnimationRange;
  5883. }
  5884. }
  5885. declare module BABYLON {
  5886. /**
  5887. * Composed of a frame, and an action function
  5888. */
  5889. export class AnimationEvent {
  5890. /** The frame for which the event is triggered **/
  5891. frame: number;
  5892. /** The event to perform when triggered **/
  5893. action: (currentFrame: number) => void;
  5894. /** Specifies if the event should be triggered only once**/
  5895. onlyOnce?: boolean | undefined;
  5896. /**
  5897. * Specifies if the animation event is done
  5898. */
  5899. isDone: boolean;
  5900. /**
  5901. * Initializes the animation event
  5902. * @param frame The frame for which the event is triggered
  5903. * @param action The event to perform when triggered
  5904. * @param onlyOnce Specifies if the event should be triggered only once
  5905. */
  5906. constructor(
  5907. /** The frame for which the event is triggered **/
  5908. frame: number,
  5909. /** The event to perform when triggered **/
  5910. action: (currentFrame: number) => void,
  5911. /** Specifies if the event should be triggered only once**/
  5912. onlyOnce?: boolean | undefined);
  5913. /** @hidden */
  5914. _clone(): AnimationEvent;
  5915. }
  5916. }
  5917. declare module BABYLON {
  5918. /**
  5919. * Interface used to define a behavior
  5920. */
  5921. export interface Behavior<T> {
  5922. /** gets or sets behavior's name */
  5923. name: string;
  5924. /**
  5925. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5926. */
  5927. init(): void;
  5928. /**
  5929. * Called when the behavior is attached to a target
  5930. * @param target defines the target where the behavior is attached to
  5931. */
  5932. attach(target: T): void;
  5933. /**
  5934. * Called when the behavior is detached from its target
  5935. */
  5936. detach(): void;
  5937. }
  5938. /**
  5939. * Interface implemented by classes supporting behaviors
  5940. */
  5941. export interface IBehaviorAware<T> {
  5942. /**
  5943. * Attach a behavior
  5944. * @param behavior defines the behavior to attach
  5945. * @returns the current host
  5946. */
  5947. addBehavior(behavior: Behavior<T>): T;
  5948. /**
  5949. * Remove a behavior from the current object
  5950. * @param behavior defines the behavior to detach
  5951. * @returns the current host
  5952. */
  5953. removeBehavior(behavior: Behavior<T>): T;
  5954. /**
  5955. * Gets a behavior using its name to search
  5956. * @param name defines the name to search
  5957. * @returns the behavior or null if not found
  5958. */
  5959. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5960. }
  5961. }
  5962. declare module BABYLON {
  5963. /**
  5964. * Defines an array and its length.
  5965. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5966. */
  5967. export interface ISmartArrayLike<T> {
  5968. /**
  5969. * The data of the array.
  5970. */
  5971. data: Array<T>;
  5972. /**
  5973. * The active length of the array.
  5974. */
  5975. length: number;
  5976. }
  5977. /**
  5978. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5979. */
  5980. export class SmartArray<T> implements ISmartArrayLike<T> {
  5981. /**
  5982. * The full set of data from the array.
  5983. */
  5984. data: Array<T>;
  5985. /**
  5986. * The active length of the array.
  5987. */
  5988. length: number;
  5989. protected _id: number;
  5990. /**
  5991. * Instantiates a Smart Array.
  5992. * @param capacity defines the default capacity of the array.
  5993. */
  5994. constructor(capacity: number);
  5995. /**
  5996. * Pushes a value at the end of the active data.
  5997. * @param value defines the object to push in the array.
  5998. */
  5999. push(value: T): void;
  6000. /**
  6001. * Iterates over the active data and apply the lambda to them.
  6002. * @param func defines the action to apply on each value.
  6003. */
  6004. forEach(func: (content: T) => void): void;
  6005. /**
  6006. * Sorts the full sets of data.
  6007. * @param compareFn defines the comparison function to apply.
  6008. */
  6009. sort(compareFn: (a: T, b: T) => number): void;
  6010. /**
  6011. * Resets the active data to an empty array.
  6012. */
  6013. reset(): void;
  6014. /**
  6015. * Releases all the data from the array as well as the array.
  6016. */
  6017. dispose(): void;
  6018. /**
  6019. * Concats the active data with a given array.
  6020. * @param array defines the data to concatenate with.
  6021. */
  6022. concat(array: any): void;
  6023. /**
  6024. * Returns the position of a value in the active data.
  6025. * @param value defines the value to find the index for
  6026. * @returns the index if found in the active data otherwise -1
  6027. */
  6028. indexOf(value: T): number;
  6029. /**
  6030. * Returns whether an element is part of the active data.
  6031. * @param value defines the value to look for
  6032. * @returns true if found in the active data otherwise false
  6033. */
  6034. contains(value: T): boolean;
  6035. private static _GlobalId;
  6036. }
  6037. /**
  6038. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6039. * The data in this array can only be present once
  6040. */
  6041. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6042. private _duplicateId;
  6043. /**
  6044. * Pushes a value at the end of the active data.
  6045. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6046. * @param value defines the object to push in the array.
  6047. */
  6048. push(value: T): void;
  6049. /**
  6050. * Pushes a value at the end of the active data.
  6051. * If the data is already present, it won t be added again
  6052. * @param value defines the object to push in the array.
  6053. * @returns true if added false if it was already present
  6054. */
  6055. pushNoDuplicate(value: T): boolean;
  6056. /**
  6057. * Resets the active data to an empty array.
  6058. */
  6059. reset(): void;
  6060. /**
  6061. * Concats the active data with a given array.
  6062. * This ensures no dupplicate will be present in the result.
  6063. * @param array defines the data to concatenate with.
  6064. */
  6065. concatWithNoDuplicate(array: any): void;
  6066. }
  6067. }
  6068. declare module BABYLON {
  6069. /**
  6070. * @ignore
  6071. * This is a list of all the different input types that are available in the application.
  6072. * Fo instance: ArcRotateCameraGamepadInput...
  6073. */
  6074. export var CameraInputTypes: {};
  6075. /**
  6076. * This is the contract to implement in order to create a new input class.
  6077. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6078. */
  6079. export interface ICameraInput<TCamera extends Camera> {
  6080. /**
  6081. * Defines the camera the input is attached to.
  6082. */
  6083. camera: Nullable<TCamera>;
  6084. /**
  6085. * Gets the class name of the current intput.
  6086. * @returns the class name
  6087. */
  6088. getClassName(): string;
  6089. /**
  6090. * Get the friendly name associated with the input class.
  6091. * @returns the input friendly name
  6092. */
  6093. getSimpleName(): string;
  6094. /**
  6095. * Attach the input controls to a specific dom element to get the input from.
  6096. * @param element Defines the element the controls should be listened from
  6097. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6098. */
  6099. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6100. /**
  6101. * Detach the current controls from the specified dom element.
  6102. * @param element Defines the element to stop listening the inputs from
  6103. */
  6104. detachControl(element: Nullable<HTMLElement>): void;
  6105. /**
  6106. * Update the current camera state depending on the inputs that have been used this frame.
  6107. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6108. */
  6109. checkInputs?: () => void;
  6110. }
  6111. /**
  6112. * Represents a map of input types to input instance or input index to input instance.
  6113. */
  6114. export interface CameraInputsMap<TCamera extends Camera> {
  6115. /**
  6116. * Accessor to the input by input type.
  6117. */
  6118. [name: string]: ICameraInput<TCamera>;
  6119. /**
  6120. * Accessor to the input by input index.
  6121. */
  6122. [idx: number]: ICameraInput<TCamera>;
  6123. }
  6124. /**
  6125. * This represents the input manager used within a camera.
  6126. * It helps dealing with all the different kind of input attached to a camera.
  6127. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6128. */
  6129. export class CameraInputsManager<TCamera extends Camera> {
  6130. /**
  6131. * Defines the list of inputs attahed to the camera.
  6132. */
  6133. attached: CameraInputsMap<TCamera>;
  6134. /**
  6135. * Defines the dom element the camera is collecting inputs from.
  6136. * This is null if the controls have not been attached.
  6137. */
  6138. attachedElement: Nullable<HTMLElement>;
  6139. /**
  6140. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6141. */
  6142. noPreventDefault: boolean;
  6143. /**
  6144. * Defined the camera the input manager belongs to.
  6145. */
  6146. camera: TCamera;
  6147. /**
  6148. * Update the current camera state depending on the inputs that have been used this frame.
  6149. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6150. */
  6151. checkInputs: () => void;
  6152. /**
  6153. * Instantiate a new Camera Input Manager.
  6154. * @param camera Defines the camera the input manager blongs to
  6155. */
  6156. constructor(camera: TCamera);
  6157. /**
  6158. * Add an input method to a camera
  6159. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6160. * @param input camera input method
  6161. */
  6162. add(input: ICameraInput<TCamera>): void;
  6163. /**
  6164. * Remove a specific input method from a camera
  6165. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6166. * @param inputToRemove camera input method
  6167. */
  6168. remove(inputToRemove: ICameraInput<TCamera>): void;
  6169. /**
  6170. * Remove a specific input type from a camera
  6171. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6172. * @param inputType the type of the input to remove
  6173. */
  6174. removeByType(inputType: string): void;
  6175. private _addCheckInputs;
  6176. /**
  6177. * Attach the input controls to the currently attached dom element to listen the events from.
  6178. * @param input Defines the input to attach
  6179. */
  6180. attachInput(input: ICameraInput<TCamera>): void;
  6181. /**
  6182. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6183. * @param element Defines the dom element to collect the events from
  6184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6185. */
  6186. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6187. /**
  6188. * Detach the current manager inputs controls from a specific dom element.
  6189. * @param element Defines the dom element to collect the events from
  6190. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6191. */
  6192. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6193. /**
  6194. * Rebuild the dynamic inputCheck function from the current list of
  6195. * defined inputs in the manager.
  6196. */
  6197. rebuildInputCheck(): void;
  6198. /**
  6199. * Remove all attached input methods from a camera
  6200. */
  6201. clear(): void;
  6202. /**
  6203. * Serialize the current input manager attached to a camera.
  6204. * This ensures than once parsed,
  6205. * the input associated to the camera will be identical to the current ones
  6206. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6207. */
  6208. serialize(serializedCamera: any): void;
  6209. /**
  6210. * Parses an input manager serialized JSON to restore the previous list of inputs
  6211. * and states associated to a camera.
  6212. * @param parsedCamera Defines the JSON to parse
  6213. */
  6214. parse(parsedCamera: any): void;
  6215. }
  6216. }
  6217. declare module BABYLON {
  6218. /**
  6219. * Class used to store data that will be store in GPU memory
  6220. */
  6221. export class Buffer {
  6222. private _engine;
  6223. private _buffer;
  6224. /** @hidden */
  6225. _data: Nullable<DataArray>;
  6226. private _updatable;
  6227. private _instanced;
  6228. private _divisor;
  6229. /**
  6230. * Gets the byte stride.
  6231. */
  6232. readonly byteStride: number;
  6233. /**
  6234. * Constructor
  6235. * @param engine the engine
  6236. * @param data the data to use for this buffer
  6237. * @param updatable whether the data is updatable
  6238. * @param stride the stride (optional)
  6239. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6240. * @param instanced whether the buffer is instanced (optional)
  6241. * @param useBytes set to true if the stride in in bytes (optional)
  6242. * @param divisor sets an optional divisor for instances (1 by default)
  6243. */
  6244. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6245. /**
  6246. * Create a new VertexBuffer based on the current buffer
  6247. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6248. * @param offset defines offset in the buffer (0 by default)
  6249. * @param size defines the size in floats of attributes (position is 3 for instance)
  6250. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6251. * @param instanced defines if the vertex buffer contains indexed data
  6252. * @param useBytes defines if the offset and stride are in bytes *
  6253. * @param divisor sets an optional divisor for instances (1 by default)
  6254. * @returns the new vertex buffer
  6255. */
  6256. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6257. /**
  6258. * Gets a boolean indicating if the Buffer is updatable?
  6259. * @returns true if the buffer is updatable
  6260. */
  6261. isUpdatable(): boolean;
  6262. /**
  6263. * Gets current buffer's data
  6264. * @returns a DataArray or null
  6265. */
  6266. getData(): Nullable<DataArray>;
  6267. /**
  6268. * Gets underlying native buffer
  6269. * @returns underlying native buffer
  6270. */
  6271. getBuffer(): Nullable<DataBuffer>;
  6272. /**
  6273. * Gets the stride in float32 units (i.e. byte stride / 4).
  6274. * May not be an integer if the byte stride is not divisible by 4.
  6275. * @returns the stride in float32 units
  6276. * @deprecated Please use byteStride instead.
  6277. */
  6278. getStrideSize(): number;
  6279. /**
  6280. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6281. * @param data defines the data to store
  6282. */
  6283. create(data?: Nullable<DataArray>): void;
  6284. /** @hidden */
  6285. _rebuild(): void;
  6286. /**
  6287. * Update current buffer data
  6288. * @param data defines the data to store
  6289. */
  6290. update(data: DataArray): void;
  6291. /**
  6292. * Updates the data directly.
  6293. * @param data the new data
  6294. * @param offset the new offset
  6295. * @param vertexCount the vertex count (optional)
  6296. * @param useBytes set to true if the offset is in bytes
  6297. */
  6298. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6299. /**
  6300. * Release all resources
  6301. */
  6302. dispose(): void;
  6303. }
  6304. /**
  6305. * Specialized buffer used to store vertex data
  6306. */
  6307. export class VertexBuffer {
  6308. /** @hidden */
  6309. _buffer: Buffer;
  6310. private _kind;
  6311. private _size;
  6312. private _ownsBuffer;
  6313. private _instanced;
  6314. private _instanceDivisor;
  6315. /**
  6316. * The byte type.
  6317. */
  6318. static readonly BYTE: number;
  6319. /**
  6320. * The unsigned byte type.
  6321. */
  6322. static readonly UNSIGNED_BYTE: number;
  6323. /**
  6324. * The short type.
  6325. */
  6326. static readonly SHORT: number;
  6327. /**
  6328. * The unsigned short type.
  6329. */
  6330. static readonly UNSIGNED_SHORT: number;
  6331. /**
  6332. * The integer type.
  6333. */
  6334. static readonly INT: number;
  6335. /**
  6336. * The unsigned integer type.
  6337. */
  6338. static readonly UNSIGNED_INT: number;
  6339. /**
  6340. * The float type.
  6341. */
  6342. static readonly FLOAT: number;
  6343. /**
  6344. * Gets or sets the instance divisor when in instanced mode
  6345. */
  6346. instanceDivisor: number;
  6347. /**
  6348. * Gets the byte stride.
  6349. */
  6350. readonly byteStride: number;
  6351. /**
  6352. * Gets the byte offset.
  6353. */
  6354. readonly byteOffset: number;
  6355. /**
  6356. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6357. */
  6358. readonly normalized: boolean;
  6359. /**
  6360. * Gets the data type of each component in the array.
  6361. */
  6362. readonly type: number;
  6363. /**
  6364. * Constructor
  6365. * @param engine the engine
  6366. * @param data the data to use for this vertex buffer
  6367. * @param kind the vertex buffer kind
  6368. * @param updatable whether the data is updatable
  6369. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6370. * @param stride the stride (optional)
  6371. * @param instanced whether the buffer is instanced (optional)
  6372. * @param offset the offset of the data (optional)
  6373. * @param size the number of components (optional)
  6374. * @param type the type of the component (optional)
  6375. * @param normalized whether the data contains normalized data (optional)
  6376. * @param useBytes set to true if stride and offset are in bytes (optional)
  6377. * @param divisor defines the instance divisor to use (1 by default)
  6378. */
  6379. 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);
  6380. /** @hidden */
  6381. _rebuild(): void;
  6382. /**
  6383. * Returns the kind of the VertexBuffer (string)
  6384. * @returns a string
  6385. */
  6386. getKind(): string;
  6387. /**
  6388. * Gets a boolean indicating if the VertexBuffer is updatable?
  6389. * @returns true if the buffer is updatable
  6390. */
  6391. isUpdatable(): boolean;
  6392. /**
  6393. * Gets current buffer's data
  6394. * @returns a DataArray or null
  6395. */
  6396. getData(): Nullable<DataArray>;
  6397. /**
  6398. * Gets underlying native buffer
  6399. * @returns underlying native buffer
  6400. */
  6401. getBuffer(): Nullable<DataBuffer>;
  6402. /**
  6403. * Gets the stride in float32 units (i.e. byte stride / 4).
  6404. * May not be an integer if the byte stride is not divisible by 4.
  6405. * @returns the stride in float32 units
  6406. * @deprecated Please use byteStride instead.
  6407. */
  6408. getStrideSize(): number;
  6409. /**
  6410. * Returns the offset as a multiple of the type byte length.
  6411. * @returns the offset in bytes
  6412. * @deprecated Please use byteOffset instead.
  6413. */
  6414. getOffset(): number;
  6415. /**
  6416. * Returns the number of components per vertex attribute (integer)
  6417. * @returns the size in float
  6418. */
  6419. getSize(): number;
  6420. /**
  6421. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6422. * @returns true if this buffer is instanced
  6423. */
  6424. getIsInstanced(): boolean;
  6425. /**
  6426. * Returns the instancing divisor, zero for non-instanced (integer).
  6427. * @returns a number
  6428. */
  6429. getInstanceDivisor(): number;
  6430. /**
  6431. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6432. * @param data defines the data to store
  6433. */
  6434. create(data?: DataArray): void;
  6435. /**
  6436. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6437. * This function will create a new buffer if the current one is not updatable
  6438. * @param data defines the data to store
  6439. */
  6440. update(data: DataArray): void;
  6441. /**
  6442. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6443. * Returns the directly updated WebGLBuffer.
  6444. * @param data the new data
  6445. * @param offset the new offset
  6446. * @param useBytes set to true if the offset is in bytes
  6447. */
  6448. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6449. /**
  6450. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6451. */
  6452. dispose(): void;
  6453. /**
  6454. * Enumerates each value of this vertex buffer as numbers.
  6455. * @param count the number of values to enumerate
  6456. * @param callback the callback function called for each value
  6457. */
  6458. forEach(count: number, callback: (value: number, index: number) => void): void;
  6459. /**
  6460. * Positions
  6461. */
  6462. static readonly PositionKind: string;
  6463. /**
  6464. * Normals
  6465. */
  6466. static readonly NormalKind: string;
  6467. /**
  6468. * Tangents
  6469. */
  6470. static readonly TangentKind: string;
  6471. /**
  6472. * Texture coordinates
  6473. */
  6474. static readonly UVKind: string;
  6475. /**
  6476. * Texture coordinates 2
  6477. */
  6478. static readonly UV2Kind: string;
  6479. /**
  6480. * Texture coordinates 3
  6481. */
  6482. static readonly UV3Kind: string;
  6483. /**
  6484. * Texture coordinates 4
  6485. */
  6486. static readonly UV4Kind: string;
  6487. /**
  6488. * Texture coordinates 5
  6489. */
  6490. static readonly UV5Kind: string;
  6491. /**
  6492. * Texture coordinates 6
  6493. */
  6494. static readonly UV6Kind: string;
  6495. /**
  6496. * Colors
  6497. */
  6498. static readonly ColorKind: string;
  6499. /**
  6500. * Matrix indices (for bones)
  6501. */
  6502. static readonly MatricesIndicesKind: string;
  6503. /**
  6504. * Matrix weights (for bones)
  6505. */
  6506. static readonly MatricesWeightsKind: string;
  6507. /**
  6508. * Additional matrix indices (for bones)
  6509. */
  6510. static readonly MatricesIndicesExtraKind: string;
  6511. /**
  6512. * Additional matrix weights (for bones)
  6513. */
  6514. static readonly MatricesWeightsExtraKind: string;
  6515. /**
  6516. * Deduces the stride given a kind.
  6517. * @param kind The kind string to deduce
  6518. * @returns The deduced stride
  6519. */
  6520. static DeduceStride(kind: string): number;
  6521. /**
  6522. * Gets the byte length of the given type.
  6523. * @param type the type
  6524. * @returns the number of bytes
  6525. */
  6526. static GetTypeByteLength(type: number): number;
  6527. /**
  6528. * Enumerates each value of the given parameters as numbers.
  6529. * @param data the data to enumerate
  6530. * @param byteOffset the byte offset of the data
  6531. * @param byteStride the byte stride of the data
  6532. * @param componentCount the number of components per element
  6533. * @param componentType the type of the component
  6534. * @param count the number of values to enumerate
  6535. * @param normalized whether the data is normalized
  6536. * @param callback the callback function called for each value
  6537. */
  6538. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6539. private static _GetFloatValue;
  6540. }
  6541. }
  6542. declare module BABYLON {
  6543. /**
  6544. * @hidden
  6545. */
  6546. export class IntersectionInfo {
  6547. bu: Nullable<number>;
  6548. bv: Nullable<number>;
  6549. distance: number;
  6550. faceId: number;
  6551. subMeshId: number;
  6552. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6553. }
  6554. }
  6555. declare module BABYLON {
  6556. /**
  6557. * Represens a plane by the equation ax + by + cz + d = 0
  6558. */
  6559. export class Plane {
  6560. private static _TmpMatrix;
  6561. /**
  6562. * Normal of the plane (a,b,c)
  6563. */
  6564. normal: Vector3;
  6565. /**
  6566. * d component of the plane
  6567. */
  6568. d: number;
  6569. /**
  6570. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6571. * @param a a component of the plane
  6572. * @param b b component of the plane
  6573. * @param c c component of the plane
  6574. * @param d d component of the plane
  6575. */
  6576. constructor(a: number, b: number, c: number, d: number);
  6577. /**
  6578. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6579. */
  6580. asArray(): number[];
  6581. /**
  6582. * @returns a new plane copied from the current Plane.
  6583. */
  6584. clone(): Plane;
  6585. /**
  6586. * @returns the string "Plane".
  6587. */
  6588. getClassName(): string;
  6589. /**
  6590. * @returns the Plane hash code.
  6591. */
  6592. getHashCode(): number;
  6593. /**
  6594. * Normalize the current Plane in place.
  6595. * @returns the updated Plane.
  6596. */
  6597. normalize(): Plane;
  6598. /**
  6599. * Applies a transformation the plane and returns the result
  6600. * @param transformation the transformation matrix to be applied to the plane
  6601. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6602. */
  6603. transform(transformation: DeepImmutable<Matrix>): Plane;
  6604. /**
  6605. * Calcualtte the dot product between the point and the plane normal
  6606. * @param point point to calculate the dot product with
  6607. * @returns the dot product (float) of the point coordinates and the plane normal.
  6608. */
  6609. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6610. /**
  6611. * Updates the current Plane from the plane defined by the three given points.
  6612. * @param point1 one of the points used to contruct the plane
  6613. * @param point2 one of the points used to contruct the plane
  6614. * @param point3 one of the points used to contruct the plane
  6615. * @returns the updated Plane.
  6616. */
  6617. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6618. /**
  6619. * Checks if the plane is facing a given direction
  6620. * @param direction the direction to check if the plane is facing
  6621. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6622. * @returns True is the vector "direction" is the same side than the plane normal.
  6623. */
  6624. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6625. /**
  6626. * Calculates the distance to a point
  6627. * @param point point to calculate distance to
  6628. * @returns the signed distance (float) from the given point to the Plane.
  6629. */
  6630. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6631. /**
  6632. * Creates a plane from an array
  6633. * @param array the array to create a plane from
  6634. * @returns a new Plane from the given array.
  6635. */
  6636. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6637. /**
  6638. * Creates a plane from three points
  6639. * @param point1 point used to create the plane
  6640. * @param point2 point used to create the plane
  6641. * @param point3 point used to create the plane
  6642. * @returns a new Plane defined by the three given points.
  6643. */
  6644. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6645. /**
  6646. * Creates a plane from an origin point and a normal
  6647. * @param origin origin of the plane to be constructed
  6648. * @param normal normal of the plane to be constructed
  6649. * @returns a new Plane the normal vector to this plane at the given origin point.
  6650. * Note : the vector "normal" is updated because normalized.
  6651. */
  6652. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6653. /**
  6654. * Calculates the distance from a plane and a point
  6655. * @param origin origin of the plane to be constructed
  6656. * @param normal normal of the plane to be constructed
  6657. * @param point point to calculate distance to
  6658. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6659. */
  6660. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6661. }
  6662. }
  6663. declare module BABYLON {
  6664. /**
  6665. * Class used to store bounding sphere information
  6666. */
  6667. export class BoundingSphere {
  6668. /**
  6669. * Gets the center of the bounding sphere in local space
  6670. */
  6671. readonly center: Vector3;
  6672. /**
  6673. * Radius of the bounding sphere in local space
  6674. */
  6675. radius: number;
  6676. /**
  6677. * Gets the center of the bounding sphere in world space
  6678. */
  6679. readonly centerWorld: Vector3;
  6680. /**
  6681. * Radius of the bounding sphere in world space
  6682. */
  6683. radiusWorld: number;
  6684. /**
  6685. * Gets the minimum vector in local space
  6686. */
  6687. readonly minimum: Vector3;
  6688. /**
  6689. * Gets the maximum vector in local space
  6690. */
  6691. readonly maximum: Vector3;
  6692. private _worldMatrix;
  6693. private static readonly TmpVector3;
  6694. /**
  6695. * Creates a new bounding sphere
  6696. * @param min defines the minimum vector (in local space)
  6697. * @param max defines the maximum vector (in local space)
  6698. * @param worldMatrix defines the new world matrix
  6699. */
  6700. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6701. /**
  6702. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6703. * @param min defines the new minimum vector (in local space)
  6704. * @param max defines the new maximum vector (in local space)
  6705. * @param worldMatrix defines the new world matrix
  6706. */
  6707. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6708. /**
  6709. * Scale the current bounding sphere by applying a scale factor
  6710. * @param factor defines the scale factor to apply
  6711. * @returns the current bounding box
  6712. */
  6713. scale(factor: number): BoundingSphere;
  6714. /**
  6715. * Gets the world matrix of the bounding box
  6716. * @returns a matrix
  6717. */
  6718. getWorldMatrix(): DeepImmutable<Matrix>;
  6719. /** @hidden */
  6720. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6721. /**
  6722. * Tests if the bounding sphere is intersecting the frustum planes
  6723. * @param frustumPlanes defines the frustum planes to test
  6724. * @returns true if there is an intersection
  6725. */
  6726. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6727. /**
  6728. * Tests if the bounding sphere center is in between the frustum planes.
  6729. * Used for optimistic fast inclusion.
  6730. * @param frustumPlanes defines the frustum planes to test
  6731. * @returns true if the sphere center is in between the frustum planes
  6732. */
  6733. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6734. /**
  6735. * Tests if a point is inside the bounding sphere
  6736. * @param point defines the point to test
  6737. * @returns true if the point is inside the bounding sphere
  6738. */
  6739. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6740. /**
  6741. * Checks if two sphere intersct
  6742. * @param sphere0 sphere 0
  6743. * @param sphere1 sphere 1
  6744. * @returns true if the speres intersect
  6745. */
  6746. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6747. }
  6748. }
  6749. declare module BABYLON {
  6750. /**
  6751. * Class used to store bounding box information
  6752. */
  6753. export class BoundingBox implements ICullable {
  6754. /**
  6755. * Gets the 8 vectors representing the bounding box in local space
  6756. */
  6757. readonly vectors: Vector3[];
  6758. /**
  6759. * Gets the center of the bounding box in local space
  6760. */
  6761. readonly center: Vector3;
  6762. /**
  6763. * Gets the center of the bounding box in world space
  6764. */
  6765. readonly centerWorld: Vector3;
  6766. /**
  6767. * Gets the extend size in local space
  6768. */
  6769. readonly extendSize: Vector3;
  6770. /**
  6771. * Gets the extend size in world space
  6772. */
  6773. readonly extendSizeWorld: Vector3;
  6774. /**
  6775. * Gets the OBB (object bounding box) directions
  6776. */
  6777. readonly directions: Vector3[];
  6778. /**
  6779. * Gets the 8 vectors representing the bounding box in world space
  6780. */
  6781. readonly vectorsWorld: Vector3[];
  6782. /**
  6783. * Gets the minimum vector in world space
  6784. */
  6785. readonly minimumWorld: Vector3;
  6786. /**
  6787. * Gets the maximum vector in world space
  6788. */
  6789. readonly maximumWorld: Vector3;
  6790. /**
  6791. * Gets the minimum vector in local space
  6792. */
  6793. readonly minimum: Vector3;
  6794. /**
  6795. * Gets the maximum vector in local space
  6796. */
  6797. readonly maximum: Vector3;
  6798. private _worldMatrix;
  6799. private static readonly TmpVector3;
  6800. /**
  6801. * @hidden
  6802. */
  6803. _tag: number;
  6804. /**
  6805. * Creates a new bounding box
  6806. * @param min defines the minimum vector (in local space)
  6807. * @param max defines the maximum vector (in local space)
  6808. * @param worldMatrix defines the new world matrix
  6809. */
  6810. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6811. /**
  6812. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6813. * @param min defines the new minimum vector (in local space)
  6814. * @param max defines the new maximum vector (in local space)
  6815. * @param worldMatrix defines the new world matrix
  6816. */
  6817. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6818. /**
  6819. * Scale the current bounding box by applying a scale factor
  6820. * @param factor defines the scale factor to apply
  6821. * @returns the current bounding box
  6822. */
  6823. scale(factor: number): BoundingBox;
  6824. /**
  6825. * Gets the world matrix of the bounding box
  6826. * @returns a matrix
  6827. */
  6828. getWorldMatrix(): DeepImmutable<Matrix>;
  6829. /** @hidden */
  6830. _update(world: DeepImmutable<Matrix>): void;
  6831. /**
  6832. * Tests if the bounding box is intersecting the frustum planes
  6833. * @param frustumPlanes defines the frustum planes to test
  6834. * @returns true if there is an intersection
  6835. */
  6836. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6837. /**
  6838. * Tests if the bounding box is entirely inside the frustum planes
  6839. * @param frustumPlanes defines the frustum planes to test
  6840. * @returns true if there is an inclusion
  6841. */
  6842. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6843. /**
  6844. * Tests if a point is inside the bounding box
  6845. * @param point defines the point to test
  6846. * @returns true if the point is inside the bounding box
  6847. */
  6848. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6849. /**
  6850. * Tests if the bounding box intersects with a bounding sphere
  6851. * @param sphere defines the sphere to test
  6852. * @returns true if there is an intersection
  6853. */
  6854. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6855. /**
  6856. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6857. * @param min defines the min vector to use
  6858. * @param max defines the max vector to use
  6859. * @returns true if there is an intersection
  6860. */
  6861. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6862. /**
  6863. * Tests if two bounding boxes are intersections
  6864. * @param box0 defines the first box to test
  6865. * @param box1 defines the second box to test
  6866. * @returns true if there is an intersection
  6867. */
  6868. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6869. /**
  6870. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6871. * @param minPoint defines the minimum vector of the bounding box
  6872. * @param maxPoint defines the maximum vector of the bounding box
  6873. * @param sphereCenter defines the sphere center
  6874. * @param sphereRadius defines the sphere radius
  6875. * @returns true if there is an intersection
  6876. */
  6877. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6878. /**
  6879. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6880. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6881. * @param frustumPlanes defines the frustum planes to test
  6882. * @return true if there is an inclusion
  6883. */
  6884. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6885. /**
  6886. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6887. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6888. * @param frustumPlanes defines the frustum planes to test
  6889. * @return true if there is an intersection
  6890. */
  6891. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6892. }
  6893. }
  6894. declare module BABYLON {
  6895. /** @hidden */
  6896. export class Collider {
  6897. /** Define if a collision was found */
  6898. collisionFound: boolean;
  6899. /**
  6900. * Define last intersection point in local space
  6901. */
  6902. intersectionPoint: Vector3;
  6903. /**
  6904. * Define last collided mesh
  6905. */
  6906. collidedMesh: Nullable<AbstractMesh>;
  6907. private _collisionPoint;
  6908. private _planeIntersectionPoint;
  6909. private _tempVector;
  6910. private _tempVector2;
  6911. private _tempVector3;
  6912. private _tempVector4;
  6913. private _edge;
  6914. private _baseToVertex;
  6915. private _destinationPoint;
  6916. private _slidePlaneNormal;
  6917. private _displacementVector;
  6918. /** @hidden */
  6919. _radius: Vector3;
  6920. /** @hidden */
  6921. _retry: number;
  6922. private _velocity;
  6923. private _basePoint;
  6924. private _epsilon;
  6925. /** @hidden */
  6926. _velocityWorldLength: number;
  6927. /** @hidden */
  6928. _basePointWorld: Vector3;
  6929. private _velocityWorld;
  6930. private _normalizedVelocity;
  6931. /** @hidden */
  6932. _initialVelocity: Vector3;
  6933. /** @hidden */
  6934. _initialPosition: Vector3;
  6935. private _nearestDistance;
  6936. private _collisionMask;
  6937. collisionMask: number;
  6938. /**
  6939. * Gets the plane normal used to compute the sliding response (in local space)
  6940. */
  6941. readonly slidePlaneNormal: Vector3;
  6942. /** @hidden */
  6943. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6944. /** @hidden */
  6945. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6946. /** @hidden */
  6947. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6948. /** @hidden */
  6949. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6950. /** @hidden */
  6951. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6952. /** @hidden */
  6953. _getResponse(pos: Vector3, vel: Vector3): void;
  6954. }
  6955. }
  6956. declare module BABYLON {
  6957. /**
  6958. * Interface for cullable objects
  6959. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6960. */
  6961. export interface ICullable {
  6962. /**
  6963. * Checks if the object or part of the object is in the frustum
  6964. * @param frustumPlanes Camera near/planes
  6965. * @returns true if the object is in frustum otherwise false
  6966. */
  6967. isInFrustum(frustumPlanes: Plane[]): boolean;
  6968. /**
  6969. * Checks if a cullable object (mesh...) is in the camera frustum
  6970. * Unlike isInFrustum this cheks the full bounding box
  6971. * @param frustumPlanes Camera near/planes
  6972. * @returns true if the object is in frustum otherwise false
  6973. */
  6974. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6975. }
  6976. /**
  6977. * Info for a bounding data of a mesh
  6978. */
  6979. export class BoundingInfo implements ICullable {
  6980. /**
  6981. * Bounding box for the mesh
  6982. */
  6983. readonly boundingBox: BoundingBox;
  6984. /**
  6985. * Bounding sphere for the mesh
  6986. */
  6987. readonly boundingSphere: BoundingSphere;
  6988. private _isLocked;
  6989. private static readonly TmpVector3;
  6990. /**
  6991. * Constructs bounding info
  6992. * @param minimum min vector of the bounding box/sphere
  6993. * @param maximum max vector of the bounding box/sphere
  6994. * @param worldMatrix defines the new world matrix
  6995. */
  6996. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6997. /**
  6998. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6999. * @param min defines the new minimum vector (in local space)
  7000. * @param max defines the new maximum vector (in local space)
  7001. * @param worldMatrix defines the new world matrix
  7002. */
  7003. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7004. /**
  7005. * min vector of the bounding box/sphere
  7006. */
  7007. readonly minimum: Vector3;
  7008. /**
  7009. * max vector of the bounding box/sphere
  7010. */
  7011. readonly maximum: Vector3;
  7012. /**
  7013. * If the info is locked and won't be updated to avoid perf overhead
  7014. */
  7015. isLocked: boolean;
  7016. /**
  7017. * Updates the bounding sphere and box
  7018. * @param world world matrix to be used to update
  7019. */
  7020. update(world: DeepImmutable<Matrix>): void;
  7021. /**
  7022. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7023. * @param center New center of the bounding info
  7024. * @param extend New extend of the bounding info
  7025. * @returns the current bounding info
  7026. */
  7027. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7028. /**
  7029. * Scale the current bounding info by applying a scale factor
  7030. * @param factor defines the scale factor to apply
  7031. * @returns the current bounding info
  7032. */
  7033. scale(factor: number): BoundingInfo;
  7034. /**
  7035. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7036. * @param frustumPlanes defines the frustum to test
  7037. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7038. * @returns true if the bounding info is in the frustum planes
  7039. */
  7040. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7041. /**
  7042. * Gets the world distance between the min and max points of the bounding box
  7043. */
  7044. readonly diagonalLength: number;
  7045. /**
  7046. * Checks if a cullable object (mesh...) is in the camera frustum
  7047. * Unlike isInFrustum this cheks the full bounding box
  7048. * @param frustumPlanes Camera near/planes
  7049. * @returns true if the object is in frustum otherwise false
  7050. */
  7051. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7052. /** @hidden */
  7053. _checkCollision(collider: Collider): boolean;
  7054. /**
  7055. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7056. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7057. * @param point the point to check intersection with
  7058. * @returns if the point intersects
  7059. */
  7060. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7061. /**
  7062. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7063. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7064. * @param boundingInfo the bounding info to check intersection with
  7065. * @param precise if the intersection should be done using OBB
  7066. * @returns if the bounding info intersects
  7067. */
  7068. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7069. }
  7070. }
  7071. declare module BABYLON {
  7072. /**
  7073. * Extracts minimum and maximum values from a list of indexed positions
  7074. * @param positions defines the positions to use
  7075. * @param indices defines the indices to the positions
  7076. * @param indexStart defines the start index
  7077. * @param indexCount defines the end index
  7078. * @param bias defines bias value to add to the result
  7079. * @return minimum and maximum values
  7080. */
  7081. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7082. minimum: Vector3;
  7083. maximum: Vector3;
  7084. };
  7085. /**
  7086. * Extracts minimum and maximum values from a list of positions
  7087. * @param positions defines the positions to use
  7088. * @param start defines the start index in the positions array
  7089. * @param count defines the number of positions to handle
  7090. * @param bias defines bias value to add to the result
  7091. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7092. * @return minimum and maximum values
  7093. */
  7094. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7095. minimum: Vector3;
  7096. maximum: Vector3;
  7097. };
  7098. }
  7099. declare module BABYLON {
  7100. /** @hidden */
  7101. export class WebGLDataBuffer extends DataBuffer {
  7102. private _buffer;
  7103. constructor(resource: WebGLBuffer);
  7104. readonly underlyingResource: any;
  7105. }
  7106. }
  7107. declare module BABYLON {
  7108. /** @hidden */
  7109. export class WebGLPipelineContext implements IPipelineContext {
  7110. engine: ThinEngine;
  7111. program: Nullable<WebGLProgram>;
  7112. context?: WebGLRenderingContext;
  7113. vertexShader?: WebGLShader;
  7114. fragmentShader?: WebGLShader;
  7115. isParallelCompiled: boolean;
  7116. onCompiled?: () => void;
  7117. transformFeedback?: WebGLTransformFeedback | null;
  7118. readonly isAsync: boolean;
  7119. readonly isReady: boolean;
  7120. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7121. }
  7122. }
  7123. declare module BABYLON {
  7124. interface ThinEngine {
  7125. /**
  7126. * Create an uniform buffer
  7127. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7128. * @param elements defines the content of the uniform buffer
  7129. * @returns the webGL uniform buffer
  7130. */
  7131. createUniformBuffer(elements: FloatArray): DataBuffer;
  7132. /**
  7133. * Create a dynamic uniform buffer
  7134. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7135. * @param elements defines the content of the uniform buffer
  7136. * @returns the webGL uniform buffer
  7137. */
  7138. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7139. /**
  7140. * Update an existing uniform buffer
  7141. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7142. * @param uniformBuffer defines the target uniform buffer
  7143. * @param elements defines the content to update
  7144. * @param offset defines the offset in the uniform buffer where update should start
  7145. * @param count defines the size of the data to update
  7146. */
  7147. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7148. /**
  7149. * Bind an uniform buffer to the current webGL context
  7150. * @param buffer defines the buffer to bind
  7151. */
  7152. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7153. /**
  7154. * Bind a buffer to the current webGL context at a given location
  7155. * @param buffer defines the buffer to bind
  7156. * @param location defines the index where to bind the buffer
  7157. */
  7158. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7159. /**
  7160. * Bind a specific block at a given index in a specific shader program
  7161. * @param pipelineContext defines the pipeline context to use
  7162. * @param blockName defines the block name
  7163. * @param index defines the index where to bind the block
  7164. */
  7165. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7166. }
  7167. }
  7168. declare module BABYLON {
  7169. /**
  7170. * Uniform buffer objects.
  7171. *
  7172. * Handles blocks of uniform on the GPU.
  7173. *
  7174. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7175. *
  7176. * For more information, please refer to :
  7177. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7178. */
  7179. export class UniformBuffer {
  7180. private _engine;
  7181. private _buffer;
  7182. private _data;
  7183. private _bufferData;
  7184. private _dynamic?;
  7185. private _uniformLocations;
  7186. private _uniformSizes;
  7187. private _uniformLocationPointer;
  7188. private _needSync;
  7189. private _noUBO;
  7190. private _currentEffect;
  7191. /** @hidden */
  7192. _alreadyBound: boolean;
  7193. private static _MAX_UNIFORM_SIZE;
  7194. private static _tempBuffer;
  7195. /**
  7196. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7197. * This is dynamic to allow compat with webgl 1 and 2.
  7198. * You will need to pass the name of the uniform as well as the value.
  7199. */
  7200. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7201. /**
  7202. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7203. * This is dynamic to allow compat with webgl 1 and 2.
  7204. * You will need to pass the name of the uniform as well as the value.
  7205. */
  7206. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7207. /**
  7208. * Lambda to Update a single float in a uniform buffer.
  7209. * This is dynamic to allow compat with webgl 1 and 2.
  7210. * You will need to pass the name of the uniform as well as the value.
  7211. */
  7212. updateFloat: (name: string, x: number) => void;
  7213. /**
  7214. * Lambda to Update a vec2 of float in a uniform buffer.
  7215. * This is dynamic to allow compat with webgl 1 and 2.
  7216. * You will need to pass the name of the uniform as well as the value.
  7217. */
  7218. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7219. /**
  7220. * Lambda to Update a vec3 of float in a uniform buffer.
  7221. * This is dynamic to allow compat with webgl 1 and 2.
  7222. * You will need to pass the name of the uniform as well as the value.
  7223. */
  7224. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7225. /**
  7226. * Lambda to Update a vec4 of float in a uniform buffer.
  7227. * This is dynamic to allow compat with webgl 1 and 2.
  7228. * You will need to pass the name of the uniform as well as the value.
  7229. */
  7230. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7231. /**
  7232. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7233. * This is dynamic to allow compat with webgl 1 and 2.
  7234. * You will need to pass the name of the uniform as well as the value.
  7235. */
  7236. updateMatrix: (name: string, mat: Matrix) => void;
  7237. /**
  7238. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7239. * This is dynamic to allow compat with webgl 1 and 2.
  7240. * You will need to pass the name of the uniform as well as the value.
  7241. */
  7242. updateVector3: (name: string, vector: Vector3) => void;
  7243. /**
  7244. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7245. * This is dynamic to allow compat with webgl 1 and 2.
  7246. * You will need to pass the name of the uniform as well as the value.
  7247. */
  7248. updateVector4: (name: string, vector: Vector4) => void;
  7249. /**
  7250. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7251. * This is dynamic to allow compat with webgl 1 and 2.
  7252. * You will need to pass the name of the uniform as well as the value.
  7253. */
  7254. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7255. /**
  7256. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7257. * This is dynamic to allow compat with webgl 1 and 2.
  7258. * You will need to pass the name of the uniform as well as the value.
  7259. */
  7260. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7261. /**
  7262. * Instantiates a new Uniform buffer objects.
  7263. *
  7264. * Handles blocks of uniform on the GPU.
  7265. *
  7266. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7267. *
  7268. * For more information, please refer to :
  7269. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7270. * @param engine Define the engine the buffer is associated with
  7271. * @param data Define the data contained in the buffer
  7272. * @param dynamic Define if the buffer is updatable
  7273. */
  7274. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7275. /**
  7276. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7277. * or just falling back on setUniformXXX calls.
  7278. */
  7279. readonly useUbo: boolean;
  7280. /**
  7281. * Indicates if the WebGL underlying uniform buffer is in sync
  7282. * with the javascript cache data.
  7283. */
  7284. readonly isSync: boolean;
  7285. /**
  7286. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7287. * Also, a dynamic UniformBuffer will disable cache verification and always
  7288. * update the underlying WebGL uniform buffer to the GPU.
  7289. * @returns if Dynamic, otherwise false
  7290. */
  7291. isDynamic(): boolean;
  7292. /**
  7293. * The data cache on JS side.
  7294. * @returns the underlying data as a float array
  7295. */
  7296. getData(): Float32Array;
  7297. /**
  7298. * The underlying WebGL Uniform buffer.
  7299. * @returns the webgl buffer
  7300. */
  7301. getBuffer(): Nullable<DataBuffer>;
  7302. /**
  7303. * std140 layout specifies how to align data within an UBO structure.
  7304. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7305. * for specs.
  7306. */
  7307. private _fillAlignment;
  7308. /**
  7309. * Adds an uniform in the buffer.
  7310. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7311. * for the layout to be correct !
  7312. * @param name Name of the uniform, as used in the uniform block in the shader.
  7313. * @param size Data size, or data directly.
  7314. */
  7315. addUniform(name: string, size: number | number[]): void;
  7316. /**
  7317. * Adds a Matrix 4x4 to the uniform buffer.
  7318. * @param name Name of the uniform, as used in the uniform block in the shader.
  7319. * @param mat A 4x4 matrix.
  7320. */
  7321. addMatrix(name: string, mat: Matrix): void;
  7322. /**
  7323. * Adds a vec2 to the uniform buffer.
  7324. * @param name Name of the uniform, as used in the uniform block in the shader.
  7325. * @param x Define the x component value of the vec2
  7326. * @param y Define the y component value of the vec2
  7327. */
  7328. addFloat2(name: string, x: number, y: number): void;
  7329. /**
  7330. * Adds a vec3 to the uniform buffer.
  7331. * @param name Name of the uniform, as used in the uniform block in the shader.
  7332. * @param x Define the x component value of the vec3
  7333. * @param y Define the y component value of the vec3
  7334. * @param z Define the z component value of the vec3
  7335. */
  7336. addFloat3(name: string, x: number, y: number, z: number): void;
  7337. /**
  7338. * Adds a vec3 to the uniform buffer.
  7339. * @param name Name of the uniform, as used in the uniform block in the shader.
  7340. * @param color Define the vec3 from a Color
  7341. */
  7342. addColor3(name: string, color: Color3): void;
  7343. /**
  7344. * Adds a vec4 to the uniform buffer.
  7345. * @param name Name of the uniform, as used in the uniform block in the shader.
  7346. * @param color Define the rgb components from a Color
  7347. * @param alpha Define the a component of the vec4
  7348. */
  7349. addColor4(name: string, color: Color3, alpha: number): void;
  7350. /**
  7351. * Adds a vec3 to the uniform buffer.
  7352. * @param name Name of the uniform, as used in the uniform block in the shader.
  7353. * @param vector Define the vec3 components from a Vector
  7354. */
  7355. addVector3(name: string, vector: Vector3): void;
  7356. /**
  7357. * Adds a Matrix 3x3 to the uniform buffer.
  7358. * @param name Name of the uniform, as used in the uniform block in the shader.
  7359. */
  7360. addMatrix3x3(name: string): void;
  7361. /**
  7362. * Adds a Matrix 2x2 to the uniform buffer.
  7363. * @param name Name of the uniform, as used in the uniform block in the shader.
  7364. */
  7365. addMatrix2x2(name: string): void;
  7366. /**
  7367. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7368. */
  7369. create(): void;
  7370. /** @hidden */
  7371. _rebuild(): void;
  7372. /**
  7373. * Updates the WebGL Uniform Buffer on the GPU.
  7374. * If the `dynamic` flag is set to true, no cache comparison is done.
  7375. * Otherwise, the buffer will be updated only if the cache differs.
  7376. */
  7377. update(): void;
  7378. /**
  7379. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7380. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7381. * @param data Define the flattened data
  7382. * @param size Define the size of the data.
  7383. */
  7384. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7385. private _valueCache;
  7386. private _cacheMatrix;
  7387. private _updateMatrix3x3ForUniform;
  7388. private _updateMatrix3x3ForEffect;
  7389. private _updateMatrix2x2ForEffect;
  7390. private _updateMatrix2x2ForUniform;
  7391. private _updateFloatForEffect;
  7392. private _updateFloatForUniform;
  7393. private _updateFloat2ForEffect;
  7394. private _updateFloat2ForUniform;
  7395. private _updateFloat3ForEffect;
  7396. private _updateFloat3ForUniform;
  7397. private _updateFloat4ForEffect;
  7398. private _updateFloat4ForUniform;
  7399. private _updateMatrixForEffect;
  7400. private _updateMatrixForUniform;
  7401. private _updateVector3ForEffect;
  7402. private _updateVector3ForUniform;
  7403. private _updateVector4ForEffect;
  7404. private _updateVector4ForUniform;
  7405. private _updateColor3ForEffect;
  7406. private _updateColor3ForUniform;
  7407. private _updateColor4ForEffect;
  7408. private _updateColor4ForUniform;
  7409. /**
  7410. * Sets a sampler uniform on the effect.
  7411. * @param name Define the name of the sampler.
  7412. * @param texture Define the texture to set in the sampler
  7413. */
  7414. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7415. /**
  7416. * Directly updates the value of the uniform in the cache AND on the GPU.
  7417. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7418. * @param data Define the flattened data
  7419. */
  7420. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7421. /**
  7422. * Binds this uniform buffer to an effect.
  7423. * @param effect Define the effect to bind the buffer to
  7424. * @param name Name of the uniform block in the shader.
  7425. */
  7426. bindToEffect(effect: Effect, name: string): void;
  7427. /**
  7428. * Disposes the uniform buffer.
  7429. */
  7430. dispose(): void;
  7431. }
  7432. }
  7433. declare module BABYLON {
  7434. /**
  7435. * Enum that determines the text-wrapping mode to use.
  7436. */
  7437. export enum InspectableType {
  7438. /**
  7439. * Checkbox for booleans
  7440. */
  7441. Checkbox = 0,
  7442. /**
  7443. * Sliders for numbers
  7444. */
  7445. Slider = 1,
  7446. /**
  7447. * Vector3
  7448. */
  7449. Vector3 = 2,
  7450. /**
  7451. * Quaternions
  7452. */
  7453. Quaternion = 3,
  7454. /**
  7455. * Color3
  7456. */
  7457. Color3 = 4,
  7458. /**
  7459. * String
  7460. */
  7461. String = 5
  7462. }
  7463. /**
  7464. * Interface used to define custom inspectable properties.
  7465. * This interface is used by the inspector to display custom property grids
  7466. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7467. */
  7468. export interface IInspectable {
  7469. /**
  7470. * Gets the label to display
  7471. */
  7472. label: string;
  7473. /**
  7474. * Gets the name of the property to edit
  7475. */
  7476. propertyName: string;
  7477. /**
  7478. * Gets the type of the editor to use
  7479. */
  7480. type: InspectableType;
  7481. /**
  7482. * Gets the minimum value of the property when using in "slider" mode
  7483. */
  7484. min?: number;
  7485. /**
  7486. * Gets the maximum value of the property when using in "slider" mode
  7487. */
  7488. max?: number;
  7489. /**
  7490. * Gets the setp to use when using in "slider" mode
  7491. */
  7492. step?: number;
  7493. }
  7494. }
  7495. declare module BABYLON {
  7496. /**
  7497. * Class used to provide helper for timing
  7498. */
  7499. export class TimingTools {
  7500. /**
  7501. * Polyfill for setImmediate
  7502. * @param action defines the action to execute after the current execution block
  7503. */
  7504. static SetImmediate(action: () => void): void;
  7505. }
  7506. }
  7507. declare module BABYLON {
  7508. /**
  7509. * Class used to enable instatition of objects by class name
  7510. */
  7511. export class InstantiationTools {
  7512. /**
  7513. * Use this object to register external classes like custom textures or material
  7514. * to allow the laoders to instantiate them
  7515. */
  7516. static RegisteredExternalClasses: {
  7517. [key: string]: Object;
  7518. };
  7519. /**
  7520. * Tries to instantiate a new object from a given class name
  7521. * @param className defines the class name to instantiate
  7522. * @returns the new object or null if the system was not able to do the instantiation
  7523. */
  7524. static Instantiate(className: string): any;
  7525. }
  7526. }
  7527. declare module BABYLON {
  7528. /**
  7529. * Define options used to create a depth texture
  7530. */
  7531. export class DepthTextureCreationOptions {
  7532. /** Specifies whether or not a stencil should be allocated in the texture */
  7533. generateStencil?: boolean;
  7534. /** Specifies whether or not bilinear filtering is enable on the texture */
  7535. bilinearFiltering?: boolean;
  7536. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7537. comparisonFunction?: number;
  7538. /** Specifies if the created texture is a cube texture */
  7539. isCube?: boolean;
  7540. }
  7541. }
  7542. declare module BABYLON {
  7543. interface ThinEngine {
  7544. /**
  7545. * Creates a depth stencil cube texture.
  7546. * This is only available in WebGL 2.
  7547. * @param size The size of face edge in the cube texture.
  7548. * @param options The options defining the cube texture.
  7549. * @returns The cube texture
  7550. */
  7551. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7552. /**
  7553. * Creates a cube texture
  7554. * @param rootUrl defines the url where the files to load is located
  7555. * @param scene defines the current scene
  7556. * @param files defines the list of files to load (1 per face)
  7557. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7558. * @param onLoad defines an optional callback raised when the texture is loaded
  7559. * @param onError defines an optional callback raised if there is an issue to load the texture
  7560. * @param format defines the format of the data
  7561. * @param forcedExtension defines the extension to use to pick the right loader
  7562. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7563. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7564. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7565. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7566. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7567. * @returns the cube texture as an InternalTexture
  7568. */
  7569. 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;
  7570. /**
  7571. * Creates a cube texture
  7572. * @param rootUrl defines the url where the files to load is located
  7573. * @param scene defines the current scene
  7574. * @param files defines the list of files to load (1 per face)
  7575. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7576. * @param onLoad defines an optional callback raised when the texture is loaded
  7577. * @param onError defines an optional callback raised if there is an issue to load the texture
  7578. * @param format defines the format of the data
  7579. * @param forcedExtension defines the extension to use to pick the right loader
  7580. * @returns the cube texture as an InternalTexture
  7581. */
  7582. 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;
  7583. /**
  7584. * Creates a cube texture
  7585. * @param rootUrl defines the url where the files to load is located
  7586. * @param scene defines the current scene
  7587. * @param files defines the list of files to load (1 per face)
  7588. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7589. * @param onLoad defines an optional callback raised when the texture is loaded
  7590. * @param onError defines an optional callback raised if there is an issue to load the texture
  7591. * @param format defines the format of the data
  7592. * @param forcedExtension defines the extension to use to pick the right loader
  7593. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7594. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7595. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7596. * @returns the cube texture as an InternalTexture
  7597. */
  7598. 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;
  7599. /** @hidden */
  7600. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7601. /** @hidden */
  7602. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7603. /** @hidden */
  7604. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7605. /** @hidden */
  7606. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7607. /**
  7608. * @hidden
  7609. */
  7610. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7611. }
  7612. }
  7613. declare module BABYLON {
  7614. /**
  7615. * Class for creating a cube texture
  7616. */
  7617. export class CubeTexture extends BaseTexture {
  7618. private _delayedOnLoad;
  7619. /**
  7620. * The url of the texture
  7621. */
  7622. url: string;
  7623. /**
  7624. * Gets or sets the center of the bounding box associated with the cube texture.
  7625. * It must define where the camera used to render the texture was set
  7626. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7627. */
  7628. boundingBoxPosition: Vector3;
  7629. private _boundingBoxSize;
  7630. /**
  7631. * Gets or sets the size of the bounding box associated with the cube texture
  7632. * When defined, the cubemap will switch to local mode
  7633. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7634. * @example https://www.babylonjs-playground.com/#RNASML
  7635. */
  7636. /**
  7637. * Returns the bounding box size
  7638. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7639. */
  7640. boundingBoxSize: Vector3;
  7641. protected _rotationY: number;
  7642. /**
  7643. * Sets texture matrix rotation angle around Y axis in radians.
  7644. */
  7645. /**
  7646. * Gets texture matrix rotation angle around Y axis radians.
  7647. */
  7648. rotationY: number;
  7649. /**
  7650. * Are mip maps generated for this texture or not.
  7651. */
  7652. readonly noMipmap: boolean;
  7653. private _noMipmap;
  7654. private _files;
  7655. protected _forcedExtension: Nullable<string>;
  7656. private _extensions;
  7657. private _textureMatrix;
  7658. private _format;
  7659. private _createPolynomials;
  7660. /** @hidden */
  7661. _prefiltered: boolean;
  7662. /**
  7663. * Creates a cube texture from an array of image urls
  7664. * @param files defines an array of image urls
  7665. * @param scene defines the hosting scene
  7666. * @param noMipmap specifies if mip maps are not used
  7667. * @returns a cube texture
  7668. */
  7669. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7670. /**
  7671. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7672. * @param url defines the url of the prefiltered texture
  7673. * @param scene defines the scene the texture is attached to
  7674. * @param forcedExtension defines the extension of the file if different from the url
  7675. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7676. * @return the prefiltered texture
  7677. */
  7678. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7679. /**
  7680. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7681. * as prefiltered data.
  7682. * @param rootUrl defines the url of the texture or the root name of the six images
  7683. * @param scene defines the scene the texture is attached to
  7684. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7685. * @param noMipmap defines if mipmaps should be created or not
  7686. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7687. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7688. * @param onError defines a callback triggered in case of error during load
  7689. * @param format defines the internal format to use for the texture once loaded
  7690. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7691. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7692. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7693. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7694. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7695. * @return the cube texture
  7696. */
  7697. 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);
  7698. /**
  7699. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7700. */
  7701. readonly isPrefiltered: boolean;
  7702. /**
  7703. * Get the current class name of the texture useful for serialization or dynamic coding.
  7704. * @returns "CubeTexture"
  7705. */
  7706. getClassName(): string;
  7707. /**
  7708. * Update the url (and optional buffer) of this texture if url was null during construction.
  7709. * @param url the url of the texture
  7710. * @param forcedExtension defines the extension to use
  7711. * @param onLoad callback called when the texture is loaded (defaults to null)
  7712. */
  7713. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7714. /**
  7715. * Delays loading of the cube texture
  7716. * @param forcedExtension defines the extension to use
  7717. */
  7718. delayLoad(forcedExtension?: string): void;
  7719. /**
  7720. * Returns the reflection texture matrix
  7721. * @returns the reflection texture matrix
  7722. */
  7723. getReflectionTextureMatrix(): Matrix;
  7724. /**
  7725. * Sets the reflection texture matrix
  7726. * @param value Reflection texture matrix
  7727. */
  7728. setReflectionTextureMatrix(value: Matrix): void;
  7729. /**
  7730. * Parses text to create a cube texture
  7731. * @param parsedTexture define the serialized text to read from
  7732. * @param scene defines the hosting scene
  7733. * @param rootUrl defines the root url of the cube texture
  7734. * @returns a cube texture
  7735. */
  7736. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7737. /**
  7738. * Makes a clone, or deep copy, of the cube texture
  7739. * @returns a new cube texture
  7740. */
  7741. clone(): CubeTexture;
  7742. }
  7743. }
  7744. declare module BABYLON {
  7745. /**
  7746. * Manages the defines for the Material
  7747. */
  7748. export class MaterialDefines {
  7749. /** @hidden */
  7750. protected _keys: string[];
  7751. private _isDirty;
  7752. /** @hidden */
  7753. _renderId: number;
  7754. /** @hidden */
  7755. _areLightsDirty: boolean;
  7756. /** @hidden */
  7757. _areLightsDisposed: boolean;
  7758. /** @hidden */
  7759. _areAttributesDirty: boolean;
  7760. /** @hidden */
  7761. _areTexturesDirty: boolean;
  7762. /** @hidden */
  7763. _areFresnelDirty: boolean;
  7764. /** @hidden */
  7765. _areMiscDirty: boolean;
  7766. /** @hidden */
  7767. _areImageProcessingDirty: boolean;
  7768. /** @hidden */
  7769. _normals: boolean;
  7770. /** @hidden */
  7771. _uvs: boolean;
  7772. /** @hidden */
  7773. _needNormals: boolean;
  7774. /** @hidden */
  7775. _needUVs: boolean;
  7776. [id: string]: any;
  7777. /**
  7778. * Specifies if the material needs to be re-calculated
  7779. */
  7780. readonly isDirty: boolean;
  7781. /**
  7782. * Marks the material to indicate that it has been re-calculated
  7783. */
  7784. markAsProcessed(): void;
  7785. /**
  7786. * Marks the material to indicate that it needs to be re-calculated
  7787. */
  7788. markAsUnprocessed(): void;
  7789. /**
  7790. * Marks the material to indicate all of its defines need to be re-calculated
  7791. */
  7792. markAllAsDirty(): void;
  7793. /**
  7794. * Marks the material to indicate that image processing needs to be re-calculated
  7795. */
  7796. markAsImageProcessingDirty(): void;
  7797. /**
  7798. * Marks the material to indicate the lights need to be re-calculated
  7799. * @param disposed Defines whether the light is dirty due to dispose or not
  7800. */
  7801. markAsLightDirty(disposed?: boolean): void;
  7802. /**
  7803. * Marks the attribute state as changed
  7804. */
  7805. markAsAttributesDirty(): void;
  7806. /**
  7807. * Marks the texture state as changed
  7808. */
  7809. markAsTexturesDirty(): void;
  7810. /**
  7811. * Marks the fresnel state as changed
  7812. */
  7813. markAsFresnelDirty(): void;
  7814. /**
  7815. * Marks the misc state as changed
  7816. */
  7817. markAsMiscDirty(): void;
  7818. /**
  7819. * Rebuilds the material defines
  7820. */
  7821. rebuild(): void;
  7822. /**
  7823. * Specifies if two material defines are equal
  7824. * @param other - A material define instance to compare to
  7825. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7826. */
  7827. isEqual(other: MaterialDefines): boolean;
  7828. /**
  7829. * Clones this instance's defines to another instance
  7830. * @param other - material defines to clone values to
  7831. */
  7832. cloneTo(other: MaterialDefines): void;
  7833. /**
  7834. * Resets the material define values
  7835. */
  7836. reset(): void;
  7837. /**
  7838. * Converts the material define values to a string
  7839. * @returns - String of material define information
  7840. */
  7841. toString(): string;
  7842. }
  7843. }
  7844. declare module BABYLON {
  7845. /**
  7846. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7847. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7848. * 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;
  7849. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7850. */
  7851. export class ColorCurves {
  7852. private _dirty;
  7853. private _tempColor;
  7854. private _globalCurve;
  7855. private _highlightsCurve;
  7856. private _midtonesCurve;
  7857. private _shadowsCurve;
  7858. private _positiveCurve;
  7859. private _negativeCurve;
  7860. private _globalHue;
  7861. private _globalDensity;
  7862. private _globalSaturation;
  7863. private _globalExposure;
  7864. /**
  7865. * Gets the global Hue value.
  7866. * 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).
  7867. */
  7868. /**
  7869. * Sets the global Hue value.
  7870. * 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).
  7871. */
  7872. globalHue: number;
  7873. /**
  7874. * Gets the global Density value.
  7875. * 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.
  7876. * Values less than zero provide a filter of opposite hue.
  7877. */
  7878. /**
  7879. * Sets the global Density value.
  7880. * 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.
  7881. * Values less than zero provide a filter of opposite hue.
  7882. */
  7883. globalDensity: number;
  7884. /**
  7885. * Gets the global Saturation value.
  7886. * 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.
  7887. */
  7888. /**
  7889. * Sets the global Saturation value.
  7890. * 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.
  7891. */
  7892. globalSaturation: number;
  7893. /**
  7894. * Gets the global Exposure value.
  7895. * 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.
  7896. */
  7897. /**
  7898. * Sets the global Exposure value.
  7899. * 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.
  7900. */
  7901. globalExposure: number;
  7902. private _highlightsHue;
  7903. private _highlightsDensity;
  7904. private _highlightsSaturation;
  7905. private _highlightsExposure;
  7906. /**
  7907. * Gets the highlights Hue value.
  7908. * 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).
  7909. */
  7910. /**
  7911. * Sets the highlights 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. highlightsHue: number;
  7915. /**
  7916. * Gets the highlights 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. /**
  7921. * Sets the highlights Density value.
  7922. * 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.
  7923. * Values less than zero provide a filter of opposite hue.
  7924. */
  7925. highlightsDensity: number;
  7926. /**
  7927. * Gets the highlights Saturation value.
  7928. * 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.
  7929. */
  7930. /**
  7931. * Sets the highlights Saturation value.
  7932. * 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.
  7933. */
  7934. highlightsSaturation: number;
  7935. /**
  7936. * Gets the highlights Exposure value.
  7937. * 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.
  7938. */
  7939. /**
  7940. * Sets the highlights Exposure value.
  7941. * 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.
  7942. */
  7943. highlightsExposure: number;
  7944. private _midtonesHue;
  7945. private _midtonesDensity;
  7946. private _midtonesSaturation;
  7947. private _midtonesExposure;
  7948. /**
  7949. * Gets the midtones Hue value.
  7950. * 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).
  7951. */
  7952. /**
  7953. * Sets the midtones Hue value.
  7954. * 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).
  7955. */
  7956. midtonesHue: number;
  7957. /**
  7958. * Gets the midtones Density value.
  7959. * 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.
  7960. * Values less than zero provide a filter of opposite hue.
  7961. */
  7962. /**
  7963. * Sets the midtones Density value.
  7964. * 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.
  7965. * Values less than zero provide a filter of opposite hue.
  7966. */
  7967. midtonesDensity: number;
  7968. /**
  7969. * Gets the midtones Saturation value.
  7970. * 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.
  7971. */
  7972. /**
  7973. * Sets the midtones Saturation value.
  7974. * 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.
  7975. */
  7976. midtonesSaturation: number;
  7977. /**
  7978. * Gets the midtones Exposure value.
  7979. * 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.
  7980. */
  7981. /**
  7982. * Sets the midtones Exposure value.
  7983. * 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.
  7984. */
  7985. midtonesExposure: number;
  7986. private _shadowsHue;
  7987. private _shadowsDensity;
  7988. private _shadowsSaturation;
  7989. private _shadowsExposure;
  7990. /**
  7991. * Gets the shadows Hue value.
  7992. * 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).
  7993. */
  7994. /**
  7995. * Sets the shadows Hue value.
  7996. * 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).
  7997. */
  7998. shadowsHue: number;
  7999. /**
  8000. * Gets the shadows Density value.
  8001. * 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.
  8002. * Values less than zero provide a filter of opposite hue.
  8003. */
  8004. /**
  8005. * Sets the shadows Density value.
  8006. * 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.
  8007. * Values less than zero provide a filter of opposite hue.
  8008. */
  8009. shadowsDensity: number;
  8010. /**
  8011. * Gets the shadows Saturation value.
  8012. * 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.
  8013. */
  8014. /**
  8015. * Sets the shadows Saturation value.
  8016. * 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.
  8017. */
  8018. shadowsSaturation: number;
  8019. /**
  8020. * Gets the shadows Exposure 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 exposure and negative values decrease exposure.
  8022. */
  8023. /**
  8024. * Sets the shadows Exposure value.
  8025. * 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.
  8026. */
  8027. shadowsExposure: number;
  8028. /**
  8029. * Returns the class name
  8030. * @returns The class name
  8031. */
  8032. getClassName(): string;
  8033. /**
  8034. * Binds the color curves to the shader.
  8035. * @param colorCurves The color curve to bind
  8036. * @param effect The effect to bind to
  8037. * @param positiveUniform The positive uniform shader parameter
  8038. * @param neutralUniform The neutral uniform shader parameter
  8039. * @param negativeUniform The negative uniform shader parameter
  8040. */
  8041. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8042. /**
  8043. * Prepare the list of uniforms associated with the ColorCurves effects.
  8044. * @param uniformsList The list of uniforms used in the effect
  8045. */
  8046. static PrepareUniforms(uniformsList: string[]): void;
  8047. /**
  8048. * Returns color grading data based on a hue, density, saturation and exposure value.
  8049. * @param filterHue The hue of the color filter.
  8050. * @param filterDensity The density of the color filter.
  8051. * @param saturation The saturation.
  8052. * @param exposure The exposure.
  8053. * @param result The result data container.
  8054. */
  8055. private getColorGradingDataToRef;
  8056. /**
  8057. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8058. * @param value The input slider value in range [-100,100].
  8059. * @returns Adjusted value.
  8060. */
  8061. private static applyColorGradingSliderNonlinear;
  8062. /**
  8063. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8064. * @param hue The hue (H) input.
  8065. * @param saturation The saturation (S) input.
  8066. * @param brightness The brightness (B) input.
  8067. * @result An RGBA color represented as Vector4.
  8068. */
  8069. private static fromHSBToRef;
  8070. /**
  8071. * Returns a value clamped between min and max
  8072. * @param value The value to clamp
  8073. * @param min The minimum of value
  8074. * @param max The maximum of value
  8075. * @returns The clamped value.
  8076. */
  8077. private static clamp;
  8078. /**
  8079. * Clones the current color curve instance.
  8080. * @return The cloned curves
  8081. */
  8082. clone(): ColorCurves;
  8083. /**
  8084. * Serializes the current color curve instance to a json representation.
  8085. * @return a JSON representation
  8086. */
  8087. serialize(): any;
  8088. /**
  8089. * Parses the color curve from a json representation.
  8090. * @param source the JSON source to parse
  8091. * @return The parsed curves
  8092. */
  8093. static Parse(source: any): ColorCurves;
  8094. }
  8095. }
  8096. declare module BABYLON {
  8097. /**
  8098. * Interface to follow in your material defines to integrate easily the
  8099. * Image proccessing functions.
  8100. * @hidden
  8101. */
  8102. export interface IImageProcessingConfigurationDefines {
  8103. IMAGEPROCESSING: boolean;
  8104. VIGNETTE: boolean;
  8105. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8106. VIGNETTEBLENDMODEOPAQUE: boolean;
  8107. TONEMAPPING: boolean;
  8108. TONEMAPPING_ACES: boolean;
  8109. CONTRAST: boolean;
  8110. EXPOSURE: boolean;
  8111. COLORCURVES: boolean;
  8112. COLORGRADING: boolean;
  8113. COLORGRADING3D: boolean;
  8114. SAMPLER3DGREENDEPTH: boolean;
  8115. SAMPLER3DBGRMAP: boolean;
  8116. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8117. }
  8118. /**
  8119. * @hidden
  8120. */
  8121. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8122. IMAGEPROCESSING: boolean;
  8123. VIGNETTE: boolean;
  8124. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8125. VIGNETTEBLENDMODEOPAQUE: boolean;
  8126. TONEMAPPING: boolean;
  8127. TONEMAPPING_ACES: boolean;
  8128. CONTRAST: boolean;
  8129. COLORCURVES: boolean;
  8130. COLORGRADING: boolean;
  8131. COLORGRADING3D: boolean;
  8132. SAMPLER3DGREENDEPTH: boolean;
  8133. SAMPLER3DBGRMAP: boolean;
  8134. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8135. EXPOSURE: boolean;
  8136. constructor();
  8137. }
  8138. /**
  8139. * This groups together the common properties used for image processing either in direct forward pass
  8140. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8141. * or not.
  8142. */
  8143. export class ImageProcessingConfiguration {
  8144. /**
  8145. * Default tone mapping applied in BabylonJS.
  8146. */
  8147. static readonly TONEMAPPING_STANDARD: number;
  8148. /**
  8149. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8150. * to other engines rendering to increase portability.
  8151. */
  8152. static readonly TONEMAPPING_ACES: number;
  8153. /**
  8154. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8155. */
  8156. colorCurves: Nullable<ColorCurves>;
  8157. private _colorCurvesEnabled;
  8158. /**
  8159. * Gets wether the color curves effect is enabled.
  8160. */
  8161. /**
  8162. * Sets wether the color curves effect is enabled.
  8163. */
  8164. colorCurvesEnabled: boolean;
  8165. private _colorGradingTexture;
  8166. /**
  8167. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8168. */
  8169. /**
  8170. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8171. */
  8172. colorGradingTexture: Nullable<BaseTexture>;
  8173. private _colorGradingEnabled;
  8174. /**
  8175. * Gets wether the color grading effect is enabled.
  8176. */
  8177. /**
  8178. * Sets wether the color grading effect is enabled.
  8179. */
  8180. colorGradingEnabled: boolean;
  8181. private _colorGradingWithGreenDepth;
  8182. /**
  8183. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8184. */
  8185. /**
  8186. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8187. */
  8188. colorGradingWithGreenDepth: boolean;
  8189. private _colorGradingBGR;
  8190. /**
  8191. * Gets wether the color grading texture contains BGR values.
  8192. */
  8193. /**
  8194. * Sets wether the color grading texture contains BGR values.
  8195. */
  8196. colorGradingBGR: boolean;
  8197. /** @hidden */
  8198. _exposure: number;
  8199. /**
  8200. * Gets the Exposure used in the effect.
  8201. */
  8202. /**
  8203. * Sets the Exposure used in the effect.
  8204. */
  8205. exposure: number;
  8206. private _toneMappingEnabled;
  8207. /**
  8208. * Gets wether the tone mapping effect is enabled.
  8209. */
  8210. /**
  8211. * Sets wether the tone mapping effect is enabled.
  8212. */
  8213. toneMappingEnabled: boolean;
  8214. private _toneMappingType;
  8215. /**
  8216. * Gets the type of tone mapping effect.
  8217. */
  8218. /**
  8219. * Sets the type of tone mapping effect used in BabylonJS.
  8220. */
  8221. toneMappingType: number;
  8222. protected _contrast: number;
  8223. /**
  8224. * Gets the contrast used in the effect.
  8225. */
  8226. /**
  8227. * Sets the contrast used in the effect.
  8228. */
  8229. contrast: number;
  8230. /**
  8231. * Vignette stretch size.
  8232. */
  8233. vignetteStretch: number;
  8234. /**
  8235. * Vignette centre X Offset.
  8236. */
  8237. vignetteCentreX: number;
  8238. /**
  8239. * Vignette centre Y Offset.
  8240. */
  8241. vignetteCentreY: number;
  8242. /**
  8243. * Vignette weight or intensity of the vignette effect.
  8244. */
  8245. vignetteWeight: number;
  8246. /**
  8247. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8248. * if vignetteEnabled is set to true.
  8249. */
  8250. vignetteColor: Color4;
  8251. /**
  8252. * Camera field of view used by the Vignette effect.
  8253. */
  8254. vignetteCameraFov: number;
  8255. private _vignetteBlendMode;
  8256. /**
  8257. * Gets the vignette blend mode allowing different kind of effect.
  8258. */
  8259. /**
  8260. * Sets the vignette blend mode allowing different kind of effect.
  8261. */
  8262. vignetteBlendMode: number;
  8263. private _vignetteEnabled;
  8264. /**
  8265. * Gets wether the vignette effect is enabled.
  8266. */
  8267. /**
  8268. * Sets wether the vignette effect is enabled.
  8269. */
  8270. vignetteEnabled: boolean;
  8271. private _applyByPostProcess;
  8272. /**
  8273. * Gets wether the image processing is applied through a post process or not.
  8274. */
  8275. /**
  8276. * Sets wether the image processing is applied through a post process or not.
  8277. */
  8278. applyByPostProcess: boolean;
  8279. private _isEnabled;
  8280. /**
  8281. * Gets wether the image processing is enabled or not.
  8282. */
  8283. /**
  8284. * Sets wether the image processing is enabled or not.
  8285. */
  8286. isEnabled: boolean;
  8287. /**
  8288. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8289. */
  8290. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8291. /**
  8292. * Method called each time the image processing information changes requires to recompile the effect.
  8293. */
  8294. protected _updateParameters(): void;
  8295. /**
  8296. * Gets the current class name.
  8297. * @return "ImageProcessingConfiguration"
  8298. */
  8299. getClassName(): string;
  8300. /**
  8301. * Prepare the list of uniforms associated with the Image Processing effects.
  8302. * @param uniforms The list of uniforms used in the effect
  8303. * @param defines the list of defines currently in use
  8304. */
  8305. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8306. /**
  8307. * Prepare the list of samplers associated with the Image Processing effects.
  8308. * @param samplersList The list of uniforms used in the effect
  8309. * @param defines the list of defines currently in use
  8310. */
  8311. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8312. /**
  8313. * Prepare the list of defines associated to the shader.
  8314. * @param defines the list of defines to complete
  8315. * @param forPostProcess Define if we are currently in post process mode or not
  8316. */
  8317. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8318. /**
  8319. * Returns true if all the image processing information are ready.
  8320. * @returns True if ready, otherwise, false
  8321. */
  8322. isReady(): boolean;
  8323. /**
  8324. * Binds the image processing to the shader.
  8325. * @param effect The effect to bind to
  8326. * @param overrideAspectRatio Override the aspect ratio of the effect
  8327. */
  8328. bind(effect: Effect, overrideAspectRatio?: number): void;
  8329. /**
  8330. * Clones the current image processing instance.
  8331. * @return The cloned image processing
  8332. */
  8333. clone(): ImageProcessingConfiguration;
  8334. /**
  8335. * Serializes the current image processing instance to a json representation.
  8336. * @return a JSON representation
  8337. */
  8338. serialize(): any;
  8339. /**
  8340. * Parses the image processing from a json representation.
  8341. * @param source the JSON source to parse
  8342. * @return The parsed image processing
  8343. */
  8344. static Parse(source: any): ImageProcessingConfiguration;
  8345. private static _VIGNETTEMODE_MULTIPLY;
  8346. private static _VIGNETTEMODE_OPAQUE;
  8347. /**
  8348. * Used to apply the vignette as a mix with the pixel color.
  8349. */
  8350. static readonly VIGNETTEMODE_MULTIPLY: number;
  8351. /**
  8352. * Used to apply the vignette as a replacement of the pixel color.
  8353. */
  8354. static readonly VIGNETTEMODE_OPAQUE: number;
  8355. }
  8356. }
  8357. declare module BABYLON {
  8358. /** @hidden */
  8359. export var postprocessVertexShader: {
  8360. name: string;
  8361. shader: string;
  8362. };
  8363. }
  8364. declare module BABYLON {
  8365. interface ThinEngine {
  8366. /**
  8367. * Creates a new render target texture
  8368. * @param size defines the size of the texture
  8369. * @param options defines the options used to create the texture
  8370. * @returns a new render target texture stored in an InternalTexture
  8371. */
  8372. createRenderTargetTexture(size: number | {
  8373. width: number;
  8374. height: number;
  8375. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8376. /**
  8377. * Creates a depth stencil texture.
  8378. * This is only available in WebGL 2 or with the depth texture extension available.
  8379. * @param size The size of face edge in the texture.
  8380. * @param options The options defining the texture.
  8381. * @returns The texture
  8382. */
  8383. createDepthStencilTexture(size: number | {
  8384. width: number;
  8385. height: number;
  8386. }, options: DepthTextureCreationOptions): InternalTexture;
  8387. /** @hidden */
  8388. _createDepthStencilTexture(size: number | {
  8389. width: number;
  8390. height: number;
  8391. }, options: DepthTextureCreationOptions): InternalTexture;
  8392. }
  8393. }
  8394. declare module BABYLON {
  8395. /** Defines supported spaces */
  8396. export enum Space {
  8397. /** Local (object) space */
  8398. LOCAL = 0,
  8399. /** World space */
  8400. WORLD = 1,
  8401. /** Bone space */
  8402. BONE = 2
  8403. }
  8404. /** Defines the 3 main axes */
  8405. export class Axis {
  8406. /** X axis */
  8407. static X: Vector3;
  8408. /** Y axis */
  8409. static Y: Vector3;
  8410. /** Z axis */
  8411. static Z: Vector3;
  8412. }
  8413. }
  8414. declare module BABYLON {
  8415. /**
  8416. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8417. * This is the base of the follow, arc rotate cameras and Free camera
  8418. * @see http://doc.babylonjs.com/features/cameras
  8419. */
  8420. export class TargetCamera extends Camera {
  8421. private static _RigCamTransformMatrix;
  8422. private static _TargetTransformMatrix;
  8423. private static _TargetFocalPoint;
  8424. /**
  8425. * Define the current direction the camera is moving to
  8426. */
  8427. cameraDirection: Vector3;
  8428. /**
  8429. * Define the current rotation the camera is rotating to
  8430. */
  8431. cameraRotation: Vector2;
  8432. /**
  8433. * When set, the up vector of the camera will be updated by the rotation of the camera
  8434. */
  8435. updateUpVectorFromRotation: boolean;
  8436. private _tmpQuaternion;
  8437. /**
  8438. * Define the current rotation of the camera
  8439. */
  8440. rotation: Vector3;
  8441. /**
  8442. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8443. */
  8444. rotationQuaternion: Quaternion;
  8445. /**
  8446. * Define the current speed of the camera
  8447. */
  8448. speed: number;
  8449. /**
  8450. * Add constraint to the camera to prevent it to move freely in all directions and
  8451. * around all axis.
  8452. */
  8453. noRotationConstraint: boolean;
  8454. /**
  8455. * Define the current target of the camera as an object or a position.
  8456. */
  8457. lockedTarget: any;
  8458. /** @hidden */
  8459. _currentTarget: Vector3;
  8460. /** @hidden */
  8461. _initialFocalDistance: number;
  8462. /** @hidden */
  8463. _viewMatrix: Matrix;
  8464. /** @hidden */
  8465. _camMatrix: Matrix;
  8466. /** @hidden */
  8467. _cameraTransformMatrix: Matrix;
  8468. /** @hidden */
  8469. _cameraRotationMatrix: Matrix;
  8470. /** @hidden */
  8471. _referencePoint: Vector3;
  8472. /** @hidden */
  8473. _transformedReferencePoint: Vector3;
  8474. protected _globalCurrentTarget: Vector3;
  8475. protected _globalCurrentUpVector: Vector3;
  8476. /** @hidden */
  8477. _reset: () => void;
  8478. private _defaultUp;
  8479. /**
  8480. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8481. * This is the base of the follow, arc rotate cameras and Free camera
  8482. * @see http://doc.babylonjs.com/features/cameras
  8483. * @param name Defines the name of the camera in the scene
  8484. * @param position Defines the start position of the camera in the scene
  8485. * @param scene Defines the scene the camera belongs to
  8486. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8487. */
  8488. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8489. /**
  8490. * Gets the position in front of the camera at a given distance.
  8491. * @param distance The distance from the camera we want the position to be
  8492. * @returns the position
  8493. */
  8494. getFrontPosition(distance: number): Vector3;
  8495. /** @hidden */
  8496. _getLockedTargetPosition(): Nullable<Vector3>;
  8497. private _storedPosition;
  8498. private _storedRotation;
  8499. private _storedRotationQuaternion;
  8500. /**
  8501. * Store current camera state of the camera (fov, position, rotation, etc..)
  8502. * @returns the camera
  8503. */
  8504. storeState(): Camera;
  8505. /**
  8506. * Restored camera state. You must call storeState() first
  8507. * @returns whether it was successful or not
  8508. * @hidden
  8509. */
  8510. _restoreStateValues(): boolean;
  8511. /** @hidden */
  8512. _initCache(): void;
  8513. /** @hidden */
  8514. _updateCache(ignoreParentClass?: boolean): void;
  8515. /** @hidden */
  8516. _isSynchronizedViewMatrix(): boolean;
  8517. /** @hidden */
  8518. _computeLocalCameraSpeed(): number;
  8519. /**
  8520. * Defines the target the camera should look at.
  8521. * @param target Defines the new target as a Vector or a mesh
  8522. */
  8523. setTarget(target: Vector3): void;
  8524. /**
  8525. * Return the current target position of the camera. This value is expressed in local space.
  8526. * @returns the target position
  8527. */
  8528. getTarget(): Vector3;
  8529. /** @hidden */
  8530. _decideIfNeedsToMove(): boolean;
  8531. /** @hidden */
  8532. _updatePosition(): void;
  8533. /** @hidden */
  8534. _checkInputs(): void;
  8535. protected _updateCameraRotationMatrix(): void;
  8536. /**
  8537. * 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)
  8538. * @returns the current camera
  8539. */
  8540. private _rotateUpVectorWithCameraRotationMatrix;
  8541. private _cachedRotationZ;
  8542. private _cachedQuaternionRotationZ;
  8543. /** @hidden */
  8544. _getViewMatrix(): Matrix;
  8545. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8546. /**
  8547. * @hidden
  8548. */
  8549. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8550. /**
  8551. * @hidden
  8552. */
  8553. _updateRigCameras(): void;
  8554. private _getRigCamPositionAndTarget;
  8555. /**
  8556. * Gets the current object class name.
  8557. * @return the class name
  8558. */
  8559. getClassName(): string;
  8560. }
  8561. }
  8562. declare module BABYLON {
  8563. /**
  8564. * Gather the list of keyboard event types as constants.
  8565. */
  8566. export class KeyboardEventTypes {
  8567. /**
  8568. * The keydown event is fired when a key becomes active (pressed).
  8569. */
  8570. static readonly KEYDOWN: number;
  8571. /**
  8572. * The keyup event is fired when a key has been released.
  8573. */
  8574. static readonly KEYUP: number;
  8575. }
  8576. /**
  8577. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8578. */
  8579. export class KeyboardInfo {
  8580. /**
  8581. * Defines the type of event (KeyboardEventTypes)
  8582. */
  8583. type: number;
  8584. /**
  8585. * Defines the related dom event
  8586. */
  8587. event: KeyboardEvent;
  8588. /**
  8589. * Instantiates a new keyboard info.
  8590. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8591. * @param type Defines the type of event (KeyboardEventTypes)
  8592. * @param event Defines the related dom event
  8593. */
  8594. constructor(
  8595. /**
  8596. * Defines the type of event (KeyboardEventTypes)
  8597. */
  8598. type: number,
  8599. /**
  8600. * Defines the related dom event
  8601. */
  8602. event: KeyboardEvent);
  8603. }
  8604. /**
  8605. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8606. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8607. */
  8608. export class KeyboardInfoPre extends KeyboardInfo {
  8609. /**
  8610. * Defines the type of event (KeyboardEventTypes)
  8611. */
  8612. type: number;
  8613. /**
  8614. * Defines the related dom event
  8615. */
  8616. event: KeyboardEvent;
  8617. /**
  8618. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8619. */
  8620. skipOnPointerObservable: boolean;
  8621. /**
  8622. * Instantiates a new keyboard pre info.
  8623. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8624. * @param type Defines the type of event (KeyboardEventTypes)
  8625. * @param event Defines the related dom event
  8626. */
  8627. constructor(
  8628. /**
  8629. * Defines the type of event (KeyboardEventTypes)
  8630. */
  8631. type: number,
  8632. /**
  8633. * Defines the related dom event
  8634. */
  8635. event: KeyboardEvent);
  8636. }
  8637. }
  8638. declare module BABYLON {
  8639. /**
  8640. * Manage the keyboard inputs to control the movement of a free camera.
  8641. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8642. */
  8643. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8644. /**
  8645. * Defines the camera the input is attached to.
  8646. */
  8647. camera: FreeCamera;
  8648. /**
  8649. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8650. */
  8651. keysUp: number[];
  8652. /**
  8653. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8654. */
  8655. keysDown: number[];
  8656. /**
  8657. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8658. */
  8659. keysLeft: number[];
  8660. /**
  8661. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8662. */
  8663. keysRight: number[];
  8664. private _keys;
  8665. private _onCanvasBlurObserver;
  8666. private _onKeyboardObserver;
  8667. private _engine;
  8668. private _scene;
  8669. /**
  8670. * Attach the input controls to a specific dom element to get the input from.
  8671. * @param element Defines the element the controls should be listened from
  8672. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8673. */
  8674. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8675. /**
  8676. * Detach the current controls from the specified dom element.
  8677. * @param element Defines the element to stop listening the inputs from
  8678. */
  8679. detachControl(element: Nullable<HTMLElement>): void;
  8680. /**
  8681. * Update the current camera state depending on the inputs that have been used this frame.
  8682. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8683. */
  8684. checkInputs(): void;
  8685. /**
  8686. * Gets the class name of the current intput.
  8687. * @returns the class name
  8688. */
  8689. getClassName(): string;
  8690. /** @hidden */
  8691. _onLostFocus(): void;
  8692. /**
  8693. * Get the friendly name associated with the input class.
  8694. * @returns the input friendly name
  8695. */
  8696. getSimpleName(): string;
  8697. }
  8698. }
  8699. declare module BABYLON {
  8700. /**
  8701. * Interface describing all the common properties and methods a shadow light needs to implement.
  8702. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8703. * as well as binding the different shadow properties to the effects.
  8704. */
  8705. export interface IShadowLight extends Light {
  8706. /**
  8707. * The light id in the scene (used in scene.findLighById for instance)
  8708. */
  8709. id: string;
  8710. /**
  8711. * The position the shdow will be casted from.
  8712. */
  8713. position: Vector3;
  8714. /**
  8715. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8716. */
  8717. direction: Vector3;
  8718. /**
  8719. * The transformed position. Position of the light in world space taking parenting in account.
  8720. */
  8721. transformedPosition: Vector3;
  8722. /**
  8723. * The transformed direction. Direction of the light in world space taking parenting in account.
  8724. */
  8725. transformedDirection: Vector3;
  8726. /**
  8727. * The friendly name of the light in the scene.
  8728. */
  8729. name: string;
  8730. /**
  8731. * Defines the shadow projection clipping minimum z value.
  8732. */
  8733. shadowMinZ: number;
  8734. /**
  8735. * Defines the shadow projection clipping maximum z value.
  8736. */
  8737. shadowMaxZ: number;
  8738. /**
  8739. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8740. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8741. */
  8742. computeTransformedInformation(): boolean;
  8743. /**
  8744. * Gets the scene the light belongs to.
  8745. * @returns The scene
  8746. */
  8747. getScene(): Scene;
  8748. /**
  8749. * Callback defining a custom Projection Matrix Builder.
  8750. * This can be used to override the default projection matrix computation.
  8751. */
  8752. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8753. /**
  8754. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8755. * @param matrix The materix to updated with the projection information
  8756. * @param viewMatrix The transform matrix of the light
  8757. * @param renderList The list of mesh to render in the map
  8758. * @returns The current light
  8759. */
  8760. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8761. /**
  8762. * Gets the current depth scale used in ESM.
  8763. * @returns The scale
  8764. */
  8765. getDepthScale(): number;
  8766. /**
  8767. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8768. * @returns true if a cube texture needs to be use
  8769. */
  8770. needCube(): boolean;
  8771. /**
  8772. * Detects if the projection matrix requires to be recomputed this frame.
  8773. * @returns true if it requires to be recomputed otherwise, false.
  8774. */
  8775. needProjectionMatrixCompute(): boolean;
  8776. /**
  8777. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8778. */
  8779. forceProjectionMatrixCompute(): void;
  8780. /**
  8781. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8782. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8783. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8784. */
  8785. getShadowDirection(faceIndex?: number): Vector3;
  8786. /**
  8787. * Gets the minZ used for shadow according to both the scene and the light.
  8788. * @param activeCamera The camera we are returning the min for
  8789. * @returns the depth min z
  8790. */
  8791. getDepthMinZ(activeCamera: Camera): number;
  8792. /**
  8793. * Gets the maxZ used for shadow according to both the scene and the light.
  8794. * @param activeCamera The camera we are returning the max for
  8795. * @returns the depth max z
  8796. */
  8797. getDepthMaxZ(activeCamera: Camera): number;
  8798. }
  8799. /**
  8800. * Base implementation IShadowLight
  8801. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8802. */
  8803. export abstract class ShadowLight extends Light implements IShadowLight {
  8804. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8805. protected _position: Vector3;
  8806. protected _setPosition(value: Vector3): void;
  8807. /**
  8808. * Sets the position the shadow will be casted from. Also use as the light position for both
  8809. * point and spot lights.
  8810. */
  8811. /**
  8812. * Sets the position the shadow will be casted from. Also use as the light position for both
  8813. * point and spot lights.
  8814. */
  8815. position: Vector3;
  8816. protected _direction: Vector3;
  8817. protected _setDirection(value: Vector3): void;
  8818. /**
  8819. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8820. * Also use as the light direction on spot and directional lights.
  8821. */
  8822. /**
  8823. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8824. * Also use as the light direction on spot and directional lights.
  8825. */
  8826. direction: Vector3;
  8827. private _shadowMinZ;
  8828. /**
  8829. * Gets the shadow projection clipping minimum z value.
  8830. */
  8831. /**
  8832. * Sets the shadow projection clipping minimum z value.
  8833. */
  8834. shadowMinZ: number;
  8835. private _shadowMaxZ;
  8836. /**
  8837. * Sets the shadow projection clipping maximum z value.
  8838. */
  8839. /**
  8840. * Gets the shadow projection clipping maximum z value.
  8841. */
  8842. shadowMaxZ: number;
  8843. /**
  8844. * Callback defining a custom Projection Matrix Builder.
  8845. * This can be used to override the default projection matrix computation.
  8846. */
  8847. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8848. /**
  8849. * The transformed position. Position of the light in world space taking parenting in account.
  8850. */
  8851. transformedPosition: Vector3;
  8852. /**
  8853. * The transformed direction. Direction of the light in world space taking parenting in account.
  8854. */
  8855. transformedDirection: Vector3;
  8856. private _needProjectionMatrixCompute;
  8857. /**
  8858. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8859. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8860. */
  8861. computeTransformedInformation(): boolean;
  8862. /**
  8863. * Return the depth scale used for the shadow map.
  8864. * @returns the depth scale.
  8865. */
  8866. getDepthScale(): number;
  8867. /**
  8868. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8869. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8870. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8871. */
  8872. getShadowDirection(faceIndex?: number): Vector3;
  8873. /**
  8874. * Returns the ShadowLight absolute position in the World.
  8875. * @returns the position vector in world space
  8876. */
  8877. getAbsolutePosition(): Vector3;
  8878. /**
  8879. * Sets the ShadowLight direction toward the passed target.
  8880. * @param target The point to target in local space
  8881. * @returns the updated ShadowLight direction
  8882. */
  8883. setDirectionToTarget(target: Vector3): Vector3;
  8884. /**
  8885. * Returns the light rotation in euler definition.
  8886. * @returns the x y z rotation in local space.
  8887. */
  8888. getRotation(): Vector3;
  8889. /**
  8890. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8891. * @returns true if a cube texture needs to be use
  8892. */
  8893. needCube(): boolean;
  8894. /**
  8895. * Detects if the projection matrix requires to be recomputed this frame.
  8896. * @returns true if it requires to be recomputed otherwise, false.
  8897. */
  8898. needProjectionMatrixCompute(): boolean;
  8899. /**
  8900. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8901. */
  8902. forceProjectionMatrixCompute(): void;
  8903. /** @hidden */
  8904. _initCache(): void;
  8905. /** @hidden */
  8906. _isSynchronized(): boolean;
  8907. /**
  8908. * Computes the world matrix of the node
  8909. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8910. * @returns the world matrix
  8911. */
  8912. computeWorldMatrix(force?: boolean): Matrix;
  8913. /**
  8914. * Gets the minZ used for shadow according to both the scene and the light.
  8915. * @param activeCamera The camera we are returning the min for
  8916. * @returns the depth min z
  8917. */
  8918. getDepthMinZ(activeCamera: Camera): number;
  8919. /**
  8920. * Gets the maxZ used for shadow according to both the scene and the light.
  8921. * @param activeCamera The camera we are returning the max for
  8922. * @returns the depth max z
  8923. */
  8924. getDepthMaxZ(activeCamera: Camera): number;
  8925. /**
  8926. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8927. * @param matrix The materix to updated with the projection information
  8928. * @param viewMatrix The transform matrix of the light
  8929. * @param renderList The list of mesh to render in the map
  8930. * @returns The current light
  8931. */
  8932. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8933. }
  8934. }
  8935. declare module BABYLON {
  8936. /**
  8937. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8938. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8939. */
  8940. export class EffectFallbacks implements IEffectFallbacks {
  8941. private _defines;
  8942. private _currentRank;
  8943. private _maxRank;
  8944. private _mesh;
  8945. /**
  8946. * Removes the fallback from the bound mesh.
  8947. */
  8948. unBindMesh(): void;
  8949. /**
  8950. * Adds a fallback on the specified property.
  8951. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8952. * @param define The name of the define in the shader
  8953. */
  8954. addFallback(rank: number, define: string): void;
  8955. /**
  8956. * Sets the mesh to use CPU skinning when needing to fallback.
  8957. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8958. * @param mesh The mesh to use the fallbacks.
  8959. */
  8960. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8961. /**
  8962. * Checks to see if more fallbacks are still availible.
  8963. */
  8964. readonly hasMoreFallbacks: boolean;
  8965. /**
  8966. * Removes the defines that should be removed when falling back.
  8967. * @param currentDefines defines the current define statements for the shader.
  8968. * @param effect defines the current effect we try to compile
  8969. * @returns The resulting defines with defines of the current rank removed.
  8970. */
  8971. reduce(currentDefines: string, effect: Effect): string;
  8972. }
  8973. }
  8974. declare module BABYLON {
  8975. /**
  8976. * "Static Class" containing the most commonly used helper while dealing with material for
  8977. * rendering purpose.
  8978. *
  8979. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8980. *
  8981. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8982. */
  8983. export class MaterialHelper {
  8984. /**
  8985. * Bind the current view position to an effect.
  8986. * @param effect The effect to be bound
  8987. * @param scene The scene the eyes position is used from
  8988. */
  8989. static BindEyePosition(effect: Effect, scene: Scene): void;
  8990. /**
  8991. * Helps preparing the defines values about the UVs in used in the effect.
  8992. * UVs are shared as much as we can accross channels in the shaders.
  8993. * @param texture The texture we are preparing the UVs for
  8994. * @param defines The defines to update
  8995. * @param key The channel key "diffuse", "specular"... used in the shader
  8996. */
  8997. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8998. /**
  8999. * Binds a texture matrix value to its corrsponding uniform
  9000. * @param texture The texture to bind the matrix for
  9001. * @param uniformBuffer The uniform buffer receivin the data
  9002. * @param key The channel key "diffuse", "specular"... used in the shader
  9003. */
  9004. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9005. /**
  9006. * Gets the current status of the fog (should it be enabled?)
  9007. * @param mesh defines the mesh to evaluate for fog support
  9008. * @param scene defines the hosting scene
  9009. * @returns true if fog must be enabled
  9010. */
  9011. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9012. /**
  9013. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9014. * @param mesh defines the current mesh
  9015. * @param scene defines the current scene
  9016. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9017. * @param pointsCloud defines if point cloud rendering has to be turned on
  9018. * @param fogEnabled defines if fog has to be turned on
  9019. * @param alphaTest defines if alpha testing has to be turned on
  9020. * @param defines defines the current list of defines
  9021. */
  9022. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9023. /**
  9024. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9025. * @param scene defines the current scene
  9026. * @param engine defines the current engine
  9027. * @param defines specifies the list of active defines
  9028. * @param useInstances defines if instances have to be turned on
  9029. * @param useClipPlane defines if clip plane have to be turned on
  9030. */
  9031. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9032. /**
  9033. * Prepares the defines for bones
  9034. * @param mesh The mesh containing the geometry data we will draw
  9035. * @param defines The defines to update
  9036. */
  9037. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9038. /**
  9039. * Prepares the defines for morph targets
  9040. * @param mesh The mesh containing the geometry data we will draw
  9041. * @param defines The defines to update
  9042. */
  9043. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9044. /**
  9045. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9046. * @param mesh The mesh containing the geometry data we will draw
  9047. * @param defines The defines to update
  9048. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9049. * @param useBones Precise whether bones should be used or not (override mesh info)
  9050. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9051. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9052. * @returns false if defines are considered not dirty and have not been checked
  9053. */
  9054. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9055. /**
  9056. * Prepares the defines related to multiview
  9057. * @param scene The scene we are intending to draw
  9058. * @param defines The defines to update
  9059. */
  9060. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9061. /**
  9062. * Prepares the defines related to the light information passed in parameter
  9063. * @param scene The scene we are intending to draw
  9064. * @param mesh The mesh the effect is compiling for
  9065. * @param light The light the effect is compiling for
  9066. * @param lightIndex The index of the light
  9067. * @param defines The defines to update
  9068. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9069. * @param state Defines the current state regarding what is needed (normals, etc...)
  9070. */
  9071. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9072. needNormals: boolean;
  9073. needRebuild: boolean;
  9074. shadowEnabled: boolean;
  9075. specularEnabled: boolean;
  9076. lightmapMode: boolean;
  9077. }): void;
  9078. /**
  9079. * Prepares the defines related to the light information passed in parameter
  9080. * @param scene The scene we are intending to draw
  9081. * @param mesh The mesh the effect is compiling for
  9082. * @param defines The defines to update
  9083. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9084. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9085. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9086. * @returns true if normals will be required for the rest of the effect
  9087. */
  9088. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9089. /**
  9090. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9091. * @param lightIndex defines the light index
  9092. * @param uniformsList The uniform list
  9093. * @param samplersList The sampler list
  9094. * @param projectedLightTexture defines if projected texture must be used
  9095. * @param uniformBuffersList defines an optional list of uniform buffers
  9096. */
  9097. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9098. /**
  9099. * Prepares the uniforms and samplers list to be used in the effect
  9100. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9101. * @param samplersList The sampler list
  9102. * @param defines The defines helping in the list generation
  9103. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9104. */
  9105. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9106. /**
  9107. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9108. * @param defines The defines to update while falling back
  9109. * @param fallbacks The authorized effect fallbacks
  9110. * @param maxSimultaneousLights The maximum number of lights allowed
  9111. * @param rank the current rank of the Effect
  9112. * @returns The newly affected rank
  9113. */
  9114. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9115. private static _TmpMorphInfluencers;
  9116. /**
  9117. * Prepares the list of attributes required for morph targets according to the effect defines.
  9118. * @param attribs The current list of supported attribs
  9119. * @param mesh The mesh to prepare the morph targets attributes for
  9120. * @param influencers The number of influencers
  9121. */
  9122. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9123. /**
  9124. * Prepares the list of attributes required for morph targets according to the effect defines.
  9125. * @param attribs The current list of supported attribs
  9126. * @param mesh The mesh to prepare the morph targets attributes for
  9127. * @param defines The current Defines of the effect
  9128. */
  9129. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9130. /**
  9131. * Prepares the list of attributes required for bones according to the effect defines.
  9132. * @param attribs The current list of supported attribs
  9133. * @param mesh The mesh to prepare the bones attributes for
  9134. * @param defines The current Defines of the effect
  9135. * @param fallbacks The current efffect fallback strategy
  9136. */
  9137. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9138. /**
  9139. * Check and prepare the list of attributes required for instances according to the effect defines.
  9140. * @param attribs The current list of supported attribs
  9141. * @param defines The current MaterialDefines of the effect
  9142. */
  9143. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9144. /**
  9145. * Add the list of attributes required for instances to the attribs array.
  9146. * @param attribs The current list of supported attribs
  9147. */
  9148. static PushAttributesForInstances(attribs: string[]): void;
  9149. /**
  9150. * Binds the light information to the effect.
  9151. * @param light The light containing the generator
  9152. * @param effect The effect we are binding the data to
  9153. * @param lightIndex The light index in the effect used to render
  9154. */
  9155. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9156. /**
  9157. * Binds the lights information from the scene to the effect for the given mesh.
  9158. * @param light Light to bind
  9159. * @param lightIndex Light index
  9160. * @param scene The scene where the light belongs to
  9161. * @param effect The effect we are binding the data to
  9162. * @param useSpecular Defines if specular is supported
  9163. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9164. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9165. */
  9166. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9167. /**
  9168. * Binds the lights information from the scene to the effect for the given mesh.
  9169. * @param scene The scene the lights belongs to
  9170. * @param mesh The mesh we are binding the information to render
  9171. * @param effect The effect we are binding the data to
  9172. * @param defines The generated defines for the effect
  9173. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9174. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9175. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9176. */
  9177. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9178. private static _tempFogColor;
  9179. /**
  9180. * Binds the fog information from the scene to the effect for the given mesh.
  9181. * @param scene The scene the lights belongs to
  9182. * @param mesh The mesh we are binding the information to render
  9183. * @param effect The effect we are binding the data to
  9184. * @param linearSpace Defines if the fog effect is applied in linear space
  9185. */
  9186. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9187. /**
  9188. * Binds the bones information from the mesh to the effect.
  9189. * @param mesh The mesh we are binding the information to render
  9190. * @param effect The effect we are binding the data to
  9191. */
  9192. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9193. /**
  9194. * Binds the morph targets information from the mesh to the effect.
  9195. * @param abstractMesh The mesh we are binding the information to render
  9196. * @param effect The effect we are binding the data to
  9197. */
  9198. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9199. /**
  9200. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9201. * @param defines The generated defines used in the effect
  9202. * @param effect The effect we are binding the data to
  9203. * @param scene The scene we are willing to render with logarithmic scale for
  9204. */
  9205. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9206. /**
  9207. * Binds the clip plane information from the scene to the effect.
  9208. * @param scene The scene the clip plane information are extracted from
  9209. * @param effect The effect we are binding the data to
  9210. */
  9211. static BindClipPlane(effect: Effect, scene: Scene): void;
  9212. }
  9213. }
  9214. declare module BABYLON {
  9215. /** @hidden */
  9216. export var packingFunctions: {
  9217. name: string;
  9218. shader: string;
  9219. };
  9220. }
  9221. declare module BABYLON {
  9222. /** @hidden */
  9223. export var shadowMapPixelShader: {
  9224. name: string;
  9225. shader: string;
  9226. };
  9227. }
  9228. declare module BABYLON {
  9229. /** @hidden */
  9230. export var bonesDeclaration: {
  9231. name: string;
  9232. shader: string;
  9233. };
  9234. }
  9235. declare module BABYLON {
  9236. /** @hidden */
  9237. export var morphTargetsVertexGlobalDeclaration: {
  9238. name: string;
  9239. shader: string;
  9240. };
  9241. }
  9242. declare module BABYLON {
  9243. /** @hidden */
  9244. export var morphTargetsVertexDeclaration: {
  9245. name: string;
  9246. shader: string;
  9247. };
  9248. }
  9249. declare module BABYLON {
  9250. /** @hidden */
  9251. export var instancesDeclaration: {
  9252. name: string;
  9253. shader: string;
  9254. };
  9255. }
  9256. declare module BABYLON {
  9257. /** @hidden */
  9258. export var helperFunctions: {
  9259. name: string;
  9260. shader: string;
  9261. };
  9262. }
  9263. declare module BABYLON {
  9264. /** @hidden */
  9265. export var morphTargetsVertex: {
  9266. name: string;
  9267. shader: string;
  9268. };
  9269. }
  9270. declare module BABYLON {
  9271. /** @hidden */
  9272. export var instancesVertex: {
  9273. name: string;
  9274. shader: string;
  9275. };
  9276. }
  9277. declare module BABYLON {
  9278. /** @hidden */
  9279. export var bonesVertex: {
  9280. name: string;
  9281. shader: string;
  9282. };
  9283. }
  9284. declare module BABYLON {
  9285. /** @hidden */
  9286. export var shadowMapVertexShader: {
  9287. name: string;
  9288. shader: string;
  9289. };
  9290. }
  9291. declare module BABYLON {
  9292. /** @hidden */
  9293. export var depthBoxBlurPixelShader: {
  9294. name: string;
  9295. shader: string;
  9296. };
  9297. }
  9298. declare module BABYLON {
  9299. /**
  9300. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9301. */
  9302. export interface ICustomShaderOptions {
  9303. /**
  9304. * Gets or sets the custom shader name to use
  9305. */
  9306. shaderName: string;
  9307. /**
  9308. * The list of attribute names used in the shader
  9309. */
  9310. attributes?: string[];
  9311. /**
  9312. * The list of unifrom names used in the shader
  9313. */
  9314. uniforms?: string[];
  9315. /**
  9316. * The list of sampler names used in the shader
  9317. */
  9318. samplers?: string[];
  9319. /**
  9320. * The list of defines used in the shader
  9321. */
  9322. defines?: string[];
  9323. }
  9324. /**
  9325. * Interface to implement to create a shadow generator compatible with BJS.
  9326. */
  9327. export interface IShadowGenerator {
  9328. /**
  9329. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9330. * @returns The render target texture if present otherwise, null
  9331. */
  9332. getShadowMap(): Nullable<RenderTargetTexture>;
  9333. /**
  9334. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9335. * @returns The render target texture if the shadow map is present otherwise, null
  9336. */
  9337. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9338. /**
  9339. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9340. * @param subMesh The submesh we want to render in the shadow map
  9341. * @param useInstances Defines wether will draw in the map using instances
  9342. * @returns true if ready otherwise, false
  9343. */
  9344. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9345. /**
  9346. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9347. * @param defines Defines of the material we want to update
  9348. * @param lightIndex Index of the light in the enabled light list of the material
  9349. */
  9350. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9351. /**
  9352. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9353. * defined in the generator but impacting the effect).
  9354. * It implies the unifroms available on the materials are the standard BJS ones.
  9355. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9356. * @param effect The effect we are binfing the information for
  9357. */
  9358. bindShadowLight(lightIndex: string, effect: Effect): void;
  9359. /**
  9360. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9361. * (eq to shadow prjection matrix * light transform matrix)
  9362. * @returns The transform matrix used to create the shadow map
  9363. */
  9364. getTransformMatrix(): Matrix;
  9365. /**
  9366. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9367. * Cube and 2D textures for instance.
  9368. */
  9369. recreateShadowMap(): void;
  9370. /**
  9371. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9372. * @param onCompiled Callback triggered at the and of the effects compilation
  9373. * @param options Sets of optional options forcing the compilation with different modes
  9374. */
  9375. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9376. useInstances: boolean;
  9377. }>): void;
  9378. /**
  9379. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9380. * @param options Sets of optional options forcing the compilation with different modes
  9381. * @returns A promise that resolves when the compilation completes
  9382. */
  9383. forceCompilationAsync(options?: Partial<{
  9384. useInstances: boolean;
  9385. }>): Promise<void>;
  9386. /**
  9387. * Serializes the shadow generator setup to a json object.
  9388. * @returns The serialized JSON object
  9389. */
  9390. serialize(): any;
  9391. /**
  9392. * Disposes the Shadow map and related Textures and effects.
  9393. */
  9394. dispose(): void;
  9395. }
  9396. /**
  9397. * Default implementation IShadowGenerator.
  9398. * This is the main object responsible of generating shadows in the framework.
  9399. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9400. */
  9401. export class ShadowGenerator implements IShadowGenerator {
  9402. /**
  9403. * Shadow generator mode None: no filtering applied.
  9404. */
  9405. static readonly FILTER_NONE: number;
  9406. /**
  9407. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9408. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9409. */
  9410. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9411. /**
  9412. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9413. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9414. */
  9415. static readonly FILTER_POISSONSAMPLING: number;
  9416. /**
  9417. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9418. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9419. */
  9420. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9421. /**
  9422. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9423. * edge artifacts on steep falloff.
  9424. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9425. */
  9426. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9427. /**
  9428. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9429. * edge artifacts on steep falloff.
  9430. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9431. */
  9432. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9433. /**
  9434. * Shadow generator mode PCF: Percentage Closer Filtering
  9435. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9436. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9437. */
  9438. static readonly FILTER_PCF: number;
  9439. /**
  9440. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9441. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9442. * Contact Hardening
  9443. */
  9444. static readonly FILTER_PCSS: number;
  9445. /**
  9446. * Reserved for PCF and PCSS
  9447. * Highest Quality.
  9448. *
  9449. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9450. *
  9451. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9452. */
  9453. static readonly QUALITY_HIGH: number;
  9454. /**
  9455. * Reserved for PCF and PCSS
  9456. * Good tradeoff for quality/perf cross devices
  9457. *
  9458. * Execute PCF on a 3*3 kernel.
  9459. *
  9460. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9461. */
  9462. static readonly QUALITY_MEDIUM: number;
  9463. /**
  9464. * Reserved for PCF and PCSS
  9465. * The lowest quality but the fastest.
  9466. *
  9467. * Execute PCF on a 1*1 kernel.
  9468. *
  9469. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9470. */
  9471. static readonly QUALITY_LOW: number;
  9472. /** Gets or sets the custom shader name to use */
  9473. customShaderOptions: ICustomShaderOptions;
  9474. /**
  9475. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9476. */
  9477. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9478. /**
  9479. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9480. */
  9481. onAfterShadowMapRenderObservable: Observable<Effect>;
  9482. /**
  9483. * Observable triggered before a mesh is rendered in the shadow map.
  9484. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9485. */
  9486. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9487. /**
  9488. * Observable triggered after a mesh is rendered in the shadow map.
  9489. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9490. */
  9491. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9492. private _bias;
  9493. /**
  9494. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9495. */
  9496. /**
  9497. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9498. */
  9499. bias: number;
  9500. private _normalBias;
  9501. /**
  9502. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9503. */
  9504. /**
  9505. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9506. */
  9507. normalBias: number;
  9508. private _blurBoxOffset;
  9509. /**
  9510. * Gets the blur box offset: offset applied during the blur pass.
  9511. * Only useful if useKernelBlur = false
  9512. */
  9513. /**
  9514. * Sets the blur box offset: offset applied during the blur pass.
  9515. * Only useful if useKernelBlur = false
  9516. */
  9517. blurBoxOffset: number;
  9518. private _blurScale;
  9519. /**
  9520. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9521. * 2 means half of the size.
  9522. */
  9523. /**
  9524. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9525. * 2 means half of the size.
  9526. */
  9527. blurScale: number;
  9528. private _blurKernel;
  9529. /**
  9530. * Gets the blur kernel: kernel size of the blur pass.
  9531. * Only useful if useKernelBlur = true
  9532. */
  9533. /**
  9534. * Sets the blur kernel: kernel size of the blur pass.
  9535. * Only useful if useKernelBlur = true
  9536. */
  9537. blurKernel: number;
  9538. private _useKernelBlur;
  9539. /**
  9540. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9541. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9542. */
  9543. /**
  9544. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9545. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9546. */
  9547. useKernelBlur: boolean;
  9548. private _depthScale;
  9549. /**
  9550. * Gets the depth scale used in ESM mode.
  9551. */
  9552. /**
  9553. * Sets the depth scale used in ESM mode.
  9554. * This can override the scale stored on the light.
  9555. */
  9556. depthScale: number;
  9557. private _filter;
  9558. /**
  9559. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9560. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9561. */
  9562. /**
  9563. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9564. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9565. */
  9566. filter: number;
  9567. /**
  9568. * Gets if the current filter is set to Poisson Sampling.
  9569. */
  9570. /**
  9571. * Sets the current filter to Poisson Sampling.
  9572. */
  9573. usePoissonSampling: boolean;
  9574. /**
  9575. * Gets if the current filter is set to ESM.
  9576. */
  9577. /**
  9578. * Sets the current filter is to ESM.
  9579. */
  9580. useExponentialShadowMap: boolean;
  9581. /**
  9582. * Gets if the current filter is set to filtered ESM.
  9583. */
  9584. /**
  9585. * Gets if the current filter is set to filtered ESM.
  9586. */
  9587. useBlurExponentialShadowMap: boolean;
  9588. /**
  9589. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9590. * exponential to prevent steep falloff artifacts).
  9591. */
  9592. /**
  9593. * Sets the current filter to "close ESM" (using the inverse of the
  9594. * exponential to prevent steep falloff artifacts).
  9595. */
  9596. useCloseExponentialShadowMap: boolean;
  9597. /**
  9598. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9599. * exponential to prevent steep falloff artifacts).
  9600. */
  9601. /**
  9602. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9603. * exponential to prevent steep falloff artifacts).
  9604. */
  9605. useBlurCloseExponentialShadowMap: boolean;
  9606. /**
  9607. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9608. */
  9609. /**
  9610. * Sets the current filter to "PCF" (percentage closer filtering).
  9611. */
  9612. usePercentageCloserFiltering: boolean;
  9613. private _filteringQuality;
  9614. /**
  9615. * Gets the PCF or PCSS Quality.
  9616. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9617. */
  9618. /**
  9619. * Sets the PCF or PCSS Quality.
  9620. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9621. */
  9622. filteringQuality: number;
  9623. /**
  9624. * Gets if the current filter is set to "PCSS" (contact hardening).
  9625. */
  9626. /**
  9627. * Sets the current filter to "PCSS" (contact hardening).
  9628. */
  9629. useContactHardeningShadow: boolean;
  9630. private _contactHardeningLightSizeUVRatio;
  9631. /**
  9632. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9633. * Using a ratio helps keeping shape stability independently of the map size.
  9634. *
  9635. * It does not account for the light projection as it was having too much
  9636. * instability during the light setup or during light position changes.
  9637. *
  9638. * Only valid if useContactHardeningShadow is true.
  9639. */
  9640. /**
  9641. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9642. * Using a ratio helps keeping shape stability independently of the map size.
  9643. *
  9644. * It does not account for the light projection as it was having too much
  9645. * instability during the light setup or during light position changes.
  9646. *
  9647. * Only valid if useContactHardeningShadow is true.
  9648. */
  9649. contactHardeningLightSizeUVRatio: number;
  9650. private _darkness;
  9651. /** Gets or sets the actual darkness of a shadow */
  9652. darkness: number;
  9653. /**
  9654. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9655. * 0 means strongest and 1 would means no shadow.
  9656. * @returns the darkness.
  9657. */
  9658. getDarkness(): number;
  9659. /**
  9660. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9661. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9662. * @returns the shadow generator allowing fluent coding.
  9663. */
  9664. setDarkness(darkness: number): ShadowGenerator;
  9665. private _transparencyShadow;
  9666. /** Gets or sets the ability to have transparent shadow */
  9667. transparencyShadow: boolean;
  9668. /**
  9669. * Sets the ability to have transparent shadow (boolean).
  9670. * @param transparent True if transparent else False
  9671. * @returns the shadow generator allowing fluent coding
  9672. */
  9673. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9674. private _shadowMap;
  9675. private _shadowMap2;
  9676. /**
  9677. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9678. * @returns The render target texture if present otherwise, null
  9679. */
  9680. getShadowMap(): Nullable<RenderTargetTexture>;
  9681. /**
  9682. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9683. * @returns The render target texture if the shadow map is present otherwise, null
  9684. */
  9685. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9686. /**
  9687. * Gets the class name of that object
  9688. * @returns "ShadowGenerator"
  9689. */
  9690. getClassName(): string;
  9691. /**
  9692. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9693. * @param mesh Mesh to add
  9694. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9695. * @returns the Shadow Generator itself
  9696. */
  9697. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9698. /**
  9699. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9700. * @param mesh Mesh to remove
  9701. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9702. * @returns the Shadow Generator itself
  9703. */
  9704. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9705. /**
  9706. * Controls the extent to which the shadows fade out at the edge of the frustum
  9707. * Used only by directionals and spots
  9708. */
  9709. frustumEdgeFalloff: number;
  9710. private _light;
  9711. /**
  9712. * Returns the associated light object.
  9713. * @returns the light generating the shadow
  9714. */
  9715. getLight(): IShadowLight;
  9716. /**
  9717. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9718. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9719. * It might on the other hand introduce peter panning.
  9720. */
  9721. forceBackFacesOnly: boolean;
  9722. private _scene;
  9723. private _lightDirection;
  9724. private _effect;
  9725. private _viewMatrix;
  9726. private _projectionMatrix;
  9727. private _transformMatrix;
  9728. private _cachedPosition;
  9729. private _cachedDirection;
  9730. private _cachedDefines;
  9731. private _currentRenderID;
  9732. private _boxBlurPostprocess;
  9733. private _kernelBlurXPostprocess;
  9734. private _kernelBlurYPostprocess;
  9735. private _blurPostProcesses;
  9736. private _mapSize;
  9737. private _currentFaceIndex;
  9738. private _currentFaceIndexCache;
  9739. private _textureType;
  9740. private _defaultTextureMatrix;
  9741. private _storedUniqueId;
  9742. /** @hidden */
  9743. static _SceneComponentInitialization: (scene: Scene) => void;
  9744. /**
  9745. * Creates a ShadowGenerator object.
  9746. * A ShadowGenerator is the required tool to use the shadows.
  9747. * Each light casting shadows needs to use its own ShadowGenerator.
  9748. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9749. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9750. * @param light The light object generating the shadows.
  9751. * @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.
  9752. */
  9753. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9754. private _initializeGenerator;
  9755. private _initializeShadowMap;
  9756. private _initializeBlurRTTAndPostProcesses;
  9757. private _renderForShadowMap;
  9758. private _renderSubMeshForShadowMap;
  9759. private _applyFilterValues;
  9760. /**
  9761. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9762. * @param onCompiled Callback triggered at the and of the effects compilation
  9763. * @param options Sets of optional options forcing the compilation with different modes
  9764. */
  9765. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9766. useInstances: boolean;
  9767. }>): void;
  9768. /**
  9769. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9770. * @param options Sets of optional options forcing the compilation with different modes
  9771. * @returns A promise that resolves when the compilation completes
  9772. */
  9773. forceCompilationAsync(options?: Partial<{
  9774. useInstances: boolean;
  9775. }>): Promise<void>;
  9776. /**
  9777. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9778. * @param subMesh The submesh we want to render in the shadow map
  9779. * @param useInstances Defines wether will draw in the map using instances
  9780. * @returns true if ready otherwise, false
  9781. */
  9782. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9783. /**
  9784. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9785. * @param defines Defines of the material we want to update
  9786. * @param lightIndex Index of the light in the enabled light list of the material
  9787. */
  9788. prepareDefines(defines: any, lightIndex: number): void;
  9789. /**
  9790. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9791. * defined in the generator but impacting the effect).
  9792. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9793. * @param effect The effect we are binfing the information for
  9794. */
  9795. bindShadowLight(lightIndex: string, effect: Effect): void;
  9796. /**
  9797. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9798. * (eq to shadow prjection matrix * light transform matrix)
  9799. * @returns The transform matrix used to create the shadow map
  9800. */
  9801. getTransformMatrix(): Matrix;
  9802. /**
  9803. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9804. * Cube and 2D textures for instance.
  9805. */
  9806. recreateShadowMap(): void;
  9807. private _disposeBlurPostProcesses;
  9808. private _disposeRTTandPostProcesses;
  9809. /**
  9810. * Disposes the ShadowGenerator.
  9811. * Returns nothing.
  9812. */
  9813. dispose(): void;
  9814. /**
  9815. * Serializes the shadow generator setup to a json object.
  9816. * @returns The serialized JSON object
  9817. */
  9818. serialize(): any;
  9819. /**
  9820. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9821. * @param parsedShadowGenerator The JSON object to parse
  9822. * @param scene The scene to create the shadow map for
  9823. * @returns The parsed shadow generator
  9824. */
  9825. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9826. }
  9827. }
  9828. declare module BABYLON {
  9829. /**
  9830. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9831. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9832. * 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.
  9833. */
  9834. export abstract class Light extends Node {
  9835. /**
  9836. * Falloff Default: light is falling off following the material specification:
  9837. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9838. */
  9839. static readonly FALLOFF_DEFAULT: number;
  9840. /**
  9841. * Falloff Physical: light is falling off following the inverse squared distance law.
  9842. */
  9843. static readonly FALLOFF_PHYSICAL: number;
  9844. /**
  9845. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9846. * to enhance interoperability with other engines.
  9847. */
  9848. static readonly FALLOFF_GLTF: number;
  9849. /**
  9850. * Falloff Standard: light is falling off like in the standard material
  9851. * to enhance interoperability with other materials.
  9852. */
  9853. static readonly FALLOFF_STANDARD: number;
  9854. /**
  9855. * If every light affecting the material is in this lightmapMode,
  9856. * material.lightmapTexture adds or multiplies
  9857. * (depends on material.useLightmapAsShadowmap)
  9858. * after every other light calculations.
  9859. */
  9860. static readonly LIGHTMAP_DEFAULT: number;
  9861. /**
  9862. * material.lightmapTexture as only diffuse lighting from this light
  9863. * adds only specular lighting from this light
  9864. * adds dynamic shadows
  9865. */
  9866. static readonly LIGHTMAP_SPECULAR: number;
  9867. /**
  9868. * material.lightmapTexture as only lighting
  9869. * no light calculation from this light
  9870. * only adds dynamic shadows from this light
  9871. */
  9872. static readonly LIGHTMAP_SHADOWSONLY: number;
  9873. /**
  9874. * Each light type uses the default quantity according to its type:
  9875. * point/spot lights use luminous intensity
  9876. * directional lights use illuminance
  9877. */
  9878. static readonly INTENSITYMODE_AUTOMATIC: number;
  9879. /**
  9880. * lumen (lm)
  9881. */
  9882. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9883. /**
  9884. * candela (lm/sr)
  9885. */
  9886. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9887. /**
  9888. * lux (lm/m^2)
  9889. */
  9890. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9891. /**
  9892. * nit (cd/m^2)
  9893. */
  9894. static readonly INTENSITYMODE_LUMINANCE: number;
  9895. /**
  9896. * Light type const id of the point light.
  9897. */
  9898. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9899. /**
  9900. * Light type const id of the directional light.
  9901. */
  9902. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9903. /**
  9904. * Light type const id of the spot light.
  9905. */
  9906. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9907. /**
  9908. * Light type const id of the hemispheric light.
  9909. */
  9910. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9911. /**
  9912. * Diffuse gives the basic color to an object.
  9913. */
  9914. diffuse: Color3;
  9915. /**
  9916. * Specular produces a highlight color on an object.
  9917. * Note: This is note affecting PBR materials.
  9918. */
  9919. specular: Color3;
  9920. /**
  9921. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9922. * falling off base on range or angle.
  9923. * This can be set to any values in Light.FALLOFF_x.
  9924. *
  9925. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9926. * other types of materials.
  9927. */
  9928. falloffType: number;
  9929. /**
  9930. * Strength of the light.
  9931. * Note: By default it is define in the framework own unit.
  9932. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9933. */
  9934. intensity: number;
  9935. private _range;
  9936. protected _inverseSquaredRange: number;
  9937. /**
  9938. * Defines how far from the source the light is impacting in scene units.
  9939. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9940. */
  9941. /**
  9942. * Defines how far from the source the light is impacting in scene units.
  9943. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9944. */
  9945. range: number;
  9946. /**
  9947. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9948. * of light.
  9949. */
  9950. private _photometricScale;
  9951. private _intensityMode;
  9952. /**
  9953. * Gets the photometric scale used to interpret the intensity.
  9954. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9955. */
  9956. /**
  9957. * Sets the photometric scale used to interpret the intensity.
  9958. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9959. */
  9960. intensityMode: number;
  9961. private _radius;
  9962. /**
  9963. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9964. */
  9965. /**
  9966. * sets the light radius used by PBR Materials to simulate soft area lights.
  9967. */
  9968. radius: number;
  9969. private _renderPriority;
  9970. /**
  9971. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9972. * exceeding the number allowed of the materials.
  9973. */
  9974. renderPriority: number;
  9975. private _shadowEnabled;
  9976. /**
  9977. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9978. * the current shadow generator.
  9979. */
  9980. /**
  9981. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9982. * the current shadow generator.
  9983. */
  9984. shadowEnabled: boolean;
  9985. private _includedOnlyMeshes;
  9986. /**
  9987. * Gets the only meshes impacted by this light.
  9988. */
  9989. /**
  9990. * Sets the only meshes impacted by this light.
  9991. */
  9992. includedOnlyMeshes: AbstractMesh[];
  9993. private _excludedMeshes;
  9994. /**
  9995. * Gets the meshes not impacted by this light.
  9996. */
  9997. /**
  9998. * Sets the meshes not impacted by this light.
  9999. */
  10000. excludedMeshes: AbstractMesh[];
  10001. private _excludeWithLayerMask;
  10002. /**
  10003. * Gets the layer id use to find what meshes are not impacted by the light.
  10004. * Inactive if 0
  10005. */
  10006. /**
  10007. * Sets the layer id use to find what meshes are not impacted by the light.
  10008. * Inactive if 0
  10009. */
  10010. excludeWithLayerMask: number;
  10011. private _includeOnlyWithLayerMask;
  10012. /**
  10013. * Gets the layer id use to find what meshes are impacted by the light.
  10014. * Inactive if 0
  10015. */
  10016. /**
  10017. * Sets the layer id use to find what meshes are impacted by the light.
  10018. * Inactive if 0
  10019. */
  10020. includeOnlyWithLayerMask: number;
  10021. private _lightmapMode;
  10022. /**
  10023. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10024. */
  10025. /**
  10026. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10027. */
  10028. lightmapMode: number;
  10029. /**
  10030. * Shadow generator associted to the light.
  10031. * @hidden Internal use only.
  10032. */
  10033. _shadowGenerator: Nullable<IShadowGenerator>;
  10034. /**
  10035. * @hidden Internal use only.
  10036. */
  10037. _excludedMeshesIds: string[];
  10038. /**
  10039. * @hidden Internal use only.
  10040. */
  10041. _includedOnlyMeshesIds: string[];
  10042. /**
  10043. * The current light unifom buffer.
  10044. * @hidden Internal use only.
  10045. */
  10046. _uniformBuffer: UniformBuffer;
  10047. /** @hidden */
  10048. _renderId: number;
  10049. /**
  10050. * Creates a Light object in the scene.
  10051. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10052. * @param name The firendly name of the light
  10053. * @param scene The scene the light belongs too
  10054. */
  10055. constructor(name: string, scene: Scene);
  10056. protected abstract _buildUniformLayout(): void;
  10057. /**
  10058. * Sets the passed Effect "effect" with the Light information.
  10059. * @param effect The effect to update
  10060. * @param lightIndex The index of the light in the effect to update
  10061. * @returns The light
  10062. */
  10063. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10064. /**
  10065. * Sets the passed Effect "effect" with the Light textures.
  10066. * @param effect The effect to update
  10067. * @param lightIndex The index of the light in the effect to update
  10068. * @returns The light
  10069. */
  10070. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10071. /**
  10072. * Binds the lights information from the scene to the effect for the given mesh.
  10073. * @param lightIndex Light index
  10074. * @param scene The scene where the light belongs to
  10075. * @param effect The effect we are binding the data to
  10076. * @param useSpecular Defines if specular is supported
  10077. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10078. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10079. */
  10080. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  10081. /**
  10082. * Sets the passed Effect "effect" with the Light information.
  10083. * @param effect The effect to update
  10084. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10085. * @returns The light
  10086. */
  10087. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10088. /**
  10089. * Returns the string "Light".
  10090. * @returns the class name
  10091. */
  10092. getClassName(): string;
  10093. /** @hidden */
  10094. readonly _isLight: boolean;
  10095. /**
  10096. * Converts the light information to a readable string for debug purpose.
  10097. * @param fullDetails Supports for multiple levels of logging within scene loading
  10098. * @returns the human readable light info
  10099. */
  10100. toString(fullDetails?: boolean): string;
  10101. /** @hidden */
  10102. protected _syncParentEnabledState(): void;
  10103. /**
  10104. * Set the enabled state of this node.
  10105. * @param value - the new enabled state
  10106. */
  10107. setEnabled(value: boolean): void;
  10108. /**
  10109. * Returns the Light associated shadow generator if any.
  10110. * @return the associated shadow generator.
  10111. */
  10112. getShadowGenerator(): Nullable<IShadowGenerator>;
  10113. /**
  10114. * Returns a Vector3, the absolute light position in the World.
  10115. * @returns the world space position of the light
  10116. */
  10117. getAbsolutePosition(): Vector3;
  10118. /**
  10119. * Specifies if the light will affect the passed mesh.
  10120. * @param mesh The mesh to test against the light
  10121. * @return true the mesh is affected otherwise, false.
  10122. */
  10123. canAffectMesh(mesh: AbstractMesh): boolean;
  10124. /**
  10125. * Sort function to order lights for rendering.
  10126. * @param a First Light object to compare to second.
  10127. * @param b Second Light object to compare first.
  10128. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10129. */
  10130. static CompareLightsPriority(a: Light, b: Light): number;
  10131. /**
  10132. * Releases resources associated with this node.
  10133. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10134. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10135. */
  10136. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10137. /**
  10138. * Returns the light type ID (integer).
  10139. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10140. */
  10141. getTypeID(): number;
  10142. /**
  10143. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10144. * @returns the scaled intensity in intensity mode unit
  10145. */
  10146. getScaledIntensity(): number;
  10147. /**
  10148. * Returns a new Light object, named "name", from the current one.
  10149. * @param name The name of the cloned light
  10150. * @returns the new created light
  10151. */
  10152. clone(name: string): Nullable<Light>;
  10153. /**
  10154. * Serializes the current light into a Serialization object.
  10155. * @returns the serialized object.
  10156. */
  10157. serialize(): any;
  10158. /**
  10159. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10160. * This new light is named "name" and added to the passed scene.
  10161. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10162. * @param name The friendly name of the light
  10163. * @param scene The scene the new light will belong to
  10164. * @returns the constructor function
  10165. */
  10166. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10167. /**
  10168. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10169. * @param parsedLight The JSON representation of the light
  10170. * @param scene The scene to create the parsed light in
  10171. * @returns the created light after parsing
  10172. */
  10173. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10174. private _hookArrayForExcluded;
  10175. private _hookArrayForIncludedOnly;
  10176. private _resyncMeshes;
  10177. /**
  10178. * Forces the meshes to update their light related information in their rendering used effects
  10179. * @hidden Internal Use Only
  10180. */
  10181. _markMeshesAsLightDirty(): void;
  10182. /**
  10183. * Recomputes the cached photometric scale if needed.
  10184. */
  10185. private _computePhotometricScale;
  10186. /**
  10187. * Returns the Photometric Scale according to the light type and intensity mode.
  10188. */
  10189. private _getPhotometricScale;
  10190. /**
  10191. * Reorder the light in the scene according to their defined priority.
  10192. * @hidden Internal Use Only
  10193. */
  10194. _reorderLightsInScene(): void;
  10195. /**
  10196. * Prepares the list of defines specific to the light type.
  10197. * @param defines the list of defines
  10198. * @param lightIndex defines the index of the light for the effect
  10199. */
  10200. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10201. }
  10202. }
  10203. declare module BABYLON {
  10204. /**
  10205. * Interface used to define Action
  10206. */
  10207. export interface IAction {
  10208. /**
  10209. * Trigger for the action
  10210. */
  10211. trigger: number;
  10212. /** Options of the trigger */
  10213. triggerOptions: any;
  10214. /**
  10215. * Gets the trigger parameters
  10216. * @returns the trigger parameters
  10217. */
  10218. getTriggerParameter(): any;
  10219. /**
  10220. * Internal only - executes current action event
  10221. * @hidden
  10222. */
  10223. _executeCurrent(evt?: ActionEvent): void;
  10224. /**
  10225. * Serialize placeholder for child classes
  10226. * @param parent of child
  10227. * @returns the serialized object
  10228. */
  10229. serialize(parent: any): any;
  10230. /**
  10231. * Internal only
  10232. * @hidden
  10233. */
  10234. _prepare(): void;
  10235. /**
  10236. * Internal only - manager for action
  10237. * @hidden
  10238. */
  10239. _actionManager: AbstractActionManager;
  10240. /**
  10241. * Adds action to chain of actions, may be a DoNothingAction
  10242. * @param action defines the next action to execute
  10243. * @returns The action passed in
  10244. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10245. */
  10246. then(action: IAction): IAction;
  10247. }
  10248. /**
  10249. * The action to be carried out following a trigger
  10250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10251. */
  10252. export class Action implements IAction {
  10253. /** the trigger, with or without parameters, for the action */
  10254. triggerOptions: any;
  10255. /**
  10256. * Trigger for the action
  10257. */
  10258. trigger: number;
  10259. /**
  10260. * Internal only - manager for action
  10261. * @hidden
  10262. */
  10263. _actionManager: ActionManager;
  10264. private _nextActiveAction;
  10265. private _child;
  10266. private _condition?;
  10267. private _triggerParameter;
  10268. /**
  10269. * An event triggered prior to action being executed.
  10270. */
  10271. onBeforeExecuteObservable: Observable<Action>;
  10272. /**
  10273. * Creates a new Action
  10274. * @param triggerOptions the trigger, with or without parameters, for the action
  10275. * @param condition an optional determinant of action
  10276. */
  10277. constructor(
  10278. /** the trigger, with or without parameters, for the action */
  10279. triggerOptions: any, condition?: Condition);
  10280. /**
  10281. * Internal only
  10282. * @hidden
  10283. */
  10284. _prepare(): void;
  10285. /**
  10286. * Gets the trigger parameters
  10287. * @returns the trigger parameters
  10288. */
  10289. getTriggerParameter(): any;
  10290. /**
  10291. * Internal only - executes current action event
  10292. * @hidden
  10293. */
  10294. _executeCurrent(evt?: ActionEvent): void;
  10295. /**
  10296. * Execute placeholder for child classes
  10297. * @param evt optional action event
  10298. */
  10299. execute(evt?: ActionEvent): void;
  10300. /**
  10301. * Skips to next active action
  10302. */
  10303. skipToNextActiveAction(): void;
  10304. /**
  10305. * Adds action to chain of actions, may be a DoNothingAction
  10306. * @param action defines the next action to execute
  10307. * @returns The action passed in
  10308. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10309. */
  10310. then(action: Action): Action;
  10311. /**
  10312. * Internal only
  10313. * @hidden
  10314. */
  10315. _getProperty(propertyPath: string): string;
  10316. /**
  10317. * Internal only
  10318. * @hidden
  10319. */
  10320. _getEffectiveTarget(target: any, propertyPath: string): any;
  10321. /**
  10322. * Serialize placeholder for child classes
  10323. * @param parent of child
  10324. * @returns the serialized object
  10325. */
  10326. serialize(parent: any): any;
  10327. /**
  10328. * Internal only called by serialize
  10329. * @hidden
  10330. */
  10331. protected _serialize(serializedAction: any, parent?: any): any;
  10332. /**
  10333. * Internal only
  10334. * @hidden
  10335. */
  10336. static _SerializeValueAsString: (value: any) => string;
  10337. /**
  10338. * Internal only
  10339. * @hidden
  10340. */
  10341. static _GetTargetProperty: (target: Node | Scene) => {
  10342. name: string;
  10343. targetType: string;
  10344. value: string;
  10345. };
  10346. }
  10347. }
  10348. declare module BABYLON {
  10349. /**
  10350. * A Condition applied to an Action
  10351. */
  10352. export class Condition {
  10353. /**
  10354. * Internal only - manager for action
  10355. * @hidden
  10356. */
  10357. _actionManager: ActionManager;
  10358. /**
  10359. * Internal only
  10360. * @hidden
  10361. */
  10362. _evaluationId: number;
  10363. /**
  10364. * Internal only
  10365. * @hidden
  10366. */
  10367. _currentResult: boolean;
  10368. /**
  10369. * Creates a new Condition
  10370. * @param actionManager the manager of the action the condition is applied to
  10371. */
  10372. constructor(actionManager: ActionManager);
  10373. /**
  10374. * Check if the current condition is valid
  10375. * @returns a boolean
  10376. */
  10377. isValid(): boolean;
  10378. /**
  10379. * Internal only
  10380. * @hidden
  10381. */
  10382. _getProperty(propertyPath: string): string;
  10383. /**
  10384. * Internal only
  10385. * @hidden
  10386. */
  10387. _getEffectiveTarget(target: any, propertyPath: string): any;
  10388. /**
  10389. * Serialize placeholder for child classes
  10390. * @returns the serialized object
  10391. */
  10392. serialize(): any;
  10393. /**
  10394. * Internal only
  10395. * @hidden
  10396. */
  10397. protected _serialize(serializedCondition: any): any;
  10398. }
  10399. /**
  10400. * Defines specific conditional operators as extensions of Condition
  10401. */
  10402. export class ValueCondition extends Condition {
  10403. /** path to specify the property of the target the conditional operator uses */
  10404. propertyPath: string;
  10405. /** the value compared by the conditional operator against the current value of the property */
  10406. value: any;
  10407. /** the conditional operator, default ValueCondition.IsEqual */
  10408. operator: number;
  10409. /**
  10410. * Internal only
  10411. * @hidden
  10412. */
  10413. private static _IsEqual;
  10414. /**
  10415. * Internal only
  10416. * @hidden
  10417. */
  10418. private static _IsDifferent;
  10419. /**
  10420. * Internal only
  10421. * @hidden
  10422. */
  10423. private static _IsGreater;
  10424. /**
  10425. * Internal only
  10426. * @hidden
  10427. */
  10428. private static _IsLesser;
  10429. /**
  10430. * returns the number for IsEqual
  10431. */
  10432. static readonly IsEqual: number;
  10433. /**
  10434. * Returns the number for IsDifferent
  10435. */
  10436. static readonly IsDifferent: number;
  10437. /**
  10438. * Returns the number for IsGreater
  10439. */
  10440. static readonly IsGreater: number;
  10441. /**
  10442. * Returns the number for IsLesser
  10443. */
  10444. static readonly IsLesser: number;
  10445. /**
  10446. * Internal only The action manager for the condition
  10447. * @hidden
  10448. */
  10449. _actionManager: ActionManager;
  10450. /**
  10451. * Internal only
  10452. * @hidden
  10453. */
  10454. private _target;
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. private _effectiveTarget;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. private _property;
  10465. /**
  10466. * Creates a new ValueCondition
  10467. * @param actionManager manager for the action the condition applies to
  10468. * @param target for the action
  10469. * @param propertyPath path to specify the property of the target the conditional operator uses
  10470. * @param value the value compared by the conditional operator against the current value of the property
  10471. * @param operator the conditional operator, default ValueCondition.IsEqual
  10472. */
  10473. constructor(actionManager: ActionManager, target: any,
  10474. /** path to specify the property of the target the conditional operator uses */
  10475. propertyPath: string,
  10476. /** the value compared by the conditional operator against the current value of the property */
  10477. value: any,
  10478. /** the conditional operator, default ValueCondition.IsEqual */
  10479. operator?: number);
  10480. /**
  10481. * Compares the given value with the property value for the specified conditional operator
  10482. * @returns the result of the comparison
  10483. */
  10484. isValid(): boolean;
  10485. /**
  10486. * Serialize the ValueCondition into a JSON compatible object
  10487. * @returns serialization object
  10488. */
  10489. serialize(): any;
  10490. /**
  10491. * Gets the name of the conditional operator for the ValueCondition
  10492. * @param operator the conditional operator
  10493. * @returns the name
  10494. */
  10495. static GetOperatorName(operator: number): string;
  10496. }
  10497. /**
  10498. * Defines a predicate condition as an extension of Condition
  10499. */
  10500. export class PredicateCondition extends Condition {
  10501. /** defines the predicate function used to validate the condition */
  10502. predicate: () => boolean;
  10503. /**
  10504. * Internal only - manager for action
  10505. * @hidden
  10506. */
  10507. _actionManager: ActionManager;
  10508. /**
  10509. * Creates a new PredicateCondition
  10510. * @param actionManager manager for the action the condition applies to
  10511. * @param predicate defines the predicate function used to validate the condition
  10512. */
  10513. constructor(actionManager: ActionManager,
  10514. /** defines the predicate function used to validate the condition */
  10515. predicate: () => boolean);
  10516. /**
  10517. * @returns the validity of the predicate condition
  10518. */
  10519. isValid(): boolean;
  10520. }
  10521. /**
  10522. * Defines a state condition as an extension of Condition
  10523. */
  10524. export class StateCondition extends Condition {
  10525. /** Value to compare with target state */
  10526. value: string;
  10527. /**
  10528. * Internal only - manager for action
  10529. * @hidden
  10530. */
  10531. _actionManager: ActionManager;
  10532. /**
  10533. * Internal only
  10534. * @hidden
  10535. */
  10536. private _target;
  10537. /**
  10538. * Creates a new StateCondition
  10539. * @param actionManager manager for the action the condition applies to
  10540. * @param target of the condition
  10541. * @param value to compare with target state
  10542. */
  10543. constructor(actionManager: ActionManager, target: any,
  10544. /** Value to compare with target state */
  10545. value: string);
  10546. /**
  10547. * Gets a boolean indicating if the current condition is met
  10548. * @returns the validity of the state
  10549. */
  10550. isValid(): boolean;
  10551. /**
  10552. * Serialize the StateCondition into a JSON compatible object
  10553. * @returns serialization object
  10554. */
  10555. serialize(): any;
  10556. }
  10557. }
  10558. declare module BABYLON {
  10559. /**
  10560. * This defines an action responsible to toggle a boolean once triggered.
  10561. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10562. */
  10563. export class SwitchBooleanAction extends Action {
  10564. /**
  10565. * The path to the boolean property in the target object
  10566. */
  10567. propertyPath: string;
  10568. private _target;
  10569. private _effectiveTarget;
  10570. private _property;
  10571. /**
  10572. * Instantiate the action
  10573. * @param triggerOptions defines the trigger options
  10574. * @param target defines the object containing the boolean
  10575. * @param propertyPath defines the path to the boolean property in the target object
  10576. * @param condition defines the trigger related conditions
  10577. */
  10578. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10579. /** @hidden */
  10580. _prepare(): void;
  10581. /**
  10582. * Execute the action toggle the boolean value.
  10583. */
  10584. execute(): void;
  10585. /**
  10586. * Serializes the actions and its related information.
  10587. * @param parent defines the object to serialize in
  10588. * @returns the serialized object
  10589. */
  10590. serialize(parent: any): any;
  10591. }
  10592. /**
  10593. * This defines an action responsible to set a the state field of the target
  10594. * to a desired value once triggered.
  10595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10596. */
  10597. export class SetStateAction extends Action {
  10598. /**
  10599. * The value to store in the state field.
  10600. */
  10601. value: string;
  10602. private _target;
  10603. /**
  10604. * Instantiate the action
  10605. * @param triggerOptions defines the trigger options
  10606. * @param target defines the object containing the state property
  10607. * @param value defines the value to store in the state field
  10608. * @param condition defines the trigger related conditions
  10609. */
  10610. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10611. /**
  10612. * Execute the action and store the value on the target state property.
  10613. */
  10614. execute(): void;
  10615. /**
  10616. * Serializes the actions and its related information.
  10617. * @param parent defines the object to serialize in
  10618. * @returns the serialized object
  10619. */
  10620. serialize(parent: any): any;
  10621. }
  10622. /**
  10623. * This defines an action responsible to set a property of the target
  10624. * to a desired value once triggered.
  10625. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10626. */
  10627. export class SetValueAction extends Action {
  10628. /**
  10629. * The path of the property to set in the target.
  10630. */
  10631. propertyPath: string;
  10632. /**
  10633. * The value to set in the property
  10634. */
  10635. value: any;
  10636. private _target;
  10637. private _effectiveTarget;
  10638. private _property;
  10639. /**
  10640. * Instantiate the action
  10641. * @param triggerOptions defines the trigger options
  10642. * @param target defines the object containing the property
  10643. * @param propertyPath defines the path of the property to set in the target
  10644. * @param value defines the value to set in the property
  10645. * @param condition defines the trigger related conditions
  10646. */
  10647. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10648. /** @hidden */
  10649. _prepare(): void;
  10650. /**
  10651. * Execute the action and set the targetted property to the desired value.
  10652. */
  10653. execute(): void;
  10654. /**
  10655. * Serializes the actions and its related information.
  10656. * @param parent defines the object to serialize in
  10657. * @returns the serialized object
  10658. */
  10659. serialize(parent: any): any;
  10660. }
  10661. /**
  10662. * This defines an action responsible to increment the target value
  10663. * to a desired value once triggered.
  10664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10665. */
  10666. export class IncrementValueAction extends Action {
  10667. /**
  10668. * The path of the property to increment in the target.
  10669. */
  10670. propertyPath: string;
  10671. /**
  10672. * The value we should increment the property by.
  10673. */
  10674. value: any;
  10675. private _target;
  10676. private _effectiveTarget;
  10677. private _property;
  10678. /**
  10679. * Instantiate the action
  10680. * @param triggerOptions defines the trigger options
  10681. * @param target defines the object containing the property
  10682. * @param propertyPath defines the path of the property to increment in the target
  10683. * @param value defines the value value we should increment the property by
  10684. * @param condition defines the trigger related conditions
  10685. */
  10686. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10687. /** @hidden */
  10688. _prepare(): void;
  10689. /**
  10690. * Execute the action and increment the target of the value amount.
  10691. */
  10692. execute(): void;
  10693. /**
  10694. * Serializes the actions and its related information.
  10695. * @param parent defines the object to serialize in
  10696. * @returns the serialized object
  10697. */
  10698. serialize(parent: any): any;
  10699. }
  10700. /**
  10701. * This defines an action responsible to start an animation once triggered.
  10702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10703. */
  10704. export class PlayAnimationAction extends Action {
  10705. /**
  10706. * Where the animation should start (animation frame)
  10707. */
  10708. from: number;
  10709. /**
  10710. * Where the animation should stop (animation frame)
  10711. */
  10712. to: number;
  10713. /**
  10714. * Define if the animation should loop or stop after the first play.
  10715. */
  10716. loop?: boolean;
  10717. private _target;
  10718. /**
  10719. * Instantiate the action
  10720. * @param triggerOptions defines the trigger options
  10721. * @param target defines the target animation or animation name
  10722. * @param from defines from where the animation should start (animation frame)
  10723. * @param end defines where the animation should stop (animation frame)
  10724. * @param loop defines if the animation should loop or stop after the first play
  10725. * @param condition defines the trigger related conditions
  10726. */
  10727. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10728. /** @hidden */
  10729. _prepare(): void;
  10730. /**
  10731. * Execute the action and play the animation.
  10732. */
  10733. execute(): void;
  10734. /**
  10735. * Serializes the actions and its related information.
  10736. * @param parent defines the object to serialize in
  10737. * @returns the serialized object
  10738. */
  10739. serialize(parent: any): any;
  10740. }
  10741. /**
  10742. * This defines an action responsible to stop an animation once triggered.
  10743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10744. */
  10745. export class StopAnimationAction extends Action {
  10746. private _target;
  10747. /**
  10748. * Instantiate the action
  10749. * @param triggerOptions defines the trigger options
  10750. * @param target defines the target animation or animation name
  10751. * @param condition defines the trigger related conditions
  10752. */
  10753. constructor(triggerOptions: any, target: any, condition?: Condition);
  10754. /** @hidden */
  10755. _prepare(): void;
  10756. /**
  10757. * Execute the action and stop the animation.
  10758. */
  10759. execute(): void;
  10760. /**
  10761. * Serializes the actions and its related information.
  10762. * @param parent defines the object to serialize in
  10763. * @returns the serialized object
  10764. */
  10765. serialize(parent: any): any;
  10766. }
  10767. /**
  10768. * This defines an action responsible that does nothing once triggered.
  10769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10770. */
  10771. export class DoNothingAction extends Action {
  10772. /**
  10773. * Instantiate the action
  10774. * @param triggerOptions defines the trigger options
  10775. * @param condition defines the trigger related conditions
  10776. */
  10777. constructor(triggerOptions?: any, condition?: Condition);
  10778. /**
  10779. * Execute the action and do nothing.
  10780. */
  10781. execute(): void;
  10782. /**
  10783. * Serializes the actions and its related information.
  10784. * @param parent defines the object to serialize in
  10785. * @returns the serialized object
  10786. */
  10787. serialize(parent: any): any;
  10788. }
  10789. /**
  10790. * This defines an action responsible to trigger several actions once triggered.
  10791. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10792. */
  10793. export class CombineAction extends Action {
  10794. /**
  10795. * The list of aggregated animations to run.
  10796. */
  10797. children: Action[];
  10798. /**
  10799. * Instantiate the action
  10800. * @param triggerOptions defines the trigger options
  10801. * @param children defines the list of aggregated animations to run
  10802. * @param condition defines the trigger related conditions
  10803. */
  10804. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10805. /** @hidden */
  10806. _prepare(): void;
  10807. /**
  10808. * Execute the action and executes all the aggregated actions.
  10809. */
  10810. execute(evt: ActionEvent): void;
  10811. /**
  10812. * Serializes the actions and its related information.
  10813. * @param parent defines the object to serialize in
  10814. * @returns the serialized object
  10815. */
  10816. serialize(parent: any): any;
  10817. }
  10818. /**
  10819. * This defines an action responsible to run code (external event) once triggered.
  10820. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10821. */
  10822. export class ExecuteCodeAction extends Action {
  10823. /**
  10824. * The callback function to run.
  10825. */
  10826. func: (evt: ActionEvent) => void;
  10827. /**
  10828. * Instantiate the action
  10829. * @param triggerOptions defines the trigger options
  10830. * @param func defines the callback function to run
  10831. * @param condition defines the trigger related conditions
  10832. */
  10833. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10834. /**
  10835. * Execute the action and run the attached code.
  10836. */
  10837. execute(evt: ActionEvent): void;
  10838. }
  10839. /**
  10840. * This defines an action responsible to set the parent property of the target once triggered.
  10841. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10842. */
  10843. export class SetParentAction extends Action {
  10844. private _parent;
  10845. private _target;
  10846. /**
  10847. * Instantiate the action
  10848. * @param triggerOptions defines the trigger options
  10849. * @param target defines the target containing the parent property
  10850. * @param parent defines from where the animation should start (animation frame)
  10851. * @param condition defines the trigger related conditions
  10852. */
  10853. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10854. /** @hidden */
  10855. _prepare(): void;
  10856. /**
  10857. * Execute the action and set the parent property.
  10858. */
  10859. execute(): void;
  10860. /**
  10861. * Serializes the actions and its related information.
  10862. * @param parent defines the object to serialize in
  10863. * @returns the serialized object
  10864. */
  10865. serialize(parent: any): any;
  10866. }
  10867. }
  10868. declare module BABYLON {
  10869. /**
  10870. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10871. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10873. */
  10874. export class ActionManager extends AbstractActionManager {
  10875. /**
  10876. * Nothing
  10877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10878. */
  10879. static readonly NothingTrigger: number;
  10880. /**
  10881. * On pick
  10882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10883. */
  10884. static readonly OnPickTrigger: number;
  10885. /**
  10886. * On left pick
  10887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10888. */
  10889. static readonly OnLeftPickTrigger: number;
  10890. /**
  10891. * On right pick
  10892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10893. */
  10894. static readonly OnRightPickTrigger: number;
  10895. /**
  10896. * On center pick
  10897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10898. */
  10899. static readonly OnCenterPickTrigger: number;
  10900. /**
  10901. * On pick down
  10902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10903. */
  10904. static readonly OnPickDownTrigger: number;
  10905. /**
  10906. * On double pick
  10907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10908. */
  10909. static readonly OnDoublePickTrigger: number;
  10910. /**
  10911. * On pick up
  10912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10913. */
  10914. static readonly OnPickUpTrigger: number;
  10915. /**
  10916. * On pick out.
  10917. * This trigger will only be raised if you also declared a OnPickDown
  10918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10919. */
  10920. static readonly OnPickOutTrigger: number;
  10921. /**
  10922. * On long press
  10923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10924. */
  10925. static readonly OnLongPressTrigger: number;
  10926. /**
  10927. * On pointer over
  10928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10929. */
  10930. static readonly OnPointerOverTrigger: number;
  10931. /**
  10932. * On pointer out
  10933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10934. */
  10935. static readonly OnPointerOutTrigger: number;
  10936. /**
  10937. * On every frame
  10938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10939. */
  10940. static readonly OnEveryFrameTrigger: number;
  10941. /**
  10942. * On intersection enter
  10943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10944. */
  10945. static readonly OnIntersectionEnterTrigger: number;
  10946. /**
  10947. * On intersection exit
  10948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10949. */
  10950. static readonly OnIntersectionExitTrigger: number;
  10951. /**
  10952. * On key down
  10953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10954. */
  10955. static readonly OnKeyDownTrigger: number;
  10956. /**
  10957. * On key up
  10958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10959. */
  10960. static readonly OnKeyUpTrigger: number;
  10961. private _scene;
  10962. /**
  10963. * Creates a new action manager
  10964. * @param scene defines the hosting scene
  10965. */
  10966. constructor(scene: Scene);
  10967. /**
  10968. * Releases all associated resources
  10969. */
  10970. dispose(): void;
  10971. /**
  10972. * Gets hosting scene
  10973. * @returns the hosting scene
  10974. */
  10975. getScene(): Scene;
  10976. /**
  10977. * Does this action manager handles actions of any of the given triggers
  10978. * @param triggers defines the triggers to be tested
  10979. * @return a boolean indicating whether one (or more) of the triggers is handled
  10980. */
  10981. hasSpecificTriggers(triggers: number[]): boolean;
  10982. /**
  10983. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10984. * speed.
  10985. * @param triggerA defines the trigger to be tested
  10986. * @param triggerB defines the trigger to be tested
  10987. * @return a boolean indicating whether one (or more) of the triggers is handled
  10988. */
  10989. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10990. /**
  10991. * Does this action manager handles actions of a given trigger
  10992. * @param trigger defines the trigger to be tested
  10993. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10994. * @return whether the trigger is handled
  10995. */
  10996. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10997. /**
  10998. * Does this action manager has pointer triggers
  10999. */
  11000. readonly hasPointerTriggers: boolean;
  11001. /**
  11002. * Does this action manager has pick triggers
  11003. */
  11004. readonly hasPickTriggers: boolean;
  11005. /**
  11006. * Registers an action to this action manager
  11007. * @param action defines the action to be registered
  11008. * @return the action amended (prepared) after registration
  11009. */
  11010. registerAction(action: IAction): Nullable<IAction>;
  11011. /**
  11012. * Unregisters an action to this action manager
  11013. * @param action defines the action to be unregistered
  11014. * @return a boolean indicating whether the action has been unregistered
  11015. */
  11016. unregisterAction(action: IAction): Boolean;
  11017. /**
  11018. * Process a specific trigger
  11019. * @param trigger defines the trigger to process
  11020. * @param evt defines the event details to be processed
  11021. */
  11022. processTrigger(trigger: number, evt?: IActionEvent): void;
  11023. /** @hidden */
  11024. _getEffectiveTarget(target: any, propertyPath: string): any;
  11025. /** @hidden */
  11026. _getProperty(propertyPath: string): string;
  11027. /**
  11028. * Serialize this manager to a JSON object
  11029. * @param name defines the property name to store this manager
  11030. * @returns a JSON representation of this manager
  11031. */
  11032. serialize(name: string): any;
  11033. /**
  11034. * Creates a new ActionManager from a JSON data
  11035. * @param parsedActions defines the JSON data to read from
  11036. * @param object defines the hosting mesh
  11037. * @param scene defines the hosting scene
  11038. */
  11039. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11040. /**
  11041. * Get a trigger name by index
  11042. * @param trigger defines the trigger index
  11043. * @returns a trigger name
  11044. */
  11045. static GetTriggerName(trigger: number): string;
  11046. }
  11047. }
  11048. declare module BABYLON {
  11049. /**
  11050. * Class representing a ray with position and direction
  11051. */
  11052. export class Ray {
  11053. /** origin point */
  11054. origin: Vector3;
  11055. /** direction */
  11056. direction: Vector3;
  11057. /** length of the ray */
  11058. length: number;
  11059. private static readonly TmpVector3;
  11060. private _tmpRay;
  11061. /**
  11062. * Creates a new ray
  11063. * @param origin origin point
  11064. * @param direction direction
  11065. * @param length length of the ray
  11066. */
  11067. constructor(
  11068. /** origin point */
  11069. origin: Vector3,
  11070. /** direction */
  11071. direction: Vector3,
  11072. /** length of the ray */
  11073. length?: number);
  11074. /**
  11075. * Checks if the ray intersects a box
  11076. * @param minimum bound of the box
  11077. * @param maximum bound of the box
  11078. * @param intersectionTreshold extra extend to be added to the box in all direction
  11079. * @returns if the box was hit
  11080. */
  11081. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11082. /**
  11083. * Checks if the ray intersects a box
  11084. * @param box the bounding box to check
  11085. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11086. * @returns if the box was hit
  11087. */
  11088. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11089. /**
  11090. * If the ray hits a sphere
  11091. * @param sphere the bounding sphere to check
  11092. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11093. * @returns true if it hits the sphere
  11094. */
  11095. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11096. /**
  11097. * If the ray hits a triange
  11098. * @param vertex0 triangle vertex
  11099. * @param vertex1 triangle vertex
  11100. * @param vertex2 triangle vertex
  11101. * @returns intersection information if hit
  11102. */
  11103. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11104. /**
  11105. * Checks if ray intersects a plane
  11106. * @param plane the plane to check
  11107. * @returns the distance away it was hit
  11108. */
  11109. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11110. /**
  11111. * Calculate the intercept of a ray on a given axis
  11112. * @param axis to check 'x' | 'y' | 'z'
  11113. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11114. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11115. */
  11116. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11117. /**
  11118. * Checks if ray intersects a mesh
  11119. * @param mesh the mesh to check
  11120. * @param fastCheck if only the bounding box should checked
  11121. * @returns picking info of the intersecton
  11122. */
  11123. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11124. /**
  11125. * Checks if ray intersects a mesh
  11126. * @param meshes the meshes to check
  11127. * @param fastCheck if only the bounding box should checked
  11128. * @param results array to store result in
  11129. * @returns Array of picking infos
  11130. */
  11131. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11132. private _comparePickingInfo;
  11133. private static smallnum;
  11134. private static rayl;
  11135. /**
  11136. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11137. * @param sega the first point of the segment to test the intersection against
  11138. * @param segb the second point of the segment to test the intersection against
  11139. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11140. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11141. */
  11142. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11143. /**
  11144. * Update the ray from viewport position
  11145. * @param x position
  11146. * @param y y position
  11147. * @param viewportWidth viewport width
  11148. * @param viewportHeight viewport height
  11149. * @param world world matrix
  11150. * @param view view matrix
  11151. * @param projection projection matrix
  11152. * @returns this ray updated
  11153. */
  11154. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11155. /**
  11156. * Creates a ray with origin and direction of 0,0,0
  11157. * @returns the new ray
  11158. */
  11159. static Zero(): Ray;
  11160. /**
  11161. * Creates a new ray from screen space and viewport
  11162. * @param x position
  11163. * @param y y position
  11164. * @param viewportWidth viewport width
  11165. * @param viewportHeight viewport height
  11166. * @param world world matrix
  11167. * @param view view matrix
  11168. * @param projection projection matrix
  11169. * @returns new ray
  11170. */
  11171. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11172. /**
  11173. * 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
  11174. * transformed to the given world matrix.
  11175. * @param origin The origin point
  11176. * @param end The end point
  11177. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11178. * @returns the new ray
  11179. */
  11180. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11181. /**
  11182. * Transforms a ray by a matrix
  11183. * @param ray ray to transform
  11184. * @param matrix matrix to apply
  11185. * @returns the resulting new ray
  11186. */
  11187. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11188. /**
  11189. * Transforms a ray by a matrix
  11190. * @param ray ray to transform
  11191. * @param matrix matrix to apply
  11192. * @param result ray to store result in
  11193. */
  11194. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11195. /**
  11196. * Unproject a ray from screen space to object space
  11197. * @param sourceX defines the screen space x coordinate to use
  11198. * @param sourceY defines the screen space y coordinate to use
  11199. * @param viewportWidth defines the current width of the viewport
  11200. * @param viewportHeight defines the current height of the viewport
  11201. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11202. * @param view defines the view matrix to use
  11203. * @param projection defines the projection matrix to use
  11204. */
  11205. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11206. }
  11207. /**
  11208. * Type used to define predicate used to select faces when a mesh intersection is detected
  11209. */
  11210. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11211. interface Scene {
  11212. /** @hidden */
  11213. _tempPickingRay: Nullable<Ray>;
  11214. /** @hidden */
  11215. _cachedRayForTransform: Ray;
  11216. /** @hidden */
  11217. _pickWithRayInverseMatrix: Matrix;
  11218. /** @hidden */
  11219. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11220. /** @hidden */
  11221. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11222. }
  11223. }
  11224. declare module BABYLON {
  11225. /**
  11226. * Groups all the scene component constants in one place to ease maintenance.
  11227. * @hidden
  11228. */
  11229. export class SceneComponentConstants {
  11230. static readonly NAME_EFFECTLAYER: string;
  11231. static readonly NAME_LAYER: string;
  11232. static readonly NAME_LENSFLARESYSTEM: string;
  11233. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11234. static readonly NAME_PARTICLESYSTEM: string;
  11235. static readonly NAME_GAMEPAD: string;
  11236. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11237. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11238. static readonly NAME_DEPTHRENDERER: string;
  11239. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11240. static readonly NAME_SPRITE: string;
  11241. static readonly NAME_OUTLINERENDERER: string;
  11242. static readonly NAME_PROCEDURALTEXTURE: string;
  11243. static readonly NAME_SHADOWGENERATOR: string;
  11244. static readonly NAME_OCTREE: string;
  11245. static readonly NAME_PHYSICSENGINE: string;
  11246. static readonly NAME_AUDIO: string;
  11247. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11248. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11249. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11250. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11251. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11252. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11253. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11254. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11255. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11256. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11257. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11258. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11259. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11260. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11261. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11262. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11263. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11264. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11265. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11266. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11267. static readonly STEP_AFTERRENDER_AUDIO: number;
  11268. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11269. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11270. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11271. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11272. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11273. static readonly STEP_POINTERMOVE_SPRITE: number;
  11274. static readonly STEP_POINTERDOWN_SPRITE: number;
  11275. static readonly STEP_POINTERUP_SPRITE: number;
  11276. }
  11277. /**
  11278. * This represents a scene component.
  11279. *
  11280. * This is used to decouple the dependency the scene is having on the different workloads like
  11281. * layers, post processes...
  11282. */
  11283. export interface ISceneComponent {
  11284. /**
  11285. * The name of the component. Each component must have a unique name.
  11286. */
  11287. name: string;
  11288. /**
  11289. * The scene the component belongs to.
  11290. */
  11291. scene: Scene;
  11292. /**
  11293. * Register the component to one instance of a scene.
  11294. */
  11295. register(): void;
  11296. /**
  11297. * Rebuilds the elements related to this component in case of
  11298. * context lost for instance.
  11299. */
  11300. rebuild(): void;
  11301. /**
  11302. * Disposes the component and the associated ressources.
  11303. */
  11304. dispose(): void;
  11305. }
  11306. /**
  11307. * This represents a SERIALIZABLE scene component.
  11308. *
  11309. * This extends Scene Component to add Serialization methods on top.
  11310. */
  11311. export interface ISceneSerializableComponent extends ISceneComponent {
  11312. /**
  11313. * Adds all the elements from the container to the scene
  11314. * @param container the container holding the elements
  11315. */
  11316. addFromContainer(container: AbstractScene): void;
  11317. /**
  11318. * Removes all the elements in the container from the scene
  11319. * @param container contains the elements to remove
  11320. * @param dispose if the removed element should be disposed (default: false)
  11321. */
  11322. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11323. /**
  11324. * Serializes the component data to the specified json object
  11325. * @param serializationObject The object to serialize to
  11326. */
  11327. serialize(serializationObject: any): void;
  11328. }
  11329. /**
  11330. * Strong typing of a Mesh related stage step action
  11331. */
  11332. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11333. /**
  11334. * Strong typing of a Evaluate Sub Mesh related stage step action
  11335. */
  11336. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11337. /**
  11338. * Strong typing of a Active Mesh related stage step action
  11339. */
  11340. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11341. /**
  11342. * Strong typing of a Camera related stage step action
  11343. */
  11344. export type CameraStageAction = (camera: Camera) => void;
  11345. /**
  11346. * Strong typing of a Camera Frame buffer related stage step action
  11347. */
  11348. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11349. /**
  11350. * Strong typing of a Render Target related stage step action
  11351. */
  11352. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11353. /**
  11354. * Strong typing of a RenderingGroup related stage step action
  11355. */
  11356. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11357. /**
  11358. * Strong typing of a Mesh Render related stage step action
  11359. */
  11360. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11361. /**
  11362. * Strong typing of a simple stage step action
  11363. */
  11364. export type SimpleStageAction = () => void;
  11365. /**
  11366. * Strong typing of a render target action.
  11367. */
  11368. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11369. /**
  11370. * Strong typing of a pointer move action.
  11371. */
  11372. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11373. /**
  11374. * Strong typing of a pointer up/down action.
  11375. */
  11376. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11377. /**
  11378. * Representation of a stage in the scene (Basically a list of ordered steps)
  11379. * @hidden
  11380. */
  11381. export class Stage<T extends Function> extends Array<{
  11382. index: number;
  11383. component: ISceneComponent;
  11384. action: T;
  11385. }> {
  11386. /**
  11387. * Hide ctor from the rest of the world.
  11388. * @param items The items to add.
  11389. */
  11390. private constructor();
  11391. /**
  11392. * Creates a new Stage.
  11393. * @returns A new instance of a Stage
  11394. */
  11395. static Create<T extends Function>(): Stage<T>;
  11396. /**
  11397. * Registers a step in an ordered way in the targeted stage.
  11398. * @param index Defines the position to register the step in
  11399. * @param component Defines the component attached to the step
  11400. * @param action Defines the action to launch during the step
  11401. */
  11402. registerStep(index: number, component: ISceneComponent, action: T): void;
  11403. /**
  11404. * Clears all the steps from the stage.
  11405. */
  11406. clear(): void;
  11407. }
  11408. }
  11409. declare module BABYLON {
  11410. interface Scene {
  11411. /** @hidden */
  11412. _pointerOverSprite: Nullable<Sprite>;
  11413. /** @hidden */
  11414. _pickedDownSprite: Nullable<Sprite>;
  11415. /** @hidden */
  11416. _tempSpritePickingRay: Nullable<Ray>;
  11417. /**
  11418. * All of the sprite managers added to this scene
  11419. * @see http://doc.babylonjs.com/babylon101/sprites
  11420. */
  11421. spriteManagers: Array<ISpriteManager>;
  11422. /**
  11423. * An event triggered when sprites rendering is about to start
  11424. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11425. */
  11426. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11427. /**
  11428. * An event triggered when sprites rendering is done
  11429. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11430. */
  11431. onAfterSpritesRenderingObservable: Observable<Scene>;
  11432. /** @hidden */
  11433. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11434. /** Launch a ray to try to pick a sprite in the scene
  11435. * @param x position on screen
  11436. * @param y position on screen
  11437. * @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
  11438. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11439. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11440. * @returns a PickingInfo
  11441. */
  11442. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11443. /** Use the given ray to pick a sprite in the scene
  11444. * @param ray The ray (in world space) to use to pick meshes
  11445. * @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
  11446. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11447. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11448. * @returns a PickingInfo
  11449. */
  11450. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11451. /** @hidden */
  11452. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11453. /** Launch a ray to try to pick sprites in the scene
  11454. * @param x position on screen
  11455. * @param y position on screen
  11456. * @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
  11457. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11458. * @returns a PickingInfo array
  11459. */
  11460. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11461. /** Use the given ray to pick sprites in the scene
  11462. * @param ray The ray (in world space) to use to pick meshes
  11463. * @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
  11464. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11465. * @returns a PickingInfo array
  11466. */
  11467. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11468. /**
  11469. * Force the sprite under the pointer
  11470. * @param sprite defines the sprite to use
  11471. */
  11472. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11473. /**
  11474. * Gets the sprite under the pointer
  11475. * @returns a Sprite or null if no sprite is under the pointer
  11476. */
  11477. getPointerOverSprite(): Nullable<Sprite>;
  11478. }
  11479. /**
  11480. * Defines the sprite scene component responsible to manage sprites
  11481. * in a given scene.
  11482. */
  11483. export class SpriteSceneComponent implements ISceneComponent {
  11484. /**
  11485. * The component name helpfull to identify the component in the list of scene components.
  11486. */
  11487. readonly name: string;
  11488. /**
  11489. * The scene the component belongs to.
  11490. */
  11491. scene: Scene;
  11492. /** @hidden */
  11493. private _spritePredicate;
  11494. /**
  11495. * Creates a new instance of the component for the given scene
  11496. * @param scene Defines the scene to register the component in
  11497. */
  11498. constructor(scene: Scene);
  11499. /**
  11500. * Registers the component in a given scene
  11501. */
  11502. register(): void;
  11503. /**
  11504. * Rebuilds the elements related to this component in case of
  11505. * context lost for instance.
  11506. */
  11507. rebuild(): void;
  11508. /**
  11509. * Disposes the component and the associated ressources.
  11510. */
  11511. dispose(): void;
  11512. private _pickSpriteButKeepRay;
  11513. private _pointerMove;
  11514. private _pointerDown;
  11515. private _pointerUp;
  11516. }
  11517. }
  11518. declare module BABYLON {
  11519. /** @hidden */
  11520. export var fogFragmentDeclaration: {
  11521. name: string;
  11522. shader: string;
  11523. };
  11524. }
  11525. declare module BABYLON {
  11526. /** @hidden */
  11527. export var fogFragment: {
  11528. name: string;
  11529. shader: string;
  11530. };
  11531. }
  11532. declare module BABYLON {
  11533. /** @hidden */
  11534. export var spritesPixelShader: {
  11535. name: string;
  11536. shader: string;
  11537. };
  11538. }
  11539. declare module BABYLON {
  11540. /** @hidden */
  11541. export var fogVertexDeclaration: {
  11542. name: string;
  11543. shader: string;
  11544. };
  11545. }
  11546. declare module BABYLON {
  11547. /** @hidden */
  11548. export var spritesVertexShader: {
  11549. name: string;
  11550. shader: string;
  11551. };
  11552. }
  11553. declare module BABYLON {
  11554. /**
  11555. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11556. */
  11557. export interface ISpriteManager extends IDisposable {
  11558. /**
  11559. * Restricts the camera to viewing objects with the same layerMask.
  11560. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11561. */
  11562. layerMask: number;
  11563. /**
  11564. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11565. */
  11566. isPickable: boolean;
  11567. /**
  11568. * Specifies the rendering group id for this mesh (0 by default)
  11569. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11570. */
  11571. renderingGroupId: number;
  11572. /**
  11573. * Defines the list of sprites managed by the manager.
  11574. */
  11575. sprites: Array<Sprite>;
  11576. /**
  11577. * Tests the intersection of a sprite with a specific ray.
  11578. * @param ray The ray we are sending to test the collision
  11579. * @param camera The camera space we are sending rays in
  11580. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11581. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11582. * @returns picking info or null.
  11583. */
  11584. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11585. /**
  11586. * Intersects the sprites with a ray
  11587. * @param ray defines the ray to intersect with
  11588. * @param camera defines the current active camera
  11589. * @param predicate defines a predicate used to select candidate sprites
  11590. * @returns null if no hit or a PickingInfo array
  11591. */
  11592. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11593. /**
  11594. * Renders the list of sprites on screen.
  11595. */
  11596. render(): void;
  11597. }
  11598. /**
  11599. * Class used to manage multiple sprites on the same spritesheet
  11600. * @see http://doc.babylonjs.com/babylon101/sprites
  11601. */
  11602. export class SpriteManager implements ISpriteManager {
  11603. /** defines the manager's name */
  11604. name: string;
  11605. /** Gets the list of sprites */
  11606. sprites: Sprite[];
  11607. /** Gets or sets the rendering group id (0 by default) */
  11608. renderingGroupId: number;
  11609. /** Gets or sets camera layer mask */
  11610. layerMask: number;
  11611. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11612. fogEnabled: boolean;
  11613. /** Gets or sets a boolean indicating if the sprites are pickable */
  11614. isPickable: boolean;
  11615. /** Defines the default width of a cell in the spritesheet */
  11616. cellWidth: number;
  11617. /** Defines the default height of a cell in the spritesheet */
  11618. cellHeight: number;
  11619. /** Associative array from JSON sprite data file */
  11620. private _cellData;
  11621. /** Array of sprite names from JSON sprite data file */
  11622. private _spriteMap;
  11623. /** True when packed cell data from JSON file is ready*/
  11624. private _packedAndReady;
  11625. /**
  11626. * An event triggered when the manager is disposed.
  11627. */
  11628. onDisposeObservable: Observable<SpriteManager>;
  11629. private _onDisposeObserver;
  11630. /**
  11631. * Callback called when the manager is disposed
  11632. */
  11633. onDispose: () => void;
  11634. private _capacity;
  11635. private _fromPacked;
  11636. private _spriteTexture;
  11637. private _epsilon;
  11638. private _scene;
  11639. private _vertexData;
  11640. private _buffer;
  11641. private _vertexBuffers;
  11642. private _indexBuffer;
  11643. private _effectBase;
  11644. private _effectFog;
  11645. /**
  11646. * Gets or sets the spritesheet texture
  11647. */
  11648. texture: Texture;
  11649. /**
  11650. * Creates a new sprite manager
  11651. * @param name defines the manager's name
  11652. * @param imgUrl defines the sprite sheet url
  11653. * @param capacity defines the maximum allowed number of sprites
  11654. * @param cellSize defines the size of a sprite cell
  11655. * @param scene defines the hosting scene
  11656. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11657. * @param samplingMode defines the smapling mode to use with spritesheet
  11658. * @param fromPacked set to false; do not alter
  11659. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11660. */
  11661. constructor(
  11662. /** defines the manager's name */
  11663. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11664. private _makePacked;
  11665. private _appendSpriteVertex;
  11666. /**
  11667. * Intersects the sprites with a ray
  11668. * @param ray defines the ray to intersect with
  11669. * @param camera defines the current active camera
  11670. * @param predicate defines a predicate used to select candidate sprites
  11671. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11672. * @returns null if no hit or a PickingInfo
  11673. */
  11674. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11675. /**
  11676. * Intersects the sprites with a ray
  11677. * @param ray defines the ray to intersect with
  11678. * @param camera defines the current active camera
  11679. * @param predicate defines a predicate used to select candidate sprites
  11680. * @returns null if no hit or a PickingInfo array
  11681. */
  11682. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11683. /**
  11684. * Render all child sprites
  11685. */
  11686. render(): void;
  11687. /**
  11688. * Release associated resources
  11689. */
  11690. dispose(): void;
  11691. }
  11692. }
  11693. declare module BABYLON {
  11694. /**
  11695. * Class used to represent a sprite
  11696. * @see http://doc.babylonjs.com/babylon101/sprites
  11697. */
  11698. export class Sprite {
  11699. /** defines the name */
  11700. name: string;
  11701. /** Gets or sets the current world position */
  11702. position: Vector3;
  11703. /** Gets or sets the main color */
  11704. color: Color4;
  11705. /** Gets or sets the width */
  11706. width: number;
  11707. /** Gets or sets the height */
  11708. height: number;
  11709. /** Gets or sets rotation angle */
  11710. angle: number;
  11711. /** Gets or sets the cell index in the sprite sheet */
  11712. cellIndex: number;
  11713. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11714. cellRef: string;
  11715. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11716. invertU: number;
  11717. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11718. invertV: number;
  11719. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11720. disposeWhenFinishedAnimating: boolean;
  11721. /** Gets the list of attached animations */
  11722. animations: Animation[];
  11723. /** Gets or sets a boolean indicating if the sprite can be picked */
  11724. isPickable: boolean;
  11725. /**
  11726. * Gets or sets the associated action manager
  11727. */
  11728. actionManager: Nullable<ActionManager>;
  11729. private _animationStarted;
  11730. private _loopAnimation;
  11731. private _fromIndex;
  11732. private _toIndex;
  11733. private _delay;
  11734. private _direction;
  11735. private _manager;
  11736. private _time;
  11737. private _onAnimationEnd;
  11738. /**
  11739. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11740. */
  11741. isVisible: boolean;
  11742. /**
  11743. * Gets or sets the sprite size
  11744. */
  11745. size: number;
  11746. /**
  11747. * Creates a new Sprite
  11748. * @param name defines the name
  11749. * @param manager defines the manager
  11750. */
  11751. constructor(
  11752. /** defines the name */
  11753. name: string, manager: ISpriteManager);
  11754. /**
  11755. * Starts an animation
  11756. * @param from defines the initial key
  11757. * @param to defines the end key
  11758. * @param loop defines if the animation must loop
  11759. * @param delay defines the start delay (in ms)
  11760. * @param onAnimationEnd defines a callback to call when animation ends
  11761. */
  11762. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11763. /** Stops current animation (if any) */
  11764. stopAnimation(): void;
  11765. /** @hidden */
  11766. _animate(deltaTime: number): void;
  11767. /** Release associated resources */
  11768. dispose(): void;
  11769. }
  11770. }
  11771. declare module BABYLON {
  11772. /**
  11773. * Information about the result of picking within a scene
  11774. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11775. */
  11776. export class PickingInfo {
  11777. /** @hidden */
  11778. _pickingUnavailable: boolean;
  11779. /**
  11780. * If the pick collided with an object
  11781. */
  11782. hit: boolean;
  11783. /**
  11784. * Distance away where the pick collided
  11785. */
  11786. distance: number;
  11787. /**
  11788. * The location of pick collision
  11789. */
  11790. pickedPoint: Nullable<Vector3>;
  11791. /**
  11792. * The mesh corresponding the the pick collision
  11793. */
  11794. pickedMesh: Nullable<AbstractMesh>;
  11795. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11796. bu: number;
  11797. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11798. bv: number;
  11799. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11800. faceId: number;
  11801. /** Id of the the submesh that was picked */
  11802. subMeshId: number;
  11803. /** If a sprite was picked, this will be the sprite the pick collided with */
  11804. pickedSprite: Nullable<Sprite>;
  11805. /**
  11806. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11807. */
  11808. originMesh: Nullable<AbstractMesh>;
  11809. /**
  11810. * The ray that was used to perform the picking.
  11811. */
  11812. ray: Nullable<Ray>;
  11813. /**
  11814. * Gets the normal correspodning to the face the pick collided with
  11815. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11816. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11817. * @returns The normal correspodning to the face the pick collided with
  11818. */
  11819. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11820. /**
  11821. * Gets the texture coordinates of where the pick occured
  11822. * @returns the vector containing the coordnates of the texture
  11823. */
  11824. getTextureCoordinates(): Nullable<Vector2>;
  11825. }
  11826. }
  11827. declare module BABYLON {
  11828. /**
  11829. * Gather the list of pointer event types as constants.
  11830. */
  11831. export class PointerEventTypes {
  11832. /**
  11833. * 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.
  11834. */
  11835. static readonly POINTERDOWN: number;
  11836. /**
  11837. * The pointerup event is fired when a pointer is no longer active.
  11838. */
  11839. static readonly POINTERUP: number;
  11840. /**
  11841. * The pointermove event is fired when a pointer changes coordinates.
  11842. */
  11843. static readonly POINTERMOVE: number;
  11844. /**
  11845. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11846. */
  11847. static readonly POINTERWHEEL: number;
  11848. /**
  11849. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11850. */
  11851. static readonly POINTERPICK: number;
  11852. /**
  11853. * The pointertap event is fired when a the object has been touched and released without drag.
  11854. */
  11855. static readonly POINTERTAP: number;
  11856. /**
  11857. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11858. */
  11859. static readonly POINTERDOUBLETAP: number;
  11860. }
  11861. /**
  11862. * Base class of pointer info types.
  11863. */
  11864. export class PointerInfoBase {
  11865. /**
  11866. * Defines the type of event (PointerEventTypes)
  11867. */
  11868. type: number;
  11869. /**
  11870. * Defines the related dom event
  11871. */
  11872. event: PointerEvent | MouseWheelEvent;
  11873. /**
  11874. * Instantiates the base class of pointers info.
  11875. * @param type Defines the type of event (PointerEventTypes)
  11876. * @param event Defines the related dom event
  11877. */
  11878. constructor(
  11879. /**
  11880. * Defines the type of event (PointerEventTypes)
  11881. */
  11882. type: number,
  11883. /**
  11884. * Defines the related dom event
  11885. */
  11886. event: PointerEvent | MouseWheelEvent);
  11887. }
  11888. /**
  11889. * This class is used to store pointer related info for the onPrePointerObservable event.
  11890. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11891. */
  11892. export class PointerInfoPre extends PointerInfoBase {
  11893. /**
  11894. * Ray from a pointer if availible (eg. 6dof controller)
  11895. */
  11896. ray: Nullable<Ray>;
  11897. /**
  11898. * Defines the local position of the pointer on the canvas.
  11899. */
  11900. localPosition: Vector2;
  11901. /**
  11902. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11903. */
  11904. skipOnPointerObservable: boolean;
  11905. /**
  11906. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11907. * @param type Defines the type of event (PointerEventTypes)
  11908. * @param event Defines the related dom event
  11909. * @param localX Defines the local x coordinates of the pointer when the event occured
  11910. * @param localY Defines the local y coordinates of the pointer when the event occured
  11911. */
  11912. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11913. }
  11914. /**
  11915. * This type contains all the data related to a pointer event in Babylon.js.
  11916. * 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.
  11917. */
  11918. export class PointerInfo extends PointerInfoBase {
  11919. /**
  11920. * Defines the picking info associated to the info (if any)\
  11921. */
  11922. pickInfo: Nullable<PickingInfo>;
  11923. /**
  11924. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11925. * @param type Defines the type of event (PointerEventTypes)
  11926. * @param event Defines the related dom event
  11927. * @param pickInfo Defines the picking info associated to the info (if any)\
  11928. */
  11929. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11930. /**
  11931. * Defines the picking info associated to the info (if any)\
  11932. */
  11933. pickInfo: Nullable<PickingInfo>);
  11934. }
  11935. /**
  11936. * Data relating to a touch event on the screen.
  11937. */
  11938. export interface PointerTouch {
  11939. /**
  11940. * X coordinate of touch.
  11941. */
  11942. x: number;
  11943. /**
  11944. * Y coordinate of touch.
  11945. */
  11946. y: number;
  11947. /**
  11948. * Id of touch. Unique for each finger.
  11949. */
  11950. pointerId: number;
  11951. /**
  11952. * Event type passed from DOM.
  11953. */
  11954. type: any;
  11955. }
  11956. }
  11957. declare module BABYLON {
  11958. /**
  11959. * Manage the mouse inputs to control the movement of a free camera.
  11960. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11961. */
  11962. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11963. /**
  11964. * Define if touch is enabled in the mouse input
  11965. */
  11966. touchEnabled: boolean;
  11967. /**
  11968. * Defines the camera the input is attached to.
  11969. */
  11970. camera: FreeCamera;
  11971. /**
  11972. * Defines the buttons associated with the input to handle camera move.
  11973. */
  11974. buttons: number[];
  11975. /**
  11976. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11977. */
  11978. angularSensibility: number;
  11979. private _pointerInput;
  11980. private _onMouseMove;
  11981. private _observer;
  11982. private previousPosition;
  11983. /**
  11984. * Observable for when a pointer move event occurs containing the move offset
  11985. */
  11986. onPointerMovedObservable: Observable<{
  11987. offsetX: number;
  11988. offsetY: number;
  11989. }>;
  11990. /**
  11991. * @hidden
  11992. * If the camera should be rotated automatically based on pointer movement
  11993. */
  11994. _allowCameraRotation: boolean;
  11995. /**
  11996. * Manage the mouse inputs to control the movement of a free camera.
  11997. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11998. * @param touchEnabled Defines if touch is enabled or not
  11999. */
  12000. constructor(
  12001. /**
  12002. * Define if touch is enabled in the mouse input
  12003. */
  12004. touchEnabled?: boolean);
  12005. /**
  12006. * Attach the input controls to a specific dom element to get the input from.
  12007. * @param element Defines the element the controls should be listened from
  12008. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12009. */
  12010. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12011. /**
  12012. * Called on JS contextmenu event.
  12013. * Override this method to provide functionality.
  12014. */
  12015. protected onContextMenu(evt: PointerEvent): void;
  12016. /**
  12017. * Detach the current controls from the specified dom element.
  12018. * @param element Defines the element to stop listening the inputs from
  12019. */
  12020. detachControl(element: Nullable<HTMLElement>): void;
  12021. /**
  12022. * Gets the class name of the current intput.
  12023. * @returns the class name
  12024. */
  12025. getClassName(): string;
  12026. /**
  12027. * Get the friendly name associated with the input class.
  12028. * @returns the input friendly name
  12029. */
  12030. getSimpleName(): string;
  12031. }
  12032. }
  12033. declare module BABYLON {
  12034. /**
  12035. * Manage the touch inputs to control the movement of a free camera.
  12036. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12037. */
  12038. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12039. /**
  12040. * Defines the camera the input is attached to.
  12041. */
  12042. camera: FreeCamera;
  12043. /**
  12044. * Defines the touch sensibility for rotation.
  12045. * The higher the faster.
  12046. */
  12047. touchAngularSensibility: number;
  12048. /**
  12049. * Defines the touch sensibility for move.
  12050. * The higher the faster.
  12051. */
  12052. touchMoveSensibility: number;
  12053. private _offsetX;
  12054. private _offsetY;
  12055. private _pointerPressed;
  12056. private _pointerInput;
  12057. private _observer;
  12058. private _onLostFocus;
  12059. /**
  12060. * Attach the input controls to a specific dom element to get the input from.
  12061. * @param element Defines the element the controls should be listened from
  12062. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12063. */
  12064. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12065. /**
  12066. * Detach the current controls from the specified dom element.
  12067. * @param element Defines the element to stop listening the inputs from
  12068. */
  12069. detachControl(element: Nullable<HTMLElement>): void;
  12070. /**
  12071. * Update the current camera state depending on the inputs that have been used this frame.
  12072. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12073. */
  12074. checkInputs(): void;
  12075. /**
  12076. * Gets the class name of the current intput.
  12077. * @returns the class name
  12078. */
  12079. getClassName(): string;
  12080. /**
  12081. * Get the friendly name associated with the input class.
  12082. * @returns the input friendly name
  12083. */
  12084. getSimpleName(): string;
  12085. }
  12086. }
  12087. declare module BABYLON {
  12088. /**
  12089. * Default Inputs manager for the FreeCamera.
  12090. * It groups all the default supported inputs for ease of use.
  12091. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12092. */
  12093. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12094. /**
  12095. * @hidden
  12096. */
  12097. _mouseInput: Nullable<FreeCameraMouseInput>;
  12098. /**
  12099. * Instantiates a new FreeCameraInputsManager.
  12100. * @param camera Defines the camera the inputs belong to
  12101. */
  12102. constructor(camera: FreeCamera);
  12103. /**
  12104. * Add keyboard input support to the input manager.
  12105. * @returns the current input manager
  12106. */
  12107. addKeyboard(): FreeCameraInputsManager;
  12108. /**
  12109. * Add mouse input support to the input manager.
  12110. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12111. * @returns the current input manager
  12112. */
  12113. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12114. /**
  12115. * Removes the mouse input support from the manager
  12116. * @returns the current input manager
  12117. */
  12118. removeMouse(): FreeCameraInputsManager;
  12119. /**
  12120. * Add touch input support to the input manager.
  12121. * @returns the current input manager
  12122. */
  12123. addTouch(): FreeCameraInputsManager;
  12124. /**
  12125. * Remove all attached input methods from a camera
  12126. */
  12127. clear(): void;
  12128. }
  12129. }
  12130. declare module BABYLON {
  12131. /**
  12132. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12133. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12134. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12135. */
  12136. export class FreeCamera extends TargetCamera {
  12137. /**
  12138. * Define the collision ellipsoid of the camera.
  12139. * This is helpful to simulate a camera body like the player body around the camera
  12140. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12141. */
  12142. ellipsoid: Vector3;
  12143. /**
  12144. * Define an offset for the position of the ellipsoid around the camera.
  12145. * This can be helpful to determine the center of the body near the gravity center of the body
  12146. * instead of its head.
  12147. */
  12148. ellipsoidOffset: Vector3;
  12149. /**
  12150. * Enable or disable collisions of the camera with the rest of the scene objects.
  12151. */
  12152. checkCollisions: boolean;
  12153. /**
  12154. * Enable or disable gravity on the camera.
  12155. */
  12156. applyGravity: boolean;
  12157. /**
  12158. * Define the input manager associated to the camera.
  12159. */
  12160. inputs: FreeCameraInputsManager;
  12161. /**
  12162. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12163. * Higher values reduce sensitivity.
  12164. */
  12165. /**
  12166. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12167. * Higher values reduce sensitivity.
  12168. */
  12169. angularSensibility: number;
  12170. /**
  12171. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12172. */
  12173. keysUp: number[];
  12174. /**
  12175. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12176. */
  12177. keysDown: number[];
  12178. /**
  12179. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12180. */
  12181. keysLeft: number[];
  12182. /**
  12183. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12184. */
  12185. keysRight: number[];
  12186. /**
  12187. * Event raised when the camera collide with a mesh in the scene.
  12188. */
  12189. onCollide: (collidedMesh: AbstractMesh) => void;
  12190. private _collider;
  12191. private _needMoveForGravity;
  12192. private _oldPosition;
  12193. private _diffPosition;
  12194. private _newPosition;
  12195. /** @hidden */
  12196. _localDirection: Vector3;
  12197. /** @hidden */
  12198. _transformedDirection: Vector3;
  12199. /**
  12200. * Instantiates a Free Camera.
  12201. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12202. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12203. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12204. * @param name Define the name of the camera in the scene
  12205. * @param position Define the start position of the camera in the scene
  12206. * @param scene Define the scene the camera belongs to
  12207. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12208. */
  12209. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12210. /**
  12211. * Attached controls to the current camera.
  12212. * @param element Defines the element the controls should be listened from
  12213. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12214. */
  12215. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12216. /**
  12217. * Detach the current controls from the camera.
  12218. * The camera will stop reacting to inputs.
  12219. * @param element Defines the element to stop listening the inputs from
  12220. */
  12221. detachControl(element: HTMLElement): void;
  12222. private _collisionMask;
  12223. /**
  12224. * Define a collision mask to limit the list of object the camera can collide with
  12225. */
  12226. collisionMask: number;
  12227. /** @hidden */
  12228. _collideWithWorld(displacement: Vector3): void;
  12229. private _onCollisionPositionChange;
  12230. /** @hidden */
  12231. _checkInputs(): void;
  12232. /** @hidden */
  12233. _decideIfNeedsToMove(): boolean;
  12234. /** @hidden */
  12235. _updatePosition(): void;
  12236. /**
  12237. * Destroy the camera and release the current resources hold by it.
  12238. */
  12239. dispose(): void;
  12240. /**
  12241. * Gets the current object class name.
  12242. * @return the class name
  12243. */
  12244. getClassName(): string;
  12245. }
  12246. }
  12247. declare module BABYLON {
  12248. /**
  12249. * Represents a gamepad control stick position
  12250. */
  12251. export class StickValues {
  12252. /**
  12253. * The x component of the control stick
  12254. */
  12255. x: number;
  12256. /**
  12257. * The y component of the control stick
  12258. */
  12259. y: number;
  12260. /**
  12261. * Initializes the gamepad x and y control stick values
  12262. * @param x The x component of the gamepad control stick value
  12263. * @param y The y component of the gamepad control stick value
  12264. */
  12265. constructor(
  12266. /**
  12267. * The x component of the control stick
  12268. */
  12269. x: number,
  12270. /**
  12271. * The y component of the control stick
  12272. */
  12273. y: number);
  12274. }
  12275. /**
  12276. * An interface which manages callbacks for gamepad button changes
  12277. */
  12278. export interface GamepadButtonChanges {
  12279. /**
  12280. * Called when a gamepad has been changed
  12281. */
  12282. changed: boolean;
  12283. /**
  12284. * Called when a gamepad press event has been triggered
  12285. */
  12286. pressChanged: boolean;
  12287. /**
  12288. * Called when a touch event has been triggered
  12289. */
  12290. touchChanged: boolean;
  12291. /**
  12292. * Called when a value has changed
  12293. */
  12294. valueChanged: boolean;
  12295. }
  12296. /**
  12297. * Represents a gamepad
  12298. */
  12299. export class Gamepad {
  12300. /**
  12301. * The id of the gamepad
  12302. */
  12303. id: string;
  12304. /**
  12305. * The index of the gamepad
  12306. */
  12307. index: number;
  12308. /**
  12309. * The browser gamepad
  12310. */
  12311. browserGamepad: any;
  12312. /**
  12313. * Specifies what type of gamepad this represents
  12314. */
  12315. type: number;
  12316. private _leftStick;
  12317. private _rightStick;
  12318. /** @hidden */
  12319. _isConnected: boolean;
  12320. private _leftStickAxisX;
  12321. private _leftStickAxisY;
  12322. private _rightStickAxisX;
  12323. private _rightStickAxisY;
  12324. /**
  12325. * Triggered when the left control stick has been changed
  12326. */
  12327. private _onleftstickchanged;
  12328. /**
  12329. * Triggered when the right control stick has been changed
  12330. */
  12331. private _onrightstickchanged;
  12332. /**
  12333. * Represents a gamepad controller
  12334. */
  12335. static GAMEPAD: number;
  12336. /**
  12337. * Represents a generic controller
  12338. */
  12339. static GENERIC: number;
  12340. /**
  12341. * Represents an XBox controller
  12342. */
  12343. static XBOX: number;
  12344. /**
  12345. * Represents a pose-enabled controller
  12346. */
  12347. static POSE_ENABLED: number;
  12348. /**
  12349. * Represents an Dual Shock controller
  12350. */
  12351. static DUALSHOCK: number;
  12352. /**
  12353. * Specifies whether the left control stick should be Y-inverted
  12354. */
  12355. protected _invertLeftStickY: boolean;
  12356. /**
  12357. * Specifies if the gamepad has been connected
  12358. */
  12359. readonly isConnected: boolean;
  12360. /**
  12361. * Initializes the gamepad
  12362. * @param id The id of the gamepad
  12363. * @param index The index of the gamepad
  12364. * @param browserGamepad The browser gamepad
  12365. * @param leftStickX The x component of the left joystick
  12366. * @param leftStickY The y component of the left joystick
  12367. * @param rightStickX The x component of the right joystick
  12368. * @param rightStickY The y component of the right joystick
  12369. */
  12370. constructor(
  12371. /**
  12372. * The id of the gamepad
  12373. */
  12374. id: string,
  12375. /**
  12376. * The index of the gamepad
  12377. */
  12378. index: number,
  12379. /**
  12380. * The browser gamepad
  12381. */
  12382. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12383. /**
  12384. * Callback triggered when the left joystick has changed
  12385. * @param callback
  12386. */
  12387. onleftstickchanged(callback: (values: StickValues) => void): void;
  12388. /**
  12389. * Callback triggered when the right joystick has changed
  12390. * @param callback
  12391. */
  12392. onrightstickchanged(callback: (values: StickValues) => void): void;
  12393. /**
  12394. * Gets the left joystick
  12395. */
  12396. /**
  12397. * Sets the left joystick values
  12398. */
  12399. leftStick: StickValues;
  12400. /**
  12401. * Gets the right joystick
  12402. */
  12403. /**
  12404. * Sets the right joystick value
  12405. */
  12406. rightStick: StickValues;
  12407. /**
  12408. * Updates the gamepad joystick positions
  12409. */
  12410. update(): void;
  12411. /**
  12412. * Disposes the gamepad
  12413. */
  12414. dispose(): void;
  12415. }
  12416. /**
  12417. * Represents a generic gamepad
  12418. */
  12419. export class GenericPad extends Gamepad {
  12420. private _buttons;
  12421. private _onbuttondown;
  12422. private _onbuttonup;
  12423. /**
  12424. * Observable triggered when a button has been pressed
  12425. */
  12426. onButtonDownObservable: Observable<number>;
  12427. /**
  12428. * Observable triggered when a button has been released
  12429. */
  12430. onButtonUpObservable: Observable<number>;
  12431. /**
  12432. * Callback triggered when a button has been pressed
  12433. * @param callback Called when a button has been pressed
  12434. */
  12435. onbuttondown(callback: (buttonPressed: number) => void): void;
  12436. /**
  12437. * Callback triggered when a button has been released
  12438. * @param callback Called when a button has been released
  12439. */
  12440. onbuttonup(callback: (buttonReleased: number) => void): void;
  12441. /**
  12442. * Initializes the generic gamepad
  12443. * @param id The id of the generic gamepad
  12444. * @param index The index of the generic gamepad
  12445. * @param browserGamepad The browser gamepad
  12446. */
  12447. constructor(id: string, index: number, browserGamepad: any);
  12448. private _setButtonValue;
  12449. /**
  12450. * Updates the generic gamepad
  12451. */
  12452. update(): void;
  12453. /**
  12454. * Disposes the generic gamepad
  12455. */
  12456. dispose(): void;
  12457. }
  12458. }
  12459. declare module BABYLON {
  12460. interface Engine {
  12461. /**
  12462. * Creates a raw texture
  12463. * @param data defines the data to store in the texture
  12464. * @param width defines the width of the texture
  12465. * @param height defines the height of the texture
  12466. * @param format defines the format of the data
  12467. * @param generateMipMaps defines if the engine should generate the mip levels
  12468. * @param invertY defines if data must be stored with Y axis inverted
  12469. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12470. * @param compression defines the compression used (null by default)
  12471. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12472. * @returns the raw texture inside an InternalTexture
  12473. */
  12474. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12475. /**
  12476. * Update a raw texture
  12477. * @param texture defines the texture to update
  12478. * @param data defines the data to store in the texture
  12479. * @param format defines the format of the data
  12480. * @param invertY defines if data must be stored with Y axis inverted
  12481. */
  12482. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12483. /**
  12484. * Update a raw texture
  12485. * @param texture defines the texture to update
  12486. * @param data defines the data to store in the texture
  12487. * @param format defines the format of the data
  12488. * @param invertY defines if data must be stored with Y axis inverted
  12489. * @param compression defines the compression used (null by default)
  12490. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12491. */
  12492. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12493. /**
  12494. * Creates a new raw cube texture
  12495. * @param data defines the array of data to use to create each face
  12496. * @param size defines the size of the textures
  12497. * @param format defines the format of the data
  12498. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12499. * @param generateMipMaps defines if the engine should generate the mip levels
  12500. * @param invertY defines if data must be stored with Y axis inverted
  12501. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12502. * @param compression defines the compression used (null by default)
  12503. * @returns the cube texture as an InternalTexture
  12504. */
  12505. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12506. /**
  12507. * Update a raw cube texture
  12508. * @param texture defines the texture to udpdate
  12509. * @param data defines the data to store
  12510. * @param format defines the data format
  12511. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12512. * @param invertY defines if data must be stored with Y axis inverted
  12513. */
  12514. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12515. /**
  12516. * Update a raw cube texture
  12517. * @param texture defines the texture to udpdate
  12518. * @param data defines the data to store
  12519. * @param format defines the data format
  12520. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12521. * @param invertY defines if data must be stored with Y axis inverted
  12522. * @param compression defines the compression used (null by default)
  12523. */
  12524. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12525. /**
  12526. * Update a raw cube texture
  12527. * @param texture defines the texture to udpdate
  12528. * @param data defines the data to store
  12529. * @param format defines the data format
  12530. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12531. * @param invertY defines if data must be stored with Y axis inverted
  12532. * @param compression defines the compression used (null by default)
  12533. * @param level defines which level of the texture to update
  12534. */
  12535. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12536. /**
  12537. * Creates a new raw cube texture from a specified url
  12538. * @param url defines the url where the data is located
  12539. * @param scene defines the current scene
  12540. * @param size defines the size of the textures
  12541. * @param format defines the format of the data
  12542. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12543. * @param noMipmap defines if the engine should avoid generating the mip levels
  12544. * @param callback defines a callback used to extract texture data from loaded data
  12545. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12546. * @param onLoad defines a callback called when texture is loaded
  12547. * @param onError defines a callback called if there is an error
  12548. * @returns the cube texture as an InternalTexture
  12549. */
  12550. 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;
  12551. /**
  12552. * Creates a new raw cube texture from a specified url
  12553. * @param url defines the url where the data is located
  12554. * @param scene defines the current scene
  12555. * @param size defines the size of the textures
  12556. * @param format defines the format of the data
  12557. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12558. * @param noMipmap defines if the engine should avoid generating the mip levels
  12559. * @param callback defines a callback used to extract texture data from loaded data
  12560. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12561. * @param onLoad defines a callback called when texture is loaded
  12562. * @param onError defines a callback called if there is an error
  12563. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12564. * @param invertY defines if data must be stored with Y axis inverted
  12565. * @returns the cube texture as an InternalTexture
  12566. */
  12567. 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;
  12568. /**
  12569. * Creates a new raw 3D texture
  12570. * @param data defines the data used to create the texture
  12571. * @param width defines the width of the texture
  12572. * @param height defines the height of the texture
  12573. * @param depth defines the depth of the texture
  12574. * @param format defines the format of the texture
  12575. * @param generateMipMaps defines if the engine must generate mip levels
  12576. * @param invertY defines if data must be stored with Y axis inverted
  12577. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12578. * @param compression defines the compressed used (can be null)
  12579. * @param textureType defines the compressed used (can be null)
  12580. * @returns a new raw 3D texture (stored in an InternalTexture)
  12581. */
  12582. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12583. /**
  12584. * Update a raw 3D texture
  12585. * @param texture defines the texture to update
  12586. * @param data defines the data to store
  12587. * @param format defines the data format
  12588. * @param invertY defines if data must be stored with Y axis inverted
  12589. */
  12590. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12591. /**
  12592. * Update a raw 3D texture
  12593. * @param texture defines the texture to update
  12594. * @param data defines the data to store
  12595. * @param format defines the data format
  12596. * @param invertY defines if data must be stored with Y axis inverted
  12597. * @param compression defines the used compression (can be null)
  12598. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12599. */
  12600. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12601. /**
  12602. * Creates a new raw 2D array texture
  12603. * @param data defines the data used to create the texture
  12604. * @param width defines the width of the texture
  12605. * @param height defines the height of the texture
  12606. * @param depth defines the number of layers of the texture
  12607. * @param format defines the format of the texture
  12608. * @param generateMipMaps defines if the engine must generate mip levels
  12609. * @param invertY defines if data must be stored with Y axis inverted
  12610. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12611. * @param compression defines the compressed used (can be null)
  12612. * @param textureType defines the compressed used (can be null)
  12613. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12614. */
  12615. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12616. /**
  12617. * Update a raw 2D array texture
  12618. * @param texture defines the texture to update
  12619. * @param data defines the data to store
  12620. * @param format defines the data format
  12621. * @param invertY defines if data must be stored with Y axis inverted
  12622. */
  12623. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12624. /**
  12625. * Update a raw 2D array texture
  12626. * @param texture defines the texture to update
  12627. * @param data defines the data to store
  12628. * @param format defines the data format
  12629. * @param invertY defines if data must be stored with Y axis inverted
  12630. * @param compression defines the used compression (can be null)
  12631. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12632. */
  12633. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12634. }
  12635. }
  12636. declare module BABYLON {
  12637. /**
  12638. * Raw texture can help creating a texture directly from an array of data.
  12639. * This can be super useful if you either get the data from an uncompressed source or
  12640. * if you wish to create your texture pixel by pixel.
  12641. */
  12642. export class RawTexture extends Texture {
  12643. /**
  12644. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12645. */
  12646. format: number;
  12647. private _engine;
  12648. /**
  12649. * Instantiates a new RawTexture.
  12650. * Raw texture can help creating a texture directly from an array of data.
  12651. * This can be super useful if you either get the data from an uncompressed source or
  12652. * if you wish to create your texture pixel by pixel.
  12653. * @param data define the array of data to use to create the texture
  12654. * @param width define the width of the texture
  12655. * @param height define the height of the texture
  12656. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12657. * @param scene define the scene the texture belongs to
  12658. * @param generateMipMaps define whether mip maps should be generated or not
  12659. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12660. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12661. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12662. */
  12663. constructor(data: ArrayBufferView, width: number, height: number,
  12664. /**
  12665. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12666. */
  12667. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12668. /**
  12669. * Updates the texture underlying data.
  12670. * @param data Define the new data of the texture
  12671. */
  12672. update(data: ArrayBufferView): void;
  12673. /**
  12674. * Creates a luminance texture from some data.
  12675. * @param data Define the texture data
  12676. * @param width Define the width of the texture
  12677. * @param height Define the height of the texture
  12678. * @param scene Define the scene the texture belongs to
  12679. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12680. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12681. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12682. * @returns the luminance texture
  12683. */
  12684. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12685. /**
  12686. * Creates a luminance alpha texture from some data.
  12687. * @param data Define the texture data
  12688. * @param width Define the width of the texture
  12689. * @param height Define the height of the texture
  12690. * @param scene Define the scene the texture belongs to
  12691. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12692. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12693. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12694. * @returns the luminance alpha texture
  12695. */
  12696. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12697. /**
  12698. * Creates an alpha texture from some data.
  12699. * @param data Define the texture data
  12700. * @param width Define the width of the texture
  12701. * @param height Define the height of the texture
  12702. * @param scene Define the scene the texture belongs to
  12703. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12704. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12705. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12706. * @returns the alpha texture
  12707. */
  12708. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12709. /**
  12710. * Creates a RGB texture from some data.
  12711. * @param data Define the texture data
  12712. * @param width Define the width of the texture
  12713. * @param height Define the height of the texture
  12714. * @param scene Define the scene the texture belongs to
  12715. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12716. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12717. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12718. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12719. * @returns the RGB alpha texture
  12720. */
  12721. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12722. /**
  12723. * Creates a RGBA texture from some data.
  12724. * @param data Define the texture data
  12725. * @param width Define the width of the texture
  12726. * @param height Define the height of the texture
  12727. * @param scene Define the scene the texture belongs to
  12728. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12729. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12730. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12731. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12732. * @returns the RGBA texture
  12733. */
  12734. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12735. /**
  12736. * Creates a R texture from some data.
  12737. * @param data Define the texture data
  12738. * @param width Define the width of the texture
  12739. * @param height Define the height of the texture
  12740. * @param scene Define the scene the texture belongs to
  12741. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12742. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12743. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12744. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12745. * @returns the R texture
  12746. */
  12747. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12748. }
  12749. }
  12750. declare module BABYLON {
  12751. /**
  12752. * Interface for the size containing width and height
  12753. */
  12754. export interface ISize {
  12755. /**
  12756. * Width
  12757. */
  12758. width: number;
  12759. /**
  12760. * Heighht
  12761. */
  12762. height: number;
  12763. }
  12764. /**
  12765. * Size containing widht and height
  12766. */
  12767. export class Size implements ISize {
  12768. /**
  12769. * Width
  12770. */
  12771. width: number;
  12772. /**
  12773. * Height
  12774. */
  12775. height: number;
  12776. /**
  12777. * Creates a Size object from the given width and height (floats).
  12778. * @param width width of the new size
  12779. * @param height height of the new size
  12780. */
  12781. constructor(width: number, height: number);
  12782. /**
  12783. * Returns a string with the Size width and height
  12784. * @returns a string with the Size width and height
  12785. */
  12786. toString(): string;
  12787. /**
  12788. * "Size"
  12789. * @returns the string "Size"
  12790. */
  12791. getClassName(): string;
  12792. /**
  12793. * Returns the Size hash code.
  12794. * @returns a hash code for a unique width and height
  12795. */
  12796. getHashCode(): number;
  12797. /**
  12798. * Updates the current size from the given one.
  12799. * @param src the given size
  12800. */
  12801. copyFrom(src: Size): void;
  12802. /**
  12803. * Updates in place the current Size from the given floats.
  12804. * @param width width of the new size
  12805. * @param height height of the new size
  12806. * @returns the updated Size.
  12807. */
  12808. copyFromFloats(width: number, height: number): Size;
  12809. /**
  12810. * Updates in place the current Size from the given floats.
  12811. * @param width width to set
  12812. * @param height height to set
  12813. * @returns the updated Size.
  12814. */
  12815. set(width: number, height: number): Size;
  12816. /**
  12817. * Multiplies the width and height by numbers
  12818. * @param w factor to multiple the width by
  12819. * @param h factor to multiple the height by
  12820. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12821. */
  12822. multiplyByFloats(w: number, h: number): Size;
  12823. /**
  12824. * Clones the size
  12825. * @returns a new Size copied from the given one.
  12826. */
  12827. clone(): Size;
  12828. /**
  12829. * True if the current Size and the given one width and height are strictly equal.
  12830. * @param other the other size to compare against
  12831. * @returns True if the current Size and the given one width and height are strictly equal.
  12832. */
  12833. equals(other: Size): boolean;
  12834. /**
  12835. * The surface of the Size : width * height (float).
  12836. */
  12837. readonly surface: number;
  12838. /**
  12839. * Create a new size of zero
  12840. * @returns a new Size set to (0.0, 0.0)
  12841. */
  12842. static Zero(): Size;
  12843. /**
  12844. * Sums the width and height of two sizes
  12845. * @param otherSize size to add to this size
  12846. * @returns a new Size set as the addition result of the current Size and the given one.
  12847. */
  12848. add(otherSize: Size): Size;
  12849. /**
  12850. * Subtracts the width and height of two
  12851. * @param otherSize size to subtract to this size
  12852. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12853. */
  12854. subtract(otherSize: Size): Size;
  12855. /**
  12856. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12857. * @param start starting size to lerp between
  12858. * @param end end size to lerp between
  12859. * @param amount amount to lerp between the start and end values
  12860. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12861. */
  12862. static Lerp(start: Size, end: Size, amount: number): Size;
  12863. }
  12864. }
  12865. declare module BABYLON {
  12866. /**
  12867. * Defines a runtime animation
  12868. */
  12869. export class RuntimeAnimation {
  12870. private _events;
  12871. /**
  12872. * The current frame of the runtime animation
  12873. */
  12874. private _currentFrame;
  12875. /**
  12876. * The animation used by the runtime animation
  12877. */
  12878. private _animation;
  12879. /**
  12880. * The target of the runtime animation
  12881. */
  12882. private _target;
  12883. /**
  12884. * The initiating animatable
  12885. */
  12886. private _host;
  12887. /**
  12888. * The original value of the runtime animation
  12889. */
  12890. private _originalValue;
  12891. /**
  12892. * The original blend value of the runtime animation
  12893. */
  12894. private _originalBlendValue;
  12895. /**
  12896. * The offsets cache of the runtime animation
  12897. */
  12898. private _offsetsCache;
  12899. /**
  12900. * The high limits cache of the runtime animation
  12901. */
  12902. private _highLimitsCache;
  12903. /**
  12904. * Specifies if the runtime animation has been stopped
  12905. */
  12906. private _stopped;
  12907. /**
  12908. * The blending factor of the runtime animation
  12909. */
  12910. private _blendingFactor;
  12911. /**
  12912. * The BabylonJS scene
  12913. */
  12914. private _scene;
  12915. /**
  12916. * The current value of the runtime animation
  12917. */
  12918. private _currentValue;
  12919. /** @hidden */
  12920. _animationState: _IAnimationState;
  12921. /**
  12922. * The active target of the runtime animation
  12923. */
  12924. private _activeTargets;
  12925. private _currentActiveTarget;
  12926. private _directTarget;
  12927. /**
  12928. * The target path of the runtime animation
  12929. */
  12930. private _targetPath;
  12931. /**
  12932. * The weight of the runtime animation
  12933. */
  12934. private _weight;
  12935. /**
  12936. * The ratio offset of the runtime animation
  12937. */
  12938. private _ratioOffset;
  12939. /**
  12940. * The previous delay of the runtime animation
  12941. */
  12942. private _previousDelay;
  12943. /**
  12944. * The previous ratio of the runtime animation
  12945. */
  12946. private _previousRatio;
  12947. private _enableBlending;
  12948. private _keys;
  12949. private _minFrame;
  12950. private _maxFrame;
  12951. private _minValue;
  12952. private _maxValue;
  12953. private _targetIsArray;
  12954. /**
  12955. * Gets the current frame of the runtime animation
  12956. */
  12957. readonly currentFrame: number;
  12958. /**
  12959. * Gets the weight of the runtime animation
  12960. */
  12961. readonly weight: number;
  12962. /**
  12963. * Gets the current value of the runtime animation
  12964. */
  12965. readonly currentValue: any;
  12966. /**
  12967. * Gets the target path of the runtime animation
  12968. */
  12969. readonly targetPath: string;
  12970. /**
  12971. * Gets the actual target of the runtime animation
  12972. */
  12973. readonly target: any;
  12974. /** @hidden */
  12975. _onLoop: () => void;
  12976. /**
  12977. * Create a new RuntimeAnimation object
  12978. * @param target defines the target of the animation
  12979. * @param animation defines the source animation object
  12980. * @param scene defines the hosting scene
  12981. * @param host defines the initiating Animatable
  12982. */
  12983. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12984. private _preparePath;
  12985. /**
  12986. * Gets the animation from the runtime animation
  12987. */
  12988. readonly animation: Animation;
  12989. /**
  12990. * Resets the runtime animation to the beginning
  12991. * @param restoreOriginal defines whether to restore the target property to the original value
  12992. */
  12993. reset(restoreOriginal?: boolean): void;
  12994. /**
  12995. * Specifies if the runtime animation is stopped
  12996. * @returns Boolean specifying if the runtime animation is stopped
  12997. */
  12998. isStopped(): boolean;
  12999. /**
  13000. * Disposes of the runtime animation
  13001. */
  13002. dispose(): void;
  13003. /**
  13004. * Apply the interpolated value to the target
  13005. * @param currentValue defines the value computed by the animation
  13006. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13007. */
  13008. setValue(currentValue: any, weight: number): void;
  13009. private _getOriginalValues;
  13010. private _setValue;
  13011. /**
  13012. * Gets the loop pmode of the runtime animation
  13013. * @returns Loop Mode
  13014. */
  13015. private _getCorrectLoopMode;
  13016. /**
  13017. * Move the current animation to a given frame
  13018. * @param frame defines the frame to move to
  13019. */
  13020. goToFrame(frame: number): void;
  13021. /**
  13022. * @hidden Internal use only
  13023. */
  13024. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13025. /**
  13026. * Execute the current animation
  13027. * @param delay defines the delay to add to the current frame
  13028. * @param from defines the lower bound of the animation range
  13029. * @param to defines the upper bound of the animation range
  13030. * @param loop defines if the current animation must loop
  13031. * @param speedRatio defines the current speed ratio
  13032. * @param weight defines the weight of the animation (default is -1 so no weight)
  13033. * @param onLoop optional callback called when animation loops
  13034. * @returns a boolean indicating if the animation is running
  13035. */
  13036. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13037. }
  13038. }
  13039. declare module BABYLON {
  13040. /**
  13041. * Class used to store an actual running animation
  13042. */
  13043. export class Animatable {
  13044. /** defines the target object */
  13045. target: any;
  13046. /** defines the starting frame number (default is 0) */
  13047. fromFrame: number;
  13048. /** defines the ending frame number (default is 100) */
  13049. toFrame: number;
  13050. /** defines if the animation must loop (default is false) */
  13051. loopAnimation: boolean;
  13052. /** defines a callback to call when animation ends if it is not looping */
  13053. onAnimationEnd?: (() => void) | null | undefined;
  13054. /** defines a callback to call when animation loops */
  13055. onAnimationLoop?: (() => void) | null | undefined;
  13056. private _localDelayOffset;
  13057. private _pausedDelay;
  13058. private _runtimeAnimations;
  13059. private _paused;
  13060. private _scene;
  13061. private _speedRatio;
  13062. private _weight;
  13063. private _syncRoot;
  13064. /**
  13065. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13066. * This will only apply for non looping animation (default is true)
  13067. */
  13068. disposeOnEnd: boolean;
  13069. /**
  13070. * Gets a boolean indicating if the animation has started
  13071. */
  13072. animationStarted: boolean;
  13073. /**
  13074. * Observer raised when the animation ends
  13075. */
  13076. onAnimationEndObservable: Observable<Animatable>;
  13077. /**
  13078. * Observer raised when the animation loops
  13079. */
  13080. onAnimationLoopObservable: Observable<Animatable>;
  13081. /**
  13082. * Gets the root Animatable used to synchronize and normalize animations
  13083. */
  13084. readonly syncRoot: Nullable<Animatable>;
  13085. /**
  13086. * Gets the current frame of the first RuntimeAnimation
  13087. * Used to synchronize Animatables
  13088. */
  13089. readonly masterFrame: number;
  13090. /**
  13091. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13092. */
  13093. weight: number;
  13094. /**
  13095. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13096. */
  13097. speedRatio: number;
  13098. /**
  13099. * Creates a new Animatable
  13100. * @param scene defines the hosting scene
  13101. * @param target defines the target object
  13102. * @param fromFrame defines the starting frame number (default is 0)
  13103. * @param toFrame defines the ending frame number (default is 100)
  13104. * @param loopAnimation defines if the animation must loop (default is false)
  13105. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13106. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13107. * @param animations defines a group of animation to add to the new Animatable
  13108. * @param onAnimationLoop defines a callback to call when animation loops
  13109. */
  13110. constructor(scene: Scene,
  13111. /** defines the target object */
  13112. target: any,
  13113. /** defines the starting frame number (default is 0) */
  13114. fromFrame?: number,
  13115. /** defines the ending frame number (default is 100) */
  13116. toFrame?: number,
  13117. /** defines if the animation must loop (default is false) */
  13118. loopAnimation?: boolean, speedRatio?: number,
  13119. /** defines a callback to call when animation ends if it is not looping */
  13120. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13121. /** defines a callback to call when animation loops */
  13122. onAnimationLoop?: (() => void) | null | undefined);
  13123. /**
  13124. * Synchronize and normalize current Animatable with a source Animatable
  13125. * This is useful when using animation weights and when animations are not of the same length
  13126. * @param root defines the root Animatable to synchronize with
  13127. * @returns the current Animatable
  13128. */
  13129. syncWith(root: Animatable): Animatable;
  13130. /**
  13131. * Gets the list of runtime animations
  13132. * @returns an array of RuntimeAnimation
  13133. */
  13134. getAnimations(): RuntimeAnimation[];
  13135. /**
  13136. * Adds more animations to the current animatable
  13137. * @param target defines the target of the animations
  13138. * @param animations defines the new animations to add
  13139. */
  13140. appendAnimations(target: any, animations: Animation[]): void;
  13141. /**
  13142. * Gets the source animation for a specific property
  13143. * @param property defines the propertyu to look for
  13144. * @returns null or the source animation for the given property
  13145. */
  13146. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13147. /**
  13148. * Gets the runtime animation for a specific property
  13149. * @param property defines the propertyu to look for
  13150. * @returns null or the runtime animation for the given property
  13151. */
  13152. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13153. /**
  13154. * Resets the animatable to its original state
  13155. */
  13156. reset(): void;
  13157. /**
  13158. * Allows the animatable to blend with current running animations
  13159. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13160. * @param blendingSpeed defines the blending speed to use
  13161. */
  13162. enableBlending(blendingSpeed: number): void;
  13163. /**
  13164. * Disable animation blending
  13165. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13166. */
  13167. disableBlending(): void;
  13168. /**
  13169. * Jump directly to a given frame
  13170. * @param frame defines the frame to jump to
  13171. */
  13172. goToFrame(frame: number): void;
  13173. /**
  13174. * Pause the animation
  13175. */
  13176. pause(): void;
  13177. /**
  13178. * Restart the animation
  13179. */
  13180. restart(): void;
  13181. private _raiseOnAnimationEnd;
  13182. /**
  13183. * Stop and delete the current animation
  13184. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13185. * @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)
  13186. */
  13187. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13188. /**
  13189. * Wait asynchronously for the animation to end
  13190. * @returns a promise which will be fullfilled when the animation ends
  13191. */
  13192. waitAsync(): Promise<Animatable>;
  13193. /** @hidden */
  13194. _animate(delay: number): boolean;
  13195. }
  13196. interface Scene {
  13197. /** @hidden */
  13198. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13199. /** @hidden */
  13200. _processLateAnimationBindingsForMatrices(holder: {
  13201. totalWeight: number;
  13202. animations: RuntimeAnimation[];
  13203. originalValue: Matrix;
  13204. }): any;
  13205. /** @hidden */
  13206. _processLateAnimationBindingsForQuaternions(holder: {
  13207. totalWeight: number;
  13208. animations: RuntimeAnimation[];
  13209. originalValue: Quaternion;
  13210. }, refQuaternion: Quaternion): Quaternion;
  13211. /** @hidden */
  13212. _processLateAnimationBindings(): void;
  13213. /**
  13214. * Will start the animation sequence of a given target
  13215. * @param target defines the target
  13216. * @param from defines from which frame should animation start
  13217. * @param to defines until which frame should animation run.
  13218. * @param weight defines the weight to apply to the animation (1.0 by default)
  13219. * @param loop defines if the animation loops
  13220. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13221. * @param onAnimationEnd defines the function to be executed when the animation ends
  13222. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13223. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13224. * @param onAnimationLoop defines the callback to call when an animation loops
  13225. * @returns the animatable object created for this animation
  13226. */
  13227. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13228. /**
  13229. * Will start the animation sequence of a given target
  13230. * @param target defines the target
  13231. * @param from defines from which frame should animation start
  13232. * @param to defines until which frame should animation run.
  13233. * @param loop defines if the animation loops
  13234. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13235. * @param onAnimationEnd defines the function to be executed when the animation ends
  13236. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13237. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13238. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13239. * @param onAnimationLoop defines the callback to call when an animation loops
  13240. * @returns the animatable object created for this animation
  13241. */
  13242. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13243. /**
  13244. * Will start the animation sequence of a given target and its hierarchy
  13245. * @param target defines the target
  13246. * @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.
  13247. * @param from defines from which frame should animation start
  13248. * @param to defines until which frame should animation run.
  13249. * @param loop defines if the animation loops
  13250. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13251. * @param onAnimationEnd defines the function to be executed when the animation ends
  13252. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13253. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13254. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13255. * @param onAnimationLoop defines the callback to call when an animation loops
  13256. * @returns the list of created animatables
  13257. */
  13258. 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[];
  13259. /**
  13260. * Begin a new animation on a given node
  13261. * @param target defines the target where the animation will take place
  13262. * @param animations defines the list of animations to start
  13263. * @param from defines the initial value
  13264. * @param to defines the final value
  13265. * @param loop defines if you want animation to loop (off by default)
  13266. * @param speedRatio defines the speed ratio to apply to all animations
  13267. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13268. * @param onAnimationLoop defines the callback to call when an animation loops
  13269. * @returns the list of created animatables
  13270. */
  13271. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13272. /**
  13273. * Begin a new animation on a given node and its hierarchy
  13274. * @param target defines the root node where the animation will take place
  13275. * @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.
  13276. * @param animations defines the list of animations to start
  13277. * @param from defines the initial value
  13278. * @param to defines the final value
  13279. * @param loop defines if you want animation to loop (off by default)
  13280. * @param speedRatio defines the speed ratio to apply to all animations
  13281. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13282. * @param onAnimationLoop defines the callback to call when an animation loops
  13283. * @returns the list of animatables created for all nodes
  13284. */
  13285. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13286. /**
  13287. * Gets the animatable associated with a specific target
  13288. * @param target defines the target of the animatable
  13289. * @returns the required animatable if found
  13290. */
  13291. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13292. /**
  13293. * Gets all animatables associated with a given target
  13294. * @param target defines the target to look animatables for
  13295. * @returns an array of Animatables
  13296. */
  13297. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13298. /**
  13299. * Stops and removes all animations that have been applied to the scene
  13300. */
  13301. stopAllAnimations(): void;
  13302. /**
  13303. * Gets the current delta time used by animation engine
  13304. */
  13305. deltaTime: number;
  13306. }
  13307. interface Bone {
  13308. /**
  13309. * Copy an animation range from another bone
  13310. * @param source defines the source bone
  13311. * @param rangeName defines the range name to copy
  13312. * @param frameOffset defines the frame offset
  13313. * @param rescaleAsRequired defines if rescaling must be applied if required
  13314. * @param skelDimensionsRatio defines the scaling ratio
  13315. * @returns true if operation was successful
  13316. */
  13317. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13318. }
  13319. }
  13320. declare module BABYLON {
  13321. /**
  13322. * Class used to override all child animations of a given target
  13323. */
  13324. export class AnimationPropertiesOverride {
  13325. /**
  13326. * Gets or sets a value indicating if animation blending must be used
  13327. */
  13328. enableBlending: boolean;
  13329. /**
  13330. * Gets or sets the blending speed to use when enableBlending is true
  13331. */
  13332. blendingSpeed: number;
  13333. /**
  13334. * Gets or sets the default loop mode to use
  13335. */
  13336. loopMode: number;
  13337. }
  13338. }
  13339. declare module BABYLON {
  13340. /**
  13341. * Class used to handle skinning animations
  13342. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13343. */
  13344. export class Skeleton implements IAnimatable {
  13345. /** defines the skeleton name */
  13346. name: string;
  13347. /** defines the skeleton Id */
  13348. id: string;
  13349. /**
  13350. * Defines the list of child bones
  13351. */
  13352. bones: Bone[];
  13353. /**
  13354. * Defines an estimate of the dimension of the skeleton at rest
  13355. */
  13356. dimensionsAtRest: Vector3;
  13357. /**
  13358. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13359. */
  13360. needInitialSkinMatrix: boolean;
  13361. /**
  13362. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13363. */
  13364. overrideMesh: Nullable<AbstractMesh>;
  13365. /**
  13366. * Gets the list of animations attached to this skeleton
  13367. */
  13368. animations: Array<Animation>;
  13369. private _scene;
  13370. private _isDirty;
  13371. private _transformMatrices;
  13372. private _transformMatrixTexture;
  13373. private _meshesWithPoseMatrix;
  13374. private _animatables;
  13375. private _identity;
  13376. private _synchronizedWithMesh;
  13377. private _ranges;
  13378. private _lastAbsoluteTransformsUpdateId;
  13379. private _canUseTextureForBones;
  13380. private _uniqueId;
  13381. /** @hidden */
  13382. _numBonesWithLinkedTransformNode: number;
  13383. /** @hidden */
  13384. _hasWaitingData: Nullable<boolean>;
  13385. /**
  13386. * Specifies if the skeleton should be serialized
  13387. */
  13388. doNotSerialize: boolean;
  13389. private _useTextureToStoreBoneMatrices;
  13390. /**
  13391. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13392. * Please note that this option is not available if the hardware does not support it
  13393. */
  13394. useTextureToStoreBoneMatrices: boolean;
  13395. private _animationPropertiesOverride;
  13396. /**
  13397. * Gets or sets the animation properties override
  13398. */
  13399. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13400. /**
  13401. * List of inspectable custom properties (used by the Inspector)
  13402. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13403. */
  13404. inspectableCustomProperties: IInspectable[];
  13405. /**
  13406. * An observable triggered before computing the skeleton's matrices
  13407. */
  13408. onBeforeComputeObservable: Observable<Skeleton>;
  13409. /**
  13410. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13411. */
  13412. readonly isUsingTextureForMatrices: boolean;
  13413. /**
  13414. * Gets the unique ID of this skeleton
  13415. */
  13416. readonly uniqueId: number;
  13417. /**
  13418. * Creates a new skeleton
  13419. * @param name defines the skeleton name
  13420. * @param id defines the skeleton Id
  13421. * @param scene defines the hosting scene
  13422. */
  13423. constructor(
  13424. /** defines the skeleton name */
  13425. name: string,
  13426. /** defines the skeleton Id */
  13427. id: string, scene: Scene);
  13428. /**
  13429. * Gets the current object class name.
  13430. * @return the class name
  13431. */
  13432. getClassName(): string;
  13433. /**
  13434. * Returns an array containing the root bones
  13435. * @returns an array containing the root bones
  13436. */
  13437. getChildren(): Array<Bone>;
  13438. /**
  13439. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13440. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13441. * @returns a Float32Array containing matrices data
  13442. */
  13443. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13444. /**
  13445. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13446. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13447. * @returns a raw texture containing the data
  13448. */
  13449. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13450. /**
  13451. * Gets the current hosting scene
  13452. * @returns a scene object
  13453. */
  13454. getScene(): Scene;
  13455. /**
  13456. * Gets a string representing the current skeleton data
  13457. * @param fullDetails defines a boolean indicating if we want a verbose version
  13458. * @returns a string representing the current skeleton data
  13459. */
  13460. toString(fullDetails?: boolean): string;
  13461. /**
  13462. * Get bone's index searching by name
  13463. * @param name defines bone's name to search for
  13464. * @return the indice of the bone. Returns -1 if not found
  13465. */
  13466. getBoneIndexByName(name: string): number;
  13467. /**
  13468. * Creater a new animation range
  13469. * @param name defines the name of the range
  13470. * @param from defines the start key
  13471. * @param to defines the end key
  13472. */
  13473. createAnimationRange(name: string, from: number, to: number): void;
  13474. /**
  13475. * Delete a specific animation range
  13476. * @param name defines the name of the range
  13477. * @param deleteFrames defines if frames must be removed as well
  13478. */
  13479. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13480. /**
  13481. * Gets a specific animation range
  13482. * @param name defines the name of the range to look for
  13483. * @returns the requested animation range or null if not found
  13484. */
  13485. getAnimationRange(name: string): Nullable<AnimationRange>;
  13486. /**
  13487. * Gets the list of all animation ranges defined on this skeleton
  13488. * @returns an array
  13489. */
  13490. getAnimationRanges(): Nullable<AnimationRange>[];
  13491. /**
  13492. * Copy animation range from a source skeleton.
  13493. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13494. * @param source defines the source skeleton
  13495. * @param name defines the name of the range to copy
  13496. * @param rescaleAsRequired defines if rescaling must be applied if required
  13497. * @returns true if operation was successful
  13498. */
  13499. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13500. /**
  13501. * Forces the skeleton to go to rest pose
  13502. */
  13503. returnToRest(): void;
  13504. private _getHighestAnimationFrame;
  13505. /**
  13506. * Begin a specific animation range
  13507. * @param name defines the name of the range to start
  13508. * @param loop defines if looping must be turned on (false by default)
  13509. * @param speedRatio defines the speed ratio to apply (1 by default)
  13510. * @param onAnimationEnd defines a callback which will be called when animation will end
  13511. * @returns a new animatable
  13512. */
  13513. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13514. /** @hidden */
  13515. _markAsDirty(): void;
  13516. /** @hidden */
  13517. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13518. /** @hidden */
  13519. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13520. private _computeTransformMatrices;
  13521. /**
  13522. * Build all resources required to render a skeleton
  13523. */
  13524. prepare(): void;
  13525. /**
  13526. * Gets the list of animatables currently running for this skeleton
  13527. * @returns an array of animatables
  13528. */
  13529. getAnimatables(): IAnimatable[];
  13530. /**
  13531. * Clone the current skeleton
  13532. * @param name defines the name of the new skeleton
  13533. * @param id defines the id of the new skeleton
  13534. * @returns the new skeleton
  13535. */
  13536. clone(name: string, id?: string): Skeleton;
  13537. /**
  13538. * Enable animation blending for this skeleton
  13539. * @param blendingSpeed defines the blending speed to apply
  13540. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13541. */
  13542. enableBlending(blendingSpeed?: number): void;
  13543. /**
  13544. * Releases all resources associated with the current skeleton
  13545. */
  13546. dispose(): void;
  13547. /**
  13548. * Serialize the skeleton in a JSON object
  13549. * @returns a JSON object
  13550. */
  13551. serialize(): any;
  13552. /**
  13553. * Creates a new skeleton from serialized data
  13554. * @param parsedSkeleton defines the serialized data
  13555. * @param scene defines the hosting scene
  13556. * @returns a new skeleton
  13557. */
  13558. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13559. /**
  13560. * Compute all node absolute transforms
  13561. * @param forceUpdate defines if computation must be done even if cache is up to date
  13562. */
  13563. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13564. /**
  13565. * Gets the root pose matrix
  13566. * @returns a matrix
  13567. */
  13568. getPoseMatrix(): Nullable<Matrix>;
  13569. /**
  13570. * Sorts bones per internal index
  13571. */
  13572. sortBones(): void;
  13573. private _sortBones;
  13574. }
  13575. }
  13576. declare module BABYLON {
  13577. /**
  13578. * Class used to store bone information
  13579. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13580. */
  13581. export class Bone extends Node {
  13582. /**
  13583. * defines the bone name
  13584. */
  13585. name: string;
  13586. private static _tmpVecs;
  13587. private static _tmpQuat;
  13588. private static _tmpMats;
  13589. /**
  13590. * Gets the list of child bones
  13591. */
  13592. children: Bone[];
  13593. /** Gets the animations associated with this bone */
  13594. animations: Animation[];
  13595. /**
  13596. * Gets or sets bone length
  13597. */
  13598. length: number;
  13599. /**
  13600. * @hidden Internal only
  13601. * Set this value to map this bone to a different index in the transform matrices
  13602. * Set this value to -1 to exclude the bone from the transform matrices
  13603. */
  13604. _index: Nullable<number>;
  13605. private _skeleton;
  13606. private _localMatrix;
  13607. private _restPose;
  13608. private _baseMatrix;
  13609. private _absoluteTransform;
  13610. private _invertedAbsoluteTransform;
  13611. private _parent;
  13612. private _scalingDeterminant;
  13613. private _worldTransform;
  13614. private _localScaling;
  13615. private _localRotation;
  13616. private _localPosition;
  13617. private _needToDecompose;
  13618. private _needToCompose;
  13619. /** @hidden */
  13620. _linkedTransformNode: Nullable<TransformNode>;
  13621. /** @hidden */
  13622. _waitingTransformNodeId: Nullable<string>;
  13623. /** @hidden */
  13624. /** @hidden */
  13625. _matrix: Matrix;
  13626. /**
  13627. * Create a new bone
  13628. * @param name defines the bone name
  13629. * @param skeleton defines the parent skeleton
  13630. * @param parentBone defines the parent (can be null if the bone is the root)
  13631. * @param localMatrix defines the local matrix
  13632. * @param restPose defines the rest pose matrix
  13633. * @param baseMatrix defines the base matrix
  13634. * @param index defines index of the bone in the hiearchy
  13635. */
  13636. constructor(
  13637. /**
  13638. * defines the bone name
  13639. */
  13640. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13641. /**
  13642. * Gets the current object class name.
  13643. * @return the class name
  13644. */
  13645. getClassName(): string;
  13646. /**
  13647. * Gets the parent skeleton
  13648. * @returns a skeleton
  13649. */
  13650. getSkeleton(): Skeleton;
  13651. /**
  13652. * Gets parent bone
  13653. * @returns a bone or null if the bone is the root of the bone hierarchy
  13654. */
  13655. getParent(): Nullable<Bone>;
  13656. /**
  13657. * Returns an array containing the root bones
  13658. * @returns an array containing the root bones
  13659. */
  13660. getChildren(): Array<Bone>;
  13661. /**
  13662. * Gets the node index in matrix array generated for rendering
  13663. * @returns the node index
  13664. */
  13665. getIndex(): number;
  13666. /**
  13667. * Sets the parent bone
  13668. * @param parent defines the parent (can be null if the bone is the root)
  13669. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13670. */
  13671. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13672. /**
  13673. * Gets the local matrix
  13674. * @returns a matrix
  13675. */
  13676. getLocalMatrix(): Matrix;
  13677. /**
  13678. * Gets the base matrix (initial matrix which remains unchanged)
  13679. * @returns a matrix
  13680. */
  13681. getBaseMatrix(): Matrix;
  13682. /**
  13683. * Gets the rest pose matrix
  13684. * @returns a matrix
  13685. */
  13686. getRestPose(): Matrix;
  13687. /**
  13688. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13689. */
  13690. getWorldMatrix(): Matrix;
  13691. /**
  13692. * Sets the local matrix to rest pose matrix
  13693. */
  13694. returnToRest(): void;
  13695. /**
  13696. * Gets the inverse of the absolute transform matrix.
  13697. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13698. * @returns a matrix
  13699. */
  13700. getInvertedAbsoluteTransform(): Matrix;
  13701. /**
  13702. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13703. * @returns a matrix
  13704. */
  13705. getAbsoluteTransform(): Matrix;
  13706. /**
  13707. * Links with the given transform node.
  13708. * The local matrix of this bone is copied from the transform node every frame.
  13709. * @param transformNode defines the transform node to link to
  13710. */
  13711. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13712. /**
  13713. * Gets the node used to drive the bone's transformation
  13714. * @returns a transform node or null
  13715. */
  13716. getTransformNode(): Nullable<TransformNode>;
  13717. /** Gets or sets current position (in local space) */
  13718. position: Vector3;
  13719. /** Gets or sets current rotation (in local space) */
  13720. rotation: Vector3;
  13721. /** Gets or sets current rotation quaternion (in local space) */
  13722. rotationQuaternion: Quaternion;
  13723. /** Gets or sets current scaling (in local space) */
  13724. scaling: Vector3;
  13725. /**
  13726. * Gets the animation properties override
  13727. */
  13728. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13729. private _decompose;
  13730. private _compose;
  13731. /**
  13732. * Update the base and local matrices
  13733. * @param matrix defines the new base or local matrix
  13734. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13735. * @param updateLocalMatrix defines if the local matrix should be updated
  13736. */
  13737. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13738. /** @hidden */
  13739. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13740. /**
  13741. * Flag the bone as dirty (Forcing it to update everything)
  13742. */
  13743. markAsDirty(): void;
  13744. /** @hidden */
  13745. _markAsDirtyAndCompose(): void;
  13746. private _markAsDirtyAndDecompose;
  13747. /**
  13748. * Translate the bone in local or world space
  13749. * @param vec The amount to translate the bone
  13750. * @param space The space that the translation is in
  13751. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13752. */
  13753. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13754. /**
  13755. * Set the postion of the bone in local or world space
  13756. * @param position The position to set the bone
  13757. * @param space The space that the position is in
  13758. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13759. */
  13760. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13761. /**
  13762. * Set the absolute position of the bone (world space)
  13763. * @param position The position to set the bone
  13764. * @param mesh The mesh that this bone is attached to
  13765. */
  13766. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13767. /**
  13768. * Scale the bone on the x, y and z axes (in local space)
  13769. * @param x The amount to scale the bone on the x axis
  13770. * @param y The amount to scale the bone on the y axis
  13771. * @param z The amount to scale the bone on the z axis
  13772. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13773. */
  13774. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13775. /**
  13776. * Set the bone scaling in local space
  13777. * @param scale defines the scaling vector
  13778. */
  13779. setScale(scale: Vector3): void;
  13780. /**
  13781. * Gets the current scaling in local space
  13782. * @returns the current scaling vector
  13783. */
  13784. getScale(): Vector3;
  13785. /**
  13786. * Gets the current scaling in local space and stores it in a target vector
  13787. * @param result defines the target vector
  13788. */
  13789. getScaleToRef(result: Vector3): void;
  13790. /**
  13791. * Set the yaw, pitch, and roll of the bone in local or world space
  13792. * @param yaw The rotation of the bone on the y axis
  13793. * @param pitch The rotation of the bone on the x axis
  13794. * @param roll The rotation of the bone on the z axis
  13795. * @param space The space that the axes of rotation are in
  13796. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13797. */
  13798. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13799. /**
  13800. * Add a rotation to the bone on an axis in local or world space
  13801. * @param axis The axis to rotate the bone on
  13802. * @param amount The amount to rotate the bone
  13803. * @param space The space that the axis is in
  13804. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13805. */
  13806. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13807. /**
  13808. * Set the rotation of the bone to a particular axis angle in local or world space
  13809. * @param axis The axis to rotate the bone on
  13810. * @param angle The angle that the bone should be rotated to
  13811. * @param space The space that the axis is in
  13812. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13813. */
  13814. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13815. /**
  13816. * Set the euler rotation of the bone in local of world space
  13817. * @param rotation The euler rotation that the bone should be set to
  13818. * @param space The space that the rotation is in
  13819. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13820. */
  13821. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13822. /**
  13823. * Set the quaternion rotation of the bone in local of world space
  13824. * @param quat The quaternion rotation that the bone should be set to
  13825. * @param space The space that the rotation is in
  13826. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13827. */
  13828. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13829. /**
  13830. * Set the rotation matrix of the bone in local of world space
  13831. * @param rotMat The rotation matrix that the bone should be set to
  13832. * @param space The space that the rotation is in
  13833. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13834. */
  13835. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13836. private _rotateWithMatrix;
  13837. private _getNegativeRotationToRef;
  13838. /**
  13839. * Get the position of the bone in local or world space
  13840. * @param space The space that the returned position is in
  13841. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13842. * @returns The position of the bone
  13843. */
  13844. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13845. /**
  13846. * Copy the position of the bone to a vector3 in local or world space
  13847. * @param space The space that the returned position is in
  13848. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13849. * @param result The vector3 to copy the position to
  13850. */
  13851. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13852. /**
  13853. * Get the absolute position of the bone (world space)
  13854. * @param mesh The mesh that this bone is attached to
  13855. * @returns The absolute position of the bone
  13856. */
  13857. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13858. /**
  13859. * Copy the absolute position of the bone (world space) to the result param
  13860. * @param mesh The mesh that this bone is attached to
  13861. * @param result The vector3 to copy the absolute position to
  13862. */
  13863. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13864. /**
  13865. * Compute the absolute transforms of this bone and its children
  13866. */
  13867. computeAbsoluteTransforms(): void;
  13868. /**
  13869. * Get the world direction from an axis that is in the local space of the bone
  13870. * @param localAxis The local direction that is used to compute the world direction
  13871. * @param mesh The mesh that this bone is attached to
  13872. * @returns The world direction
  13873. */
  13874. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13875. /**
  13876. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13877. * @param localAxis The local direction that is used to compute the world direction
  13878. * @param mesh The mesh that this bone is attached to
  13879. * @param result The vector3 that the world direction will be copied to
  13880. */
  13881. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13882. /**
  13883. * Get the euler rotation of the bone in local or world space
  13884. * @param space The space that the rotation should be in
  13885. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13886. * @returns The euler rotation
  13887. */
  13888. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13889. /**
  13890. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13891. * @param space The space that the rotation should be in
  13892. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13893. * @param result The vector3 that the rotation should be copied to
  13894. */
  13895. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13896. /**
  13897. * Get the quaternion rotation of the bone in either local or world space
  13898. * @param space The space that the rotation should be in
  13899. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13900. * @returns The quaternion rotation
  13901. */
  13902. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13903. /**
  13904. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13905. * @param space The space that the rotation should be in
  13906. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13907. * @param result The quaternion that the rotation should be copied to
  13908. */
  13909. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13910. /**
  13911. * Get the rotation matrix of the bone in local or world space
  13912. * @param space The space that the rotation should be in
  13913. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13914. * @returns The rotation matrix
  13915. */
  13916. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13917. /**
  13918. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13919. * @param space The space that the rotation should be in
  13920. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13921. * @param result The quaternion that the rotation should be copied to
  13922. */
  13923. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13924. /**
  13925. * Get the world position of a point that is in the local space of the bone
  13926. * @param position The local position
  13927. * @param mesh The mesh that this bone is attached to
  13928. * @returns The world position
  13929. */
  13930. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13931. /**
  13932. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13933. * @param position The local position
  13934. * @param mesh The mesh that this bone is attached to
  13935. * @param result The vector3 that the world position should be copied to
  13936. */
  13937. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13938. /**
  13939. * Get the local position of a point that is in world space
  13940. * @param position The world position
  13941. * @param mesh The mesh that this bone is attached to
  13942. * @returns The local position
  13943. */
  13944. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13945. /**
  13946. * Get the local position of a point that is in world space and copy it to the result param
  13947. * @param position The world position
  13948. * @param mesh The mesh that this bone is attached to
  13949. * @param result The vector3 that the local position should be copied to
  13950. */
  13951. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13952. }
  13953. }
  13954. declare module BABYLON {
  13955. /**
  13956. * 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.
  13957. * @see https://doc.babylonjs.com/how_to/transformnode
  13958. */
  13959. export class TransformNode extends Node {
  13960. /**
  13961. * Object will not rotate to face the camera
  13962. */
  13963. static BILLBOARDMODE_NONE: number;
  13964. /**
  13965. * Object will rotate to face the camera but only on the x axis
  13966. */
  13967. static BILLBOARDMODE_X: number;
  13968. /**
  13969. * Object will rotate to face the camera but only on the y axis
  13970. */
  13971. static BILLBOARDMODE_Y: number;
  13972. /**
  13973. * Object will rotate to face the camera but only on the z axis
  13974. */
  13975. static BILLBOARDMODE_Z: number;
  13976. /**
  13977. * Object will rotate to face the camera
  13978. */
  13979. static BILLBOARDMODE_ALL: number;
  13980. /**
  13981. * Object will rotate to face the camera's position instead of orientation
  13982. */
  13983. static BILLBOARDMODE_USE_POSITION: number;
  13984. private _forward;
  13985. private _forwardInverted;
  13986. private _up;
  13987. private _right;
  13988. private _rightInverted;
  13989. private _position;
  13990. private _rotation;
  13991. private _rotationQuaternion;
  13992. protected _scaling: Vector3;
  13993. protected _isDirty: boolean;
  13994. private _transformToBoneReferal;
  13995. private _isAbsoluteSynced;
  13996. private _billboardMode;
  13997. /**
  13998. * Gets or sets the billboard mode. Default is 0.
  13999. *
  14000. * | Value | Type | Description |
  14001. * | --- | --- | --- |
  14002. * | 0 | BILLBOARDMODE_NONE | |
  14003. * | 1 | BILLBOARDMODE_X | |
  14004. * | 2 | BILLBOARDMODE_Y | |
  14005. * | 4 | BILLBOARDMODE_Z | |
  14006. * | 7 | BILLBOARDMODE_ALL | |
  14007. *
  14008. */
  14009. billboardMode: number;
  14010. private _preserveParentRotationForBillboard;
  14011. /**
  14012. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14013. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14014. */
  14015. preserveParentRotationForBillboard: boolean;
  14016. /**
  14017. * 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
  14018. */
  14019. scalingDeterminant: number;
  14020. private _infiniteDistance;
  14021. /**
  14022. * Gets or sets the distance of the object to max, often used by skybox
  14023. */
  14024. infiniteDistance: boolean;
  14025. /**
  14026. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14027. * By default the system will update normals to compensate
  14028. */
  14029. ignoreNonUniformScaling: boolean;
  14030. /**
  14031. * 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
  14032. */
  14033. reIntegrateRotationIntoRotationQuaternion: boolean;
  14034. /** @hidden */
  14035. _poseMatrix: Nullable<Matrix>;
  14036. /** @hidden */
  14037. _localMatrix: Matrix;
  14038. private _usePivotMatrix;
  14039. private _absolutePosition;
  14040. private _absoluteScaling;
  14041. private _absoluteRotationQuaternion;
  14042. private _pivotMatrix;
  14043. private _pivotMatrixInverse;
  14044. protected _postMultiplyPivotMatrix: boolean;
  14045. protected _isWorldMatrixFrozen: boolean;
  14046. /** @hidden */
  14047. _indexInSceneTransformNodesArray: number;
  14048. /**
  14049. * An event triggered after the world matrix is updated
  14050. */
  14051. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14052. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14053. /**
  14054. * Gets a string identifying the name of the class
  14055. * @returns "TransformNode" string
  14056. */
  14057. getClassName(): string;
  14058. /**
  14059. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14060. */
  14061. position: Vector3;
  14062. /**
  14063. * 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)).
  14064. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14065. */
  14066. rotation: Vector3;
  14067. /**
  14068. * 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)).
  14069. */
  14070. scaling: Vector3;
  14071. /**
  14072. * 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).
  14073. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14074. */
  14075. rotationQuaternion: Nullable<Quaternion>;
  14076. /**
  14077. * The forward direction of that transform in world space.
  14078. */
  14079. readonly forward: Vector3;
  14080. /**
  14081. * The up direction of that transform in world space.
  14082. */
  14083. readonly up: Vector3;
  14084. /**
  14085. * The right direction of that transform in world space.
  14086. */
  14087. readonly right: Vector3;
  14088. /**
  14089. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14090. * @param matrix the matrix to copy the pose from
  14091. * @returns this TransformNode.
  14092. */
  14093. updatePoseMatrix(matrix: Matrix): TransformNode;
  14094. /**
  14095. * Returns the mesh Pose matrix.
  14096. * @returns the pose matrix
  14097. */
  14098. getPoseMatrix(): Matrix;
  14099. /** @hidden */
  14100. _isSynchronized(): boolean;
  14101. /** @hidden */
  14102. _initCache(): void;
  14103. /**
  14104. * Flag the transform node as dirty (Forcing it to update everything)
  14105. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14106. * @returns this transform node
  14107. */
  14108. markAsDirty(property: string): TransformNode;
  14109. /**
  14110. * Returns the current mesh absolute position.
  14111. * Returns a Vector3.
  14112. */
  14113. readonly absolutePosition: Vector3;
  14114. /**
  14115. * Returns the current mesh absolute scaling.
  14116. * Returns a Vector3.
  14117. */
  14118. readonly absoluteScaling: Vector3;
  14119. /**
  14120. * Returns the current mesh absolute rotation.
  14121. * Returns a Quaternion.
  14122. */
  14123. readonly absoluteRotationQuaternion: Quaternion;
  14124. /**
  14125. * Sets a new matrix to apply before all other transformation
  14126. * @param matrix defines the transform matrix
  14127. * @returns the current TransformNode
  14128. */
  14129. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14130. /**
  14131. * Sets a new pivot matrix to the current node
  14132. * @param matrix defines the new pivot matrix to use
  14133. * @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
  14134. * @returns the current TransformNode
  14135. */
  14136. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14137. /**
  14138. * Returns the mesh pivot matrix.
  14139. * Default : Identity.
  14140. * @returns the matrix
  14141. */
  14142. getPivotMatrix(): Matrix;
  14143. /**
  14144. * Instantiate (when possible) or clone that node with its hierarchy
  14145. * @param newParent defines the new parent to use for the instance (or clone)
  14146. * @param options defines options to configure how copy is done
  14147. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14148. * @returns an instance (or a clone) of the current node with its hiearchy
  14149. */
  14150. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14151. doNotInstantiate: boolean;
  14152. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14153. /**
  14154. * Prevents the World matrix to be computed any longer
  14155. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14156. * @returns the TransformNode.
  14157. */
  14158. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14159. /**
  14160. * Allows back the World matrix computation.
  14161. * @returns the TransformNode.
  14162. */
  14163. unfreezeWorldMatrix(): this;
  14164. /**
  14165. * True if the World matrix has been frozen.
  14166. */
  14167. readonly isWorldMatrixFrozen: boolean;
  14168. /**
  14169. * Retuns the mesh absolute position in the World.
  14170. * @returns a Vector3.
  14171. */
  14172. getAbsolutePosition(): Vector3;
  14173. /**
  14174. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14175. * @param absolutePosition the absolute position to set
  14176. * @returns the TransformNode.
  14177. */
  14178. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14179. /**
  14180. * Sets the mesh position in its local space.
  14181. * @param vector3 the position to set in localspace
  14182. * @returns the TransformNode.
  14183. */
  14184. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14185. /**
  14186. * Returns the mesh position in the local space from the current World matrix values.
  14187. * @returns a new Vector3.
  14188. */
  14189. getPositionExpressedInLocalSpace(): Vector3;
  14190. /**
  14191. * Translates the mesh along the passed Vector3 in its local space.
  14192. * @param vector3 the distance to translate in localspace
  14193. * @returns the TransformNode.
  14194. */
  14195. locallyTranslate(vector3: Vector3): TransformNode;
  14196. private static _lookAtVectorCache;
  14197. /**
  14198. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14199. * @param targetPoint the position (must be in same space as current mesh) to look at
  14200. * @param yawCor optional yaw (y-axis) correction in radians
  14201. * @param pitchCor optional pitch (x-axis) correction in radians
  14202. * @param rollCor optional roll (z-axis) correction in radians
  14203. * @param space the choosen space of the target
  14204. * @returns the TransformNode.
  14205. */
  14206. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14207. /**
  14208. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14209. * This Vector3 is expressed in the World space.
  14210. * @param localAxis axis to rotate
  14211. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14212. */
  14213. getDirection(localAxis: Vector3): Vector3;
  14214. /**
  14215. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14216. * localAxis is expressed in the mesh local space.
  14217. * result is computed in the Wordl space from the mesh World matrix.
  14218. * @param localAxis axis to rotate
  14219. * @param result the resulting transformnode
  14220. * @returns this TransformNode.
  14221. */
  14222. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14223. /**
  14224. * Sets this transform node rotation to the given local axis.
  14225. * @param localAxis the axis in local space
  14226. * @param yawCor optional yaw (y-axis) correction in radians
  14227. * @param pitchCor optional pitch (x-axis) correction in radians
  14228. * @param rollCor optional roll (z-axis) correction in radians
  14229. * @returns this TransformNode
  14230. */
  14231. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14232. /**
  14233. * Sets a new pivot point to the current node
  14234. * @param point defines the new pivot point to use
  14235. * @param space defines if the point is in world or local space (local by default)
  14236. * @returns the current TransformNode
  14237. */
  14238. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14239. /**
  14240. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14241. * @returns the pivot point
  14242. */
  14243. getPivotPoint(): Vector3;
  14244. /**
  14245. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14246. * @param result the vector3 to store the result
  14247. * @returns this TransformNode.
  14248. */
  14249. getPivotPointToRef(result: Vector3): TransformNode;
  14250. /**
  14251. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14252. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14253. */
  14254. getAbsolutePivotPoint(): Vector3;
  14255. /**
  14256. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14257. * @param result vector3 to store the result
  14258. * @returns this TransformNode.
  14259. */
  14260. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14261. /**
  14262. * Defines the passed node as the parent of the current node.
  14263. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14264. * @see https://doc.babylonjs.com/how_to/parenting
  14265. * @param node the node ot set as the parent
  14266. * @returns this TransformNode.
  14267. */
  14268. setParent(node: Nullable<Node>): TransformNode;
  14269. private _nonUniformScaling;
  14270. /**
  14271. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14272. */
  14273. readonly nonUniformScaling: boolean;
  14274. /** @hidden */
  14275. _updateNonUniformScalingState(value: boolean): boolean;
  14276. /**
  14277. * Attach the current TransformNode to another TransformNode associated with a bone
  14278. * @param bone Bone affecting the TransformNode
  14279. * @param affectedTransformNode TransformNode associated with the bone
  14280. * @returns this object
  14281. */
  14282. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14283. /**
  14284. * Detach the transform node if its associated with a bone
  14285. * @returns this object
  14286. */
  14287. detachFromBone(): TransformNode;
  14288. private static _rotationAxisCache;
  14289. /**
  14290. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14291. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14292. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14293. * The passed axis is also normalized.
  14294. * @param axis the axis to rotate around
  14295. * @param amount the amount to rotate in radians
  14296. * @param space Space to rotate in (Default: local)
  14297. * @returns the TransformNode.
  14298. */
  14299. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14300. /**
  14301. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14302. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14303. * The passed axis is also normalized. .
  14304. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14305. * @param point the point to rotate around
  14306. * @param axis the axis to rotate around
  14307. * @param amount the amount to rotate in radians
  14308. * @returns the TransformNode
  14309. */
  14310. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14311. /**
  14312. * Translates the mesh along the axis vector for the passed distance in the given space.
  14313. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14314. * @param axis the axis to translate in
  14315. * @param distance the distance to translate
  14316. * @param space Space to rotate in (Default: local)
  14317. * @returns the TransformNode.
  14318. */
  14319. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14320. /**
  14321. * Adds a rotation step to the mesh current rotation.
  14322. * x, y, z are Euler angles expressed in radians.
  14323. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14324. * This means this rotation is made in the mesh local space only.
  14325. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14326. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14327. * ```javascript
  14328. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14329. * ```
  14330. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14331. * 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.
  14332. * @param x Rotation to add
  14333. * @param y Rotation to add
  14334. * @param z Rotation to add
  14335. * @returns the TransformNode.
  14336. */
  14337. addRotation(x: number, y: number, z: number): TransformNode;
  14338. /**
  14339. * @hidden
  14340. */
  14341. protected _getEffectiveParent(): Nullable<Node>;
  14342. /**
  14343. * Computes the world matrix of the node
  14344. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14345. * @returns the world matrix
  14346. */
  14347. computeWorldMatrix(force?: boolean): Matrix;
  14348. protected _afterComputeWorldMatrix(): void;
  14349. /**
  14350. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14351. * @param func callback function to add
  14352. *
  14353. * @returns the TransformNode.
  14354. */
  14355. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14356. /**
  14357. * Removes a registered callback function.
  14358. * @param func callback function to remove
  14359. * @returns the TransformNode.
  14360. */
  14361. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14362. /**
  14363. * Gets the position of the current mesh in camera space
  14364. * @param camera defines the camera to use
  14365. * @returns a position
  14366. */
  14367. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14368. /**
  14369. * Returns the distance from the mesh to the active camera
  14370. * @param camera defines the camera to use
  14371. * @returns the distance
  14372. */
  14373. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14374. /**
  14375. * Clone the current transform node
  14376. * @param name Name of the new clone
  14377. * @param newParent New parent for the clone
  14378. * @param doNotCloneChildren Do not clone children hierarchy
  14379. * @returns the new transform node
  14380. */
  14381. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14382. /**
  14383. * Serializes the objects information.
  14384. * @param currentSerializationObject defines the object to serialize in
  14385. * @returns the serialized object
  14386. */
  14387. serialize(currentSerializationObject?: any): any;
  14388. /**
  14389. * Returns a new TransformNode object parsed from the source provided.
  14390. * @param parsedTransformNode is the source.
  14391. * @param scene the scne the object belongs to
  14392. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14393. * @returns a new TransformNode object parsed from the source provided.
  14394. */
  14395. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14396. /**
  14397. * Get all child-transformNodes of this node
  14398. * @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
  14399. * @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
  14400. * @returns an array of TransformNode
  14401. */
  14402. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14403. /**
  14404. * Releases resources associated with this transform node.
  14405. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14406. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14407. */
  14408. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14409. /**
  14410. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14411. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14412. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14413. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14414. * @returns the current mesh
  14415. */
  14416. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14417. private _syncAbsoluteScalingAndRotation;
  14418. }
  14419. }
  14420. declare module BABYLON {
  14421. /**
  14422. * Defines the types of pose enabled controllers that are supported
  14423. */
  14424. export enum PoseEnabledControllerType {
  14425. /**
  14426. * HTC Vive
  14427. */
  14428. VIVE = 0,
  14429. /**
  14430. * Oculus Rift
  14431. */
  14432. OCULUS = 1,
  14433. /**
  14434. * Windows mixed reality
  14435. */
  14436. WINDOWS = 2,
  14437. /**
  14438. * Samsung gear VR
  14439. */
  14440. GEAR_VR = 3,
  14441. /**
  14442. * Google Daydream
  14443. */
  14444. DAYDREAM = 4,
  14445. /**
  14446. * Generic
  14447. */
  14448. GENERIC = 5
  14449. }
  14450. /**
  14451. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14452. */
  14453. export interface MutableGamepadButton {
  14454. /**
  14455. * Value of the button/trigger
  14456. */
  14457. value: number;
  14458. /**
  14459. * If the button/trigger is currently touched
  14460. */
  14461. touched: boolean;
  14462. /**
  14463. * If the button/trigger is currently pressed
  14464. */
  14465. pressed: boolean;
  14466. }
  14467. /**
  14468. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14469. * @hidden
  14470. */
  14471. export interface ExtendedGamepadButton extends GamepadButton {
  14472. /**
  14473. * If the button/trigger is currently pressed
  14474. */
  14475. readonly pressed: boolean;
  14476. /**
  14477. * If the button/trigger is currently touched
  14478. */
  14479. readonly touched: boolean;
  14480. /**
  14481. * Value of the button/trigger
  14482. */
  14483. readonly value: number;
  14484. }
  14485. /** @hidden */
  14486. export interface _GamePadFactory {
  14487. /**
  14488. * Returns wether or not the current gamepad can be created for this type of controller.
  14489. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14490. * @returns true if it can be created, otherwise false
  14491. */
  14492. canCreate(gamepadInfo: any): boolean;
  14493. /**
  14494. * Creates a new instance of the Gamepad.
  14495. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14496. * @returns the new gamepad instance
  14497. */
  14498. create(gamepadInfo: any): Gamepad;
  14499. }
  14500. /**
  14501. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14502. */
  14503. export class PoseEnabledControllerHelper {
  14504. /** @hidden */
  14505. static _ControllerFactories: _GamePadFactory[];
  14506. /** @hidden */
  14507. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14508. /**
  14509. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14510. * @param vrGamepad the gamepad to initialized
  14511. * @returns a vr controller of the type the gamepad identified as
  14512. */
  14513. static InitiateController(vrGamepad: any): Gamepad;
  14514. }
  14515. /**
  14516. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14517. */
  14518. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14519. /**
  14520. * If the controller is used in a webXR session
  14521. */
  14522. isXR: boolean;
  14523. private _deviceRoomPosition;
  14524. private _deviceRoomRotationQuaternion;
  14525. /**
  14526. * The device position in babylon space
  14527. */
  14528. devicePosition: Vector3;
  14529. /**
  14530. * The device rotation in babylon space
  14531. */
  14532. deviceRotationQuaternion: Quaternion;
  14533. /**
  14534. * The scale factor of the device in babylon space
  14535. */
  14536. deviceScaleFactor: number;
  14537. /**
  14538. * (Likely devicePosition should be used instead) The device position in its room space
  14539. */
  14540. position: Vector3;
  14541. /**
  14542. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14543. */
  14544. rotationQuaternion: Quaternion;
  14545. /**
  14546. * The type of controller (Eg. Windows mixed reality)
  14547. */
  14548. controllerType: PoseEnabledControllerType;
  14549. protected _calculatedPosition: Vector3;
  14550. private _calculatedRotation;
  14551. /**
  14552. * The raw pose from the device
  14553. */
  14554. rawPose: DevicePose;
  14555. private _trackPosition;
  14556. private _maxRotationDistFromHeadset;
  14557. private _draggedRoomRotation;
  14558. /**
  14559. * @hidden
  14560. */
  14561. _disableTrackPosition(fixedPosition: Vector3): void;
  14562. /**
  14563. * Internal, the mesh attached to the controller
  14564. * @hidden
  14565. */
  14566. _mesh: Nullable<AbstractMesh>;
  14567. private _poseControlledCamera;
  14568. private _leftHandSystemQuaternion;
  14569. /**
  14570. * Internal, matrix used to convert room space to babylon space
  14571. * @hidden
  14572. */
  14573. _deviceToWorld: Matrix;
  14574. /**
  14575. * Node to be used when casting a ray from the controller
  14576. * @hidden
  14577. */
  14578. _pointingPoseNode: Nullable<TransformNode>;
  14579. /**
  14580. * Name of the child mesh that can be used to cast a ray from the controller
  14581. */
  14582. static readonly POINTING_POSE: string;
  14583. /**
  14584. * Creates a new PoseEnabledController from a gamepad
  14585. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14586. */
  14587. constructor(browserGamepad: any);
  14588. private _workingMatrix;
  14589. /**
  14590. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14591. */
  14592. update(): void;
  14593. /**
  14594. * Updates only the pose device and mesh without doing any button event checking
  14595. */
  14596. protected _updatePoseAndMesh(): void;
  14597. /**
  14598. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14599. * @param poseData raw pose fromthe device
  14600. */
  14601. updateFromDevice(poseData: DevicePose): void;
  14602. /**
  14603. * @hidden
  14604. */
  14605. _meshAttachedObservable: Observable<AbstractMesh>;
  14606. /**
  14607. * Attaches a mesh to the controller
  14608. * @param mesh the mesh to be attached
  14609. */
  14610. attachToMesh(mesh: AbstractMesh): void;
  14611. /**
  14612. * Attaches the controllers mesh to a camera
  14613. * @param camera the camera the mesh should be attached to
  14614. */
  14615. attachToPoseControlledCamera(camera: TargetCamera): void;
  14616. /**
  14617. * Disposes of the controller
  14618. */
  14619. dispose(): void;
  14620. /**
  14621. * The mesh that is attached to the controller
  14622. */
  14623. readonly mesh: Nullable<AbstractMesh>;
  14624. /**
  14625. * Gets the ray of the controller in the direction the controller is pointing
  14626. * @param length the length the resulting ray should be
  14627. * @returns a ray in the direction the controller is pointing
  14628. */
  14629. getForwardRay(length?: number): Ray;
  14630. }
  14631. }
  14632. declare module BABYLON {
  14633. /**
  14634. * Defines the WebVRController object that represents controllers tracked in 3D space
  14635. */
  14636. export abstract class WebVRController extends PoseEnabledController {
  14637. /**
  14638. * Internal, the default controller model for the controller
  14639. */
  14640. protected _defaultModel: Nullable<AbstractMesh>;
  14641. /**
  14642. * Fired when the trigger state has changed
  14643. */
  14644. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14645. /**
  14646. * Fired when the main button state has changed
  14647. */
  14648. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14649. /**
  14650. * Fired when the secondary button state has changed
  14651. */
  14652. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14653. /**
  14654. * Fired when the pad state has changed
  14655. */
  14656. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14657. /**
  14658. * Fired when controllers stick values have changed
  14659. */
  14660. onPadValuesChangedObservable: Observable<StickValues>;
  14661. /**
  14662. * Array of button availible on the controller
  14663. */
  14664. protected _buttons: Array<MutableGamepadButton>;
  14665. private _onButtonStateChange;
  14666. /**
  14667. * Fired when a controller button's state has changed
  14668. * @param callback the callback containing the button that was modified
  14669. */
  14670. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14671. /**
  14672. * X and Y axis corresponding to the controllers joystick
  14673. */
  14674. pad: StickValues;
  14675. /**
  14676. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14677. */
  14678. hand: string;
  14679. /**
  14680. * The default controller model for the controller
  14681. */
  14682. readonly defaultModel: Nullable<AbstractMesh>;
  14683. /**
  14684. * Creates a new WebVRController from a gamepad
  14685. * @param vrGamepad the gamepad that the WebVRController should be created from
  14686. */
  14687. constructor(vrGamepad: any);
  14688. /**
  14689. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14690. */
  14691. update(): void;
  14692. /**
  14693. * Function to be called when a button is modified
  14694. */
  14695. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14696. /**
  14697. * Loads a mesh and attaches it to the controller
  14698. * @param scene the scene the mesh should be added to
  14699. * @param meshLoaded callback for when the mesh has been loaded
  14700. */
  14701. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14702. private _setButtonValue;
  14703. private _changes;
  14704. private _checkChanges;
  14705. /**
  14706. * Disposes of th webVRCOntroller
  14707. */
  14708. dispose(): void;
  14709. }
  14710. }
  14711. declare module BABYLON {
  14712. /**
  14713. * The HemisphericLight simulates the ambient environment light,
  14714. * so the passed direction is the light reflection direction, not the incoming direction.
  14715. */
  14716. export class HemisphericLight extends Light {
  14717. /**
  14718. * The groundColor is the light in the opposite direction to the one specified during creation.
  14719. * 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.
  14720. */
  14721. groundColor: Color3;
  14722. /**
  14723. * The light reflection direction, not the incoming direction.
  14724. */
  14725. direction: Vector3;
  14726. /**
  14727. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14728. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14729. * The HemisphericLight can't cast shadows.
  14730. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14731. * @param name The friendly name of the light
  14732. * @param direction The direction of the light reflection
  14733. * @param scene The scene the light belongs to
  14734. */
  14735. constructor(name: string, direction: Vector3, scene: Scene);
  14736. protected _buildUniformLayout(): void;
  14737. /**
  14738. * Returns the string "HemisphericLight".
  14739. * @return The class name
  14740. */
  14741. getClassName(): string;
  14742. /**
  14743. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14744. * Returns the updated direction.
  14745. * @param target The target the direction should point to
  14746. * @return The computed direction
  14747. */
  14748. setDirectionToTarget(target: Vector3): Vector3;
  14749. /**
  14750. * Returns the shadow generator associated to the light.
  14751. * @returns Always null for hemispheric lights because it does not support shadows.
  14752. */
  14753. getShadowGenerator(): Nullable<IShadowGenerator>;
  14754. /**
  14755. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14756. * @param effect The effect to update
  14757. * @param lightIndex The index of the light in the effect to update
  14758. * @returns The hemispheric light
  14759. */
  14760. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14761. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14762. /**
  14763. * Computes the world matrix of the node
  14764. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14765. * @param useWasUpdatedFlag defines a reserved property
  14766. * @returns the world matrix
  14767. */
  14768. computeWorldMatrix(): Matrix;
  14769. /**
  14770. * Returns the integer 3.
  14771. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14772. */
  14773. getTypeID(): number;
  14774. /**
  14775. * Prepares the list of defines specific to the light type.
  14776. * @param defines the list of defines
  14777. * @param lightIndex defines the index of the light for the effect
  14778. */
  14779. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14780. }
  14781. }
  14782. declare module BABYLON {
  14783. /** @hidden */
  14784. export var vrMultiviewToSingleviewPixelShader: {
  14785. name: string;
  14786. shader: string;
  14787. };
  14788. }
  14789. declare module BABYLON {
  14790. /**
  14791. * Renders to multiple views with a single draw call
  14792. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14793. */
  14794. export class MultiviewRenderTarget extends RenderTargetTexture {
  14795. /**
  14796. * Creates a multiview render target
  14797. * @param scene scene used with the render target
  14798. * @param size the size of the render target (used for each view)
  14799. */
  14800. constructor(scene: Scene, size?: number | {
  14801. width: number;
  14802. height: number;
  14803. } | {
  14804. ratio: number;
  14805. });
  14806. /**
  14807. * @hidden
  14808. * @param faceIndex the face index, if its a cube texture
  14809. */
  14810. _bindFrameBuffer(faceIndex?: number): void;
  14811. /**
  14812. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14813. * @returns the view count
  14814. */
  14815. getViewCount(): number;
  14816. }
  14817. }
  14818. declare module BABYLON {
  14819. /**
  14820. * Represents a camera frustum
  14821. */
  14822. export class Frustum {
  14823. /**
  14824. * Gets the planes representing the frustum
  14825. * @param transform matrix to be applied to the returned planes
  14826. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14827. */
  14828. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14829. /**
  14830. * Gets the near frustum plane transformed by the transform matrix
  14831. * @param transform transformation matrix to be applied to the resulting frustum plane
  14832. * @param frustumPlane the resuling frustum plane
  14833. */
  14834. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14835. /**
  14836. * Gets the far frustum plane transformed by the transform matrix
  14837. * @param transform transformation matrix to be applied to the resulting frustum plane
  14838. * @param frustumPlane the resuling frustum plane
  14839. */
  14840. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14841. /**
  14842. * Gets the left frustum plane transformed by the transform matrix
  14843. * @param transform transformation matrix to be applied to the resulting frustum plane
  14844. * @param frustumPlane the resuling frustum plane
  14845. */
  14846. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14847. /**
  14848. * Gets the right frustum plane transformed by the transform matrix
  14849. * @param transform transformation matrix to be applied to the resulting frustum plane
  14850. * @param frustumPlane the resuling frustum plane
  14851. */
  14852. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14853. /**
  14854. * Gets the top frustum plane transformed by the transform matrix
  14855. * @param transform transformation matrix to be applied to the resulting frustum plane
  14856. * @param frustumPlane the resuling frustum plane
  14857. */
  14858. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14859. /**
  14860. * Gets the bottom frustum plane transformed by the transform matrix
  14861. * @param transform transformation matrix to be applied to the resulting frustum plane
  14862. * @param frustumPlane the resuling frustum plane
  14863. */
  14864. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14865. /**
  14866. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14867. * @param transform transformation matrix to be applied to the resulting frustum planes
  14868. * @param frustumPlanes the resuling frustum planes
  14869. */
  14870. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14871. }
  14872. }
  14873. declare module BABYLON {
  14874. interface Engine {
  14875. /**
  14876. * Creates a new multiview render target
  14877. * @param width defines the width of the texture
  14878. * @param height defines the height of the texture
  14879. * @returns the created multiview texture
  14880. */
  14881. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14882. /**
  14883. * Binds a multiview framebuffer to be drawn to
  14884. * @param multiviewTexture texture to bind
  14885. */
  14886. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14887. }
  14888. interface Camera {
  14889. /**
  14890. * @hidden
  14891. * 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)
  14892. */
  14893. _useMultiviewToSingleView: boolean;
  14894. /**
  14895. * @hidden
  14896. * 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)
  14897. */
  14898. _multiviewTexture: Nullable<RenderTargetTexture>;
  14899. /**
  14900. * @hidden
  14901. * ensures the multiview texture of the camera exists and has the specified width/height
  14902. * @param width height to set on the multiview texture
  14903. * @param height width to set on the multiview texture
  14904. */
  14905. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14906. }
  14907. interface Scene {
  14908. /** @hidden */
  14909. _transformMatrixR: Matrix;
  14910. /** @hidden */
  14911. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14912. /** @hidden */
  14913. _createMultiviewUbo(): void;
  14914. /** @hidden */
  14915. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14916. /** @hidden */
  14917. _renderMultiviewToSingleView(camera: Camera): void;
  14918. }
  14919. }
  14920. declare module BABYLON {
  14921. /**
  14922. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14923. * This will not be used for webXR as it supports displaying texture arrays directly
  14924. */
  14925. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14926. /**
  14927. * Initializes a VRMultiviewToSingleview
  14928. * @param name name of the post process
  14929. * @param camera camera to be applied to
  14930. * @param scaleFactor scaling factor to the size of the output texture
  14931. */
  14932. constructor(name: string, camera: Camera, scaleFactor: number);
  14933. }
  14934. }
  14935. declare module BABYLON {
  14936. /**
  14937. * Interface used to define additional presentation attributes
  14938. */
  14939. export interface IVRPresentationAttributes {
  14940. /**
  14941. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  14942. */
  14943. highRefreshRate: boolean;
  14944. /**
  14945. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  14946. */
  14947. foveationLevel: number;
  14948. }
  14949. interface Engine {
  14950. /** @hidden */
  14951. _vrDisplay: any;
  14952. /** @hidden */
  14953. _vrSupported: boolean;
  14954. /** @hidden */
  14955. _oldSize: Size;
  14956. /** @hidden */
  14957. _oldHardwareScaleFactor: number;
  14958. /** @hidden */
  14959. _vrExclusivePointerMode: boolean;
  14960. /** @hidden */
  14961. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14962. /** @hidden */
  14963. _onVRDisplayPointerRestricted: () => void;
  14964. /** @hidden */
  14965. _onVRDisplayPointerUnrestricted: () => void;
  14966. /** @hidden */
  14967. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14968. /** @hidden */
  14969. _onVrDisplayDisconnect: Nullable<() => void>;
  14970. /** @hidden */
  14971. _onVrDisplayPresentChange: Nullable<() => void>;
  14972. /**
  14973. * Observable signaled when VR display mode changes
  14974. */
  14975. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14976. /**
  14977. * Observable signaled when VR request present is complete
  14978. */
  14979. onVRRequestPresentComplete: Observable<boolean>;
  14980. /**
  14981. * Observable signaled when VR request present starts
  14982. */
  14983. onVRRequestPresentStart: Observable<Engine>;
  14984. /**
  14985. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14986. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14987. */
  14988. isInVRExclusivePointerMode: boolean;
  14989. /**
  14990. * Gets a boolean indicating if a webVR device was detected
  14991. * @returns true if a webVR device was detected
  14992. */
  14993. isVRDevicePresent(): boolean;
  14994. /**
  14995. * Gets the current webVR device
  14996. * @returns the current webVR device (or null)
  14997. */
  14998. getVRDevice(): any;
  14999. /**
  15000. * Initializes a webVR display and starts listening to display change events
  15001. * The onVRDisplayChangedObservable will be notified upon these changes
  15002. * @returns A promise containing a VRDisplay and if vr is supported
  15003. */
  15004. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15005. /** @hidden */
  15006. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15007. /**
  15008. * Gets or sets the presentation attributes used to configure VR rendering
  15009. */
  15010. vrPresentationAttributes?: IVRPresentationAttributes;
  15011. /**
  15012. * Call this function to switch to webVR mode
  15013. * Will do nothing if webVR is not supported or if there is no webVR device
  15014. * @param options the webvr options provided to the camera. mainly used for multiview
  15015. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15016. */
  15017. enableVR(options: WebVROptions): void;
  15018. /** @hidden */
  15019. _onVRFullScreenTriggered(): void;
  15020. }
  15021. }
  15022. declare module BABYLON {
  15023. /**
  15024. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15025. * IMPORTANT!! The data is right-hand data.
  15026. * @export
  15027. * @interface DevicePose
  15028. */
  15029. export interface DevicePose {
  15030. /**
  15031. * The position of the device, values in array are [x,y,z].
  15032. */
  15033. readonly position: Nullable<Float32Array>;
  15034. /**
  15035. * The linearVelocity of the device, values in array are [x,y,z].
  15036. */
  15037. readonly linearVelocity: Nullable<Float32Array>;
  15038. /**
  15039. * The linearAcceleration of the device, values in array are [x,y,z].
  15040. */
  15041. readonly linearAcceleration: Nullable<Float32Array>;
  15042. /**
  15043. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15044. */
  15045. readonly orientation: Nullable<Float32Array>;
  15046. /**
  15047. * The angularVelocity of the device, values in array are [x,y,z].
  15048. */
  15049. readonly angularVelocity: Nullable<Float32Array>;
  15050. /**
  15051. * The angularAcceleration of the device, values in array are [x,y,z].
  15052. */
  15053. readonly angularAcceleration: Nullable<Float32Array>;
  15054. }
  15055. /**
  15056. * Interface representing a pose controlled object in Babylon.
  15057. * A pose controlled object has both regular pose values as well as pose values
  15058. * from an external device such as a VR head mounted display
  15059. */
  15060. export interface PoseControlled {
  15061. /**
  15062. * The position of the object in babylon space.
  15063. */
  15064. position: Vector3;
  15065. /**
  15066. * The rotation quaternion of the object in babylon space.
  15067. */
  15068. rotationQuaternion: Quaternion;
  15069. /**
  15070. * The position of the device in babylon space.
  15071. */
  15072. devicePosition?: Vector3;
  15073. /**
  15074. * The rotation quaternion of the device in babylon space.
  15075. */
  15076. deviceRotationQuaternion: Quaternion;
  15077. /**
  15078. * The raw pose coming from the device.
  15079. */
  15080. rawPose: Nullable<DevicePose>;
  15081. /**
  15082. * The scale of the device to be used when translating from device space to babylon space.
  15083. */
  15084. deviceScaleFactor: number;
  15085. /**
  15086. * Updates the poseControlled values based on the input device pose.
  15087. * @param poseData the pose data to update the object with
  15088. */
  15089. updateFromDevice(poseData: DevicePose): void;
  15090. }
  15091. /**
  15092. * Set of options to customize the webVRCamera
  15093. */
  15094. export interface WebVROptions {
  15095. /**
  15096. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15097. */
  15098. trackPosition?: boolean;
  15099. /**
  15100. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15101. */
  15102. positionScale?: number;
  15103. /**
  15104. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15105. */
  15106. displayName?: string;
  15107. /**
  15108. * Should the native controller meshes be initialized. (default: true)
  15109. */
  15110. controllerMeshes?: boolean;
  15111. /**
  15112. * Creating a default HemiLight only on controllers. (default: true)
  15113. */
  15114. defaultLightingOnControllers?: boolean;
  15115. /**
  15116. * If you don't want to use the default VR button of the helper. (default: false)
  15117. */
  15118. useCustomVRButton?: boolean;
  15119. /**
  15120. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15121. */
  15122. customVRButton?: HTMLButtonElement;
  15123. /**
  15124. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15125. */
  15126. rayLength?: number;
  15127. /**
  15128. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15129. */
  15130. defaultHeight?: number;
  15131. /**
  15132. * If multiview should be used if availible (default: false)
  15133. */
  15134. useMultiview?: boolean;
  15135. }
  15136. /**
  15137. * This represents a WebVR camera.
  15138. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15139. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15140. */
  15141. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15142. private webVROptions;
  15143. /**
  15144. * @hidden
  15145. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15146. */
  15147. _vrDevice: any;
  15148. /**
  15149. * The rawPose of the vrDevice.
  15150. */
  15151. rawPose: Nullable<DevicePose>;
  15152. private _onVREnabled;
  15153. private _specsVersion;
  15154. private _attached;
  15155. private _frameData;
  15156. protected _descendants: Array<Node>;
  15157. private _deviceRoomPosition;
  15158. /** @hidden */
  15159. _deviceRoomRotationQuaternion: Quaternion;
  15160. private _standingMatrix;
  15161. /**
  15162. * Represents device position in babylon space.
  15163. */
  15164. devicePosition: Vector3;
  15165. /**
  15166. * Represents device rotation in babylon space.
  15167. */
  15168. deviceRotationQuaternion: Quaternion;
  15169. /**
  15170. * The scale of the device to be used when translating from device space to babylon space.
  15171. */
  15172. deviceScaleFactor: number;
  15173. private _deviceToWorld;
  15174. private _worldToDevice;
  15175. /**
  15176. * References to the webVR controllers for the vrDevice.
  15177. */
  15178. controllers: Array<WebVRController>;
  15179. /**
  15180. * Emits an event when a controller is attached.
  15181. */
  15182. onControllersAttachedObservable: Observable<WebVRController[]>;
  15183. /**
  15184. * Emits an event when a controller's mesh has been loaded;
  15185. */
  15186. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15187. /**
  15188. * Emits an event when the HMD's pose has been updated.
  15189. */
  15190. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15191. private _poseSet;
  15192. /**
  15193. * If the rig cameras be used as parent instead of this camera.
  15194. */
  15195. rigParenting: boolean;
  15196. private _lightOnControllers;
  15197. private _defaultHeight?;
  15198. /**
  15199. * Instantiates a WebVRFreeCamera.
  15200. * @param name The name of the WebVRFreeCamera
  15201. * @param position The starting anchor position for the camera
  15202. * @param scene The scene the camera belongs to
  15203. * @param webVROptions a set of customizable options for the webVRCamera
  15204. */
  15205. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15206. /**
  15207. * Gets the device distance from the ground in meters.
  15208. * @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.
  15209. */
  15210. deviceDistanceToRoomGround(): number;
  15211. /**
  15212. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15213. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15214. */
  15215. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15216. /**
  15217. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15218. * @returns A promise with a boolean set to if the standing matrix is supported.
  15219. */
  15220. useStandingMatrixAsync(): Promise<boolean>;
  15221. /**
  15222. * Disposes the camera
  15223. */
  15224. dispose(): void;
  15225. /**
  15226. * Gets a vrController by name.
  15227. * @param name The name of the controller to retreive
  15228. * @returns the controller matching the name specified or null if not found
  15229. */
  15230. getControllerByName(name: string): Nullable<WebVRController>;
  15231. private _leftController;
  15232. /**
  15233. * The controller corresponding to the users left hand.
  15234. */
  15235. readonly leftController: Nullable<WebVRController>;
  15236. private _rightController;
  15237. /**
  15238. * The controller corresponding to the users right hand.
  15239. */
  15240. readonly rightController: Nullable<WebVRController>;
  15241. /**
  15242. * Casts a ray forward from the vrCamera's gaze.
  15243. * @param length Length of the ray (default: 100)
  15244. * @returns the ray corresponding to the gaze
  15245. */
  15246. getForwardRay(length?: number): Ray;
  15247. /**
  15248. * @hidden
  15249. * Updates the camera based on device's frame data
  15250. */
  15251. _checkInputs(): void;
  15252. /**
  15253. * Updates the poseControlled values based on the input device pose.
  15254. * @param poseData Pose coming from the device
  15255. */
  15256. updateFromDevice(poseData: DevicePose): void;
  15257. private _htmlElementAttached;
  15258. private _detachIfAttached;
  15259. /**
  15260. * WebVR's attach control will start broadcasting frames to the device.
  15261. * Note that in certain browsers (chrome for example) this function must be called
  15262. * within a user-interaction callback. Example:
  15263. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15264. *
  15265. * @param element html element to attach the vrDevice to
  15266. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15267. */
  15268. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15269. /**
  15270. * Detaches the camera from the html element and disables VR
  15271. *
  15272. * @param element html element to detach from
  15273. */
  15274. detachControl(element: HTMLElement): void;
  15275. /**
  15276. * @returns the name of this class
  15277. */
  15278. getClassName(): string;
  15279. /**
  15280. * Calls resetPose on the vrDisplay
  15281. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15282. */
  15283. resetToCurrentRotation(): void;
  15284. /**
  15285. * @hidden
  15286. * Updates the rig cameras (left and right eye)
  15287. */
  15288. _updateRigCameras(): void;
  15289. private _workingVector;
  15290. private _oneVector;
  15291. private _workingMatrix;
  15292. private updateCacheCalled;
  15293. private _correctPositionIfNotTrackPosition;
  15294. /**
  15295. * @hidden
  15296. * Updates the cached values of the camera
  15297. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15298. */
  15299. _updateCache(ignoreParentClass?: boolean): void;
  15300. /**
  15301. * @hidden
  15302. * Get current device position in babylon world
  15303. */
  15304. _computeDevicePosition(): void;
  15305. /**
  15306. * Updates the current device position and rotation in the babylon world
  15307. */
  15308. update(): void;
  15309. /**
  15310. * @hidden
  15311. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15312. * @returns an identity matrix
  15313. */
  15314. _getViewMatrix(): Matrix;
  15315. private _tmpMatrix;
  15316. /**
  15317. * This function is called by the two RIG cameras.
  15318. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15319. * @hidden
  15320. */
  15321. _getWebVRViewMatrix(): Matrix;
  15322. /** @hidden */
  15323. _getWebVRProjectionMatrix(): Matrix;
  15324. private _onGamepadConnectedObserver;
  15325. private _onGamepadDisconnectedObserver;
  15326. private _updateCacheWhenTrackingDisabledObserver;
  15327. /**
  15328. * Initializes the controllers and their meshes
  15329. */
  15330. initControllers(): void;
  15331. }
  15332. }
  15333. declare module BABYLON {
  15334. /**
  15335. * Size options for a post process
  15336. */
  15337. export type PostProcessOptions = {
  15338. width: number;
  15339. height: number;
  15340. };
  15341. /**
  15342. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15343. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15344. */
  15345. export class PostProcess {
  15346. /** Name of the PostProcess. */
  15347. name: string;
  15348. /**
  15349. * Gets or sets the unique id of the post process
  15350. */
  15351. uniqueId: number;
  15352. /**
  15353. * Width of the texture to apply the post process on
  15354. */
  15355. width: number;
  15356. /**
  15357. * Height of the texture to apply the post process on
  15358. */
  15359. height: number;
  15360. /**
  15361. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15362. * @hidden
  15363. */
  15364. _outputTexture: Nullable<InternalTexture>;
  15365. /**
  15366. * Sampling mode used by the shader
  15367. * See https://doc.babylonjs.com/classes/3.1/texture
  15368. */
  15369. renderTargetSamplingMode: number;
  15370. /**
  15371. * Clear color to use when screen clearing
  15372. */
  15373. clearColor: Color4;
  15374. /**
  15375. * If the buffer needs to be cleared before applying the post process. (default: true)
  15376. * Should be set to false if shader will overwrite all previous pixels.
  15377. */
  15378. autoClear: boolean;
  15379. /**
  15380. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15381. */
  15382. alphaMode: number;
  15383. /**
  15384. * Sets the setAlphaBlendConstants of the babylon engine
  15385. */
  15386. alphaConstants: Color4;
  15387. /**
  15388. * Animations to be used for the post processing
  15389. */
  15390. animations: Animation[];
  15391. /**
  15392. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15393. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15394. */
  15395. enablePixelPerfectMode: boolean;
  15396. /**
  15397. * Force the postprocess to be applied without taking in account viewport
  15398. */
  15399. forceFullscreenViewport: boolean;
  15400. /**
  15401. * List of inspectable custom properties (used by the Inspector)
  15402. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15403. */
  15404. inspectableCustomProperties: IInspectable[];
  15405. /**
  15406. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15407. *
  15408. * | Value | Type | Description |
  15409. * | ----- | ----------------------------------- | ----------- |
  15410. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15411. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15412. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15413. *
  15414. */
  15415. scaleMode: number;
  15416. /**
  15417. * Force textures to be a power of two (default: false)
  15418. */
  15419. alwaysForcePOT: boolean;
  15420. private _samples;
  15421. /**
  15422. * Number of sample textures (default: 1)
  15423. */
  15424. samples: number;
  15425. /**
  15426. * Modify the scale of the post process to be the same as the viewport (default: false)
  15427. */
  15428. adaptScaleToCurrentViewport: boolean;
  15429. private _camera;
  15430. private _scene;
  15431. private _engine;
  15432. private _options;
  15433. private _reusable;
  15434. private _textureType;
  15435. /**
  15436. * Smart array of input and output textures for the post process.
  15437. * @hidden
  15438. */
  15439. _textures: SmartArray<InternalTexture>;
  15440. /**
  15441. * The index in _textures that corresponds to the output texture.
  15442. * @hidden
  15443. */
  15444. _currentRenderTextureInd: number;
  15445. private _effect;
  15446. private _samplers;
  15447. private _fragmentUrl;
  15448. private _vertexUrl;
  15449. private _parameters;
  15450. private _scaleRatio;
  15451. protected _indexParameters: any;
  15452. private _shareOutputWithPostProcess;
  15453. private _texelSize;
  15454. private _forcedOutputTexture;
  15455. /**
  15456. * Returns the fragment url or shader name used in the post process.
  15457. * @returns the fragment url or name in the shader store.
  15458. */
  15459. getEffectName(): string;
  15460. /**
  15461. * An event triggered when the postprocess is activated.
  15462. */
  15463. onActivateObservable: Observable<Camera>;
  15464. private _onActivateObserver;
  15465. /**
  15466. * A function that is added to the onActivateObservable
  15467. */
  15468. onActivate: Nullable<(camera: Camera) => void>;
  15469. /**
  15470. * An event triggered when the postprocess changes its size.
  15471. */
  15472. onSizeChangedObservable: Observable<PostProcess>;
  15473. private _onSizeChangedObserver;
  15474. /**
  15475. * A function that is added to the onSizeChangedObservable
  15476. */
  15477. onSizeChanged: (postProcess: PostProcess) => void;
  15478. /**
  15479. * An event triggered when the postprocess applies its effect.
  15480. */
  15481. onApplyObservable: Observable<Effect>;
  15482. private _onApplyObserver;
  15483. /**
  15484. * A function that is added to the onApplyObservable
  15485. */
  15486. onApply: (effect: Effect) => void;
  15487. /**
  15488. * An event triggered before rendering the postprocess
  15489. */
  15490. onBeforeRenderObservable: Observable<Effect>;
  15491. private _onBeforeRenderObserver;
  15492. /**
  15493. * A function that is added to the onBeforeRenderObservable
  15494. */
  15495. onBeforeRender: (effect: Effect) => void;
  15496. /**
  15497. * An event triggered after rendering the postprocess
  15498. */
  15499. onAfterRenderObservable: Observable<Effect>;
  15500. private _onAfterRenderObserver;
  15501. /**
  15502. * A function that is added to the onAfterRenderObservable
  15503. */
  15504. onAfterRender: (efect: Effect) => void;
  15505. /**
  15506. * 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
  15507. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15508. */
  15509. inputTexture: InternalTexture;
  15510. /**
  15511. * Gets the camera which post process is applied to.
  15512. * @returns The camera the post process is applied to.
  15513. */
  15514. getCamera(): Camera;
  15515. /**
  15516. * Gets the texel size of the postprocess.
  15517. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15518. */
  15519. readonly texelSize: Vector2;
  15520. /**
  15521. * Creates a new instance PostProcess
  15522. * @param name The name of the PostProcess.
  15523. * @param fragmentUrl The url of the fragment shader to be used.
  15524. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15525. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15526. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15527. * @param camera The camera to apply the render pass to.
  15528. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15529. * @param engine The engine which the post process will be applied. (default: current engine)
  15530. * @param reusable If the post process can be reused on the same frame. (default: false)
  15531. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15532. * @param textureType Type of textures used when performing the post process. (default: 0)
  15533. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15534. * @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
  15535. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15536. */
  15537. constructor(
  15538. /** Name of the PostProcess. */
  15539. 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);
  15540. /**
  15541. * Gets a string idenfifying the name of the class
  15542. * @returns "PostProcess" string
  15543. */
  15544. getClassName(): string;
  15545. /**
  15546. * Gets the engine which this post process belongs to.
  15547. * @returns The engine the post process was enabled with.
  15548. */
  15549. getEngine(): Engine;
  15550. /**
  15551. * The effect that is created when initializing the post process.
  15552. * @returns The created effect corresponding the the postprocess.
  15553. */
  15554. getEffect(): Effect;
  15555. /**
  15556. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15557. * @param postProcess The post process to share the output with.
  15558. * @returns This post process.
  15559. */
  15560. shareOutputWith(postProcess: PostProcess): PostProcess;
  15561. /**
  15562. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15563. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15564. */
  15565. useOwnOutput(): void;
  15566. /**
  15567. * Updates the effect with the current post process compile time values and recompiles the shader.
  15568. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15569. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15570. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15571. * @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
  15572. * @param onCompiled Called when the shader has been compiled.
  15573. * @param onError Called if there is an error when compiling a shader.
  15574. */
  15575. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15576. /**
  15577. * The post process is reusable if it can be used multiple times within one frame.
  15578. * @returns If the post process is reusable
  15579. */
  15580. isReusable(): boolean;
  15581. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15582. markTextureDirty(): void;
  15583. /**
  15584. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15585. * 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.
  15586. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15587. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15588. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15589. * @returns The target texture that was bound to be written to.
  15590. */
  15591. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15592. /**
  15593. * If the post process is supported.
  15594. */
  15595. readonly isSupported: boolean;
  15596. /**
  15597. * The aspect ratio of the output texture.
  15598. */
  15599. readonly aspectRatio: number;
  15600. /**
  15601. * Get a value indicating if the post-process is ready to be used
  15602. * @returns true if the post-process is ready (shader is compiled)
  15603. */
  15604. isReady(): boolean;
  15605. /**
  15606. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15607. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15608. */
  15609. apply(): Nullable<Effect>;
  15610. private _disposeTextures;
  15611. /**
  15612. * Disposes the post process.
  15613. * @param camera The camera to dispose the post process on.
  15614. */
  15615. dispose(camera?: Camera): void;
  15616. }
  15617. }
  15618. declare module BABYLON {
  15619. /** @hidden */
  15620. export var kernelBlurVaryingDeclaration: {
  15621. name: string;
  15622. shader: string;
  15623. };
  15624. }
  15625. declare module BABYLON {
  15626. /** @hidden */
  15627. export var kernelBlurFragment: {
  15628. name: string;
  15629. shader: string;
  15630. };
  15631. }
  15632. declare module BABYLON {
  15633. /** @hidden */
  15634. export var kernelBlurFragment2: {
  15635. name: string;
  15636. shader: string;
  15637. };
  15638. }
  15639. declare module BABYLON {
  15640. /** @hidden */
  15641. export var kernelBlurPixelShader: {
  15642. name: string;
  15643. shader: string;
  15644. };
  15645. }
  15646. declare module BABYLON {
  15647. /** @hidden */
  15648. export var kernelBlurVertex: {
  15649. name: string;
  15650. shader: string;
  15651. };
  15652. }
  15653. declare module BABYLON {
  15654. /** @hidden */
  15655. export var kernelBlurVertexShader: {
  15656. name: string;
  15657. shader: string;
  15658. };
  15659. }
  15660. declare module BABYLON {
  15661. /**
  15662. * The Blur Post Process which blurs an image based on a kernel and direction.
  15663. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15664. */
  15665. export class BlurPostProcess extends PostProcess {
  15666. /** The direction in which to blur the image. */
  15667. direction: Vector2;
  15668. private blockCompilation;
  15669. protected _kernel: number;
  15670. protected _idealKernel: number;
  15671. protected _packedFloat: boolean;
  15672. private _staticDefines;
  15673. /**
  15674. * Sets the length in pixels of the blur sample region
  15675. */
  15676. /**
  15677. * Gets the length in pixels of the blur sample region
  15678. */
  15679. kernel: number;
  15680. /**
  15681. * Sets wether or not the blur needs to unpack/repack floats
  15682. */
  15683. /**
  15684. * Gets wether or not the blur is unpacking/repacking floats
  15685. */
  15686. packedFloat: boolean;
  15687. /**
  15688. * Creates a new instance BlurPostProcess
  15689. * @param name The name of the effect.
  15690. * @param direction The direction in which to blur the image.
  15691. * @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.
  15692. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15693. * @param camera The camera to apply the render pass to.
  15694. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15695. * @param engine The engine which the post process will be applied. (default: current engine)
  15696. * @param reusable If the post process can be reused on the same frame. (default: false)
  15697. * @param textureType Type of textures used when performing the post process. (default: 0)
  15698. * @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)
  15699. */
  15700. constructor(name: string,
  15701. /** The direction in which to blur the image. */
  15702. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15703. /**
  15704. * Updates the effect with the current post process compile time values and recompiles the shader.
  15705. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15706. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15707. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15708. * @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
  15709. * @param onCompiled Called when the shader has been compiled.
  15710. * @param onError Called if there is an error when compiling a shader.
  15711. */
  15712. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15713. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15714. /**
  15715. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15716. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15717. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15718. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15719. * The gaps between physical kernels are compensated for in the weighting of the samples
  15720. * @param idealKernel Ideal blur kernel.
  15721. * @return Nearest best kernel.
  15722. */
  15723. protected _nearestBestKernel(idealKernel: number): number;
  15724. /**
  15725. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15726. * @param x The point on the Gaussian distribution to sample.
  15727. * @return the value of the Gaussian function at x.
  15728. */
  15729. protected _gaussianWeight(x: number): number;
  15730. /**
  15731. * Generates a string that can be used as a floating point number in GLSL.
  15732. * @param x Value to print.
  15733. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15734. * @return GLSL float string.
  15735. */
  15736. protected _glslFloat(x: number, decimalFigures?: number): string;
  15737. }
  15738. }
  15739. declare module BABYLON {
  15740. /**
  15741. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15742. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15743. * You can then easily use it as a reflectionTexture on a flat surface.
  15744. * In case the surface is not a plane, please consider relying on reflection probes.
  15745. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15746. */
  15747. export class MirrorTexture extends RenderTargetTexture {
  15748. private scene;
  15749. /**
  15750. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15751. * 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.
  15752. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15753. */
  15754. mirrorPlane: Plane;
  15755. /**
  15756. * Define the blur ratio used to blur the reflection if needed.
  15757. */
  15758. blurRatio: number;
  15759. /**
  15760. * Define the adaptive blur kernel used to blur the reflection if needed.
  15761. * This will autocompute the closest best match for the `blurKernel`
  15762. */
  15763. adaptiveBlurKernel: number;
  15764. /**
  15765. * Define the blur kernel used to blur the reflection if needed.
  15766. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15767. */
  15768. blurKernel: number;
  15769. /**
  15770. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15771. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15772. */
  15773. blurKernelX: number;
  15774. /**
  15775. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15776. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15777. */
  15778. blurKernelY: number;
  15779. private _autoComputeBlurKernel;
  15780. protected _onRatioRescale(): void;
  15781. private _updateGammaSpace;
  15782. private _imageProcessingConfigChangeObserver;
  15783. private _transformMatrix;
  15784. private _mirrorMatrix;
  15785. private _savedViewMatrix;
  15786. private _blurX;
  15787. private _blurY;
  15788. private _adaptiveBlurKernel;
  15789. private _blurKernelX;
  15790. private _blurKernelY;
  15791. private _blurRatio;
  15792. /**
  15793. * Instantiates a Mirror Texture.
  15794. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15795. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15796. * You can then easily use it as a reflectionTexture on a flat surface.
  15797. * In case the surface is not a plane, please consider relying on reflection probes.
  15798. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15799. * @param name
  15800. * @param size
  15801. * @param scene
  15802. * @param generateMipMaps
  15803. * @param type
  15804. * @param samplingMode
  15805. * @param generateDepthBuffer
  15806. */
  15807. constructor(name: string, size: number | {
  15808. width: number;
  15809. height: number;
  15810. } | {
  15811. ratio: number;
  15812. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15813. private _preparePostProcesses;
  15814. /**
  15815. * Clone the mirror texture.
  15816. * @returns the cloned texture
  15817. */
  15818. clone(): MirrorTexture;
  15819. /**
  15820. * Serialize the texture to a JSON representation you could use in Parse later on
  15821. * @returns the serialized JSON representation
  15822. */
  15823. serialize(): any;
  15824. /**
  15825. * Dispose the texture and release its associated resources.
  15826. */
  15827. dispose(): void;
  15828. }
  15829. }
  15830. declare module BABYLON {
  15831. /**
  15832. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15833. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15834. */
  15835. export class Texture extends BaseTexture {
  15836. /**
  15837. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15838. */
  15839. static SerializeBuffers: boolean;
  15840. /** @hidden */
  15841. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15842. /** @hidden */
  15843. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15844. /** @hidden */
  15845. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15846. /** nearest is mag = nearest and min = nearest and mip = linear */
  15847. static readonly NEAREST_SAMPLINGMODE: number;
  15848. /** nearest is mag = nearest and min = nearest and mip = linear */
  15849. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15850. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15851. static readonly BILINEAR_SAMPLINGMODE: number;
  15852. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15853. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15854. /** Trilinear is mag = linear and min = linear and mip = linear */
  15855. static readonly TRILINEAR_SAMPLINGMODE: number;
  15856. /** Trilinear is mag = linear and min = linear and mip = linear */
  15857. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15858. /** mag = nearest and min = nearest and mip = nearest */
  15859. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15860. /** mag = nearest and min = linear and mip = nearest */
  15861. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15862. /** mag = nearest and min = linear and mip = linear */
  15863. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15864. /** mag = nearest and min = linear and mip = none */
  15865. static readonly NEAREST_LINEAR: number;
  15866. /** mag = nearest and min = nearest and mip = none */
  15867. static readonly NEAREST_NEAREST: number;
  15868. /** mag = linear and min = nearest and mip = nearest */
  15869. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15870. /** mag = linear and min = nearest and mip = linear */
  15871. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15872. /** mag = linear and min = linear and mip = none */
  15873. static readonly LINEAR_LINEAR: number;
  15874. /** mag = linear and min = nearest and mip = none */
  15875. static readonly LINEAR_NEAREST: number;
  15876. /** Explicit coordinates mode */
  15877. static readonly EXPLICIT_MODE: number;
  15878. /** Spherical coordinates mode */
  15879. static readonly SPHERICAL_MODE: number;
  15880. /** Planar coordinates mode */
  15881. static readonly PLANAR_MODE: number;
  15882. /** Cubic coordinates mode */
  15883. static readonly CUBIC_MODE: number;
  15884. /** Projection coordinates mode */
  15885. static readonly PROJECTION_MODE: number;
  15886. /** Inverse Cubic coordinates mode */
  15887. static readonly SKYBOX_MODE: number;
  15888. /** Inverse Cubic coordinates mode */
  15889. static readonly INVCUBIC_MODE: number;
  15890. /** Equirectangular coordinates mode */
  15891. static readonly EQUIRECTANGULAR_MODE: number;
  15892. /** Equirectangular Fixed coordinates mode */
  15893. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15894. /** Equirectangular Fixed Mirrored coordinates mode */
  15895. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15896. /** Texture is not repeating outside of 0..1 UVs */
  15897. static readonly CLAMP_ADDRESSMODE: number;
  15898. /** Texture is repeating outside of 0..1 UVs */
  15899. static readonly WRAP_ADDRESSMODE: number;
  15900. /** Texture is repeating and mirrored */
  15901. static readonly MIRROR_ADDRESSMODE: number;
  15902. /**
  15903. * 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
  15904. */
  15905. static UseSerializedUrlIfAny: boolean;
  15906. /**
  15907. * Define the url of the texture.
  15908. */
  15909. url: Nullable<string>;
  15910. /**
  15911. * Define an offset on the texture to offset the u coordinates of the UVs
  15912. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15913. */
  15914. uOffset: number;
  15915. /**
  15916. * Define an offset on the texture to offset the v coordinates of the UVs
  15917. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15918. */
  15919. vOffset: number;
  15920. /**
  15921. * Define an offset on the texture to scale the u coordinates of the UVs
  15922. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15923. */
  15924. uScale: number;
  15925. /**
  15926. * Define an offset on the texture to scale the v coordinates of the UVs
  15927. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15928. */
  15929. vScale: number;
  15930. /**
  15931. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15932. * @see http://doc.babylonjs.com/how_to/more_materials
  15933. */
  15934. uAng: number;
  15935. /**
  15936. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15937. * @see http://doc.babylonjs.com/how_to/more_materials
  15938. */
  15939. vAng: number;
  15940. /**
  15941. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15942. * @see http://doc.babylonjs.com/how_to/more_materials
  15943. */
  15944. wAng: number;
  15945. /**
  15946. * Defines the center of rotation (U)
  15947. */
  15948. uRotationCenter: number;
  15949. /**
  15950. * Defines the center of rotation (V)
  15951. */
  15952. vRotationCenter: number;
  15953. /**
  15954. * Defines the center of rotation (W)
  15955. */
  15956. wRotationCenter: number;
  15957. /**
  15958. * Are mip maps generated for this texture or not.
  15959. */
  15960. readonly noMipmap: boolean;
  15961. /**
  15962. * List of inspectable custom properties (used by the Inspector)
  15963. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15964. */
  15965. inspectableCustomProperties: Nullable<IInspectable[]>;
  15966. private _noMipmap;
  15967. /** @hidden */
  15968. _invertY: boolean;
  15969. private _rowGenerationMatrix;
  15970. private _cachedTextureMatrix;
  15971. private _projectionModeMatrix;
  15972. private _t0;
  15973. private _t1;
  15974. private _t2;
  15975. private _cachedUOffset;
  15976. private _cachedVOffset;
  15977. private _cachedUScale;
  15978. private _cachedVScale;
  15979. private _cachedUAng;
  15980. private _cachedVAng;
  15981. private _cachedWAng;
  15982. private _cachedProjectionMatrixId;
  15983. private _cachedCoordinatesMode;
  15984. /** @hidden */
  15985. protected _initialSamplingMode: number;
  15986. /** @hidden */
  15987. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  15988. private _deleteBuffer;
  15989. protected _format: Nullable<number>;
  15990. private _delayedOnLoad;
  15991. private _delayedOnError;
  15992. private _mimeType?;
  15993. /**
  15994. * Observable triggered once the texture has been loaded.
  15995. */
  15996. onLoadObservable: Observable<Texture>;
  15997. protected _isBlocking: boolean;
  15998. /**
  15999. * Is the texture preventing material to render while loading.
  16000. * If false, a default texture will be used instead of the loading one during the preparation step.
  16001. */
  16002. isBlocking: boolean;
  16003. /**
  16004. * Get the current sampling mode associated with the texture.
  16005. */
  16006. readonly samplingMode: number;
  16007. /**
  16008. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16009. */
  16010. readonly invertY: boolean;
  16011. /**
  16012. * Instantiates a new texture.
  16013. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16014. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16015. * @param url defines the url of the picture to load as a texture
  16016. * @param scene defines the scene or engine the texture will belong to
  16017. * @param noMipmap defines if the texture will require mip maps or not
  16018. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16019. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16020. * @param onLoad defines a callback triggered when the texture has been loaded
  16021. * @param onError defines a callback triggered when an error occurred during the loading session
  16022. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16023. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16024. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16025. * @param mimeType defines an optional mime type information
  16026. */
  16027. 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);
  16028. /**
  16029. * Update the url (and optional buffer) of this texture if url was null during construction.
  16030. * @param url the url of the texture
  16031. * @param buffer the buffer of the texture (defaults to null)
  16032. * @param onLoad callback called when the texture is loaded (defaults to null)
  16033. */
  16034. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16035. /**
  16036. * Finish the loading sequence of a texture flagged as delayed load.
  16037. * @hidden
  16038. */
  16039. delayLoad(): void;
  16040. private _prepareRowForTextureGeneration;
  16041. /**
  16042. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16043. * @returns the transform matrix of the texture.
  16044. */
  16045. getTextureMatrix(uBase?: number): Matrix;
  16046. /**
  16047. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16048. * @returns The reflection texture transform
  16049. */
  16050. getReflectionTextureMatrix(): Matrix;
  16051. /**
  16052. * Clones the texture.
  16053. * @returns the cloned texture
  16054. */
  16055. clone(): Texture;
  16056. /**
  16057. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16058. * @returns The JSON representation of the texture
  16059. */
  16060. serialize(): any;
  16061. /**
  16062. * Get the current class name of the texture useful for serialization or dynamic coding.
  16063. * @returns "Texture"
  16064. */
  16065. getClassName(): string;
  16066. /**
  16067. * Dispose the texture and release its associated resources.
  16068. */
  16069. dispose(): void;
  16070. /**
  16071. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16072. * @param parsedTexture Define the JSON representation of the texture
  16073. * @param scene Define the scene the parsed texture should be instantiated in
  16074. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16075. * @returns The parsed texture if successful
  16076. */
  16077. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16078. /**
  16079. * Creates a texture from its base 64 representation.
  16080. * @param data Define the base64 payload without the data: prefix
  16081. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16082. * @param scene Define the scene the texture should belong to
  16083. * @param noMipmap Forces the texture to not create mip map information if true
  16084. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16085. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16086. * @param onLoad define a callback triggered when the texture has been loaded
  16087. * @param onError define a callback triggered when an error occurred during the loading session
  16088. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16089. * @returns the created texture
  16090. */
  16091. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16092. /**
  16093. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16094. * @param data Define the base64 payload without the data: prefix
  16095. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16096. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16097. * @param scene Define the scene the texture should belong to
  16098. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16099. * @param noMipmap Forces the texture to not create mip map information if true
  16100. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16101. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16102. * @param onLoad define a callback triggered when the texture has been loaded
  16103. * @param onError define a callback triggered when an error occurred during the loading session
  16104. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16105. * @returns the created texture
  16106. */
  16107. 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;
  16108. }
  16109. }
  16110. declare module BABYLON {
  16111. /**
  16112. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16113. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16114. */
  16115. export class PostProcessManager {
  16116. private _scene;
  16117. private _indexBuffer;
  16118. private _vertexBuffers;
  16119. /**
  16120. * Creates a new instance PostProcess
  16121. * @param scene The scene that the post process is associated with.
  16122. */
  16123. constructor(scene: Scene);
  16124. private _prepareBuffers;
  16125. private _buildIndexBuffer;
  16126. /**
  16127. * Rebuilds the vertex buffers of the manager.
  16128. * @hidden
  16129. */
  16130. _rebuild(): void;
  16131. /**
  16132. * Prepares a frame to be run through a post process.
  16133. * @param sourceTexture The input texture to the post procesess. (default: null)
  16134. * @param postProcesses An array of post processes to be run. (default: null)
  16135. * @returns True if the post processes were able to be run.
  16136. * @hidden
  16137. */
  16138. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16139. /**
  16140. * Manually render a set of post processes to a texture.
  16141. * @param postProcesses An array of post processes to be run.
  16142. * @param targetTexture The target texture to render to.
  16143. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16144. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16145. * @param lodLevel defines which lod of the texture to render to
  16146. */
  16147. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16148. /**
  16149. * Finalize the result of the output of the postprocesses.
  16150. * @param doNotPresent If true the result will not be displayed to the screen.
  16151. * @param targetTexture The target texture to render to.
  16152. * @param faceIndex The index of the face to bind the target texture to.
  16153. * @param postProcesses The array of post processes to render.
  16154. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16155. * @hidden
  16156. */
  16157. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16158. /**
  16159. * Disposes of the post process manager.
  16160. */
  16161. dispose(): void;
  16162. }
  16163. }
  16164. declare module BABYLON {
  16165. /** Interface used by value gradients (color, factor, ...) */
  16166. export interface IValueGradient {
  16167. /**
  16168. * Gets or sets the gradient value (between 0 and 1)
  16169. */
  16170. gradient: number;
  16171. }
  16172. /** Class used to store color4 gradient */
  16173. export class ColorGradient implements IValueGradient {
  16174. /**
  16175. * Gets or sets the gradient value (between 0 and 1)
  16176. */
  16177. gradient: number;
  16178. /**
  16179. * Gets or sets first associated color
  16180. */
  16181. color1: Color4;
  16182. /**
  16183. * Gets or sets second associated color
  16184. */
  16185. color2?: Color4;
  16186. /**
  16187. * Will get a color picked randomly between color1 and color2.
  16188. * If color2 is undefined then color1 will be used
  16189. * @param result defines the target Color4 to store the result in
  16190. */
  16191. getColorToRef(result: Color4): void;
  16192. }
  16193. /** Class used to store color 3 gradient */
  16194. export class Color3Gradient implements IValueGradient {
  16195. /**
  16196. * Gets or sets the gradient value (between 0 and 1)
  16197. */
  16198. gradient: number;
  16199. /**
  16200. * Gets or sets the associated color
  16201. */
  16202. color: Color3;
  16203. }
  16204. /** Class used to store factor gradient */
  16205. export class FactorGradient implements IValueGradient {
  16206. /**
  16207. * Gets or sets the gradient value (between 0 and 1)
  16208. */
  16209. gradient: number;
  16210. /**
  16211. * Gets or sets first associated factor
  16212. */
  16213. factor1: number;
  16214. /**
  16215. * Gets or sets second associated factor
  16216. */
  16217. factor2?: number;
  16218. /**
  16219. * Will get a number picked randomly between factor1 and factor2.
  16220. * If factor2 is undefined then factor1 will be used
  16221. * @returns the picked number
  16222. */
  16223. getFactor(): number;
  16224. }
  16225. /**
  16226. * Helper used to simplify some generic gradient tasks
  16227. */
  16228. export class GradientHelper {
  16229. /**
  16230. * Gets the current gradient from an array of IValueGradient
  16231. * @param ratio defines the current ratio to get
  16232. * @param gradients defines the array of IValueGradient
  16233. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16234. */
  16235. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16236. }
  16237. }
  16238. declare module BABYLON {
  16239. interface ThinEngine {
  16240. /**
  16241. * Creates a dynamic texture
  16242. * @param width defines the width of the texture
  16243. * @param height defines the height of the texture
  16244. * @param generateMipMaps defines if the engine should generate the mip levels
  16245. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16246. * @returns the dynamic texture inside an InternalTexture
  16247. */
  16248. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16249. /**
  16250. * Update the content of a dynamic texture
  16251. * @param texture defines the texture to update
  16252. * @param canvas defines the canvas containing the source
  16253. * @param invertY defines if data must be stored with Y axis inverted
  16254. * @param premulAlpha defines if alpha is stored as premultiplied
  16255. * @param format defines the format of the data
  16256. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16257. */
  16258. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16259. }
  16260. }
  16261. declare module BABYLON {
  16262. /**
  16263. * Helper class used to generate a canvas to manipulate images
  16264. */
  16265. export class CanvasGenerator {
  16266. /**
  16267. * Create a new canvas (or offscreen canvas depending on the context)
  16268. * @param width defines the expected width
  16269. * @param height defines the expected height
  16270. * @return a new canvas or offscreen canvas
  16271. */
  16272. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16273. }
  16274. }
  16275. declare module BABYLON {
  16276. /**
  16277. * A class extending Texture allowing drawing on a texture
  16278. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16279. */
  16280. export class DynamicTexture extends Texture {
  16281. private _generateMipMaps;
  16282. private _canvas;
  16283. private _context;
  16284. private _engine;
  16285. /**
  16286. * Creates a DynamicTexture
  16287. * @param name defines the name of the texture
  16288. * @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
  16289. * @param scene defines the scene where you want the texture
  16290. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16291. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16292. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16293. */
  16294. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16295. /**
  16296. * Get the current class name of the texture useful for serialization or dynamic coding.
  16297. * @returns "DynamicTexture"
  16298. */
  16299. getClassName(): string;
  16300. /**
  16301. * Gets the current state of canRescale
  16302. */
  16303. readonly canRescale: boolean;
  16304. private _recreate;
  16305. /**
  16306. * Scales the texture
  16307. * @param ratio the scale factor to apply to both width and height
  16308. */
  16309. scale(ratio: number): void;
  16310. /**
  16311. * Resizes the texture
  16312. * @param width the new width
  16313. * @param height the new height
  16314. */
  16315. scaleTo(width: number, height: number): void;
  16316. /**
  16317. * Gets the context of the canvas used by the texture
  16318. * @returns the canvas context of the dynamic texture
  16319. */
  16320. getContext(): CanvasRenderingContext2D;
  16321. /**
  16322. * Clears the texture
  16323. */
  16324. clear(): void;
  16325. /**
  16326. * Updates the texture
  16327. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16328. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16329. */
  16330. update(invertY?: boolean, premulAlpha?: boolean): void;
  16331. /**
  16332. * Draws text onto the texture
  16333. * @param text defines the text to be drawn
  16334. * @param x defines the placement of the text from the left
  16335. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16336. * @param font defines the font to be used with font-style, font-size, font-name
  16337. * @param color defines the color used for the text
  16338. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16339. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16340. * @param update defines whether texture is immediately update (default is true)
  16341. */
  16342. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16343. /**
  16344. * Clones the texture
  16345. * @returns the clone of the texture.
  16346. */
  16347. clone(): DynamicTexture;
  16348. /**
  16349. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16350. * @returns a serialized dynamic texture object
  16351. */
  16352. serialize(): any;
  16353. /** @hidden */
  16354. _rebuild(): void;
  16355. }
  16356. }
  16357. declare module BABYLON {
  16358. interface AbstractScene {
  16359. /**
  16360. * The list of procedural textures added to the scene
  16361. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16362. */
  16363. proceduralTextures: Array<ProceduralTexture>;
  16364. }
  16365. /**
  16366. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16367. * in a given scene.
  16368. */
  16369. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16370. /**
  16371. * The component name helpfull to identify the component in the list of scene components.
  16372. */
  16373. readonly name: string;
  16374. /**
  16375. * The scene the component belongs to.
  16376. */
  16377. scene: Scene;
  16378. /**
  16379. * Creates a new instance of the component for the given scene
  16380. * @param scene Defines the scene to register the component in
  16381. */
  16382. constructor(scene: Scene);
  16383. /**
  16384. * Registers the component in a given scene
  16385. */
  16386. register(): void;
  16387. /**
  16388. * Rebuilds the elements related to this component in case of
  16389. * context lost for instance.
  16390. */
  16391. rebuild(): void;
  16392. /**
  16393. * Disposes the component and the associated ressources.
  16394. */
  16395. dispose(): void;
  16396. private _beforeClear;
  16397. }
  16398. }
  16399. declare module BABYLON {
  16400. interface ThinEngine {
  16401. /**
  16402. * Creates a new render target cube texture
  16403. * @param size defines the size of the texture
  16404. * @param options defines the options used to create the texture
  16405. * @returns a new render target cube texture stored in an InternalTexture
  16406. */
  16407. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16408. }
  16409. }
  16410. declare module BABYLON {
  16411. /** @hidden */
  16412. export var proceduralVertexShader: {
  16413. name: string;
  16414. shader: string;
  16415. };
  16416. }
  16417. declare module BABYLON {
  16418. /**
  16419. * 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.
  16420. * This is the base class of any Procedural texture and contains most of the shareable code.
  16421. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16422. */
  16423. export class ProceduralTexture extends Texture {
  16424. isCube: boolean;
  16425. /**
  16426. * Define if the texture is enabled or not (disabled texture will not render)
  16427. */
  16428. isEnabled: boolean;
  16429. /**
  16430. * Define if the texture must be cleared before rendering (default is true)
  16431. */
  16432. autoClear: boolean;
  16433. /**
  16434. * Callback called when the texture is generated
  16435. */
  16436. onGenerated: () => void;
  16437. /**
  16438. * Event raised when the texture is generated
  16439. */
  16440. onGeneratedObservable: Observable<ProceduralTexture>;
  16441. /** @hidden */
  16442. _generateMipMaps: boolean;
  16443. /** @hidden **/
  16444. _effect: Effect;
  16445. /** @hidden */
  16446. _textures: {
  16447. [key: string]: Texture;
  16448. };
  16449. private _size;
  16450. private _currentRefreshId;
  16451. private _refreshRate;
  16452. private _vertexBuffers;
  16453. private _indexBuffer;
  16454. private _uniforms;
  16455. private _samplers;
  16456. private _fragment;
  16457. private _floats;
  16458. private _ints;
  16459. private _floatsArrays;
  16460. private _colors3;
  16461. private _colors4;
  16462. private _vectors2;
  16463. private _vectors3;
  16464. private _matrices;
  16465. private _fallbackTexture;
  16466. private _fallbackTextureUsed;
  16467. private _engine;
  16468. private _cachedDefines;
  16469. private _contentUpdateId;
  16470. private _contentData;
  16471. /**
  16472. * Instantiates a new procedural texture.
  16473. * 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.
  16474. * This is the base class of any Procedural texture and contains most of the shareable code.
  16475. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16476. * @param name Define the name of the texture
  16477. * @param size Define the size of the texture to create
  16478. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16479. * @param scene Define the scene the texture belongs to
  16480. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16481. * @param generateMipMaps Define if the texture should creates mip maps or not
  16482. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16483. */
  16484. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16485. /**
  16486. * The effect that is created when initializing the post process.
  16487. * @returns The created effect corresponding the the postprocess.
  16488. */
  16489. getEffect(): Effect;
  16490. /**
  16491. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16492. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16493. */
  16494. getContent(): Nullable<ArrayBufferView>;
  16495. private _createIndexBuffer;
  16496. /** @hidden */
  16497. _rebuild(): void;
  16498. /**
  16499. * Resets the texture in order to recreate its associated resources.
  16500. * This can be called in case of context loss
  16501. */
  16502. reset(): void;
  16503. protected _getDefines(): string;
  16504. /**
  16505. * Is the texture ready to be used ? (rendered at least once)
  16506. * @returns true if ready, otherwise, false.
  16507. */
  16508. isReady(): boolean;
  16509. /**
  16510. * Resets the refresh counter of the texture and start bak from scratch.
  16511. * Could be useful to regenerate the texture if it is setup to render only once.
  16512. */
  16513. resetRefreshCounter(): void;
  16514. /**
  16515. * Set the fragment shader to use in order to render the texture.
  16516. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16517. */
  16518. setFragment(fragment: any): void;
  16519. /**
  16520. * Define the refresh rate of the texture or the rendering frequency.
  16521. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16522. */
  16523. refreshRate: number;
  16524. /** @hidden */
  16525. _shouldRender(): boolean;
  16526. /**
  16527. * Get the size the texture is rendering at.
  16528. * @returns the size (texture is always squared)
  16529. */
  16530. getRenderSize(): number;
  16531. /**
  16532. * Resize the texture to new value.
  16533. * @param size Define the new size the texture should have
  16534. * @param generateMipMaps Define whether the new texture should create mip maps
  16535. */
  16536. resize(size: number, generateMipMaps: boolean): void;
  16537. private _checkUniform;
  16538. /**
  16539. * Set a texture in the shader program used to render.
  16540. * @param name Define the name of the uniform samplers as defined in the shader
  16541. * @param texture Define the texture to bind to this sampler
  16542. * @return the texture itself allowing "fluent" like uniform updates
  16543. */
  16544. setTexture(name: string, texture: Texture): ProceduralTexture;
  16545. /**
  16546. * Set a float in the shader.
  16547. * @param name Define the name of the uniform as defined in the shader
  16548. * @param value Define the value to give to the uniform
  16549. * @return the texture itself allowing "fluent" like uniform updates
  16550. */
  16551. setFloat(name: string, value: number): ProceduralTexture;
  16552. /**
  16553. * Set a int in the shader.
  16554. * @param name Define the name of the uniform as defined in the shader
  16555. * @param value Define the value to give to the uniform
  16556. * @return the texture itself allowing "fluent" like uniform updates
  16557. */
  16558. setInt(name: string, value: number): ProceduralTexture;
  16559. /**
  16560. * Set an array of floats in the shader.
  16561. * @param name Define the name of the uniform as defined in the shader
  16562. * @param value Define the value to give to the uniform
  16563. * @return the texture itself allowing "fluent" like uniform updates
  16564. */
  16565. setFloats(name: string, value: number[]): ProceduralTexture;
  16566. /**
  16567. * Set a vec3 in the shader from a Color3.
  16568. * @param name Define the name of the uniform as defined in the shader
  16569. * @param value Define the value to give to the uniform
  16570. * @return the texture itself allowing "fluent" like uniform updates
  16571. */
  16572. setColor3(name: string, value: Color3): ProceduralTexture;
  16573. /**
  16574. * Set a vec4 in the shader from a Color4.
  16575. * @param name Define the name of the uniform as defined in the shader
  16576. * @param value Define the value to give to the uniform
  16577. * @return the texture itself allowing "fluent" like uniform updates
  16578. */
  16579. setColor4(name: string, value: Color4): ProceduralTexture;
  16580. /**
  16581. * Set a vec2 in the shader from a Vector2.
  16582. * @param name Define the name of the uniform as defined in the shader
  16583. * @param value Define the value to give to the uniform
  16584. * @return the texture itself allowing "fluent" like uniform updates
  16585. */
  16586. setVector2(name: string, value: Vector2): ProceduralTexture;
  16587. /**
  16588. * Set a vec3 in the shader from a Vector3.
  16589. * @param name Define the name of the uniform as defined in the shader
  16590. * @param value Define the value to give to the uniform
  16591. * @return the texture itself allowing "fluent" like uniform updates
  16592. */
  16593. setVector3(name: string, value: Vector3): ProceduralTexture;
  16594. /**
  16595. * Set a mat4 in the shader from a MAtrix.
  16596. * @param name Define the name of the uniform as defined in the shader
  16597. * @param value Define the value to give to the uniform
  16598. * @return the texture itself allowing "fluent" like uniform updates
  16599. */
  16600. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16601. /**
  16602. * Render the texture to its associated render target.
  16603. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16604. */
  16605. render(useCameraPostProcess?: boolean): void;
  16606. /**
  16607. * Clone the texture.
  16608. * @returns the cloned texture
  16609. */
  16610. clone(): ProceduralTexture;
  16611. /**
  16612. * Dispose the texture and release its asoociated resources.
  16613. */
  16614. dispose(): void;
  16615. }
  16616. }
  16617. declare module BABYLON {
  16618. /**
  16619. * This represents the base class for particle system in Babylon.
  16620. * 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.
  16621. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16622. * @example https://doc.babylonjs.com/babylon101/particles
  16623. */
  16624. export class BaseParticleSystem {
  16625. /**
  16626. * Source color is added to the destination color without alpha affecting the result
  16627. */
  16628. static BLENDMODE_ONEONE: number;
  16629. /**
  16630. * Blend current color and particle color using particle’s alpha
  16631. */
  16632. static BLENDMODE_STANDARD: number;
  16633. /**
  16634. * Add current color and particle color multiplied by particle’s alpha
  16635. */
  16636. static BLENDMODE_ADD: number;
  16637. /**
  16638. * Multiply current color with particle color
  16639. */
  16640. static BLENDMODE_MULTIPLY: number;
  16641. /**
  16642. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16643. */
  16644. static BLENDMODE_MULTIPLYADD: number;
  16645. /**
  16646. * List of animations used by the particle system.
  16647. */
  16648. animations: Animation[];
  16649. /**
  16650. * The id of the Particle system.
  16651. */
  16652. id: string;
  16653. /**
  16654. * The friendly name of the Particle system.
  16655. */
  16656. name: string;
  16657. /**
  16658. * The rendering group used by the Particle system to chose when to render.
  16659. */
  16660. renderingGroupId: number;
  16661. /**
  16662. * The emitter represents the Mesh or position we are attaching the particle system to.
  16663. */
  16664. emitter: Nullable<AbstractMesh | Vector3>;
  16665. /**
  16666. * The maximum number of particles to emit per frame
  16667. */
  16668. emitRate: number;
  16669. /**
  16670. * If you want to launch only a few particles at once, that can be done, as well.
  16671. */
  16672. manualEmitCount: number;
  16673. /**
  16674. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16675. */
  16676. updateSpeed: number;
  16677. /**
  16678. * The amount of time the particle system is running (depends of the overall update speed).
  16679. */
  16680. targetStopDuration: number;
  16681. /**
  16682. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16683. */
  16684. disposeOnStop: boolean;
  16685. /**
  16686. * Minimum power of emitting particles.
  16687. */
  16688. minEmitPower: number;
  16689. /**
  16690. * Maximum power of emitting particles.
  16691. */
  16692. maxEmitPower: number;
  16693. /**
  16694. * Minimum life time of emitting particles.
  16695. */
  16696. minLifeTime: number;
  16697. /**
  16698. * Maximum life time of emitting particles.
  16699. */
  16700. maxLifeTime: number;
  16701. /**
  16702. * Minimum Size of emitting particles.
  16703. */
  16704. minSize: number;
  16705. /**
  16706. * Maximum Size of emitting particles.
  16707. */
  16708. maxSize: number;
  16709. /**
  16710. * Minimum scale of emitting particles on X axis.
  16711. */
  16712. minScaleX: number;
  16713. /**
  16714. * Maximum scale of emitting particles on X axis.
  16715. */
  16716. maxScaleX: number;
  16717. /**
  16718. * Minimum scale of emitting particles on Y axis.
  16719. */
  16720. minScaleY: number;
  16721. /**
  16722. * Maximum scale of emitting particles on Y axis.
  16723. */
  16724. maxScaleY: number;
  16725. /**
  16726. * Gets or sets the minimal initial rotation in radians.
  16727. */
  16728. minInitialRotation: number;
  16729. /**
  16730. * Gets or sets the maximal initial rotation in radians.
  16731. */
  16732. maxInitialRotation: number;
  16733. /**
  16734. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16735. */
  16736. minAngularSpeed: number;
  16737. /**
  16738. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16739. */
  16740. maxAngularSpeed: number;
  16741. /**
  16742. * The texture used to render each particle. (this can be a spritesheet)
  16743. */
  16744. particleTexture: Nullable<Texture>;
  16745. /**
  16746. * The layer mask we are rendering the particles through.
  16747. */
  16748. layerMask: number;
  16749. /**
  16750. * This can help using your own shader to render the particle system.
  16751. * The according effect will be created
  16752. */
  16753. customShader: any;
  16754. /**
  16755. * By default particle system starts as soon as they are created. This prevents the
  16756. * automatic start to happen and let you decide when to start emitting particles.
  16757. */
  16758. preventAutoStart: boolean;
  16759. private _noiseTexture;
  16760. /**
  16761. * Gets or sets a texture used to add random noise to particle positions
  16762. */
  16763. noiseTexture: Nullable<ProceduralTexture>;
  16764. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16765. noiseStrength: Vector3;
  16766. /**
  16767. * Callback triggered when the particle animation is ending.
  16768. */
  16769. onAnimationEnd: Nullable<() => void>;
  16770. /**
  16771. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16772. */
  16773. blendMode: number;
  16774. /**
  16775. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16776. * to override the particles.
  16777. */
  16778. forceDepthWrite: boolean;
  16779. /** 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 */
  16780. preWarmCycles: number;
  16781. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16782. preWarmStepOffset: number;
  16783. /**
  16784. * 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)
  16785. */
  16786. spriteCellChangeSpeed: number;
  16787. /**
  16788. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16789. */
  16790. startSpriteCellID: number;
  16791. /**
  16792. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16793. */
  16794. endSpriteCellID: number;
  16795. /**
  16796. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16797. */
  16798. spriteCellWidth: number;
  16799. /**
  16800. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16801. */
  16802. spriteCellHeight: number;
  16803. /**
  16804. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16805. */
  16806. spriteRandomStartCell: boolean;
  16807. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16808. translationPivot: Vector2;
  16809. /** @hidden */
  16810. protected _isAnimationSheetEnabled: boolean;
  16811. /**
  16812. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16813. */
  16814. beginAnimationOnStart: boolean;
  16815. /**
  16816. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16817. */
  16818. beginAnimationFrom: number;
  16819. /**
  16820. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16821. */
  16822. beginAnimationTo: number;
  16823. /**
  16824. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16825. */
  16826. beginAnimationLoop: boolean;
  16827. /**
  16828. * Gets or sets a world offset applied to all particles
  16829. */
  16830. worldOffset: Vector3;
  16831. /**
  16832. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16833. */
  16834. isAnimationSheetEnabled: boolean;
  16835. /**
  16836. * Get hosting scene
  16837. * @returns the scene
  16838. */
  16839. getScene(): Scene;
  16840. /**
  16841. * You can use gravity if you want to give an orientation to your particles.
  16842. */
  16843. gravity: Vector3;
  16844. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16845. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16846. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16847. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16848. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16849. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16850. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16851. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16852. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16853. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16854. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16855. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16856. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16857. /**
  16858. * Defines the delay in milliseconds before starting the system (0 by default)
  16859. */
  16860. startDelay: number;
  16861. /**
  16862. * Gets the current list of drag gradients.
  16863. * You must use addDragGradient and removeDragGradient to udpate this list
  16864. * @returns the list of drag gradients
  16865. */
  16866. getDragGradients(): Nullable<Array<FactorGradient>>;
  16867. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16868. limitVelocityDamping: number;
  16869. /**
  16870. * Gets the current list of limit velocity gradients.
  16871. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16872. * @returns the list of limit velocity gradients
  16873. */
  16874. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16875. /**
  16876. * Gets the current list of color gradients.
  16877. * You must use addColorGradient and removeColorGradient to udpate this list
  16878. * @returns the list of color gradients
  16879. */
  16880. getColorGradients(): Nullable<Array<ColorGradient>>;
  16881. /**
  16882. * Gets the current list of size gradients.
  16883. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16884. * @returns the list of size gradients
  16885. */
  16886. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16887. /**
  16888. * Gets the current list of color remap gradients.
  16889. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16890. * @returns the list of color remap gradients
  16891. */
  16892. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16893. /**
  16894. * Gets the current list of alpha remap gradients.
  16895. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16896. * @returns the list of alpha remap gradients
  16897. */
  16898. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16899. /**
  16900. * Gets the current list of life time gradients.
  16901. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16902. * @returns the list of life time gradients
  16903. */
  16904. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16905. /**
  16906. * Gets the current list of angular speed gradients.
  16907. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16908. * @returns the list of angular speed gradients
  16909. */
  16910. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16911. /**
  16912. * Gets the current list of velocity gradients.
  16913. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16914. * @returns the list of velocity gradients
  16915. */
  16916. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16917. /**
  16918. * Gets the current list of start size gradients.
  16919. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16920. * @returns the list of start size gradients
  16921. */
  16922. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16923. /**
  16924. * Gets the current list of emit rate gradients.
  16925. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16926. * @returns the list of emit rate gradients
  16927. */
  16928. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16929. /**
  16930. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16931. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16932. */
  16933. direction1: Vector3;
  16934. /**
  16935. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16936. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16937. */
  16938. direction2: Vector3;
  16939. /**
  16940. * 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.
  16941. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16942. */
  16943. minEmitBox: Vector3;
  16944. /**
  16945. * 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.
  16946. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16947. */
  16948. maxEmitBox: Vector3;
  16949. /**
  16950. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16951. */
  16952. color1: Color4;
  16953. /**
  16954. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16955. */
  16956. color2: Color4;
  16957. /**
  16958. * Color the particle will have at the end of its lifetime
  16959. */
  16960. colorDead: Color4;
  16961. /**
  16962. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16963. */
  16964. textureMask: Color4;
  16965. /**
  16966. * The particle emitter type defines the emitter used by the particle system.
  16967. * It can be for example box, sphere, or cone...
  16968. */
  16969. particleEmitterType: IParticleEmitterType;
  16970. /** @hidden */
  16971. _isSubEmitter: boolean;
  16972. /**
  16973. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16974. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16975. */
  16976. billboardMode: number;
  16977. protected _isBillboardBased: boolean;
  16978. /**
  16979. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16980. */
  16981. isBillboardBased: boolean;
  16982. /**
  16983. * The scene the particle system belongs to.
  16984. */
  16985. protected _scene: Scene;
  16986. /**
  16987. * Local cache of defines for image processing.
  16988. */
  16989. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16990. /**
  16991. * Default configuration related to image processing available in the standard Material.
  16992. */
  16993. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16994. /**
  16995. * Gets the image processing configuration used either in this material.
  16996. */
  16997. /**
  16998. * Sets the Default image processing configuration used either in the this material.
  16999. *
  17000. * If sets to null, the scene one is in use.
  17001. */
  17002. imageProcessingConfiguration: ImageProcessingConfiguration;
  17003. /**
  17004. * Attaches a new image processing configuration to the Standard Material.
  17005. * @param configuration
  17006. */
  17007. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17008. /** @hidden */
  17009. protected _reset(): void;
  17010. /** @hidden */
  17011. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17012. /**
  17013. * Instantiates a particle system.
  17014. * 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.
  17015. * @param name The name of the particle system
  17016. */
  17017. constructor(name: string);
  17018. /**
  17019. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17020. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17021. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17022. * @returns the emitter
  17023. */
  17024. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17025. /**
  17026. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17027. * @param radius The radius of the hemisphere to emit from
  17028. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17029. * @returns the emitter
  17030. */
  17031. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17032. /**
  17033. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17034. * @param radius The radius of the sphere to emit from
  17035. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17036. * @returns the emitter
  17037. */
  17038. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17039. /**
  17040. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17041. * @param radius The radius of the sphere to emit from
  17042. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17043. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17044. * @returns the emitter
  17045. */
  17046. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17047. /**
  17048. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17049. * @param radius The radius of the emission cylinder
  17050. * @param height The height of the emission cylinder
  17051. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17052. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17053. * @returns the emitter
  17054. */
  17055. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17056. /**
  17057. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17058. * @param radius The radius of the cylinder to emit from
  17059. * @param height The height of the emission cylinder
  17060. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17061. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17062. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17063. * @returns the emitter
  17064. */
  17065. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17066. /**
  17067. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17068. * @param radius The radius of the cone to emit from
  17069. * @param angle The base angle of the cone
  17070. * @returns the emitter
  17071. */
  17072. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17073. /**
  17074. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17075. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17076. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17077. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17078. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17079. * @returns the emitter
  17080. */
  17081. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17082. }
  17083. }
  17084. declare module BABYLON {
  17085. /**
  17086. * Type of sub emitter
  17087. */
  17088. export enum SubEmitterType {
  17089. /**
  17090. * Attached to the particle over it's lifetime
  17091. */
  17092. ATTACHED = 0,
  17093. /**
  17094. * Created when the particle dies
  17095. */
  17096. END = 1
  17097. }
  17098. /**
  17099. * Sub emitter class used to emit particles from an existing particle
  17100. */
  17101. export class SubEmitter {
  17102. /**
  17103. * the particle system to be used by the sub emitter
  17104. */
  17105. particleSystem: ParticleSystem;
  17106. /**
  17107. * Type of the submitter (Default: END)
  17108. */
  17109. type: SubEmitterType;
  17110. /**
  17111. * 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)
  17112. * Note: This only is supported when using an emitter of type Mesh
  17113. */
  17114. inheritDirection: boolean;
  17115. /**
  17116. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17117. */
  17118. inheritedVelocityAmount: number;
  17119. /**
  17120. * Creates a sub emitter
  17121. * @param particleSystem the particle system to be used by the sub emitter
  17122. */
  17123. constructor(
  17124. /**
  17125. * the particle system to be used by the sub emitter
  17126. */
  17127. particleSystem: ParticleSystem);
  17128. /**
  17129. * Clones the sub emitter
  17130. * @returns the cloned sub emitter
  17131. */
  17132. clone(): SubEmitter;
  17133. /**
  17134. * Serialize current object to a JSON object
  17135. * @returns the serialized object
  17136. */
  17137. serialize(): any;
  17138. /** @hidden */
  17139. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17140. /**
  17141. * Creates a new SubEmitter from a serialized JSON version
  17142. * @param serializationObject defines the JSON object to read from
  17143. * @param scene defines the hosting scene
  17144. * @param rootUrl defines the rootUrl for data loading
  17145. * @returns a new SubEmitter
  17146. */
  17147. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17148. /** Release associated resources */
  17149. dispose(): void;
  17150. }
  17151. }
  17152. declare module BABYLON {
  17153. /** @hidden */
  17154. export var clipPlaneFragmentDeclaration: {
  17155. name: string;
  17156. shader: string;
  17157. };
  17158. }
  17159. declare module BABYLON {
  17160. /** @hidden */
  17161. export var imageProcessingDeclaration: {
  17162. name: string;
  17163. shader: string;
  17164. };
  17165. }
  17166. declare module BABYLON {
  17167. /** @hidden */
  17168. export var imageProcessingFunctions: {
  17169. name: string;
  17170. shader: string;
  17171. };
  17172. }
  17173. declare module BABYLON {
  17174. /** @hidden */
  17175. export var clipPlaneFragment: {
  17176. name: string;
  17177. shader: string;
  17178. };
  17179. }
  17180. declare module BABYLON {
  17181. /** @hidden */
  17182. export var particlesPixelShader: {
  17183. name: string;
  17184. shader: string;
  17185. };
  17186. }
  17187. declare module BABYLON {
  17188. /** @hidden */
  17189. export var clipPlaneVertexDeclaration: {
  17190. name: string;
  17191. shader: string;
  17192. };
  17193. }
  17194. declare module BABYLON {
  17195. /** @hidden */
  17196. export var clipPlaneVertex: {
  17197. name: string;
  17198. shader: string;
  17199. };
  17200. }
  17201. declare module BABYLON {
  17202. /** @hidden */
  17203. export var particlesVertexShader: {
  17204. name: string;
  17205. shader: string;
  17206. };
  17207. }
  17208. declare module BABYLON {
  17209. /**
  17210. * This represents a particle system in Babylon.
  17211. * 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.
  17212. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17213. * @example https://doc.babylonjs.com/babylon101/particles
  17214. */
  17215. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17216. /**
  17217. * Billboard mode will only apply to Y axis
  17218. */
  17219. static readonly BILLBOARDMODE_Y: number;
  17220. /**
  17221. * Billboard mode will apply to all axes
  17222. */
  17223. static readonly BILLBOARDMODE_ALL: number;
  17224. /**
  17225. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17226. */
  17227. static readonly BILLBOARDMODE_STRETCHED: number;
  17228. /**
  17229. * This function can be defined to provide custom update for active particles.
  17230. * This function will be called instead of regular update (age, position, color, etc.).
  17231. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17232. */
  17233. updateFunction: (particles: Particle[]) => void;
  17234. private _emitterWorldMatrix;
  17235. /**
  17236. * This function can be defined to specify initial direction for every new particle.
  17237. * It by default use the emitterType defined function
  17238. */
  17239. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17240. /**
  17241. * This function can be defined to specify initial position for every new particle.
  17242. * It by default use the emitterType defined function
  17243. */
  17244. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17245. /**
  17246. * @hidden
  17247. */
  17248. _inheritedVelocityOffset: Vector3;
  17249. /**
  17250. * An event triggered when the system is disposed
  17251. */
  17252. onDisposeObservable: Observable<ParticleSystem>;
  17253. private _onDisposeObserver;
  17254. /**
  17255. * Sets a callback that will be triggered when the system is disposed
  17256. */
  17257. onDispose: () => void;
  17258. private _particles;
  17259. private _epsilon;
  17260. private _capacity;
  17261. private _stockParticles;
  17262. private _newPartsExcess;
  17263. private _vertexData;
  17264. private _vertexBuffer;
  17265. private _vertexBuffers;
  17266. private _spriteBuffer;
  17267. private _indexBuffer;
  17268. private _effect;
  17269. private _customEffect;
  17270. private _cachedDefines;
  17271. private _scaledColorStep;
  17272. private _colorDiff;
  17273. private _scaledDirection;
  17274. private _scaledGravity;
  17275. private _currentRenderId;
  17276. private _alive;
  17277. private _useInstancing;
  17278. private _started;
  17279. private _stopped;
  17280. private _actualFrame;
  17281. private _scaledUpdateSpeed;
  17282. private _vertexBufferSize;
  17283. /** @hidden */
  17284. _currentEmitRateGradient: Nullable<FactorGradient>;
  17285. /** @hidden */
  17286. _currentEmitRate1: number;
  17287. /** @hidden */
  17288. _currentEmitRate2: number;
  17289. /** @hidden */
  17290. _currentStartSizeGradient: Nullable<FactorGradient>;
  17291. /** @hidden */
  17292. _currentStartSize1: number;
  17293. /** @hidden */
  17294. _currentStartSize2: number;
  17295. private readonly _rawTextureWidth;
  17296. private _rampGradientsTexture;
  17297. private _useRampGradients;
  17298. /** Gets or sets a boolean indicating that ramp gradients must be used
  17299. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17300. */
  17301. useRampGradients: boolean;
  17302. /**
  17303. * 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.
  17304. * 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: [])
  17305. */
  17306. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17307. private _subEmitters;
  17308. /**
  17309. * @hidden
  17310. * If the particle systems emitter should be disposed when the particle system is disposed
  17311. */
  17312. _disposeEmitterOnDispose: boolean;
  17313. /**
  17314. * The current active Sub-systems, this property is used by the root particle system only.
  17315. */
  17316. activeSubSystems: Array<ParticleSystem>;
  17317. private _rootParticleSystem;
  17318. /**
  17319. * Gets the current list of active particles
  17320. */
  17321. readonly particles: Particle[];
  17322. /**
  17323. * Returns the string "ParticleSystem"
  17324. * @returns a string containing the class name
  17325. */
  17326. getClassName(): string;
  17327. /**
  17328. * Instantiates a particle system.
  17329. * 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.
  17330. * @param name The name of the particle system
  17331. * @param capacity The max number of particles alive at the same time
  17332. * @param scene The scene the particle system belongs to
  17333. * @param customEffect a custom effect used to change the way particles are rendered by default
  17334. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17335. * @param epsilon Offset used to render the particles
  17336. */
  17337. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17338. private _addFactorGradient;
  17339. private _removeFactorGradient;
  17340. /**
  17341. * Adds a new life time gradient
  17342. * @param gradient defines the gradient to use (between 0 and 1)
  17343. * @param factor defines the life time factor to affect to the specified gradient
  17344. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17345. * @returns the current particle system
  17346. */
  17347. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17348. /**
  17349. * Remove a specific life time gradient
  17350. * @param gradient defines the gradient to remove
  17351. * @returns the current particle system
  17352. */
  17353. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17354. /**
  17355. * Adds a new size gradient
  17356. * @param gradient defines the gradient to use (between 0 and 1)
  17357. * @param factor defines the size factor to affect to the specified gradient
  17358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17359. * @returns the current particle system
  17360. */
  17361. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17362. /**
  17363. * Remove a specific size gradient
  17364. * @param gradient defines the gradient to remove
  17365. * @returns the current particle system
  17366. */
  17367. removeSizeGradient(gradient: number): IParticleSystem;
  17368. /**
  17369. * Adds a new color remap gradient
  17370. * @param gradient defines the gradient to use (between 0 and 1)
  17371. * @param min defines the color remap minimal range
  17372. * @param max defines the color remap maximal range
  17373. * @returns the current particle system
  17374. */
  17375. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17376. /**
  17377. * Remove a specific color remap gradient
  17378. * @param gradient defines the gradient to remove
  17379. * @returns the current particle system
  17380. */
  17381. removeColorRemapGradient(gradient: number): IParticleSystem;
  17382. /**
  17383. * Adds a new alpha remap gradient
  17384. * @param gradient defines the gradient to use (between 0 and 1)
  17385. * @param min defines the alpha remap minimal range
  17386. * @param max defines the alpha remap maximal range
  17387. * @returns the current particle system
  17388. */
  17389. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17390. /**
  17391. * Remove a specific alpha remap gradient
  17392. * @param gradient defines the gradient to remove
  17393. * @returns the current particle system
  17394. */
  17395. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17396. /**
  17397. * Adds a new angular speed gradient
  17398. * @param gradient defines the gradient to use (between 0 and 1)
  17399. * @param factor defines the angular speed to affect to the specified gradient
  17400. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17401. * @returns the current particle system
  17402. */
  17403. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17404. /**
  17405. * Remove a specific angular speed gradient
  17406. * @param gradient defines the gradient to remove
  17407. * @returns the current particle system
  17408. */
  17409. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17410. /**
  17411. * Adds a new velocity gradient
  17412. * @param gradient defines the gradient to use (between 0 and 1)
  17413. * @param factor defines the velocity to affect to the specified gradient
  17414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17415. * @returns the current particle system
  17416. */
  17417. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17418. /**
  17419. * Remove a specific velocity gradient
  17420. * @param gradient defines the gradient to remove
  17421. * @returns the current particle system
  17422. */
  17423. removeVelocityGradient(gradient: number): IParticleSystem;
  17424. /**
  17425. * Adds a new limit velocity gradient
  17426. * @param gradient defines the gradient to use (between 0 and 1)
  17427. * @param factor defines the limit velocity value to affect to the specified gradient
  17428. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17429. * @returns the current particle system
  17430. */
  17431. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17432. /**
  17433. * Remove a specific limit velocity gradient
  17434. * @param gradient defines the gradient to remove
  17435. * @returns the current particle system
  17436. */
  17437. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17438. /**
  17439. * Adds a new drag gradient
  17440. * @param gradient defines the gradient to use (between 0 and 1)
  17441. * @param factor defines the drag value to affect to the specified gradient
  17442. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17443. * @returns the current particle system
  17444. */
  17445. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17446. /**
  17447. * Remove a specific drag gradient
  17448. * @param gradient defines the gradient to remove
  17449. * @returns the current particle system
  17450. */
  17451. removeDragGradient(gradient: number): IParticleSystem;
  17452. /**
  17453. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17454. * @param gradient defines the gradient to use (between 0 and 1)
  17455. * @param factor defines the emit rate value to affect to the specified gradient
  17456. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17457. * @returns the current particle system
  17458. */
  17459. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17460. /**
  17461. * Remove a specific emit rate gradient
  17462. * @param gradient defines the gradient to remove
  17463. * @returns the current particle system
  17464. */
  17465. removeEmitRateGradient(gradient: number): IParticleSystem;
  17466. /**
  17467. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17468. * @param gradient defines the gradient to use (between 0 and 1)
  17469. * @param factor defines the start size value to affect to the specified gradient
  17470. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17471. * @returns the current particle system
  17472. */
  17473. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17474. /**
  17475. * Remove a specific start size gradient
  17476. * @param gradient defines the gradient to remove
  17477. * @returns the current particle system
  17478. */
  17479. removeStartSizeGradient(gradient: number): IParticleSystem;
  17480. private _createRampGradientTexture;
  17481. /**
  17482. * Gets the current list of ramp gradients.
  17483. * You must use addRampGradient and removeRampGradient to udpate this list
  17484. * @returns the list of ramp gradients
  17485. */
  17486. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17487. /**
  17488. * Adds a new ramp gradient used to remap particle colors
  17489. * @param gradient defines the gradient to use (between 0 and 1)
  17490. * @param color defines the color to affect to the specified gradient
  17491. * @returns the current particle system
  17492. */
  17493. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17494. /**
  17495. * Remove a specific ramp gradient
  17496. * @param gradient defines the gradient to remove
  17497. * @returns the current particle system
  17498. */
  17499. removeRampGradient(gradient: number): ParticleSystem;
  17500. /**
  17501. * Adds a new color gradient
  17502. * @param gradient defines the gradient to use (between 0 and 1)
  17503. * @param color1 defines the color to affect to the specified gradient
  17504. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17505. * @returns this particle system
  17506. */
  17507. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17508. /**
  17509. * Remove a specific color gradient
  17510. * @param gradient defines the gradient to remove
  17511. * @returns this particle system
  17512. */
  17513. removeColorGradient(gradient: number): IParticleSystem;
  17514. private _fetchR;
  17515. protected _reset(): void;
  17516. private _resetEffect;
  17517. private _createVertexBuffers;
  17518. private _createIndexBuffer;
  17519. /**
  17520. * Gets the maximum number of particles active at the same time.
  17521. * @returns The max number of active particles.
  17522. */
  17523. getCapacity(): number;
  17524. /**
  17525. * Gets whether there are still active particles in the system.
  17526. * @returns True if it is alive, otherwise false.
  17527. */
  17528. isAlive(): boolean;
  17529. /**
  17530. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17531. * @returns True if it has been started, otherwise false.
  17532. */
  17533. isStarted(): boolean;
  17534. private _prepareSubEmitterInternalArray;
  17535. /**
  17536. * Starts the particle system and begins to emit
  17537. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17538. */
  17539. start(delay?: number): void;
  17540. /**
  17541. * Stops the particle system.
  17542. * @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.
  17543. */
  17544. stop(stopSubEmitters?: boolean): void;
  17545. /**
  17546. * Remove all active particles
  17547. */
  17548. reset(): void;
  17549. /**
  17550. * @hidden (for internal use only)
  17551. */
  17552. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17553. /**
  17554. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17555. * Its lifetime will start back at 0.
  17556. */
  17557. recycleParticle: (particle: Particle) => void;
  17558. private _stopSubEmitters;
  17559. private _createParticle;
  17560. private _removeFromRoot;
  17561. private _emitFromParticle;
  17562. private _update;
  17563. /** @hidden */
  17564. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17565. /** @hidden */
  17566. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17567. /** @hidden */
  17568. private _getEffect;
  17569. /**
  17570. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17571. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17572. */
  17573. animate(preWarmOnly?: boolean): void;
  17574. private _appendParticleVertices;
  17575. /**
  17576. * Rebuilds the particle system.
  17577. */
  17578. rebuild(): void;
  17579. /**
  17580. * Is this system ready to be used/rendered
  17581. * @return true if the system is ready
  17582. */
  17583. isReady(): boolean;
  17584. private _render;
  17585. /**
  17586. * Renders the particle system in its current state.
  17587. * @returns the current number of particles
  17588. */
  17589. render(): number;
  17590. /**
  17591. * Disposes the particle system and free the associated resources
  17592. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17593. */
  17594. dispose(disposeTexture?: boolean): void;
  17595. /**
  17596. * Clones the particle system.
  17597. * @param name The name of the cloned object
  17598. * @param newEmitter The new emitter to use
  17599. * @returns the cloned particle system
  17600. */
  17601. clone(name: string, newEmitter: any): ParticleSystem;
  17602. /**
  17603. * Serializes the particle system to a JSON object.
  17604. * @returns the JSON object
  17605. */
  17606. serialize(): any;
  17607. /** @hidden */
  17608. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17609. /** @hidden */
  17610. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17611. /**
  17612. * Parses a JSON object to create a particle system.
  17613. * @param parsedParticleSystem The JSON object to parse
  17614. * @param scene The scene to create the particle system in
  17615. * @param rootUrl The root url to use to load external dependencies like texture
  17616. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17617. * @returns the Parsed particle system
  17618. */
  17619. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17620. }
  17621. }
  17622. declare module BABYLON {
  17623. /**
  17624. * A particle represents one of the element emitted by a particle system.
  17625. * This is mainly define by its coordinates, direction, velocity and age.
  17626. */
  17627. export class Particle {
  17628. /**
  17629. * The particle system the particle belongs to.
  17630. */
  17631. particleSystem: ParticleSystem;
  17632. private static _Count;
  17633. /**
  17634. * Unique ID of the particle
  17635. */
  17636. id: number;
  17637. /**
  17638. * The world position of the particle in the scene.
  17639. */
  17640. position: Vector3;
  17641. /**
  17642. * The world direction of the particle in the scene.
  17643. */
  17644. direction: Vector3;
  17645. /**
  17646. * The color of the particle.
  17647. */
  17648. color: Color4;
  17649. /**
  17650. * The color change of the particle per step.
  17651. */
  17652. colorStep: Color4;
  17653. /**
  17654. * Defines how long will the life of the particle be.
  17655. */
  17656. lifeTime: number;
  17657. /**
  17658. * The current age of the particle.
  17659. */
  17660. age: number;
  17661. /**
  17662. * The current size of the particle.
  17663. */
  17664. size: number;
  17665. /**
  17666. * The current scale of the particle.
  17667. */
  17668. scale: Vector2;
  17669. /**
  17670. * The current angle of the particle.
  17671. */
  17672. angle: number;
  17673. /**
  17674. * Defines how fast is the angle changing.
  17675. */
  17676. angularSpeed: number;
  17677. /**
  17678. * Defines the cell index used by the particle to be rendered from a sprite.
  17679. */
  17680. cellIndex: number;
  17681. /**
  17682. * The information required to support color remapping
  17683. */
  17684. remapData: Vector4;
  17685. /** @hidden */
  17686. _randomCellOffset?: number;
  17687. /** @hidden */
  17688. _initialDirection: Nullable<Vector3>;
  17689. /** @hidden */
  17690. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17691. /** @hidden */
  17692. _initialStartSpriteCellID: number;
  17693. /** @hidden */
  17694. _initialEndSpriteCellID: number;
  17695. /** @hidden */
  17696. _currentColorGradient: Nullable<ColorGradient>;
  17697. /** @hidden */
  17698. _currentColor1: Color4;
  17699. /** @hidden */
  17700. _currentColor2: Color4;
  17701. /** @hidden */
  17702. _currentSizeGradient: Nullable<FactorGradient>;
  17703. /** @hidden */
  17704. _currentSize1: number;
  17705. /** @hidden */
  17706. _currentSize2: number;
  17707. /** @hidden */
  17708. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17709. /** @hidden */
  17710. _currentAngularSpeed1: number;
  17711. /** @hidden */
  17712. _currentAngularSpeed2: number;
  17713. /** @hidden */
  17714. _currentVelocityGradient: Nullable<FactorGradient>;
  17715. /** @hidden */
  17716. _currentVelocity1: number;
  17717. /** @hidden */
  17718. _currentVelocity2: number;
  17719. /** @hidden */
  17720. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17721. /** @hidden */
  17722. _currentLimitVelocity1: number;
  17723. /** @hidden */
  17724. _currentLimitVelocity2: number;
  17725. /** @hidden */
  17726. _currentDragGradient: Nullable<FactorGradient>;
  17727. /** @hidden */
  17728. _currentDrag1: number;
  17729. /** @hidden */
  17730. _currentDrag2: number;
  17731. /** @hidden */
  17732. _randomNoiseCoordinates1: Vector3;
  17733. /** @hidden */
  17734. _randomNoiseCoordinates2: Vector3;
  17735. /**
  17736. * Creates a new instance Particle
  17737. * @param particleSystem the particle system the particle belongs to
  17738. */
  17739. constructor(
  17740. /**
  17741. * The particle system the particle belongs to.
  17742. */
  17743. particleSystem: ParticleSystem);
  17744. private updateCellInfoFromSystem;
  17745. /**
  17746. * Defines how the sprite cell index is updated for the particle
  17747. */
  17748. updateCellIndex(): void;
  17749. /** @hidden */
  17750. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17751. /** @hidden */
  17752. _inheritParticleInfoToSubEmitters(): void;
  17753. /** @hidden */
  17754. _reset(): void;
  17755. /**
  17756. * Copy the properties of particle to another one.
  17757. * @param other the particle to copy the information to.
  17758. */
  17759. copyTo(other: Particle): void;
  17760. }
  17761. }
  17762. declare module BABYLON {
  17763. /**
  17764. * Particle emitter represents a volume emitting particles.
  17765. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17766. */
  17767. export interface IParticleEmitterType {
  17768. /**
  17769. * Called by the particle System when the direction is computed for the created particle.
  17770. * @param worldMatrix is the world matrix of the particle system
  17771. * @param directionToUpdate is the direction vector to update with the result
  17772. * @param particle is the particle we are computed the direction for
  17773. */
  17774. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17775. /**
  17776. * Called by the particle System when the position is computed for the created particle.
  17777. * @param worldMatrix is the world matrix of the particle system
  17778. * @param positionToUpdate is the position vector to update with the result
  17779. * @param particle is the particle we are computed the position for
  17780. */
  17781. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17782. /**
  17783. * Clones the current emitter and returns a copy of it
  17784. * @returns the new emitter
  17785. */
  17786. clone(): IParticleEmitterType;
  17787. /**
  17788. * Called by the GPUParticleSystem to setup the update shader
  17789. * @param effect defines the update shader
  17790. */
  17791. applyToShader(effect: Effect): void;
  17792. /**
  17793. * Returns a string to use to update the GPU particles update shader
  17794. * @returns the effect defines string
  17795. */
  17796. getEffectDefines(): string;
  17797. /**
  17798. * Returns a string representing the class name
  17799. * @returns a string containing the class name
  17800. */
  17801. getClassName(): string;
  17802. /**
  17803. * Serializes the particle system to a JSON object.
  17804. * @returns the JSON object
  17805. */
  17806. serialize(): any;
  17807. /**
  17808. * Parse properties from a JSON object
  17809. * @param serializationObject defines the JSON object
  17810. */
  17811. parse(serializationObject: any): void;
  17812. }
  17813. }
  17814. declare module BABYLON {
  17815. /**
  17816. * Particle emitter emitting particles from the inside of a box.
  17817. * It emits the particles randomly between 2 given directions.
  17818. */
  17819. export class BoxParticleEmitter implements IParticleEmitterType {
  17820. /**
  17821. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17822. */
  17823. direction1: Vector3;
  17824. /**
  17825. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17826. */
  17827. direction2: Vector3;
  17828. /**
  17829. * 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.
  17830. */
  17831. minEmitBox: Vector3;
  17832. /**
  17833. * 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.
  17834. */
  17835. maxEmitBox: Vector3;
  17836. /**
  17837. * Creates a new instance BoxParticleEmitter
  17838. */
  17839. constructor();
  17840. /**
  17841. * Called by the particle System when the direction is computed for the created particle.
  17842. * @param worldMatrix is the world matrix of the particle system
  17843. * @param directionToUpdate is the direction vector to update with the result
  17844. * @param particle is the particle we are computed the direction for
  17845. */
  17846. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17847. /**
  17848. * Called by the particle System when the position is computed for the created particle.
  17849. * @param worldMatrix is the world matrix of the particle system
  17850. * @param positionToUpdate is the position vector to update with the result
  17851. * @param particle is the particle we are computed the position for
  17852. */
  17853. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17854. /**
  17855. * Clones the current emitter and returns a copy of it
  17856. * @returns the new emitter
  17857. */
  17858. clone(): BoxParticleEmitter;
  17859. /**
  17860. * Called by the GPUParticleSystem to setup the update shader
  17861. * @param effect defines the update shader
  17862. */
  17863. applyToShader(effect: Effect): void;
  17864. /**
  17865. * Returns a string to use to update the GPU particles update shader
  17866. * @returns a string containng the defines string
  17867. */
  17868. getEffectDefines(): string;
  17869. /**
  17870. * Returns the string "BoxParticleEmitter"
  17871. * @returns a string containing the class name
  17872. */
  17873. getClassName(): string;
  17874. /**
  17875. * Serializes the particle system to a JSON object.
  17876. * @returns the JSON object
  17877. */
  17878. serialize(): any;
  17879. /**
  17880. * Parse properties from a JSON object
  17881. * @param serializationObject defines the JSON object
  17882. */
  17883. parse(serializationObject: any): void;
  17884. }
  17885. }
  17886. declare module BABYLON {
  17887. /**
  17888. * Particle emitter emitting particles from the inside of a cone.
  17889. * It emits the particles alongside the cone volume from the base to the particle.
  17890. * The emission direction might be randomized.
  17891. */
  17892. export class ConeParticleEmitter implements IParticleEmitterType {
  17893. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17894. directionRandomizer: number;
  17895. private _radius;
  17896. private _angle;
  17897. private _height;
  17898. /**
  17899. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17900. */
  17901. radiusRange: number;
  17902. /**
  17903. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17904. */
  17905. heightRange: number;
  17906. /**
  17907. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17908. */
  17909. emitFromSpawnPointOnly: boolean;
  17910. /**
  17911. * Gets or sets the radius of the emission cone
  17912. */
  17913. radius: number;
  17914. /**
  17915. * Gets or sets the angle of the emission cone
  17916. */
  17917. angle: number;
  17918. private _buildHeight;
  17919. /**
  17920. * Creates a new instance ConeParticleEmitter
  17921. * @param radius the radius of the emission cone (1 by default)
  17922. * @param angle the cone base angle (PI by default)
  17923. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17924. */
  17925. constructor(radius?: number, angle?: number,
  17926. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17927. directionRandomizer?: number);
  17928. /**
  17929. * Called by the particle System when the direction is computed for the created particle.
  17930. * @param worldMatrix is the world matrix of the particle system
  17931. * @param directionToUpdate is the direction vector to update with the result
  17932. * @param particle is the particle we are computed the direction for
  17933. */
  17934. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17935. /**
  17936. * Called by the particle System when the position is computed for the created particle.
  17937. * @param worldMatrix is the world matrix of the particle system
  17938. * @param positionToUpdate is the position vector to update with the result
  17939. * @param particle is the particle we are computed the position for
  17940. */
  17941. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17942. /**
  17943. * Clones the current emitter and returns a copy of it
  17944. * @returns the new emitter
  17945. */
  17946. clone(): ConeParticleEmitter;
  17947. /**
  17948. * Called by the GPUParticleSystem to setup the update shader
  17949. * @param effect defines the update shader
  17950. */
  17951. applyToShader(effect: Effect): void;
  17952. /**
  17953. * Returns a string to use to update the GPU particles update shader
  17954. * @returns a string containng the defines string
  17955. */
  17956. getEffectDefines(): string;
  17957. /**
  17958. * Returns the string "ConeParticleEmitter"
  17959. * @returns a string containing the class name
  17960. */
  17961. getClassName(): string;
  17962. /**
  17963. * Serializes the particle system to a JSON object.
  17964. * @returns the JSON object
  17965. */
  17966. serialize(): any;
  17967. /**
  17968. * Parse properties from a JSON object
  17969. * @param serializationObject defines the JSON object
  17970. */
  17971. parse(serializationObject: any): void;
  17972. }
  17973. }
  17974. declare module BABYLON {
  17975. /**
  17976. * Particle emitter emitting particles from the inside of a cylinder.
  17977. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17978. */
  17979. export class CylinderParticleEmitter implements IParticleEmitterType {
  17980. /**
  17981. * The radius of the emission cylinder.
  17982. */
  17983. radius: number;
  17984. /**
  17985. * The height of the emission cylinder.
  17986. */
  17987. height: number;
  17988. /**
  17989. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17990. */
  17991. radiusRange: number;
  17992. /**
  17993. * How much to randomize the particle direction [0-1].
  17994. */
  17995. directionRandomizer: number;
  17996. /**
  17997. * Creates a new instance CylinderParticleEmitter
  17998. * @param radius the radius of the emission cylinder (1 by default)
  17999. * @param height the height of the emission cylinder (1 by default)
  18000. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18001. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18002. */
  18003. constructor(
  18004. /**
  18005. * The radius of the emission cylinder.
  18006. */
  18007. radius?: number,
  18008. /**
  18009. * The height of the emission cylinder.
  18010. */
  18011. height?: number,
  18012. /**
  18013. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18014. */
  18015. radiusRange?: number,
  18016. /**
  18017. * How much to randomize the particle direction [0-1].
  18018. */
  18019. directionRandomizer?: number);
  18020. /**
  18021. * Called by the particle System when the direction is computed for the created particle.
  18022. * @param worldMatrix is the world matrix of the particle system
  18023. * @param directionToUpdate is the direction vector to update with the result
  18024. * @param particle is the particle we are computed the direction for
  18025. */
  18026. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18027. /**
  18028. * Called by the particle System when the position is computed for the created particle.
  18029. * @param worldMatrix is the world matrix of the particle system
  18030. * @param positionToUpdate is the position vector to update with the result
  18031. * @param particle is the particle we are computed the position for
  18032. */
  18033. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18034. /**
  18035. * Clones the current emitter and returns a copy of it
  18036. * @returns the new emitter
  18037. */
  18038. clone(): CylinderParticleEmitter;
  18039. /**
  18040. * Called by the GPUParticleSystem to setup the update shader
  18041. * @param effect defines the update shader
  18042. */
  18043. applyToShader(effect: Effect): void;
  18044. /**
  18045. * Returns a string to use to update the GPU particles update shader
  18046. * @returns a string containng the defines string
  18047. */
  18048. getEffectDefines(): string;
  18049. /**
  18050. * Returns the string "CylinderParticleEmitter"
  18051. * @returns a string containing the class name
  18052. */
  18053. getClassName(): string;
  18054. /**
  18055. * Serializes the particle system to a JSON object.
  18056. * @returns the JSON object
  18057. */
  18058. serialize(): any;
  18059. /**
  18060. * Parse properties from a JSON object
  18061. * @param serializationObject defines the JSON object
  18062. */
  18063. parse(serializationObject: any): void;
  18064. }
  18065. /**
  18066. * Particle emitter emitting particles from the inside of a cylinder.
  18067. * It emits the particles randomly between two vectors.
  18068. */
  18069. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18070. /**
  18071. * The min limit of the emission direction.
  18072. */
  18073. direction1: Vector3;
  18074. /**
  18075. * The max limit of the emission direction.
  18076. */
  18077. direction2: Vector3;
  18078. /**
  18079. * Creates a new instance CylinderDirectedParticleEmitter
  18080. * @param radius the radius of the emission cylinder (1 by default)
  18081. * @param height the height of the emission cylinder (1 by default)
  18082. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18083. * @param direction1 the min limit of the emission direction (up vector by default)
  18084. * @param direction2 the max limit of the emission direction (up vector by default)
  18085. */
  18086. constructor(radius?: number, height?: number, radiusRange?: number,
  18087. /**
  18088. * The min limit of the emission direction.
  18089. */
  18090. direction1?: Vector3,
  18091. /**
  18092. * The max limit of the emission direction.
  18093. */
  18094. direction2?: Vector3);
  18095. /**
  18096. * Called by the particle System when the direction is computed for the created particle.
  18097. * @param worldMatrix is the world matrix of the particle system
  18098. * @param directionToUpdate is the direction vector to update with the result
  18099. * @param particle is the particle we are computed the direction for
  18100. */
  18101. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18102. /**
  18103. * Clones the current emitter and returns a copy of it
  18104. * @returns the new emitter
  18105. */
  18106. clone(): CylinderDirectedParticleEmitter;
  18107. /**
  18108. * Called by the GPUParticleSystem to setup the update shader
  18109. * @param effect defines the update shader
  18110. */
  18111. applyToShader(effect: Effect): void;
  18112. /**
  18113. * Returns a string to use to update the GPU particles update shader
  18114. * @returns a string containng the defines string
  18115. */
  18116. getEffectDefines(): string;
  18117. /**
  18118. * Returns the string "CylinderDirectedParticleEmitter"
  18119. * @returns a string containing the class name
  18120. */
  18121. getClassName(): string;
  18122. /**
  18123. * Serializes the particle system to a JSON object.
  18124. * @returns the JSON object
  18125. */
  18126. serialize(): any;
  18127. /**
  18128. * Parse properties from a JSON object
  18129. * @param serializationObject defines the JSON object
  18130. */
  18131. parse(serializationObject: any): void;
  18132. }
  18133. }
  18134. declare module BABYLON {
  18135. /**
  18136. * Particle emitter emitting particles from the inside of a hemisphere.
  18137. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18138. */
  18139. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18140. /**
  18141. * The radius of the emission hemisphere.
  18142. */
  18143. radius: number;
  18144. /**
  18145. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18146. */
  18147. radiusRange: number;
  18148. /**
  18149. * How much to randomize the particle direction [0-1].
  18150. */
  18151. directionRandomizer: number;
  18152. /**
  18153. * Creates a new instance HemisphericParticleEmitter
  18154. * @param radius the radius of the emission hemisphere (1 by default)
  18155. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18156. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18157. */
  18158. constructor(
  18159. /**
  18160. * The radius of the emission hemisphere.
  18161. */
  18162. radius?: number,
  18163. /**
  18164. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18165. */
  18166. radiusRange?: number,
  18167. /**
  18168. * How much to randomize the particle direction [0-1].
  18169. */
  18170. directionRandomizer?: number);
  18171. /**
  18172. * Called by the particle System when the direction is computed for the created particle.
  18173. * @param worldMatrix is the world matrix of the particle system
  18174. * @param directionToUpdate is the direction vector to update with the result
  18175. * @param particle is the particle we are computed the direction for
  18176. */
  18177. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18178. /**
  18179. * Called by the particle System when the position is computed for the created particle.
  18180. * @param worldMatrix is the world matrix of the particle system
  18181. * @param positionToUpdate is the position vector to update with the result
  18182. * @param particle is the particle we are computed the position for
  18183. */
  18184. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18185. /**
  18186. * Clones the current emitter and returns a copy of it
  18187. * @returns the new emitter
  18188. */
  18189. clone(): HemisphericParticleEmitter;
  18190. /**
  18191. * Called by the GPUParticleSystem to setup the update shader
  18192. * @param effect defines the update shader
  18193. */
  18194. applyToShader(effect: Effect): void;
  18195. /**
  18196. * Returns a string to use to update the GPU particles update shader
  18197. * @returns a string containng the defines string
  18198. */
  18199. getEffectDefines(): string;
  18200. /**
  18201. * Returns the string "HemisphericParticleEmitter"
  18202. * @returns a string containing the class name
  18203. */
  18204. getClassName(): string;
  18205. /**
  18206. * Serializes the particle system to a JSON object.
  18207. * @returns the JSON object
  18208. */
  18209. serialize(): any;
  18210. /**
  18211. * Parse properties from a JSON object
  18212. * @param serializationObject defines the JSON object
  18213. */
  18214. parse(serializationObject: any): void;
  18215. }
  18216. }
  18217. declare module BABYLON {
  18218. /**
  18219. * Particle emitter emitting particles from a point.
  18220. * It emits the particles randomly between 2 given directions.
  18221. */
  18222. export class PointParticleEmitter implements IParticleEmitterType {
  18223. /**
  18224. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18225. */
  18226. direction1: Vector3;
  18227. /**
  18228. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18229. */
  18230. direction2: Vector3;
  18231. /**
  18232. * Creates a new instance PointParticleEmitter
  18233. */
  18234. constructor();
  18235. /**
  18236. * Called by the particle System when the direction is computed for the created particle.
  18237. * @param worldMatrix is the world matrix of the particle system
  18238. * @param directionToUpdate is the direction vector to update with the result
  18239. * @param particle is the particle we are computed the direction for
  18240. */
  18241. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18242. /**
  18243. * Called by the particle System when the position is computed for the created particle.
  18244. * @param worldMatrix is the world matrix of the particle system
  18245. * @param positionToUpdate is the position vector to update with the result
  18246. * @param particle is the particle we are computed the position for
  18247. */
  18248. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18249. /**
  18250. * Clones the current emitter and returns a copy of it
  18251. * @returns the new emitter
  18252. */
  18253. clone(): PointParticleEmitter;
  18254. /**
  18255. * Called by the GPUParticleSystem to setup the update shader
  18256. * @param effect defines the update shader
  18257. */
  18258. applyToShader(effect: Effect): void;
  18259. /**
  18260. * Returns a string to use to update the GPU particles update shader
  18261. * @returns a string containng the defines string
  18262. */
  18263. getEffectDefines(): string;
  18264. /**
  18265. * Returns the string "PointParticleEmitter"
  18266. * @returns a string containing the class name
  18267. */
  18268. getClassName(): string;
  18269. /**
  18270. * Serializes the particle system to a JSON object.
  18271. * @returns the JSON object
  18272. */
  18273. serialize(): any;
  18274. /**
  18275. * Parse properties from a JSON object
  18276. * @param serializationObject defines the JSON object
  18277. */
  18278. parse(serializationObject: any): void;
  18279. }
  18280. }
  18281. declare module BABYLON {
  18282. /**
  18283. * Particle emitter emitting particles from the inside of a sphere.
  18284. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18285. */
  18286. export class SphereParticleEmitter implements IParticleEmitterType {
  18287. /**
  18288. * The radius of the emission sphere.
  18289. */
  18290. radius: number;
  18291. /**
  18292. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18293. */
  18294. radiusRange: number;
  18295. /**
  18296. * How much to randomize the particle direction [0-1].
  18297. */
  18298. directionRandomizer: number;
  18299. /**
  18300. * Creates a new instance SphereParticleEmitter
  18301. * @param radius the radius of the emission sphere (1 by default)
  18302. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18303. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18304. */
  18305. constructor(
  18306. /**
  18307. * The radius of the emission sphere.
  18308. */
  18309. radius?: number,
  18310. /**
  18311. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18312. */
  18313. radiusRange?: number,
  18314. /**
  18315. * How much to randomize the particle direction [0-1].
  18316. */
  18317. directionRandomizer?: number);
  18318. /**
  18319. * Called by the particle System when the direction is computed for the created particle.
  18320. * @param worldMatrix is the world matrix of the particle system
  18321. * @param directionToUpdate is the direction vector to update with the result
  18322. * @param particle is the particle we are computed the direction for
  18323. */
  18324. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18325. /**
  18326. * Called by the particle System when the position is computed for the created particle.
  18327. * @param worldMatrix is the world matrix of the particle system
  18328. * @param positionToUpdate is the position vector to update with the result
  18329. * @param particle is the particle we are computed the position for
  18330. */
  18331. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18332. /**
  18333. * Clones the current emitter and returns a copy of it
  18334. * @returns the new emitter
  18335. */
  18336. clone(): SphereParticleEmitter;
  18337. /**
  18338. * Called by the GPUParticleSystem to setup the update shader
  18339. * @param effect defines the update shader
  18340. */
  18341. applyToShader(effect: Effect): void;
  18342. /**
  18343. * Returns a string to use to update the GPU particles update shader
  18344. * @returns a string containng the defines string
  18345. */
  18346. getEffectDefines(): string;
  18347. /**
  18348. * Returns the string "SphereParticleEmitter"
  18349. * @returns a string containing the class name
  18350. */
  18351. getClassName(): string;
  18352. /**
  18353. * Serializes the particle system to a JSON object.
  18354. * @returns the JSON object
  18355. */
  18356. serialize(): any;
  18357. /**
  18358. * Parse properties from a JSON object
  18359. * @param serializationObject defines the JSON object
  18360. */
  18361. parse(serializationObject: any): void;
  18362. }
  18363. /**
  18364. * Particle emitter emitting particles from the inside of a sphere.
  18365. * It emits the particles randomly between two vectors.
  18366. */
  18367. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18368. /**
  18369. * The min limit of the emission direction.
  18370. */
  18371. direction1: Vector3;
  18372. /**
  18373. * The max limit of the emission direction.
  18374. */
  18375. direction2: Vector3;
  18376. /**
  18377. * Creates a new instance SphereDirectedParticleEmitter
  18378. * @param radius the radius of the emission sphere (1 by default)
  18379. * @param direction1 the min limit of the emission direction (up vector by default)
  18380. * @param direction2 the max limit of the emission direction (up vector by default)
  18381. */
  18382. constructor(radius?: number,
  18383. /**
  18384. * The min limit of the emission direction.
  18385. */
  18386. direction1?: Vector3,
  18387. /**
  18388. * The max limit of the emission direction.
  18389. */
  18390. direction2?: Vector3);
  18391. /**
  18392. * Called by the particle System when the direction is computed for the created particle.
  18393. * @param worldMatrix is the world matrix of the particle system
  18394. * @param directionToUpdate is the direction vector to update with the result
  18395. * @param particle is the particle we are computed the direction for
  18396. */
  18397. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18398. /**
  18399. * Clones the current emitter and returns a copy of it
  18400. * @returns the new emitter
  18401. */
  18402. clone(): SphereDirectedParticleEmitter;
  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 "SphereDirectedParticleEmitter"
  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. * Interface representing a particle system in Babylon.js.
  18433. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18434. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18435. */
  18436. export interface IParticleSystem {
  18437. /**
  18438. * List of animations used by the particle system.
  18439. */
  18440. animations: Animation[];
  18441. /**
  18442. * The id of the Particle system.
  18443. */
  18444. id: string;
  18445. /**
  18446. * The name of the Particle system.
  18447. */
  18448. name: string;
  18449. /**
  18450. * The emitter represents the Mesh or position we are attaching the particle system to.
  18451. */
  18452. emitter: Nullable<AbstractMesh | Vector3>;
  18453. /**
  18454. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18455. */
  18456. isBillboardBased: boolean;
  18457. /**
  18458. * The rendering group used by the Particle system to chose when to render.
  18459. */
  18460. renderingGroupId: number;
  18461. /**
  18462. * The layer mask we are rendering the particles through.
  18463. */
  18464. layerMask: number;
  18465. /**
  18466. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18467. */
  18468. updateSpeed: number;
  18469. /**
  18470. * The amount of time the particle system is running (depends of the overall update speed).
  18471. */
  18472. targetStopDuration: number;
  18473. /**
  18474. * The texture used to render each particle. (this can be a spritesheet)
  18475. */
  18476. particleTexture: Nullable<Texture>;
  18477. /**
  18478. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18479. */
  18480. blendMode: number;
  18481. /**
  18482. * Minimum life time of emitting particles.
  18483. */
  18484. minLifeTime: number;
  18485. /**
  18486. * Maximum life time of emitting particles.
  18487. */
  18488. maxLifeTime: number;
  18489. /**
  18490. * Minimum Size of emitting particles.
  18491. */
  18492. minSize: number;
  18493. /**
  18494. * Maximum Size of emitting particles.
  18495. */
  18496. maxSize: number;
  18497. /**
  18498. * Minimum scale of emitting particles on X axis.
  18499. */
  18500. minScaleX: number;
  18501. /**
  18502. * Maximum scale of emitting particles on X axis.
  18503. */
  18504. maxScaleX: number;
  18505. /**
  18506. * Minimum scale of emitting particles on Y axis.
  18507. */
  18508. minScaleY: number;
  18509. /**
  18510. * Maximum scale of emitting particles on Y axis.
  18511. */
  18512. maxScaleY: number;
  18513. /**
  18514. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18515. */
  18516. color1: Color4;
  18517. /**
  18518. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18519. */
  18520. color2: Color4;
  18521. /**
  18522. * Color the particle will have at the end of its lifetime.
  18523. */
  18524. colorDead: Color4;
  18525. /**
  18526. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18527. */
  18528. emitRate: number;
  18529. /**
  18530. * You can use gravity if you want to give an orientation to your particles.
  18531. */
  18532. gravity: Vector3;
  18533. /**
  18534. * Minimum power of emitting particles.
  18535. */
  18536. minEmitPower: number;
  18537. /**
  18538. * Maximum power of emitting particles.
  18539. */
  18540. maxEmitPower: number;
  18541. /**
  18542. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18543. */
  18544. minAngularSpeed: number;
  18545. /**
  18546. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18547. */
  18548. maxAngularSpeed: number;
  18549. /**
  18550. * Gets or sets the minimal initial rotation in radians.
  18551. */
  18552. minInitialRotation: number;
  18553. /**
  18554. * Gets or sets the maximal initial rotation in radians.
  18555. */
  18556. maxInitialRotation: number;
  18557. /**
  18558. * The particle emitter type defines the emitter used by the particle system.
  18559. * It can be for example box, sphere, or cone...
  18560. */
  18561. particleEmitterType: Nullable<IParticleEmitterType>;
  18562. /**
  18563. * Defines the delay in milliseconds before starting the system (0 by default)
  18564. */
  18565. startDelay: number;
  18566. /**
  18567. * 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
  18568. */
  18569. preWarmCycles: number;
  18570. /**
  18571. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18572. */
  18573. preWarmStepOffset: number;
  18574. /**
  18575. * 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)
  18576. */
  18577. spriteCellChangeSpeed: number;
  18578. /**
  18579. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18580. */
  18581. startSpriteCellID: number;
  18582. /**
  18583. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18584. */
  18585. endSpriteCellID: number;
  18586. /**
  18587. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18588. */
  18589. spriteCellWidth: number;
  18590. /**
  18591. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18592. */
  18593. spriteCellHeight: number;
  18594. /**
  18595. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18596. */
  18597. spriteRandomStartCell: boolean;
  18598. /**
  18599. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18600. */
  18601. isAnimationSheetEnabled: boolean;
  18602. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18603. translationPivot: Vector2;
  18604. /**
  18605. * Gets or sets a texture used to add random noise to particle positions
  18606. */
  18607. noiseTexture: Nullable<BaseTexture>;
  18608. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18609. noiseStrength: Vector3;
  18610. /**
  18611. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18612. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18613. */
  18614. billboardMode: number;
  18615. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18616. limitVelocityDamping: number;
  18617. /**
  18618. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18619. */
  18620. beginAnimationOnStart: boolean;
  18621. /**
  18622. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18623. */
  18624. beginAnimationFrom: number;
  18625. /**
  18626. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18627. */
  18628. beginAnimationTo: number;
  18629. /**
  18630. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18631. */
  18632. beginAnimationLoop: boolean;
  18633. /**
  18634. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18635. */
  18636. disposeOnStop: boolean;
  18637. /**
  18638. * Gets the maximum number of particles active at the same time.
  18639. * @returns The max number of active particles.
  18640. */
  18641. getCapacity(): number;
  18642. /**
  18643. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18644. * @returns True if it has been started, otherwise false.
  18645. */
  18646. isStarted(): boolean;
  18647. /**
  18648. * Animates the particle system for this frame.
  18649. */
  18650. animate(): void;
  18651. /**
  18652. * Renders the particle system in its current state.
  18653. * @returns the current number of particles
  18654. */
  18655. render(): number;
  18656. /**
  18657. * Dispose the particle system and frees its associated resources.
  18658. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18659. */
  18660. dispose(disposeTexture?: boolean): void;
  18661. /**
  18662. * Clones the particle system.
  18663. * @param name The name of the cloned object
  18664. * @param newEmitter The new emitter to use
  18665. * @returns the cloned particle system
  18666. */
  18667. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18668. /**
  18669. * Serializes the particle system to a JSON object.
  18670. * @returns the JSON object
  18671. */
  18672. serialize(): any;
  18673. /**
  18674. * Rebuild the particle system
  18675. */
  18676. rebuild(): void;
  18677. /**
  18678. * Starts the particle system and begins to emit
  18679. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18680. */
  18681. start(delay?: number): void;
  18682. /**
  18683. * Stops the particle system.
  18684. */
  18685. stop(): void;
  18686. /**
  18687. * Remove all active particles
  18688. */
  18689. reset(): void;
  18690. /**
  18691. * Is this system ready to be used/rendered
  18692. * @return true if the system is ready
  18693. */
  18694. isReady(): boolean;
  18695. /**
  18696. * Adds a new color gradient
  18697. * @param gradient defines the gradient to use (between 0 and 1)
  18698. * @param color1 defines the color to affect to the specified gradient
  18699. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18700. * @returns the current particle system
  18701. */
  18702. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18703. /**
  18704. * Remove a specific color gradient
  18705. * @param gradient defines the gradient to remove
  18706. * @returns the current particle system
  18707. */
  18708. removeColorGradient(gradient: number): IParticleSystem;
  18709. /**
  18710. * Adds a new size gradient
  18711. * @param gradient defines the gradient to use (between 0 and 1)
  18712. * @param factor defines the size factor to affect to the specified gradient
  18713. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18714. * @returns the current particle system
  18715. */
  18716. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18717. /**
  18718. * Remove a specific size gradient
  18719. * @param gradient defines the gradient to remove
  18720. * @returns the current particle system
  18721. */
  18722. removeSizeGradient(gradient: number): IParticleSystem;
  18723. /**
  18724. * Gets the current list of color gradients.
  18725. * You must use addColorGradient and removeColorGradient to udpate this list
  18726. * @returns the list of color gradients
  18727. */
  18728. getColorGradients(): Nullable<Array<ColorGradient>>;
  18729. /**
  18730. * Gets the current list of size gradients.
  18731. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18732. * @returns the list of size gradients
  18733. */
  18734. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18735. /**
  18736. * Gets the current list of angular speed gradients.
  18737. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18738. * @returns the list of angular speed gradients
  18739. */
  18740. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18741. /**
  18742. * Adds a new angular speed gradient
  18743. * @param gradient defines the gradient to use (between 0 and 1)
  18744. * @param factor defines the angular speed to affect to the specified gradient
  18745. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18746. * @returns the current particle system
  18747. */
  18748. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18749. /**
  18750. * Remove a specific angular speed gradient
  18751. * @param gradient defines the gradient to remove
  18752. * @returns the current particle system
  18753. */
  18754. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18755. /**
  18756. * Gets the current list of velocity gradients.
  18757. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18758. * @returns the list of velocity gradients
  18759. */
  18760. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18761. /**
  18762. * Adds a new velocity gradient
  18763. * @param gradient defines the gradient to use (between 0 and 1)
  18764. * @param factor defines the velocity to affect to the specified gradient
  18765. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18766. * @returns the current particle system
  18767. */
  18768. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18769. /**
  18770. * Remove a specific velocity gradient
  18771. * @param gradient defines the gradient to remove
  18772. * @returns the current particle system
  18773. */
  18774. removeVelocityGradient(gradient: number): IParticleSystem;
  18775. /**
  18776. * Gets the current list of limit velocity gradients.
  18777. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18778. * @returns the list of limit velocity gradients
  18779. */
  18780. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18781. /**
  18782. * Adds a new limit velocity gradient
  18783. * @param gradient defines the gradient to use (between 0 and 1)
  18784. * @param factor defines the limit velocity to affect to the specified gradient
  18785. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18786. * @returns the current particle system
  18787. */
  18788. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18789. /**
  18790. * Remove a specific limit velocity gradient
  18791. * @param gradient defines the gradient to remove
  18792. * @returns the current particle system
  18793. */
  18794. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18795. /**
  18796. * Adds a new drag gradient
  18797. * @param gradient defines the gradient to use (between 0 and 1)
  18798. * @param factor defines the drag to affect to the specified gradient
  18799. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18800. * @returns the current particle system
  18801. */
  18802. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18803. /**
  18804. * Remove a specific drag gradient
  18805. * @param gradient defines the gradient to remove
  18806. * @returns the current particle system
  18807. */
  18808. removeDragGradient(gradient: number): IParticleSystem;
  18809. /**
  18810. * Gets the current list of drag gradients.
  18811. * You must use addDragGradient and removeDragGradient to udpate this list
  18812. * @returns the list of drag gradients
  18813. */
  18814. getDragGradients(): Nullable<Array<FactorGradient>>;
  18815. /**
  18816. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18817. * @param gradient defines the gradient to use (between 0 and 1)
  18818. * @param factor defines the emit rate to affect to the specified gradient
  18819. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18820. * @returns the current particle system
  18821. */
  18822. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18823. /**
  18824. * Remove a specific emit rate gradient
  18825. * @param gradient defines the gradient to remove
  18826. * @returns the current particle system
  18827. */
  18828. removeEmitRateGradient(gradient: number): IParticleSystem;
  18829. /**
  18830. * Gets the current list of emit rate gradients.
  18831. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18832. * @returns the list of emit rate gradients
  18833. */
  18834. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18835. /**
  18836. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18837. * @param gradient defines the gradient to use (between 0 and 1)
  18838. * @param factor defines the start size to affect to the specified gradient
  18839. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18840. * @returns the current particle system
  18841. */
  18842. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18843. /**
  18844. * Remove a specific start size gradient
  18845. * @param gradient defines the gradient to remove
  18846. * @returns the current particle system
  18847. */
  18848. removeStartSizeGradient(gradient: number): IParticleSystem;
  18849. /**
  18850. * Gets the current list of start size gradients.
  18851. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18852. * @returns the list of start size gradients
  18853. */
  18854. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18855. /**
  18856. * Adds a new life time gradient
  18857. * @param gradient defines the gradient to use (between 0 and 1)
  18858. * @param factor defines the life time factor to affect to the specified gradient
  18859. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18860. * @returns the current particle system
  18861. */
  18862. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18863. /**
  18864. * Remove a specific life time gradient
  18865. * @param gradient defines the gradient to remove
  18866. * @returns the current particle system
  18867. */
  18868. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18869. /**
  18870. * Gets the current list of life time gradients.
  18871. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18872. * @returns the list of life time gradients
  18873. */
  18874. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18875. /**
  18876. * Gets the current list of color gradients.
  18877. * You must use addColorGradient and removeColorGradient to udpate this list
  18878. * @returns the list of color gradients
  18879. */
  18880. getColorGradients(): Nullable<Array<ColorGradient>>;
  18881. /**
  18882. * Adds a new ramp gradient used to remap particle colors
  18883. * @param gradient defines the gradient to use (between 0 and 1)
  18884. * @param color defines the color to affect to the specified gradient
  18885. * @returns the current particle system
  18886. */
  18887. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18888. /**
  18889. * Gets the current list of ramp gradients.
  18890. * You must use addRampGradient and removeRampGradient to udpate this list
  18891. * @returns the list of ramp gradients
  18892. */
  18893. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18894. /** Gets or sets a boolean indicating that ramp gradients must be used
  18895. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18896. */
  18897. useRampGradients: boolean;
  18898. /**
  18899. * Adds a new color remap gradient
  18900. * @param gradient defines the gradient to use (between 0 and 1)
  18901. * @param min defines the color remap minimal range
  18902. * @param max defines the color remap maximal range
  18903. * @returns the current particle system
  18904. */
  18905. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18906. /**
  18907. * Gets the current list of color remap gradients.
  18908. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18909. * @returns the list of color remap gradients
  18910. */
  18911. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18912. /**
  18913. * Adds a new alpha remap gradient
  18914. * @param gradient defines the gradient to use (between 0 and 1)
  18915. * @param min defines the alpha remap minimal range
  18916. * @param max defines the alpha remap maximal range
  18917. * @returns the current particle system
  18918. */
  18919. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18920. /**
  18921. * Gets the current list of alpha remap gradients.
  18922. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18923. * @returns the list of alpha remap gradients
  18924. */
  18925. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18926. /**
  18927. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18928. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18929. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18930. * @returns the emitter
  18931. */
  18932. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18933. /**
  18934. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18935. * @param radius The radius of the hemisphere to emit from
  18936. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18937. * @returns the emitter
  18938. */
  18939. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18940. /**
  18941. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18942. * @param radius The radius of the sphere to emit from
  18943. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18944. * @returns the emitter
  18945. */
  18946. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18947. /**
  18948. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18949. * @param radius The radius of the sphere to emit from
  18950. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18951. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18952. * @returns the emitter
  18953. */
  18954. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18955. /**
  18956. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18957. * @param radius The radius of the emission cylinder
  18958. * @param height The height of the emission cylinder
  18959. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18960. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18961. * @returns the emitter
  18962. */
  18963. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18964. /**
  18965. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18966. * @param radius The radius of the cylinder to emit from
  18967. * @param height The height of the emission cylinder
  18968. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18969. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18970. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18971. * @returns the emitter
  18972. */
  18973. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18974. /**
  18975. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18976. * @param radius The radius of the cone to emit from
  18977. * @param angle The base angle of the cone
  18978. * @returns the emitter
  18979. */
  18980. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18981. /**
  18982. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18983. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18984. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18985. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18986. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18987. * @returns the emitter
  18988. */
  18989. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18990. /**
  18991. * Get hosting scene
  18992. * @returns the scene
  18993. */
  18994. getScene(): Scene;
  18995. }
  18996. }
  18997. declare module BABYLON {
  18998. /**
  18999. * Creates an instance based on a source mesh.
  19000. */
  19001. export class InstancedMesh extends AbstractMesh {
  19002. private _sourceMesh;
  19003. private _currentLOD;
  19004. /** @hidden */
  19005. _indexInSourceMeshInstanceArray: number;
  19006. constructor(name: string, source: Mesh);
  19007. /**
  19008. * Returns the string "InstancedMesh".
  19009. */
  19010. getClassName(): string;
  19011. /** Gets the list of lights affecting that mesh */
  19012. readonly lightSources: Light[];
  19013. _resyncLightSources(): void;
  19014. _resyncLightSource(light: Light): void;
  19015. _removeLightSource(light: Light, dispose: boolean): void;
  19016. /**
  19017. * If the source mesh receives shadows
  19018. */
  19019. readonly receiveShadows: boolean;
  19020. /**
  19021. * The material of the source mesh
  19022. */
  19023. readonly material: Nullable<Material>;
  19024. /**
  19025. * Visibility of the source mesh
  19026. */
  19027. readonly visibility: number;
  19028. /**
  19029. * Skeleton of the source mesh
  19030. */
  19031. readonly skeleton: Nullable<Skeleton>;
  19032. /**
  19033. * Rendering ground id of the source mesh
  19034. */
  19035. renderingGroupId: number;
  19036. /**
  19037. * Returns the total number of vertices (integer).
  19038. */
  19039. getTotalVertices(): number;
  19040. /**
  19041. * Returns a positive integer : the total number of indices in this mesh geometry.
  19042. * @returns the numner of indices or zero if the mesh has no geometry.
  19043. */
  19044. getTotalIndices(): number;
  19045. /**
  19046. * The source mesh of the instance
  19047. */
  19048. readonly sourceMesh: Mesh;
  19049. /**
  19050. * Is this node ready to be used/rendered
  19051. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19052. * @return {boolean} is it ready
  19053. */
  19054. isReady(completeCheck?: boolean): boolean;
  19055. /**
  19056. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19057. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19058. * @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.
  19059. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19060. */
  19061. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19062. /**
  19063. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19064. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19065. * The `data` are either a numeric array either a Float32Array.
  19066. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19067. * 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).
  19068. * Note that a new underlying VertexBuffer object is created each call.
  19069. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19070. *
  19071. * Possible `kind` values :
  19072. * - VertexBuffer.PositionKind
  19073. * - VertexBuffer.UVKind
  19074. * - VertexBuffer.UV2Kind
  19075. * - VertexBuffer.UV3Kind
  19076. * - VertexBuffer.UV4Kind
  19077. * - VertexBuffer.UV5Kind
  19078. * - VertexBuffer.UV6Kind
  19079. * - VertexBuffer.ColorKind
  19080. * - VertexBuffer.MatricesIndicesKind
  19081. * - VertexBuffer.MatricesIndicesExtraKind
  19082. * - VertexBuffer.MatricesWeightsKind
  19083. * - VertexBuffer.MatricesWeightsExtraKind
  19084. *
  19085. * Returns the Mesh.
  19086. */
  19087. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19088. /**
  19089. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19090. * If the mesh has no geometry, it is simply returned as it is.
  19091. * The `data` are either a numeric array either a Float32Array.
  19092. * No new underlying VertexBuffer object is created.
  19093. * 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.
  19094. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19095. *
  19096. * Possible `kind` values :
  19097. * - VertexBuffer.PositionKind
  19098. * - VertexBuffer.UVKind
  19099. * - VertexBuffer.UV2Kind
  19100. * - VertexBuffer.UV3Kind
  19101. * - VertexBuffer.UV4Kind
  19102. * - VertexBuffer.UV5Kind
  19103. * - VertexBuffer.UV6Kind
  19104. * - VertexBuffer.ColorKind
  19105. * - VertexBuffer.MatricesIndicesKind
  19106. * - VertexBuffer.MatricesIndicesExtraKind
  19107. * - VertexBuffer.MatricesWeightsKind
  19108. * - VertexBuffer.MatricesWeightsExtraKind
  19109. *
  19110. * Returns the Mesh.
  19111. */
  19112. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19113. /**
  19114. * Sets the mesh indices.
  19115. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19116. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19117. * This method creates a new index buffer each call.
  19118. * Returns the Mesh.
  19119. */
  19120. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19121. /**
  19122. * Boolean : True if the mesh owns the requested kind of data.
  19123. */
  19124. isVerticesDataPresent(kind: string): boolean;
  19125. /**
  19126. * Returns an array of indices (IndicesArray).
  19127. */
  19128. getIndices(): Nullable<IndicesArray>;
  19129. readonly _positions: Nullable<Vector3[]>;
  19130. /**
  19131. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19132. * This means the mesh underlying bounding box and sphere are recomputed.
  19133. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19134. * @returns the current mesh
  19135. */
  19136. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19137. /** @hidden */
  19138. _preActivate(): InstancedMesh;
  19139. /** @hidden */
  19140. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19141. /** @hidden */
  19142. _postActivate(): void;
  19143. getWorldMatrix(): Matrix;
  19144. readonly isAnInstance: boolean;
  19145. /**
  19146. * Returns the current associated LOD AbstractMesh.
  19147. */
  19148. getLOD(camera: Camera): AbstractMesh;
  19149. /** @hidden */
  19150. _syncSubMeshes(): InstancedMesh;
  19151. /** @hidden */
  19152. _generatePointsArray(): boolean;
  19153. /**
  19154. * Creates a new InstancedMesh from the current mesh.
  19155. * - name (string) : the cloned mesh name
  19156. * - newParent (optional Node) : the optional Node to parent the clone to.
  19157. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19158. *
  19159. * Returns the clone.
  19160. */
  19161. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19162. /**
  19163. * Disposes the InstancedMesh.
  19164. * Returns nothing.
  19165. */
  19166. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19167. }
  19168. interface Mesh {
  19169. /**
  19170. * Register a custom buffer that will be instanced
  19171. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19172. * @param kind defines the buffer kind
  19173. * @param stride defines the stride in floats
  19174. */
  19175. registerInstancedBuffer(kind: string, stride: number): void;
  19176. /** @hidden */
  19177. _userInstancedBuffersStorage: {
  19178. data: {
  19179. [key: string]: Float32Array;
  19180. };
  19181. sizes: {
  19182. [key: string]: number;
  19183. };
  19184. vertexBuffers: {
  19185. [key: string]: Nullable<VertexBuffer>;
  19186. };
  19187. strides: {
  19188. [key: string]: number;
  19189. };
  19190. };
  19191. }
  19192. interface AbstractMesh {
  19193. /**
  19194. * Object used to store instanced buffers defined by user
  19195. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19196. */
  19197. instancedBuffers: {
  19198. [key: string]: any;
  19199. };
  19200. }
  19201. }
  19202. declare module BABYLON {
  19203. /**
  19204. * Defines the options associated with the creation of a shader material.
  19205. */
  19206. export interface IShaderMaterialOptions {
  19207. /**
  19208. * Does the material work in alpha blend mode
  19209. */
  19210. needAlphaBlending: boolean;
  19211. /**
  19212. * Does the material work in alpha test mode
  19213. */
  19214. needAlphaTesting: boolean;
  19215. /**
  19216. * The list of attribute names used in the shader
  19217. */
  19218. attributes: string[];
  19219. /**
  19220. * The list of unifrom names used in the shader
  19221. */
  19222. uniforms: string[];
  19223. /**
  19224. * The list of UBO names used in the shader
  19225. */
  19226. uniformBuffers: string[];
  19227. /**
  19228. * The list of sampler names used in the shader
  19229. */
  19230. samplers: string[];
  19231. /**
  19232. * The list of defines used in the shader
  19233. */
  19234. defines: string[];
  19235. }
  19236. /**
  19237. * 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.
  19238. *
  19239. * This returned material effects how the mesh will look based on the code in the shaders.
  19240. *
  19241. * @see http://doc.babylonjs.com/how_to/shader_material
  19242. */
  19243. export class ShaderMaterial extends Material {
  19244. private _shaderPath;
  19245. private _options;
  19246. private _textures;
  19247. private _textureArrays;
  19248. private _floats;
  19249. private _ints;
  19250. private _floatsArrays;
  19251. private _colors3;
  19252. private _colors3Arrays;
  19253. private _colors4;
  19254. private _colors4Arrays;
  19255. private _vectors2;
  19256. private _vectors3;
  19257. private _vectors4;
  19258. private _matrices;
  19259. private _matrixArrays;
  19260. private _matrices3x3;
  19261. private _matrices2x2;
  19262. private _vectors2Arrays;
  19263. private _vectors3Arrays;
  19264. private _vectors4Arrays;
  19265. private _cachedWorldViewMatrix;
  19266. private _cachedWorldViewProjectionMatrix;
  19267. private _renderId;
  19268. private _multiview;
  19269. /**
  19270. * Instantiate a new shader material.
  19271. * 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.
  19272. * This returned material effects how the mesh will look based on the code in the shaders.
  19273. * @see http://doc.babylonjs.com/how_to/shader_material
  19274. * @param name Define the name of the material in the scene
  19275. * @param scene Define the scene the material belongs to
  19276. * @param shaderPath Defines the route to the shader code in one of three ways:
  19277. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19278. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19279. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19280. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19281. * @param options Define the options used to create the shader
  19282. */
  19283. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19284. /**
  19285. * Gets the shader path used to define the shader code
  19286. * It can be modified to trigger a new compilation
  19287. */
  19288. /**
  19289. * Sets the shader path used to define the shader code
  19290. * It can be modified to trigger a new compilation
  19291. */
  19292. shaderPath: any;
  19293. /**
  19294. * Gets the options used to compile the shader.
  19295. * They can be modified to trigger a new compilation
  19296. */
  19297. readonly options: IShaderMaterialOptions;
  19298. /**
  19299. * Gets the current class name of the material e.g. "ShaderMaterial"
  19300. * Mainly use in serialization.
  19301. * @returns the class name
  19302. */
  19303. getClassName(): string;
  19304. /**
  19305. * Specifies if the material will require alpha blending
  19306. * @returns a boolean specifying if alpha blending is needed
  19307. */
  19308. needAlphaBlending(): boolean;
  19309. /**
  19310. * Specifies if this material should be rendered in alpha test mode
  19311. * @returns a boolean specifying if an alpha test is needed.
  19312. */
  19313. needAlphaTesting(): boolean;
  19314. private _checkUniform;
  19315. /**
  19316. * Set a texture in the shader.
  19317. * @param name Define the name of the uniform samplers as defined in the shader
  19318. * @param texture Define the texture to bind to this sampler
  19319. * @return the material itself allowing "fluent" like uniform updates
  19320. */
  19321. setTexture(name: string, texture: Texture): ShaderMaterial;
  19322. /**
  19323. * Set a texture array in the shader.
  19324. * @param name Define the name of the uniform sampler array as defined in the shader
  19325. * @param textures Define the list of textures to bind to this sampler
  19326. * @return the material itself allowing "fluent" like uniform updates
  19327. */
  19328. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19329. /**
  19330. * Set a float in the shader.
  19331. * @param name Define the name of the uniform as defined in the shader
  19332. * @param value Define the value to give to the uniform
  19333. * @return the material itself allowing "fluent" like uniform updates
  19334. */
  19335. setFloat(name: string, value: number): ShaderMaterial;
  19336. /**
  19337. * Set a int in the shader.
  19338. * @param name Define the name of the uniform as defined in the shader
  19339. * @param value Define the value to give to the uniform
  19340. * @return the material itself allowing "fluent" like uniform updates
  19341. */
  19342. setInt(name: string, value: number): ShaderMaterial;
  19343. /**
  19344. * Set an array of floats in the shader.
  19345. * @param name Define the name of the uniform as defined in the shader
  19346. * @param value Define the value to give to the uniform
  19347. * @return the material itself allowing "fluent" like uniform updates
  19348. */
  19349. setFloats(name: string, value: number[]): ShaderMaterial;
  19350. /**
  19351. * Set a vec3 in the shader from a Color3.
  19352. * @param name Define the name of the uniform as defined in the shader
  19353. * @param value Define the value to give to the uniform
  19354. * @return the material itself allowing "fluent" like uniform updates
  19355. */
  19356. setColor3(name: string, value: Color3): ShaderMaterial;
  19357. /**
  19358. * Set a vec3 array in the shader from a Color3 array.
  19359. * @param name Define the name of the uniform as defined in the shader
  19360. * @param value Define the value to give to the uniform
  19361. * @return the material itself allowing "fluent" like uniform updates
  19362. */
  19363. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19364. /**
  19365. * Set a vec4 in the shader from a Color4.
  19366. * @param name Define the name of the uniform as defined in the shader
  19367. * @param value Define the value to give to the uniform
  19368. * @return the material itself allowing "fluent" like uniform updates
  19369. */
  19370. setColor4(name: string, value: Color4): ShaderMaterial;
  19371. /**
  19372. * Set a vec4 array in the shader from a Color4 array.
  19373. * @param name Define the name of the uniform as defined in the shader
  19374. * @param value Define the value to give to the uniform
  19375. * @return the material itself allowing "fluent" like uniform updates
  19376. */
  19377. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19378. /**
  19379. * Set a vec2 in the shader from a Vector2.
  19380. * @param name Define the name of the uniform as defined in the shader
  19381. * @param value Define the value to give to the uniform
  19382. * @return the material itself allowing "fluent" like uniform updates
  19383. */
  19384. setVector2(name: string, value: Vector2): ShaderMaterial;
  19385. /**
  19386. * Set a vec3 in the shader from a Vector3.
  19387. * @param name Define the name of the uniform as defined in the shader
  19388. * @param value Define the value to give to the uniform
  19389. * @return the material itself allowing "fluent" like uniform updates
  19390. */
  19391. setVector3(name: string, value: Vector3): ShaderMaterial;
  19392. /**
  19393. * Set a vec4 in the shader from a Vector4.
  19394. * @param name Define the name of the uniform as defined in the shader
  19395. * @param value Define the value to give to the uniform
  19396. * @return the material itself allowing "fluent" like uniform updates
  19397. */
  19398. setVector4(name: string, value: Vector4): ShaderMaterial;
  19399. /**
  19400. * Set a mat4 in the shader from a Matrix.
  19401. * @param name Define the name of the uniform as defined in the shader
  19402. * @param value Define the value to give to the uniform
  19403. * @return the material itself allowing "fluent" like uniform updates
  19404. */
  19405. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19406. /**
  19407. * Set a float32Array in the shader from a matrix array.
  19408. * @param name Define the name of the uniform as defined in the shader
  19409. * @param value Define the value to give to the uniform
  19410. * @return the material itself allowing "fluent" like uniform updates
  19411. */
  19412. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19413. /**
  19414. * Set a mat3 in the shader from a Float32Array.
  19415. * @param name Define the name of the uniform as defined in the shader
  19416. * @param value Define the value to give to the uniform
  19417. * @return the material itself allowing "fluent" like uniform updates
  19418. */
  19419. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19420. /**
  19421. * Set a mat2 in the shader from a Float32Array.
  19422. * @param name Define the name of the uniform as defined in the shader
  19423. * @param value Define the value to give to the uniform
  19424. * @return the material itself allowing "fluent" like uniform updates
  19425. */
  19426. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19427. /**
  19428. * Set a vec2 array in the shader from a number array.
  19429. * @param name Define the name of the uniform as defined in the shader
  19430. * @param value Define the value to give to the uniform
  19431. * @return the material itself allowing "fluent" like uniform updates
  19432. */
  19433. setArray2(name: string, value: number[]): ShaderMaterial;
  19434. /**
  19435. * Set a vec3 array in the shader from a number array.
  19436. * @param name Define the name of the uniform as defined in the shader
  19437. * @param value Define the value to give to the uniform
  19438. * @return the material itself allowing "fluent" like uniform updates
  19439. */
  19440. setArray3(name: string, value: number[]): ShaderMaterial;
  19441. /**
  19442. * Set a vec4 array in the shader from a number array.
  19443. * @param name Define the name of the uniform as defined in the shader
  19444. * @param value Define the value to give to the uniform
  19445. * @return the material itself allowing "fluent" like uniform updates
  19446. */
  19447. setArray4(name: string, value: number[]): ShaderMaterial;
  19448. private _checkCache;
  19449. /**
  19450. * Specifies that the submesh is ready to be used
  19451. * @param mesh defines the mesh to check
  19452. * @param subMesh defines which submesh to check
  19453. * @param useInstances specifies that instances should be used
  19454. * @returns a boolean indicating that the submesh is ready or not
  19455. */
  19456. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19457. /**
  19458. * Checks if the material is ready to render the requested mesh
  19459. * @param mesh Define the mesh to render
  19460. * @param useInstances Define whether or not the material is used with instances
  19461. * @returns true if ready, otherwise false
  19462. */
  19463. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19464. /**
  19465. * Binds the world matrix to the material
  19466. * @param world defines the world transformation matrix
  19467. */
  19468. bindOnlyWorldMatrix(world: Matrix): void;
  19469. /**
  19470. * Binds the material to the mesh
  19471. * @param world defines the world transformation matrix
  19472. * @param mesh defines the mesh to bind the material to
  19473. */
  19474. bind(world: Matrix, mesh?: Mesh): void;
  19475. /**
  19476. * Gets the active textures from the material
  19477. * @returns an array of textures
  19478. */
  19479. getActiveTextures(): BaseTexture[];
  19480. /**
  19481. * Specifies if the material uses a texture
  19482. * @param texture defines the texture to check against the material
  19483. * @returns a boolean specifying if the material uses the texture
  19484. */
  19485. hasTexture(texture: BaseTexture): boolean;
  19486. /**
  19487. * Makes a duplicate of the material, and gives it a new name
  19488. * @param name defines the new name for the duplicated material
  19489. * @returns the cloned material
  19490. */
  19491. clone(name: string): ShaderMaterial;
  19492. /**
  19493. * Disposes the material
  19494. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19495. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19496. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19497. */
  19498. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19499. /**
  19500. * Serializes this material in a JSON representation
  19501. * @returns the serialized material object
  19502. */
  19503. serialize(): any;
  19504. /**
  19505. * Creates a shader material from parsed shader material data
  19506. * @param source defines the JSON represnetation of the material
  19507. * @param scene defines the hosting scene
  19508. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19509. * @returns a new material
  19510. */
  19511. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19512. }
  19513. }
  19514. declare module BABYLON {
  19515. /** @hidden */
  19516. export var colorPixelShader: {
  19517. name: string;
  19518. shader: string;
  19519. };
  19520. }
  19521. declare module BABYLON {
  19522. /** @hidden */
  19523. export var colorVertexShader: {
  19524. name: string;
  19525. shader: string;
  19526. };
  19527. }
  19528. declare module BABYLON {
  19529. /**
  19530. * Line mesh
  19531. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19532. */
  19533. export class LinesMesh extends Mesh {
  19534. /**
  19535. * If vertex color should be applied to the mesh
  19536. */
  19537. readonly useVertexColor?: boolean | undefined;
  19538. /**
  19539. * If vertex alpha should be applied to the mesh
  19540. */
  19541. readonly useVertexAlpha?: boolean | undefined;
  19542. /**
  19543. * Color of the line (Default: White)
  19544. */
  19545. color: Color3;
  19546. /**
  19547. * Alpha of the line (Default: 1)
  19548. */
  19549. alpha: number;
  19550. /**
  19551. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19552. * This margin is expressed in world space coordinates, so its value may vary.
  19553. * Default value is 0.1
  19554. */
  19555. intersectionThreshold: number;
  19556. private _colorShader;
  19557. private color4;
  19558. /**
  19559. * Creates a new LinesMesh
  19560. * @param name defines the name
  19561. * @param scene defines the hosting scene
  19562. * @param parent defines the parent mesh if any
  19563. * @param source defines the optional source LinesMesh used to clone data from
  19564. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19565. * When false, achieved by calling a clone(), also passing False.
  19566. * This will make creation of children, recursive.
  19567. * @param useVertexColor defines if this LinesMesh supports vertex color
  19568. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19569. */
  19570. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19571. /**
  19572. * If vertex color should be applied to the mesh
  19573. */
  19574. useVertexColor?: boolean | undefined,
  19575. /**
  19576. * If vertex alpha should be applied to the mesh
  19577. */
  19578. useVertexAlpha?: boolean | undefined);
  19579. private _addClipPlaneDefine;
  19580. private _removeClipPlaneDefine;
  19581. isReady(): boolean;
  19582. /**
  19583. * Returns the string "LineMesh"
  19584. */
  19585. getClassName(): string;
  19586. /**
  19587. * @hidden
  19588. */
  19589. /**
  19590. * @hidden
  19591. */
  19592. material: Material;
  19593. /**
  19594. * @hidden
  19595. */
  19596. readonly checkCollisions: boolean;
  19597. /** @hidden */
  19598. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19599. /** @hidden */
  19600. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19601. /**
  19602. * Disposes of the line mesh
  19603. * @param doNotRecurse If children should be disposed
  19604. */
  19605. dispose(doNotRecurse?: boolean): void;
  19606. /**
  19607. * Returns a new LineMesh object cloned from the current one.
  19608. */
  19609. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19610. /**
  19611. * Creates a new InstancedLinesMesh object from the mesh model.
  19612. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19613. * @param name defines the name of the new instance
  19614. * @returns a new InstancedLinesMesh
  19615. */
  19616. createInstance(name: string): InstancedLinesMesh;
  19617. }
  19618. /**
  19619. * Creates an instance based on a source LinesMesh
  19620. */
  19621. export class InstancedLinesMesh extends InstancedMesh {
  19622. /**
  19623. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19624. * This margin is expressed in world space coordinates, so its value may vary.
  19625. * Initilized with the intersectionThreshold value of the source LinesMesh
  19626. */
  19627. intersectionThreshold: number;
  19628. constructor(name: string, source: LinesMesh);
  19629. /**
  19630. * Returns the string "InstancedLinesMesh".
  19631. */
  19632. getClassName(): string;
  19633. }
  19634. }
  19635. declare module BABYLON {
  19636. /** @hidden */
  19637. export var linePixelShader: {
  19638. name: string;
  19639. shader: string;
  19640. };
  19641. }
  19642. declare module BABYLON {
  19643. /** @hidden */
  19644. export var lineVertexShader: {
  19645. name: string;
  19646. shader: string;
  19647. };
  19648. }
  19649. declare module BABYLON {
  19650. interface AbstractMesh {
  19651. /**
  19652. * Gets the edgesRenderer associated with the mesh
  19653. */
  19654. edgesRenderer: Nullable<EdgesRenderer>;
  19655. }
  19656. interface LinesMesh {
  19657. /**
  19658. * Enables the edge rendering mode on the mesh.
  19659. * This mode makes the mesh edges visible
  19660. * @param epsilon defines the maximal distance between two angles to detect a face
  19661. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19662. * @returns the currentAbstractMesh
  19663. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19664. */
  19665. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19666. }
  19667. interface InstancedLinesMesh {
  19668. /**
  19669. * Enables the edge rendering mode on the mesh.
  19670. * This mode makes the mesh edges visible
  19671. * @param epsilon defines the maximal distance between two angles to detect a face
  19672. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19673. * @returns the current InstancedLinesMesh
  19674. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19675. */
  19676. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19677. }
  19678. /**
  19679. * Defines the minimum contract an Edges renderer should follow.
  19680. */
  19681. export interface IEdgesRenderer extends IDisposable {
  19682. /**
  19683. * Gets or sets a boolean indicating if the edgesRenderer is active
  19684. */
  19685. isEnabled: boolean;
  19686. /**
  19687. * Renders the edges of the attached mesh,
  19688. */
  19689. render(): void;
  19690. /**
  19691. * Checks wether or not the edges renderer is ready to render.
  19692. * @return true if ready, otherwise false.
  19693. */
  19694. isReady(): boolean;
  19695. }
  19696. /**
  19697. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19698. */
  19699. export class EdgesRenderer implements IEdgesRenderer {
  19700. /**
  19701. * Define the size of the edges with an orthographic camera
  19702. */
  19703. edgesWidthScalerForOrthographic: number;
  19704. /**
  19705. * Define the size of the edges with a perspective camera
  19706. */
  19707. edgesWidthScalerForPerspective: number;
  19708. protected _source: AbstractMesh;
  19709. protected _linesPositions: number[];
  19710. protected _linesNormals: number[];
  19711. protected _linesIndices: number[];
  19712. protected _epsilon: number;
  19713. protected _indicesCount: number;
  19714. protected _lineShader: ShaderMaterial;
  19715. protected _ib: DataBuffer;
  19716. protected _buffers: {
  19717. [key: string]: Nullable<VertexBuffer>;
  19718. };
  19719. protected _checkVerticesInsteadOfIndices: boolean;
  19720. private _meshRebuildObserver;
  19721. private _meshDisposeObserver;
  19722. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19723. isEnabled: boolean;
  19724. /**
  19725. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19726. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19727. * @param source Mesh used to create edges
  19728. * @param epsilon sum of angles in adjacency to check for edge
  19729. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19730. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19731. */
  19732. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19733. protected _prepareRessources(): void;
  19734. /** @hidden */
  19735. _rebuild(): void;
  19736. /**
  19737. * Releases the required resources for the edges renderer
  19738. */
  19739. dispose(): void;
  19740. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19741. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19742. /**
  19743. * Checks if the pair of p0 and p1 is en edge
  19744. * @param faceIndex
  19745. * @param edge
  19746. * @param faceNormals
  19747. * @param p0
  19748. * @param p1
  19749. * @private
  19750. */
  19751. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19752. /**
  19753. * push line into the position, normal and index buffer
  19754. * @protected
  19755. */
  19756. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19757. /**
  19758. * Generates lines edges from adjacencjes
  19759. * @private
  19760. */
  19761. _generateEdgesLines(): void;
  19762. /**
  19763. * Checks wether or not the edges renderer is ready to render.
  19764. * @return true if ready, otherwise false.
  19765. */
  19766. isReady(): boolean;
  19767. /**
  19768. * Renders the edges of the attached mesh,
  19769. */
  19770. render(): void;
  19771. }
  19772. /**
  19773. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19774. */
  19775. export class LineEdgesRenderer extends EdgesRenderer {
  19776. /**
  19777. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19778. * @param source LineMesh used to generate edges
  19779. * @param epsilon not important (specified angle for edge detection)
  19780. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19781. */
  19782. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19783. /**
  19784. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19785. */
  19786. _generateEdgesLines(): void;
  19787. }
  19788. }
  19789. declare module BABYLON {
  19790. /**
  19791. * This represents the object necessary to create a rendering group.
  19792. * This is exclusively used and created by the rendering manager.
  19793. * To modify the behavior, you use the available helpers in your scene or meshes.
  19794. * @hidden
  19795. */
  19796. export class RenderingGroup {
  19797. index: number;
  19798. private static _zeroVector;
  19799. private _scene;
  19800. private _opaqueSubMeshes;
  19801. private _transparentSubMeshes;
  19802. private _alphaTestSubMeshes;
  19803. private _depthOnlySubMeshes;
  19804. private _particleSystems;
  19805. private _spriteManagers;
  19806. private _opaqueSortCompareFn;
  19807. private _alphaTestSortCompareFn;
  19808. private _transparentSortCompareFn;
  19809. private _renderOpaque;
  19810. private _renderAlphaTest;
  19811. private _renderTransparent;
  19812. /** @hidden */
  19813. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19814. onBeforeTransparentRendering: () => void;
  19815. /**
  19816. * Set the opaque sort comparison function.
  19817. * If null the sub meshes will be render in the order they were created
  19818. */
  19819. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19820. /**
  19821. * Set the alpha test sort comparison function.
  19822. * If null the sub meshes will be render in the order they were created
  19823. */
  19824. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19825. /**
  19826. * Set the transparent sort comparison function.
  19827. * If null the sub meshes will be render in the order they were created
  19828. */
  19829. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19830. /**
  19831. * Creates a new rendering group.
  19832. * @param index The rendering group index
  19833. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19834. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19835. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19836. */
  19837. 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>);
  19838. /**
  19839. * Render all the sub meshes contained in the group.
  19840. * @param customRenderFunction Used to override the default render behaviour of the group.
  19841. * @returns true if rendered some submeshes.
  19842. */
  19843. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19844. /**
  19845. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19846. * @param subMeshes The submeshes to render
  19847. */
  19848. private renderOpaqueSorted;
  19849. /**
  19850. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19851. * @param subMeshes The submeshes to render
  19852. */
  19853. private renderAlphaTestSorted;
  19854. /**
  19855. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19856. * @param subMeshes The submeshes to render
  19857. */
  19858. private renderTransparentSorted;
  19859. /**
  19860. * Renders the submeshes in a specified order.
  19861. * @param subMeshes The submeshes to sort before render
  19862. * @param sortCompareFn The comparison function use to sort
  19863. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19864. * @param transparent Specifies to activate blending if true
  19865. */
  19866. private static renderSorted;
  19867. /**
  19868. * Renders the submeshes in the order they were dispatched (no sort applied).
  19869. * @param subMeshes The submeshes to render
  19870. */
  19871. private static renderUnsorted;
  19872. /**
  19873. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19874. * are rendered back to front if in the same alpha index.
  19875. *
  19876. * @param a The first submesh
  19877. * @param b The second submesh
  19878. * @returns The result of the comparison
  19879. */
  19880. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19881. /**
  19882. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19883. * are rendered back to front.
  19884. *
  19885. * @param a The first submesh
  19886. * @param b The second submesh
  19887. * @returns The result of the comparison
  19888. */
  19889. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19890. /**
  19891. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19892. * are rendered front to back (prevent overdraw).
  19893. *
  19894. * @param a The first submesh
  19895. * @param b The second submesh
  19896. * @returns The result of the comparison
  19897. */
  19898. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19899. /**
  19900. * Resets the different lists of submeshes to prepare a new frame.
  19901. */
  19902. prepare(): void;
  19903. dispose(): void;
  19904. /**
  19905. * Inserts the submesh in its correct queue depending on its material.
  19906. * @param subMesh The submesh to dispatch
  19907. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19908. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19909. */
  19910. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19911. dispatchSprites(spriteManager: ISpriteManager): void;
  19912. dispatchParticles(particleSystem: IParticleSystem): void;
  19913. private _renderParticles;
  19914. private _renderSprites;
  19915. }
  19916. }
  19917. declare module BABYLON {
  19918. /**
  19919. * Interface describing the different options available in the rendering manager
  19920. * regarding Auto Clear between groups.
  19921. */
  19922. export interface IRenderingManagerAutoClearSetup {
  19923. /**
  19924. * Defines whether or not autoclear is enable.
  19925. */
  19926. autoClear: boolean;
  19927. /**
  19928. * Defines whether or not to autoclear the depth buffer.
  19929. */
  19930. depth: boolean;
  19931. /**
  19932. * Defines whether or not to autoclear the stencil buffer.
  19933. */
  19934. stencil: boolean;
  19935. }
  19936. /**
  19937. * This class is used by the onRenderingGroupObservable
  19938. */
  19939. export class RenderingGroupInfo {
  19940. /**
  19941. * The Scene that being rendered
  19942. */
  19943. scene: Scene;
  19944. /**
  19945. * The camera currently used for the rendering pass
  19946. */
  19947. camera: Nullable<Camera>;
  19948. /**
  19949. * The ID of the renderingGroup being processed
  19950. */
  19951. renderingGroupId: number;
  19952. }
  19953. /**
  19954. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19955. * It is enable to manage the different groups as well as the different necessary sort functions.
  19956. * This should not be used directly aside of the few static configurations
  19957. */
  19958. export class RenderingManager {
  19959. /**
  19960. * The max id used for rendering groups (not included)
  19961. */
  19962. static MAX_RENDERINGGROUPS: number;
  19963. /**
  19964. * The min id used for rendering groups (included)
  19965. */
  19966. static MIN_RENDERINGGROUPS: number;
  19967. /**
  19968. * Used to globally prevent autoclearing scenes.
  19969. */
  19970. static AUTOCLEAR: boolean;
  19971. /**
  19972. * @hidden
  19973. */
  19974. _useSceneAutoClearSetup: boolean;
  19975. private _scene;
  19976. private _renderingGroups;
  19977. private _depthStencilBufferAlreadyCleaned;
  19978. private _autoClearDepthStencil;
  19979. private _customOpaqueSortCompareFn;
  19980. private _customAlphaTestSortCompareFn;
  19981. private _customTransparentSortCompareFn;
  19982. private _renderingGroupInfo;
  19983. /**
  19984. * Instantiates a new rendering group for a particular scene
  19985. * @param scene Defines the scene the groups belongs to
  19986. */
  19987. constructor(scene: Scene);
  19988. private _clearDepthStencilBuffer;
  19989. /**
  19990. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19991. * @hidden
  19992. */
  19993. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19994. /**
  19995. * Resets the different information of the group to prepare a new frame
  19996. * @hidden
  19997. */
  19998. reset(): void;
  19999. /**
  20000. * Dispose and release the group and its associated resources.
  20001. * @hidden
  20002. */
  20003. dispose(): void;
  20004. /**
  20005. * Clear the info related to rendering groups preventing retention points during dispose.
  20006. */
  20007. freeRenderingGroups(): void;
  20008. private _prepareRenderingGroup;
  20009. /**
  20010. * Add a sprite manager to the rendering manager in order to render it this frame.
  20011. * @param spriteManager Define the sprite manager to render
  20012. */
  20013. dispatchSprites(spriteManager: ISpriteManager): void;
  20014. /**
  20015. * Add a particle system to the rendering manager in order to render it this frame.
  20016. * @param particleSystem Define the particle system to render
  20017. */
  20018. dispatchParticles(particleSystem: IParticleSystem): void;
  20019. /**
  20020. * Add a submesh to the manager in order to render it this frame
  20021. * @param subMesh The submesh to dispatch
  20022. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20023. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20024. */
  20025. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20026. /**
  20027. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20028. * This allowed control for front to back rendering or reversly depending of the special needs.
  20029. *
  20030. * @param renderingGroupId The rendering group id corresponding to its index
  20031. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20032. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20033. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20034. */
  20035. 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;
  20036. /**
  20037. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20038. *
  20039. * @param renderingGroupId The rendering group id corresponding to its index
  20040. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20041. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20042. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20043. */
  20044. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20045. /**
  20046. * Gets the current auto clear configuration for one rendering group of the rendering
  20047. * manager.
  20048. * @param index the rendering group index to get the information for
  20049. * @returns The auto clear setup for the requested rendering group
  20050. */
  20051. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20052. }
  20053. }
  20054. declare module BABYLON {
  20055. /**
  20056. * This Helps creating a texture that will be created from a camera in your scene.
  20057. * It is basically a dynamic texture that could be used to create special effects for instance.
  20058. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20059. */
  20060. export class RenderTargetTexture extends Texture {
  20061. isCube: boolean;
  20062. /**
  20063. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20064. */
  20065. static readonly REFRESHRATE_RENDER_ONCE: number;
  20066. /**
  20067. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20068. */
  20069. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20070. /**
  20071. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20072. * the central point of your effect and can save a lot of performances.
  20073. */
  20074. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20075. /**
  20076. * Use this predicate to dynamically define the list of mesh you want to render.
  20077. * If set, the renderList property will be overwritten.
  20078. */
  20079. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20080. private _renderList;
  20081. /**
  20082. * Use this list to define the list of mesh you want to render.
  20083. */
  20084. renderList: Nullable<Array<AbstractMesh>>;
  20085. private _hookArray;
  20086. /**
  20087. * Define if particles should be rendered in your texture.
  20088. */
  20089. renderParticles: boolean;
  20090. /**
  20091. * Define if sprites should be rendered in your texture.
  20092. */
  20093. renderSprites: boolean;
  20094. /**
  20095. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20096. */
  20097. coordinatesMode: number;
  20098. /**
  20099. * Define the camera used to render the texture.
  20100. */
  20101. activeCamera: Nullable<Camera>;
  20102. /**
  20103. * Override the render function of the texture with your own one.
  20104. */
  20105. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20106. /**
  20107. * Define if camera post processes should be use while rendering the texture.
  20108. */
  20109. useCameraPostProcesses: boolean;
  20110. /**
  20111. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20112. */
  20113. ignoreCameraViewport: boolean;
  20114. private _postProcessManager;
  20115. private _postProcesses;
  20116. private _resizeObserver;
  20117. /**
  20118. * An event triggered when the texture is unbind.
  20119. */
  20120. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20121. /**
  20122. * An event triggered when the texture is unbind.
  20123. */
  20124. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20125. private _onAfterUnbindObserver;
  20126. /**
  20127. * Set a after unbind callback in the texture.
  20128. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20129. */
  20130. onAfterUnbind: () => void;
  20131. /**
  20132. * An event triggered before rendering the texture
  20133. */
  20134. onBeforeRenderObservable: Observable<number>;
  20135. private _onBeforeRenderObserver;
  20136. /**
  20137. * Set a before render callback in the texture.
  20138. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20139. */
  20140. onBeforeRender: (faceIndex: number) => void;
  20141. /**
  20142. * An event triggered after rendering the texture
  20143. */
  20144. onAfterRenderObservable: Observable<number>;
  20145. private _onAfterRenderObserver;
  20146. /**
  20147. * Set a after render callback in the texture.
  20148. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20149. */
  20150. onAfterRender: (faceIndex: number) => void;
  20151. /**
  20152. * An event triggered after the texture clear
  20153. */
  20154. onClearObservable: Observable<Engine>;
  20155. private _onClearObserver;
  20156. /**
  20157. * Set a clear callback in the texture.
  20158. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20159. */
  20160. onClear: (Engine: Engine) => void;
  20161. /**
  20162. * An event triggered when the texture is resized.
  20163. */
  20164. onResizeObservable: Observable<RenderTargetTexture>;
  20165. /**
  20166. * Define the clear color of the Render Target if it should be different from the scene.
  20167. */
  20168. clearColor: Color4;
  20169. protected _size: number | {
  20170. width: number;
  20171. height: number;
  20172. };
  20173. protected _initialSizeParameter: number | {
  20174. width: number;
  20175. height: number;
  20176. } | {
  20177. ratio: number;
  20178. };
  20179. protected _sizeRatio: Nullable<number>;
  20180. /** @hidden */
  20181. _generateMipMaps: boolean;
  20182. protected _renderingManager: RenderingManager;
  20183. /** @hidden */
  20184. _waitingRenderList: string[];
  20185. protected _doNotChangeAspectRatio: boolean;
  20186. protected _currentRefreshId: number;
  20187. protected _refreshRate: number;
  20188. protected _textureMatrix: Matrix;
  20189. protected _samples: number;
  20190. protected _renderTargetOptions: RenderTargetCreationOptions;
  20191. /**
  20192. * Gets render target creation options that were used.
  20193. */
  20194. readonly renderTargetOptions: RenderTargetCreationOptions;
  20195. protected _engine: Engine;
  20196. protected _onRatioRescale(): void;
  20197. /**
  20198. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20199. * It must define where the camera used to render the texture is set
  20200. */
  20201. boundingBoxPosition: Vector3;
  20202. private _boundingBoxSize;
  20203. /**
  20204. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20205. * When defined, the cubemap will switch to local mode
  20206. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20207. * @example https://www.babylonjs-playground.com/#RNASML
  20208. */
  20209. boundingBoxSize: Vector3;
  20210. /**
  20211. * In case the RTT has been created with a depth texture, get the associated
  20212. * depth texture.
  20213. * Otherwise, return null.
  20214. */
  20215. depthStencilTexture: Nullable<InternalTexture>;
  20216. /**
  20217. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20218. * or used a shadow, depth texture...
  20219. * @param name The friendly name of the texture
  20220. * @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)
  20221. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20222. * @param generateMipMaps True if mip maps need to be generated after render.
  20223. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20224. * @param type The type of the buffer in the RTT (int, half float, float...)
  20225. * @param isCube True if a cube texture needs to be created
  20226. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20227. * @param generateDepthBuffer True to generate a depth buffer
  20228. * @param generateStencilBuffer True to generate a stencil buffer
  20229. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20230. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20231. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20232. */
  20233. constructor(name: string, size: number | {
  20234. width: number;
  20235. height: number;
  20236. } | {
  20237. ratio: number;
  20238. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20239. /**
  20240. * Creates a depth stencil texture.
  20241. * This is only available in WebGL 2 or with the depth texture extension available.
  20242. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20243. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20244. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20245. */
  20246. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20247. private _processSizeParameter;
  20248. /**
  20249. * Define the number of samples to use in case of MSAA.
  20250. * It defaults to one meaning no MSAA has been enabled.
  20251. */
  20252. samples: number;
  20253. /**
  20254. * Resets the refresh counter of the texture and start bak from scratch.
  20255. * Could be useful to regenerate the texture if it is setup to render only once.
  20256. */
  20257. resetRefreshCounter(): void;
  20258. /**
  20259. * Define the refresh rate of the texture or the rendering frequency.
  20260. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20261. */
  20262. refreshRate: number;
  20263. /**
  20264. * Adds a post process to the render target rendering passes.
  20265. * @param postProcess define the post process to add
  20266. */
  20267. addPostProcess(postProcess: PostProcess): void;
  20268. /**
  20269. * Clear all the post processes attached to the render target
  20270. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20271. */
  20272. clearPostProcesses(dispose?: boolean): void;
  20273. /**
  20274. * Remove one of the post process from the list of attached post processes to the texture
  20275. * @param postProcess define the post process to remove from the list
  20276. */
  20277. removePostProcess(postProcess: PostProcess): void;
  20278. /** @hidden */
  20279. _shouldRender(): boolean;
  20280. /**
  20281. * Gets the actual render size of the texture.
  20282. * @returns the width of the render size
  20283. */
  20284. getRenderSize(): number;
  20285. /**
  20286. * Gets the actual render width of the texture.
  20287. * @returns the width of the render size
  20288. */
  20289. getRenderWidth(): number;
  20290. /**
  20291. * Gets the actual render height of the texture.
  20292. * @returns the height of the render size
  20293. */
  20294. getRenderHeight(): number;
  20295. /**
  20296. * Get if the texture can be rescaled or not.
  20297. */
  20298. readonly canRescale: boolean;
  20299. /**
  20300. * Resize the texture using a ratio.
  20301. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20302. */
  20303. scale(ratio: number): void;
  20304. /**
  20305. * Get the texture reflection matrix used to rotate/transform the reflection.
  20306. * @returns the reflection matrix
  20307. */
  20308. getReflectionTextureMatrix(): Matrix;
  20309. /**
  20310. * Resize the texture to a new desired size.
  20311. * Be carrefull as it will recreate all the data in the new texture.
  20312. * @param size Define the new size. It can be:
  20313. * - a number for squared texture,
  20314. * - an object containing { width: number, height: number }
  20315. * - or an object containing a ratio { ratio: number }
  20316. */
  20317. resize(size: number | {
  20318. width: number;
  20319. height: number;
  20320. } | {
  20321. ratio: number;
  20322. }): void;
  20323. /**
  20324. * Renders all the objects from the render list into the texture.
  20325. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20326. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20327. */
  20328. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20329. private _bestReflectionRenderTargetDimension;
  20330. /**
  20331. * @hidden
  20332. * @param faceIndex face index to bind to if this is a cubetexture
  20333. */
  20334. _bindFrameBuffer(faceIndex?: number): void;
  20335. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20336. private renderToTarget;
  20337. /**
  20338. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20339. * This allowed control for front to back rendering or reversly depending of the special needs.
  20340. *
  20341. * @param renderingGroupId The rendering group id corresponding to its index
  20342. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20343. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20344. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20345. */
  20346. 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;
  20347. /**
  20348. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20349. *
  20350. * @param renderingGroupId The rendering group id corresponding to its index
  20351. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20352. */
  20353. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20354. /**
  20355. * Clones the texture.
  20356. * @returns the cloned texture
  20357. */
  20358. clone(): RenderTargetTexture;
  20359. /**
  20360. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20361. * @returns The JSON representation of the texture
  20362. */
  20363. serialize(): any;
  20364. /**
  20365. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20366. */
  20367. disposeFramebufferObjects(): void;
  20368. /**
  20369. * Dispose the texture and release its associated resources.
  20370. */
  20371. dispose(): void;
  20372. /** @hidden */
  20373. _rebuild(): void;
  20374. /**
  20375. * Clear the info related to rendering groups preventing retention point in material dispose.
  20376. */
  20377. freeRenderingGroups(): void;
  20378. /**
  20379. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20380. * @returns the view count
  20381. */
  20382. getViewCount(): number;
  20383. }
  20384. }
  20385. declare module BABYLON {
  20386. /**
  20387. * Options for compiling materials.
  20388. */
  20389. export interface IMaterialCompilationOptions {
  20390. /**
  20391. * Defines whether clip planes are enabled.
  20392. */
  20393. clipPlane: boolean;
  20394. /**
  20395. * Defines whether instances are enabled.
  20396. */
  20397. useInstances: boolean;
  20398. }
  20399. /**
  20400. * Base class for the main features of a material in Babylon.js
  20401. */
  20402. export class Material implements IAnimatable {
  20403. /**
  20404. * Returns the triangle fill mode
  20405. */
  20406. static readonly TriangleFillMode: number;
  20407. /**
  20408. * Returns the wireframe mode
  20409. */
  20410. static readonly WireFrameFillMode: number;
  20411. /**
  20412. * Returns the point fill mode
  20413. */
  20414. static readonly PointFillMode: number;
  20415. /**
  20416. * Returns the point list draw mode
  20417. */
  20418. static readonly PointListDrawMode: number;
  20419. /**
  20420. * Returns the line list draw mode
  20421. */
  20422. static readonly LineListDrawMode: number;
  20423. /**
  20424. * Returns the line loop draw mode
  20425. */
  20426. static readonly LineLoopDrawMode: number;
  20427. /**
  20428. * Returns the line strip draw mode
  20429. */
  20430. static readonly LineStripDrawMode: number;
  20431. /**
  20432. * Returns the triangle strip draw mode
  20433. */
  20434. static readonly TriangleStripDrawMode: number;
  20435. /**
  20436. * Returns the triangle fan draw mode
  20437. */
  20438. static readonly TriangleFanDrawMode: number;
  20439. /**
  20440. * Stores the clock-wise side orientation
  20441. */
  20442. static readonly ClockWiseSideOrientation: number;
  20443. /**
  20444. * Stores the counter clock-wise side orientation
  20445. */
  20446. static readonly CounterClockWiseSideOrientation: number;
  20447. /**
  20448. * The dirty texture flag value
  20449. */
  20450. static readonly TextureDirtyFlag: number;
  20451. /**
  20452. * The dirty light flag value
  20453. */
  20454. static readonly LightDirtyFlag: number;
  20455. /**
  20456. * The dirty fresnel flag value
  20457. */
  20458. static readonly FresnelDirtyFlag: number;
  20459. /**
  20460. * The dirty attribute flag value
  20461. */
  20462. static readonly AttributesDirtyFlag: number;
  20463. /**
  20464. * The dirty misc flag value
  20465. */
  20466. static readonly MiscDirtyFlag: number;
  20467. /**
  20468. * The all dirty flag value
  20469. */
  20470. static readonly AllDirtyFlag: number;
  20471. /**
  20472. * The ID of the material
  20473. */
  20474. id: string;
  20475. /**
  20476. * Gets or sets the unique id of the material
  20477. */
  20478. uniqueId: number;
  20479. /**
  20480. * The name of the material
  20481. */
  20482. name: string;
  20483. /**
  20484. * Gets or sets user defined metadata
  20485. */
  20486. metadata: any;
  20487. /**
  20488. * For internal use only. Please do not use.
  20489. */
  20490. reservedDataStore: any;
  20491. /**
  20492. * Specifies if the ready state should be checked on each call
  20493. */
  20494. checkReadyOnEveryCall: boolean;
  20495. /**
  20496. * Specifies if the ready state should be checked once
  20497. */
  20498. checkReadyOnlyOnce: boolean;
  20499. /**
  20500. * The state of the material
  20501. */
  20502. state: string;
  20503. /**
  20504. * The alpha value of the material
  20505. */
  20506. protected _alpha: number;
  20507. /**
  20508. * List of inspectable custom properties (used by the Inspector)
  20509. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20510. */
  20511. inspectableCustomProperties: IInspectable[];
  20512. /**
  20513. * Sets the alpha value of the material
  20514. */
  20515. /**
  20516. * Gets the alpha value of the material
  20517. */
  20518. alpha: number;
  20519. /**
  20520. * Specifies if back face culling is enabled
  20521. */
  20522. protected _backFaceCulling: boolean;
  20523. /**
  20524. * Sets the back-face culling state
  20525. */
  20526. /**
  20527. * Gets the back-face culling state
  20528. */
  20529. backFaceCulling: boolean;
  20530. /**
  20531. * Stores the value for side orientation
  20532. */
  20533. sideOrientation: number;
  20534. /**
  20535. * Callback triggered when the material is compiled
  20536. */
  20537. onCompiled: Nullable<(effect: Effect) => void>;
  20538. /**
  20539. * Callback triggered when an error occurs
  20540. */
  20541. onError: Nullable<(effect: Effect, errors: string) => void>;
  20542. /**
  20543. * Callback triggered to get the render target textures
  20544. */
  20545. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20546. /**
  20547. * Gets a boolean indicating that current material needs to register RTT
  20548. */
  20549. readonly hasRenderTargetTextures: boolean;
  20550. /**
  20551. * Specifies if the material should be serialized
  20552. */
  20553. doNotSerialize: boolean;
  20554. /**
  20555. * @hidden
  20556. */
  20557. _storeEffectOnSubMeshes: boolean;
  20558. /**
  20559. * Stores the animations for the material
  20560. */
  20561. animations: Nullable<Array<Animation>>;
  20562. /**
  20563. * An event triggered when the material is disposed
  20564. */
  20565. onDisposeObservable: Observable<Material>;
  20566. /**
  20567. * An observer which watches for dispose events
  20568. */
  20569. private _onDisposeObserver;
  20570. private _onUnBindObservable;
  20571. /**
  20572. * Called during a dispose event
  20573. */
  20574. onDispose: () => void;
  20575. private _onBindObservable;
  20576. /**
  20577. * An event triggered when the material is bound
  20578. */
  20579. readonly onBindObservable: Observable<AbstractMesh>;
  20580. /**
  20581. * An observer which watches for bind events
  20582. */
  20583. private _onBindObserver;
  20584. /**
  20585. * Called during a bind event
  20586. */
  20587. onBind: (Mesh: AbstractMesh) => void;
  20588. /**
  20589. * An event triggered when the material is unbound
  20590. */
  20591. readonly onUnBindObservable: Observable<Material>;
  20592. /**
  20593. * Stores the value of the alpha mode
  20594. */
  20595. private _alphaMode;
  20596. /**
  20597. * Sets the value of the alpha mode.
  20598. *
  20599. * | Value | Type | Description |
  20600. * | --- | --- | --- |
  20601. * | 0 | ALPHA_DISABLE | |
  20602. * | 1 | ALPHA_ADD | |
  20603. * | 2 | ALPHA_COMBINE | |
  20604. * | 3 | ALPHA_SUBTRACT | |
  20605. * | 4 | ALPHA_MULTIPLY | |
  20606. * | 5 | ALPHA_MAXIMIZED | |
  20607. * | 6 | ALPHA_ONEONE | |
  20608. * | 7 | ALPHA_PREMULTIPLIED | |
  20609. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20610. * | 9 | ALPHA_INTERPOLATE | |
  20611. * | 10 | ALPHA_SCREENMODE | |
  20612. *
  20613. */
  20614. /**
  20615. * Gets the value of the alpha mode
  20616. */
  20617. alphaMode: number;
  20618. /**
  20619. * Stores the state of the need depth pre-pass value
  20620. */
  20621. private _needDepthPrePass;
  20622. /**
  20623. * Sets the need depth pre-pass value
  20624. */
  20625. /**
  20626. * Gets the depth pre-pass value
  20627. */
  20628. needDepthPrePass: boolean;
  20629. /**
  20630. * Specifies if depth writing should be disabled
  20631. */
  20632. disableDepthWrite: boolean;
  20633. /**
  20634. * Specifies if depth writing should be forced
  20635. */
  20636. forceDepthWrite: boolean;
  20637. /**
  20638. * Specifies the depth function that should be used. 0 means the default engine function
  20639. */
  20640. depthFunction: number;
  20641. /**
  20642. * Specifies if there should be a separate pass for culling
  20643. */
  20644. separateCullingPass: boolean;
  20645. /**
  20646. * Stores the state specifing if fog should be enabled
  20647. */
  20648. private _fogEnabled;
  20649. /**
  20650. * Sets the state for enabling fog
  20651. */
  20652. /**
  20653. * Gets the value of the fog enabled state
  20654. */
  20655. fogEnabled: boolean;
  20656. /**
  20657. * Stores the size of points
  20658. */
  20659. pointSize: number;
  20660. /**
  20661. * Stores the z offset value
  20662. */
  20663. zOffset: number;
  20664. /**
  20665. * Gets a value specifying if wireframe mode is enabled
  20666. */
  20667. /**
  20668. * Sets the state of wireframe mode
  20669. */
  20670. wireframe: boolean;
  20671. /**
  20672. * Gets the value specifying if point clouds are enabled
  20673. */
  20674. /**
  20675. * Sets the state of point cloud mode
  20676. */
  20677. pointsCloud: boolean;
  20678. /**
  20679. * Gets the material fill mode
  20680. */
  20681. /**
  20682. * Sets the material fill mode
  20683. */
  20684. fillMode: number;
  20685. /**
  20686. * @hidden
  20687. * Stores the effects for the material
  20688. */
  20689. _effect: Nullable<Effect>;
  20690. /**
  20691. * @hidden
  20692. * Specifies if the material was previously ready
  20693. */
  20694. _wasPreviouslyReady: boolean;
  20695. /**
  20696. * Specifies if uniform buffers should be used
  20697. */
  20698. private _useUBO;
  20699. /**
  20700. * Stores a reference to the scene
  20701. */
  20702. private _scene;
  20703. /**
  20704. * Stores the fill mode state
  20705. */
  20706. private _fillMode;
  20707. /**
  20708. * Specifies if the depth write state should be cached
  20709. */
  20710. private _cachedDepthWriteState;
  20711. /**
  20712. * Specifies if the depth function state should be cached
  20713. */
  20714. private _cachedDepthFunctionState;
  20715. /**
  20716. * Stores the uniform buffer
  20717. */
  20718. protected _uniformBuffer: UniformBuffer;
  20719. /** @hidden */
  20720. _indexInSceneMaterialArray: number;
  20721. /** @hidden */
  20722. meshMap: Nullable<{
  20723. [id: string]: AbstractMesh | undefined;
  20724. }>;
  20725. /**
  20726. * Creates a material instance
  20727. * @param name defines the name of the material
  20728. * @param scene defines the scene to reference
  20729. * @param doNotAdd specifies if the material should be added to the scene
  20730. */
  20731. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20732. /**
  20733. * Returns a string representation of the current material
  20734. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20735. * @returns a string with material information
  20736. */
  20737. toString(fullDetails?: boolean): string;
  20738. /**
  20739. * Gets the class name of the material
  20740. * @returns a string with the class name of the material
  20741. */
  20742. getClassName(): string;
  20743. /**
  20744. * Specifies if updates for the material been locked
  20745. */
  20746. readonly isFrozen: boolean;
  20747. /**
  20748. * Locks updates for the material
  20749. */
  20750. freeze(): void;
  20751. /**
  20752. * Unlocks updates for the material
  20753. */
  20754. unfreeze(): void;
  20755. /**
  20756. * Specifies if the material is ready to be used
  20757. * @param mesh defines the mesh to check
  20758. * @param useInstances specifies if instances should be used
  20759. * @returns a boolean indicating if the material is ready to be used
  20760. */
  20761. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20762. /**
  20763. * Specifies that the submesh is ready to be used
  20764. * @param mesh defines the mesh to check
  20765. * @param subMesh defines which submesh to check
  20766. * @param useInstances specifies that instances should be used
  20767. * @returns a boolean indicating that the submesh is ready or not
  20768. */
  20769. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20770. /**
  20771. * Returns the material effect
  20772. * @returns the effect associated with the material
  20773. */
  20774. getEffect(): Nullable<Effect>;
  20775. /**
  20776. * Returns the current scene
  20777. * @returns a Scene
  20778. */
  20779. getScene(): Scene;
  20780. /**
  20781. * Specifies if the material will require alpha blending
  20782. * @returns a boolean specifying if alpha blending is needed
  20783. */
  20784. needAlphaBlending(): boolean;
  20785. /**
  20786. * Specifies if the mesh will require alpha blending
  20787. * @param mesh defines the mesh to check
  20788. * @returns a boolean specifying if alpha blending is needed for the mesh
  20789. */
  20790. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20791. /**
  20792. * Specifies if this material should be rendered in alpha test mode
  20793. * @returns a boolean specifying if an alpha test is needed.
  20794. */
  20795. needAlphaTesting(): boolean;
  20796. /**
  20797. * Gets the texture used for the alpha test
  20798. * @returns the texture to use for alpha testing
  20799. */
  20800. getAlphaTestTexture(): Nullable<BaseTexture>;
  20801. /**
  20802. * Marks the material to indicate that it needs to be re-calculated
  20803. */
  20804. markDirty(): void;
  20805. /** @hidden */
  20806. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20807. /**
  20808. * Binds the material to the mesh
  20809. * @param world defines the world transformation matrix
  20810. * @param mesh defines the mesh to bind the material to
  20811. */
  20812. bind(world: Matrix, mesh?: Mesh): void;
  20813. /**
  20814. * Binds the submesh to the material
  20815. * @param world defines the world transformation matrix
  20816. * @param mesh defines the mesh containing the submesh
  20817. * @param subMesh defines the submesh to bind the material to
  20818. */
  20819. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20820. /**
  20821. * Binds the world matrix to the material
  20822. * @param world defines the world transformation matrix
  20823. */
  20824. bindOnlyWorldMatrix(world: Matrix): void;
  20825. /**
  20826. * Binds the scene's uniform buffer to the effect.
  20827. * @param effect defines the effect to bind to the scene uniform buffer
  20828. * @param sceneUbo defines the uniform buffer storing scene data
  20829. */
  20830. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20831. /**
  20832. * Binds the view matrix to the effect
  20833. * @param effect defines the effect to bind the view matrix to
  20834. */
  20835. bindView(effect: Effect): void;
  20836. /**
  20837. * Binds the view projection matrix to the effect
  20838. * @param effect defines the effect to bind the view projection matrix to
  20839. */
  20840. bindViewProjection(effect: Effect): void;
  20841. /**
  20842. * Specifies if material alpha testing should be turned on for the mesh
  20843. * @param mesh defines the mesh to check
  20844. */
  20845. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20846. /**
  20847. * Processes to execute after binding the material to a mesh
  20848. * @param mesh defines the rendered mesh
  20849. */
  20850. protected _afterBind(mesh?: Mesh): void;
  20851. /**
  20852. * Unbinds the material from the mesh
  20853. */
  20854. unbind(): void;
  20855. /**
  20856. * Gets the active textures from the material
  20857. * @returns an array of textures
  20858. */
  20859. getActiveTextures(): BaseTexture[];
  20860. /**
  20861. * Specifies if the material uses a texture
  20862. * @param texture defines the texture to check against the material
  20863. * @returns a boolean specifying if the material uses the texture
  20864. */
  20865. hasTexture(texture: BaseTexture): boolean;
  20866. /**
  20867. * Makes a duplicate of the material, and gives it a new name
  20868. * @param name defines the new name for the duplicated material
  20869. * @returns the cloned material
  20870. */
  20871. clone(name: string): Nullable<Material>;
  20872. /**
  20873. * Gets the meshes bound to the material
  20874. * @returns an array of meshes bound to the material
  20875. */
  20876. getBindedMeshes(): AbstractMesh[];
  20877. /**
  20878. * Force shader compilation
  20879. * @param mesh defines the mesh associated with this material
  20880. * @param onCompiled defines a function to execute once the material is compiled
  20881. * @param options defines the options to configure the compilation
  20882. * @param onError defines a function to execute if the material fails compiling
  20883. */
  20884. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  20885. /**
  20886. * Force shader compilation
  20887. * @param mesh defines the mesh that will use this material
  20888. * @param options defines additional options for compiling the shaders
  20889. * @returns a promise that resolves when the compilation completes
  20890. */
  20891. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  20892. private static readonly _AllDirtyCallBack;
  20893. private static readonly _ImageProcessingDirtyCallBack;
  20894. private static readonly _TextureDirtyCallBack;
  20895. private static readonly _FresnelDirtyCallBack;
  20896. private static readonly _MiscDirtyCallBack;
  20897. private static readonly _LightsDirtyCallBack;
  20898. private static readonly _AttributeDirtyCallBack;
  20899. private static _FresnelAndMiscDirtyCallBack;
  20900. private static _TextureAndMiscDirtyCallBack;
  20901. private static readonly _DirtyCallbackArray;
  20902. private static readonly _RunDirtyCallBacks;
  20903. /**
  20904. * Marks a define in the material to indicate that it needs to be re-computed
  20905. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20906. */
  20907. markAsDirty(flag: number): void;
  20908. /**
  20909. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20910. * @param func defines a function which checks material defines against the submeshes
  20911. */
  20912. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20913. /**
  20914. * Indicates that we need to re-calculated for all submeshes
  20915. */
  20916. protected _markAllSubMeshesAsAllDirty(): void;
  20917. /**
  20918. * Indicates that image processing needs to be re-calculated for all submeshes
  20919. */
  20920. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20921. /**
  20922. * Indicates that textures need to be re-calculated for all submeshes
  20923. */
  20924. protected _markAllSubMeshesAsTexturesDirty(): void;
  20925. /**
  20926. * Indicates that fresnel needs to be re-calculated for all submeshes
  20927. */
  20928. protected _markAllSubMeshesAsFresnelDirty(): void;
  20929. /**
  20930. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20931. */
  20932. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20933. /**
  20934. * Indicates that lights need to be re-calculated for all submeshes
  20935. */
  20936. protected _markAllSubMeshesAsLightsDirty(): void;
  20937. /**
  20938. * Indicates that attributes need to be re-calculated for all submeshes
  20939. */
  20940. protected _markAllSubMeshesAsAttributesDirty(): void;
  20941. /**
  20942. * Indicates that misc needs to be re-calculated for all submeshes
  20943. */
  20944. protected _markAllSubMeshesAsMiscDirty(): void;
  20945. /**
  20946. * Indicates that textures and misc need to be re-calculated for all submeshes
  20947. */
  20948. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20949. /**
  20950. * Disposes the material
  20951. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20952. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20953. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20954. */
  20955. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20956. /** @hidden */
  20957. private releaseVertexArrayObject;
  20958. /**
  20959. * Serializes this material
  20960. * @returns the serialized material object
  20961. */
  20962. serialize(): any;
  20963. /**
  20964. * Creates a material from parsed material data
  20965. * @param parsedMaterial defines parsed material data
  20966. * @param scene defines the hosting scene
  20967. * @param rootUrl defines the root URL to use to load textures
  20968. * @returns a new material
  20969. */
  20970. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20971. }
  20972. }
  20973. declare module BABYLON {
  20974. /**
  20975. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20976. * separate meshes. This can be use to improve performances.
  20977. * @see http://doc.babylonjs.com/how_to/multi_materials
  20978. */
  20979. export class MultiMaterial extends Material {
  20980. private _subMaterials;
  20981. /**
  20982. * Gets or Sets the list of Materials used within the multi material.
  20983. * They need to be ordered according to the submeshes order in the associated mesh
  20984. */
  20985. subMaterials: Nullable<Material>[];
  20986. /**
  20987. * Function used to align with Node.getChildren()
  20988. * @returns the list of Materials used within the multi material
  20989. */
  20990. getChildren(): Nullable<Material>[];
  20991. /**
  20992. * Instantiates a new Multi Material
  20993. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20994. * separate meshes. This can be use to improve performances.
  20995. * @see http://doc.babylonjs.com/how_to/multi_materials
  20996. * @param name Define the name in the scene
  20997. * @param scene Define the scene the material belongs to
  20998. */
  20999. constructor(name: string, scene: Scene);
  21000. private _hookArray;
  21001. /**
  21002. * Get one of the submaterial by its index in the submaterials array
  21003. * @param index The index to look the sub material at
  21004. * @returns The Material if the index has been defined
  21005. */
  21006. getSubMaterial(index: number): Nullable<Material>;
  21007. /**
  21008. * Get the list of active textures for the whole sub materials list.
  21009. * @returns All the textures that will be used during the rendering
  21010. */
  21011. getActiveTextures(): BaseTexture[];
  21012. /**
  21013. * Gets the current class name of the material e.g. "MultiMaterial"
  21014. * Mainly use in serialization.
  21015. * @returns the class name
  21016. */
  21017. getClassName(): string;
  21018. /**
  21019. * Checks if the material is ready to render the requested sub mesh
  21020. * @param mesh Define the mesh the submesh belongs to
  21021. * @param subMesh Define the sub mesh to look readyness for
  21022. * @param useInstances Define whether or not the material is used with instances
  21023. * @returns true if ready, otherwise false
  21024. */
  21025. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21026. /**
  21027. * Clones the current material and its related sub materials
  21028. * @param name Define the name of the newly cloned material
  21029. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21030. * @returns the cloned material
  21031. */
  21032. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21033. /**
  21034. * Serializes the materials into a JSON representation.
  21035. * @returns the JSON representation
  21036. */
  21037. serialize(): any;
  21038. /**
  21039. * Dispose the material and release its associated resources
  21040. * @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)
  21041. * @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)
  21042. * @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)
  21043. */
  21044. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21045. /**
  21046. * Creates a MultiMaterial from parsed MultiMaterial data.
  21047. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21048. * @param scene defines the hosting scene
  21049. * @returns a new MultiMaterial
  21050. */
  21051. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21052. }
  21053. }
  21054. declare module BABYLON {
  21055. /**
  21056. * Base class for submeshes
  21057. */
  21058. export class BaseSubMesh {
  21059. /** @hidden */
  21060. _materialDefines: Nullable<MaterialDefines>;
  21061. /** @hidden */
  21062. _materialEffect: Nullable<Effect>;
  21063. /**
  21064. * Gets material defines used by the effect associated to the sub mesh
  21065. */
  21066. /**
  21067. * Sets material defines used by the effect associated to the sub mesh
  21068. */
  21069. materialDefines: Nullable<MaterialDefines>;
  21070. /**
  21071. * Gets associated effect
  21072. */
  21073. readonly effect: Nullable<Effect>;
  21074. /**
  21075. * Sets associated effect (effect used to render this submesh)
  21076. * @param effect defines the effect to associate with
  21077. * @param defines defines the set of defines used to compile this effect
  21078. */
  21079. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21080. }
  21081. /**
  21082. * Defines a subdivision inside a mesh
  21083. */
  21084. export class SubMesh extends BaseSubMesh implements ICullable {
  21085. /** the material index to use */
  21086. materialIndex: number;
  21087. /** vertex index start */
  21088. verticesStart: number;
  21089. /** vertices count */
  21090. verticesCount: number;
  21091. /** index start */
  21092. indexStart: number;
  21093. /** indices count */
  21094. indexCount: number;
  21095. /** @hidden */
  21096. _linesIndexCount: number;
  21097. private _mesh;
  21098. private _renderingMesh;
  21099. private _boundingInfo;
  21100. private _linesIndexBuffer;
  21101. /** @hidden */
  21102. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21103. /** @hidden */
  21104. _trianglePlanes: Plane[];
  21105. /** @hidden */
  21106. _lastColliderTransformMatrix: Nullable<Matrix>;
  21107. /** @hidden */
  21108. _renderId: number;
  21109. /** @hidden */
  21110. _alphaIndex: number;
  21111. /** @hidden */
  21112. _distanceToCamera: number;
  21113. /** @hidden */
  21114. _id: number;
  21115. private _currentMaterial;
  21116. /**
  21117. * Add a new submesh to a mesh
  21118. * @param materialIndex defines the material index to use
  21119. * @param verticesStart defines vertex index start
  21120. * @param verticesCount defines vertices count
  21121. * @param indexStart defines index start
  21122. * @param indexCount defines indices count
  21123. * @param mesh defines the parent mesh
  21124. * @param renderingMesh defines an optional rendering mesh
  21125. * @param createBoundingBox defines if bounding box should be created for this submesh
  21126. * @returns the new submesh
  21127. */
  21128. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21129. /**
  21130. * Creates a new submesh
  21131. * @param materialIndex defines the material index to use
  21132. * @param verticesStart defines vertex index start
  21133. * @param verticesCount defines vertices count
  21134. * @param indexStart defines index start
  21135. * @param indexCount defines indices count
  21136. * @param mesh defines the parent mesh
  21137. * @param renderingMesh defines an optional rendering mesh
  21138. * @param createBoundingBox defines if bounding box should be created for this submesh
  21139. */
  21140. constructor(
  21141. /** the material index to use */
  21142. materialIndex: number,
  21143. /** vertex index start */
  21144. verticesStart: number,
  21145. /** vertices count */
  21146. verticesCount: number,
  21147. /** index start */
  21148. indexStart: number,
  21149. /** indices count */
  21150. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21151. /**
  21152. * Returns true if this submesh covers the entire parent mesh
  21153. * @ignorenaming
  21154. */
  21155. readonly IsGlobal: boolean;
  21156. /**
  21157. * Returns the submesh BoudingInfo object
  21158. * @returns current bounding info (or mesh's one if the submesh is global)
  21159. */
  21160. getBoundingInfo(): BoundingInfo;
  21161. /**
  21162. * Sets the submesh BoundingInfo
  21163. * @param boundingInfo defines the new bounding info to use
  21164. * @returns the SubMesh
  21165. */
  21166. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21167. /**
  21168. * Returns the mesh of the current submesh
  21169. * @return the parent mesh
  21170. */
  21171. getMesh(): AbstractMesh;
  21172. /**
  21173. * Returns the rendering mesh of the submesh
  21174. * @returns the rendering mesh (could be different from parent mesh)
  21175. */
  21176. getRenderingMesh(): Mesh;
  21177. /**
  21178. * Returns the submesh material
  21179. * @returns null or the current material
  21180. */
  21181. getMaterial(): Nullable<Material>;
  21182. /**
  21183. * Sets a new updated BoundingInfo object to the submesh
  21184. * @param data defines an optional position array to use to determine the bounding info
  21185. * @returns the SubMesh
  21186. */
  21187. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21188. /** @hidden */
  21189. _checkCollision(collider: Collider): boolean;
  21190. /**
  21191. * Updates the submesh BoundingInfo
  21192. * @param world defines the world matrix to use to update the bounding info
  21193. * @returns the submesh
  21194. */
  21195. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21196. /**
  21197. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21198. * @param frustumPlanes defines the frustum planes
  21199. * @returns true if the submesh is intersecting with the frustum
  21200. */
  21201. isInFrustum(frustumPlanes: Plane[]): boolean;
  21202. /**
  21203. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21204. * @param frustumPlanes defines the frustum planes
  21205. * @returns true if the submesh is inside the frustum
  21206. */
  21207. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21208. /**
  21209. * Renders the submesh
  21210. * @param enableAlphaMode defines if alpha needs to be used
  21211. * @returns the submesh
  21212. */
  21213. render(enableAlphaMode: boolean): SubMesh;
  21214. /**
  21215. * @hidden
  21216. */
  21217. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21218. /**
  21219. * Checks if the submesh intersects with a ray
  21220. * @param ray defines the ray to test
  21221. * @returns true is the passed ray intersects the submesh bounding box
  21222. */
  21223. canIntersects(ray: Ray): boolean;
  21224. /**
  21225. * Intersects current submesh with a ray
  21226. * @param ray defines the ray to test
  21227. * @param positions defines mesh's positions array
  21228. * @param indices defines mesh's indices array
  21229. * @param fastCheck defines if only bounding info should be used
  21230. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21231. * @returns intersection info or null if no intersection
  21232. */
  21233. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21234. /** @hidden */
  21235. private _intersectLines;
  21236. /** @hidden */
  21237. private _intersectUnIndexedLines;
  21238. /** @hidden */
  21239. private _intersectTriangles;
  21240. /** @hidden */
  21241. private _intersectUnIndexedTriangles;
  21242. /** @hidden */
  21243. _rebuild(): void;
  21244. /**
  21245. * Creates a new submesh from the passed mesh
  21246. * @param newMesh defines the new hosting mesh
  21247. * @param newRenderingMesh defines an optional rendering mesh
  21248. * @returns the new submesh
  21249. */
  21250. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21251. /**
  21252. * Release associated resources
  21253. */
  21254. dispose(): void;
  21255. /**
  21256. * Gets the class name
  21257. * @returns the string "SubMesh".
  21258. */
  21259. getClassName(): string;
  21260. /**
  21261. * Creates a new submesh from indices data
  21262. * @param materialIndex the index of the main mesh material
  21263. * @param startIndex the index where to start the copy in the mesh indices array
  21264. * @param indexCount the number of indices to copy then from the startIndex
  21265. * @param mesh the main mesh to create the submesh from
  21266. * @param renderingMesh the optional rendering mesh
  21267. * @returns a new submesh
  21268. */
  21269. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21270. }
  21271. }
  21272. declare module BABYLON {
  21273. /**
  21274. * Class used to represent data loading progression
  21275. */
  21276. export class SceneLoaderFlags {
  21277. private static _ForceFullSceneLoadingForIncremental;
  21278. private static _ShowLoadingScreen;
  21279. private static _CleanBoneMatrixWeights;
  21280. private static _loggingLevel;
  21281. /**
  21282. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21283. */
  21284. static ForceFullSceneLoadingForIncremental: boolean;
  21285. /**
  21286. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21287. */
  21288. static ShowLoadingScreen: boolean;
  21289. /**
  21290. * Defines the current logging level (while loading the scene)
  21291. * @ignorenaming
  21292. */
  21293. static loggingLevel: number;
  21294. /**
  21295. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21296. */
  21297. static CleanBoneMatrixWeights: boolean;
  21298. }
  21299. }
  21300. declare module BABYLON {
  21301. /**
  21302. * Class used to store geometry data (vertex buffers + index buffer)
  21303. */
  21304. export class Geometry implements IGetSetVerticesData {
  21305. /**
  21306. * Gets or sets the ID of the geometry
  21307. */
  21308. id: string;
  21309. /**
  21310. * Gets or sets the unique ID of the geometry
  21311. */
  21312. uniqueId: number;
  21313. /**
  21314. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21315. */
  21316. delayLoadState: number;
  21317. /**
  21318. * Gets the file containing the data to load when running in delay load state
  21319. */
  21320. delayLoadingFile: Nullable<string>;
  21321. /**
  21322. * Callback called when the geometry is updated
  21323. */
  21324. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21325. private _scene;
  21326. private _engine;
  21327. private _meshes;
  21328. private _totalVertices;
  21329. /** @hidden */
  21330. _indices: IndicesArray;
  21331. /** @hidden */
  21332. _vertexBuffers: {
  21333. [key: string]: VertexBuffer;
  21334. };
  21335. private _isDisposed;
  21336. private _extend;
  21337. private _boundingBias;
  21338. /** @hidden */
  21339. _delayInfo: Array<string>;
  21340. private _indexBuffer;
  21341. private _indexBufferIsUpdatable;
  21342. /** @hidden */
  21343. _boundingInfo: Nullable<BoundingInfo>;
  21344. /** @hidden */
  21345. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21346. /** @hidden */
  21347. _softwareSkinningFrameId: number;
  21348. private _vertexArrayObjects;
  21349. private _updatable;
  21350. /** @hidden */
  21351. _positions: Nullable<Vector3[]>;
  21352. /**
  21353. * 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
  21354. */
  21355. /**
  21356. * 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
  21357. */
  21358. boundingBias: Vector2;
  21359. /**
  21360. * Static function used to attach a new empty geometry to a mesh
  21361. * @param mesh defines the mesh to attach the geometry to
  21362. * @returns the new Geometry
  21363. */
  21364. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21365. /**
  21366. * Creates a new geometry
  21367. * @param id defines the unique ID
  21368. * @param scene defines the hosting scene
  21369. * @param vertexData defines the VertexData used to get geometry data
  21370. * @param updatable defines if geometry must be updatable (false by default)
  21371. * @param mesh defines the mesh that will be associated with the geometry
  21372. */
  21373. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21374. /**
  21375. * Gets the current extend of the geometry
  21376. */
  21377. readonly extend: {
  21378. minimum: Vector3;
  21379. maximum: Vector3;
  21380. };
  21381. /**
  21382. * Gets the hosting scene
  21383. * @returns the hosting Scene
  21384. */
  21385. getScene(): Scene;
  21386. /**
  21387. * Gets the hosting engine
  21388. * @returns the hosting Engine
  21389. */
  21390. getEngine(): Engine;
  21391. /**
  21392. * Defines if the geometry is ready to use
  21393. * @returns true if the geometry is ready to be used
  21394. */
  21395. isReady(): boolean;
  21396. /**
  21397. * Gets a value indicating that the geometry should not be serialized
  21398. */
  21399. readonly doNotSerialize: boolean;
  21400. /** @hidden */
  21401. _rebuild(): void;
  21402. /**
  21403. * Affects all geometry data in one call
  21404. * @param vertexData defines the geometry data
  21405. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21406. */
  21407. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21408. /**
  21409. * Set specific vertex data
  21410. * @param kind defines the data kind (Position, normal, etc...)
  21411. * @param data defines the vertex data to use
  21412. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21413. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21414. */
  21415. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21416. /**
  21417. * Removes a specific vertex data
  21418. * @param kind defines the data kind (Position, normal, etc...)
  21419. */
  21420. removeVerticesData(kind: string): void;
  21421. /**
  21422. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21423. * @param buffer defines the vertex buffer to use
  21424. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21425. */
  21426. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21427. /**
  21428. * Update a specific vertex buffer
  21429. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21430. * It will do nothing if the buffer is not updatable
  21431. * @param kind defines the data kind (Position, normal, etc...)
  21432. * @param data defines the data to use
  21433. * @param offset defines the offset in the target buffer where to store the data
  21434. * @param useBytes set to true if the offset is in bytes
  21435. */
  21436. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21437. /**
  21438. * Update a specific vertex buffer
  21439. * This function will create a new buffer if the current one is not updatable
  21440. * @param kind defines the data kind (Position, normal, etc...)
  21441. * @param data defines the data to use
  21442. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21443. */
  21444. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21445. private _updateBoundingInfo;
  21446. /** @hidden */
  21447. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21448. /**
  21449. * Gets total number of vertices
  21450. * @returns the total number of vertices
  21451. */
  21452. getTotalVertices(): number;
  21453. /**
  21454. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21455. * @param kind defines the data kind (Position, normal, etc...)
  21456. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21457. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21458. * @returns a float array containing vertex data
  21459. */
  21460. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21461. /**
  21462. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21463. * @param kind defines the data kind (Position, normal, etc...)
  21464. * @returns true if the vertex buffer with the specified kind is updatable
  21465. */
  21466. isVertexBufferUpdatable(kind: string): boolean;
  21467. /**
  21468. * Gets a specific vertex buffer
  21469. * @param kind defines the data kind (Position, normal, etc...)
  21470. * @returns a VertexBuffer
  21471. */
  21472. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21473. /**
  21474. * Returns all vertex buffers
  21475. * @return an object holding all vertex buffers indexed by kind
  21476. */
  21477. getVertexBuffers(): Nullable<{
  21478. [key: string]: VertexBuffer;
  21479. }>;
  21480. /**
  21481. * Gets a boolean indicating if specific vertex buffer is present
  21482. * @param kind defines the data kind (Position, normal, etc...)
  21483. * @returns true if data is present
  21484. */
  21485. isVerticesDataPresent(kind: string): boolean;
  21486. /**
  21487. * Gets a list of all attached data kinds (Position, normal, etc...)
  21488. * @returns a list of string containing all kinds
  21489. */
  21490. getVerticesDataKinds(): string[];
  21491. /**
  21492. * Update index buffer
  21493. * @param indices defines the indices to store in the index buffer
  21494. * @param offset defines the offset in the target buffer where to store the data
  21495. * @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)
  21496. */
  21497. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21498. /**
  21499. * Creates a new index buffer
  21500. * @param indices defines the indices to store in the index buffer
  21501. * @param totalVertices defines the total number of vertices (could be null)
  21502. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21503. */
  21504. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21505. /**
  21506. * Return the total number of indices
  21507. * @returns the total number of indices
  21508. */
  21509. getTotalIndices(): number;
  21510. /**
  21511. * Gets the index buffer array
  21512. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21513. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21514. * @returns the index buffer array
  21515. */
  21516. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21517. /**
  21518. * Gets the index buffer
  21519. * @return the index buffer
  21520. */
  21521. getIndexBuffer(): Nullable<DataBuffer>;
  21522. /** @hidden */
  21523. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21524. /**
  21525. * Release the associated resources for a specific mesh
  21526. * @param mesh defines the source mesh
  21527. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21528. */
  21529. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21530. /**
  21531. * Apply current geometry to a given mesh
  21532. * @param mesh defines the mesh to apply geometry to
  21533. */
  21534. applyToMesh(mesh: Mesh): void;
  21535. private _updateExtend;
  21536. private _applyToMesh;
  21537. private notifyUpdate;
  21538. /**
  21539. * Load the geometry if it was flagged as delay loaded
  21540. * @param scene defines the hosting scene
  21541. * @param onLoaded defines a callback called when the geometry is loaded
  21542. */
  21543. load(scene: Scene, onLoaded?: () => void): void;
  21544. private _queueLoad;
  21545. /**
  21546. * Invert the geometry to move from a right handed system to a left handed one.
  21547. */
  21548. toLeftHanded(): void;
  21549. /** @hidden */
  21550. _resetPointsArrayCache(): void;
  21551. /** @hidden */
  21552. _generatePointsArray(): boolean;
  21553. /**
  21554. * Gets a value indicating if the geometry is disposed
  21555. * @returns true if the geometry was disposed
  21556. */
  21557. isDisposed(): boolean;
  21558. private _disposeVertexArrayObjects;
  21559. /**
  21560. * Free all associated resources
  21561. */
  21562. dispose(): void;
  21563. /**
  21564. * Clone the current geometry into a new geometry
  21565. * @param id defines the unique ID of the new geometry
  21566. * @returns a new geometry object
  21567. */
  21568. copy(id: string): Geometry;
  21569. /**
  21570. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21571. * @return a JSON representation of the current geometry data (without the vertices data)
  21572. */
  21573. serialize(): any;
  21574. private toNumberArray;
  21575. /**
  21576. * Serialize all vertices data into a JSON oject
  21577. * @returns a JSON representation of the current geometry data
  21578. */
  21579. serializeVerticeData(): any;
  21580. /**
  21581. * Extracts a clone of a mesh geometry
  21582. * @param mesh defines the source mesh
  21583. * @param id defines the unique ID of the new geometry object
  21584. * @returns the new geometry object
  21585. */
  21586. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21587. /**
  21588. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21589. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21590. * Be aware Math.random() could cause collisions, but:
  21591. * "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"
  21592. * @returns a string containing a new GUID
  21593. */
  21594. static RandomId(): string;
  21595. /** @hidden */
  21596. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21597. private static _CleanMatricesWeights;
  21598. /**
  21599. * Create a new geometry from persisted data (Using .babylon file format)
  21600. * @param parsedVertexData defines the persisted data
  21601. * @param scene defines the hosting scene
  21602. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21603. * @returns the new geometry object
  21604. */
  21605. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21606. }
  21607. }
  21608. declare module BABYLON {
  21609. /**
  21610. * Define an interface for all classes that will get and set the data on vertices
  21611. */
  21612. export interface IGetSetVerticesData {
  21613. /**
  21614. * Gets a boolean indicating if specific vertex data is present
  21615. * @param kind defines the vertex data kind to use
  21616. * @returns true is data kind is present
  21617. */
  21618. isVerticesDataPresent(kind: string): boolean;
  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 an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21629. * @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.
  21630. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21631. * @returns the indices array or an empty array if the mesh has no geometry
  21632. */
  21633. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21634. /**
  21635. * Set specific vertex data
  21636. * @param kind defines the data kind (Position, normal, etc...)
  21637. * @param data defines the vertex data to use
  21638. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21639. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21640. */
  21641. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21642. /**
  21643. * Update a specific associated vertex buffer
  21644. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21645. * - VertexBuffer.PositionKind
  21646. * - VertexBuffer.UVKind
  21647. * - VertexBuffer.UV2Kind
  21648. * - VertexBuffer.UV3Kind
  21649. * - VertexBuffer.UV4Kind
  21650. * - VertexBuffer.UV5Kind
  21651. * - VertexBuffer.UV6Kind
  21652. * - VertexBuffer.ColorKind
  21653. * - VertexBuffer.MatricesIndicesKind
  21654. * - VertexBuffer.MatricesIndicesExtraKind
  21655. * - VertexBuffer.MatricesWeightsKind
  21656. * - VertexBuffer.MatricesWeightsExtraKind
  21657. * @param data defines the data source
  21658. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21659. * @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)
  21660. */
  21661. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21662. /**
  21663. * Creates a new index buffer
  21664. * @param indices defines the indices to store in the index buffer
  21665. * @param totalVertices defines the total number of vertices (could be null)
  21666. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21667. */
  21668. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21669. }
  21670. /**
  21671. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21672. */
  21673. export class VertexData {
  21674. /**
  21675. * Mesh side orientation : usually the external or front surface
  21676. */
  21677. static readonly FRONTSIDE: number;
  21678. /**
  21679. * Mesh side orientation : usually the internal or back surface
  21680. */
  21681. static readonly BACKSIDE: number;
  21682. /**
  21683. * Mesh side orientation : both internal and external or front and back surfaces
  21684. */
  21685. static readonly DOUBLESIDE: number;
  21686. /**
  21687. * Mesh side orientation : by default, `FRONTSIDE`
  21688. */
  21689. static readonly DEFAULTSIDE: number;
  21690. /**
  21691. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21692. */
  21693. positions: Nullable<FloatArray>;
  21694. /**
  21695. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21696. */
  21697. normals: Nullable<FloatArray>;
  21698. /**
  21699. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21700. */
  21701. tangents: Nullable<FloatArray>;
  21702. /**
  21703. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21704. */
  21705. uvs: Nullable<FloatArray>;
  21706. /**
  21707. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21708. */
  21709. uvs2: Nullable<FloatArray>;
  21710. /**
  21711. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21712. */
  21713. uvs3: Nullable<FloatArray>;
  21714. /**
  21715. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21716. */
  21717. uvs4: Nullable<FloatArray>;
  21718. /**
  21719. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21720. */
  21721. uvs5: Nullable<FloatArray>;
  21722. /**
  21723. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21724. */
  21725. uvs6: Nullable<FloatArray>;
  21726. /**
  21727. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21728. */
  21729. colors: Nullable<FloatArray>;
  21730. /**
  21731. * 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).
  21732. */
  21733. matricesIndices: Nullable<FloatArray>;
  21734. /**
  21735. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21736. */
  21737. matricesWeights: Nullable<FloatArray>;
  21738. /**
  21739. * An array extending the number of possible indices
  21740. */
  21741. matricesIndicesExtra: Nullable<FloatArray>;
  21742. /**
  21743. * An array extending the number of possible weights when the number of indices is extended
  21744. */
  21745. matricesWeightsExtra: Nullable<FloatArray>;
  21746. /**
  21747. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21748. */
  21749. indices: Nullable<IndicesArray>;
  21750. /**
  21751. * Uses the passed data array to set the set the values for the specified kind of data
  21752. * @param data a linear array of floating numbers
  21753. * @param kind the type of data that is being set, eg positions, colors etc
  21754. */
  21755. set(data: FloatArray, kind: string): void;
  21756. /**
  21757. * Associates the vertexData to the passed Mesh.
  21758. * Sets it as updatable or not (default `false`)
  21759. * @param mesh the mesh the vertexData is applied to
  21760. * @param updatable when used and having the value true allows new data to update the vertexData
  21761. * @returns the VertexData
  21762. */
  21763. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21764. /**
  21765. * Associates the vertexData to the passed Geometry.
  21766. * Sets it as updatable or not (default `false`)
  21767. * @param geometry the geometry the vertexData is applied to
  21768. * @param updatable when used and having the value true allows new data to update the vertexData
  21769. * @returns VertexData
  21770. */
  21771. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21772. /**
  21773. * Updates the associated mesh
  21774. * @param mesh the mesh to be updated
  21775. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21776. * @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
  21777. * @returns VertexData
  21778. */
  21779. updateMesh(mesh: Mesh): VertexData;
  21780. /**
  21781. * Updates the associated geometry
  21782. * @param geometry the geometry to be updated
  21783. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21784. * @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
  21785. * @returns VertexData.
  21786. */
  21787. updateGeometry(geometry: Geometry): VertexData;
  21788. private _applyTo;
  21789. private _update;
  21790. /**
  21791. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21792. * @param matrix the transforming matrix
  21793. * @returns the VertexData
  21794. */
  21795. transform(matrix: Matrix): VertexData;
  21796. /**
  21797. * Merges the passed VertexData into the current one
  21798. * @param other the VertexData to be merged into the current one
  21799. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21800. * @returns the modified VertexData
  21801. */
  21802. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21803. private _mergeElement;
  21804. private _validate;
  21805. /**
  21806. * Serializes the VertexData
  21807. * @returns a serialized object
  21808. */
  21809. serialize(): any;
  21810. /**
  21811. * Extracts the vertexData from a mesh
  21812. * @param mesh the mesh from which to extract the VertexData
  21813. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21814. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21815. * @returns the object VertexData associated to the passed mesh
  21816. */
  21817. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21818. /**
  21819. * Extracts the vertexData from the geometry
  21820. * @param geometry the geometry from which to extract the VertexData
  21821. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21822. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21823. * @returns the object VertexData associated to the passed mesh
  21824. */
  21825. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21826. private static _ExtractFrom;
  21827. /**
  21828. * Creates the VertexData for a Ribbon
  21829. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21830. * * pathArray array of paths, each of which an array of successive Vector3
  21831. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21832. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21833. * * 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
  21834. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21835. * * 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)
  21836. * * 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)
  21837. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21838. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21839. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21840. * @returns the VertexData of the ribbon
  21841. */
  21842. static CreateRibbon(options: {
  21843. pathArray: Vector3[][];
  21844. closeArray?: boolean;
  21845. closePath?: boolean;
  21846. offset?: number;
  21847. sideOrientation?: number;
  21848. frontUVs?: Vector4;
  21849. backUVs?: Vector4;
  21850. invertUV?: boolean;
  21851. uvs?: Vector2[];
  21852. colors?: Color4[];
  21853. }): VertexData;
  21854. /**
  21855. * Creates the VertexData for a box
  21856. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21857. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21858. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21859. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21860. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21861. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21862. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21863. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21864. * * 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)
  21865. * * 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)
  21866. * @returns the VertexData of the box
  21867. */
  21868. static CreateBox(options: {
  21869. size?: number;
  21870. width?: number;
  21871. height?: number;
  21872. depth?: number;
  21873. faceUV?: Vector4[];
  21874. faceColors?: Color4[];
  21875. sideOrientation?: number;
  21876. frontUVs?: Vector4;
  21877. backUVs?: Vector4;
  21878. }): VertexData;
  21879. /**
  21880. * Creates the VertexData for a tiled box
  21881. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21882. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21883. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21884. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21885. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21886. * @returns the VertexData of the box
  21887. */
  21888. static CreateTiledBox(options: {
  21889. pattern?: number;
  21890. width?: number;
  21891. height?: number;
  21892. depth?: number;
  21893. tileSize?: number;
  21894. tileWidth?: number;
  21895. tileHeight?: number;
  21896. alignHorizontal?: number;
  21897. alignVertical?: number;
  21898. faceUV?: Vector4[];
  21899. faceColors?: Color4[];
  21900. sideOrientation?: number;
  21901. }): VertexData;
  21902. /**
  21903. * Creates the VertexData for a tiled plane
  21904. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21905. * * pattern a limited pattern arrangement depending on the number
  21906. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21907. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21908. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21909. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21910. * * 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)
  21911. * * 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)
  21912. * @returns the VertexData of the tiled plane
  21913. */
  21914. static CreateTiledPlane(options: {
  21915. pattern?: number;
  21916. tileSize?: number;
  21917. tileWidth?: number;
  21918. tileHeight?: number;
  21919. size?: number;
  21920. width?: number;
  21921. height?: number;
  21922. alignHorizontal?: number;
  21923. alignVertical?: number;
  21924. sideOrientation?: number;
  21925. frontUVs?: Vector4;
  21926. backUVs?: Vector4;
  21927. }): VertexData;
  21928. /**
  21929. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21930. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21931. * * segments sets the number of horizontal strips optional, default 32
  21932. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21933. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21934. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21935. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21936. * * 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
  21937. * * 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
  21938. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21939. * * 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)
  21940. * * 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)
  21941. * @returns the VertexData of the ellipsoid
  21942. */
  21943. static CreateSphere(options: {
  21944. segments?: number;
  21945. diameter?: number;
  21946. diameterX?: number;
  21947. diameterY?: number;
  21948. diameterZ?: number;
  21949. arc?: number;
  21950. slice?: number;
  21951. sideOrientation?: number;
  21952. frontUVs?: Vector4;
  21953. backUVs?: Vector4;
  21954. }): VertexData;
  21955. /**
  21956. * Creates the VertexData for a cylinder, cone or prism
  21957. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21958. * * height sets the height (y direction) of the cylinder, optional, default 2
  21959. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21960. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21961. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21962. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21963. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21964. * * 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
  21965. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21966. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21967. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21968. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21969. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21970. * * 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)
  21971. * * 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)
  21972. * @returns the VertexData of the cylinder, cone or prism
  21973. */
  21974. static CreateCylinder(options: {
  21975. height?: number;
  21976. diameterTop?: number;
  21977. diameterBottom?: number;
  21978. diameter?: number;
  21979. tessellation?: number;
  21980. subdivisions?: number;
  21981. arc?: number;
  21982. faceColors?: Color4[];
  21983. faceUV?: Vector4[];
  21984. hasRings?: boolean;
  21985. enclose?: boolean;
  21986. sideOrientation?: number;
  21987. frontUVs?: Vector4;
  21988. backUVs?: Vector4;
  21989. }): VertexData;
  21990. /**
  21991. * Creates the VertexData for a torus
  21992. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21993. * * diameter the diameter of the torus, optional default 1
  21994. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21995. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21996. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21997. * * 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)
  21998. * * 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)
  21999. * @returns the VertexData of the torus
  22000. */
  22001. static CreateTorus(options: {
  22002. diameter?: number;
  22003. thickness?: number;
  22004. tessellation?: number;
  22005. sideOrientation?: number;
  22006. frontUVs?: Vector4;
  22007. backUVs?: Vector4;
  22008. }): VertexData;
  22009. /**
  22010. * Creates the VertexData of the LineSystem
  22011. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22012. * - lines an array of lines, each line being an array of successive Vector3
  22013. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22014. * @returns the VertexData of the LineSystem
  22015. */
  22016. static CreateLineSystem(options: {
  22017. lines: Vector3[][];
  22018. colors?: Nullable<Color4[][]>;
  22019. }): VertexData;
  22020. /**
  22021. * Create the VertexData for a DashedLines
  22022. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22023. * - points an array successive Vector3
  22024. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22025. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22026. * - dashNb the intended total number of dashes, optional, default 200
  22027. * @returns the VertexData for the DashedLines
  22028. */
  22029. static CreateDashedLines(options: {
  22030. points: Vector3[];
  22031. dashSize?: number;
  22032. gapSize?: number;
  22033. dashNb?: number;
  22034. }): VertexData;
  22035. /**
  22036. * Creates the VertexData for a Ground
  22037. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22038. * - width the width (x direction) of the ground, optional, default 1
  22039. * - height the height (z direction) of the ground, optional, default 1
  22040. * - subdivisions the number of subdivisions per side, optional, default 1
  22041. * @returns the VertexData of the Ground
  22042. */
  22043. static CreateGround(options: {
  22044. width?: number;
  22045. height?: number;
  22046. subdivisions?: number;
  22047. subdivisionsX?: number;
  22048. subdivisionsY?: number;
  22049. }): VertexData;
  22050. /**
  22051. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22052. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22053. * * xmin the ground minimum X coordinate, optional, default -1
  22054. * * zmin the ground minimum Z coordinate, optional, default -1
  22055. * * xmax the ground maximum X coordinate, optional, default 1
  22056. * * zmax the ground maximum Z coordinate, optional, default 1
  22057. * * 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}
  22058. * * 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}
  22059. * @returns the VertexData of the TiledGround
  22060. */
  22061. static CreateTiledGround(options: {
  22062. xmin: number;
  22063. zmin: number;
  22064. xmax: number;
  22065. zmax: number;
  22066. subdivisions?: {
  22067. w: number;
  22068. h: number;
  22069. };
  22070. precision?: {
  22071. w: number;
  22072. h: number;
  22073. };
  22074. }): VertexData;
  22075. /**
  22076. * Creates the VertexData of the Ground designed from a heightmap
  22077. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22078. * * width the width (x direction) of the ground
  22079. * * height the height (z direction) of the ground
  22080. * * subdivisions the number of subdivisions per side
  22081. * * minHeight the minimum altitude on the ground, optional, default 0
  22082. * * maxHeight the maximum altitude on the ground, optional default 1
  22083. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22084. * * buffer the array holding the image color data
  22085. * * bufferWidth the width of image
  22086. * * bufferHeight the height of image
  22087. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22088. * @returns the VertexData of the Ground designed from a heightmap
  22089. */
  22090. static CreateGroundFromHeightMap(options: {
  22091. width: number;
  22092. height: number;
  22093. subdivisions: number;
  22094. minHeight: number;
  22095. maxHeight: number;
  22096. colorFilter: Color3;
  22097. buffer: Uint8Array;
  22098. bufferWidth: number;
  22099. bufferHeight: number;
  22100. alphaFilter: number;
  22101. }): VertexData;
  22102. /**
  22103. * Creates the VertexData for a Plane
  22104. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22105. * * size sets the width and height of the plane to the value of size, optional default 1
  22106. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22107. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22108. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22109. * * 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)
  22110. * * 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)
  22111. * @returns the VertexData of the box
  22112. */
  22113. static CreatePlane(options: {
  22114. size?: number;
  22115. width?: number;
  22116. height?: number;
  22117. sideOrientation?: number;
  22118. frontUVs?: Vector4;
  22119. backUVs?: Vector4;
  22120. }): VertexData;
  22121. /**
  22122. * Creates the VertexData of the Disc or regular Polygon
  22123. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22124. * * radius the radius of the disc, optional default 0.5
  22125. * * tessellation the number of polygon sides, optional, default 64
  22126. * * 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
  22127. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22128. * * 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)
  22129. * * 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)
  22130. * @returns the VertexData of the box
  22131. */
  22132. static CreateDisc(options: {
  22133. radius?: number;
  22134. tessellation?: number;
  22135. arc?: number;
  22136. sideOrientation?: number;
  22137. frontUVs?: Vector4;
  22138. backUVs?: Vector4;
  22139. }): VertexData;
  22140. /**
  22141. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22142. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22143. * @param polygon a mesh built from polygonTriangulation.build()
  22144. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22145. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22146. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22147. * @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)
  22148. * @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)
  22149. * @returns the VertexData of the Polygon
  22150. */
  22151. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22152. /**
  22153. * Creates the VertexData of the IcoSphere
  22154. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22155. * * radius the radius of the IcoSphere, optional default 1
  22156. * * radiusX allows stretching in the x direction, optional, default radius
  22157. * * radiusY allows stretching in the y direction, optional, default radius
  22158. * * radiusZ allows stretching in the z direction, optional, default radius
  22159. * * flat when true creates a flat shaded mesh, optional, default true
  22160. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22161. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22162. * * 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)
  22163. * * 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)
  22164. * @returns the VertexData of the IcoSphere
  22165. */
  22166. static CreateIcoSphere(options: {
  22167. radius?: number;
  22168. radiusX?: number;
  22169. radiusY?: number;
  22170. radiusZ?: number;
  22171. flat?: boolean;
  22172. subdivisions?: number;
  22173. sideOrientation?: number;
  22174. frontUVs?: Vector4;
  22175. backUVs?: Vector4;
  22176. }): VertexData;
  22177. /**
  22178. * Creates the VertexData for a Polyhedron
  22179. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22180. * * type provided types are:
  22181. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22182. * * 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)
  22183. * * size the size of the IcoSphere, optional default 1
  22184. * * sizeX allows stretching in the x direction, optional, default size
  22185. * * sizeY allows stretching in the y direction, optional, default size
  22186. * * sizeZ allows stretching in the z direction, optional, default size
  22187. * * 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
  22188. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22189. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22190. * * flat when true creates a flat shaded mesh, optional, default true
  22191. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22192. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22193. * * 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)
  22194. * * 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)
  22195. * @returns the VertexData of the Polyhedron
  22196. */
  22197. static CreatePolyhedron(options: {
  22198. type?: number;
  22199. size?: number;
  22200. sizeX?: number;
  22201. sizeY?: number;
  22202. sizeZ?: number;
  22203. custom?: any;
  22204. faceUV?: Vector4[];
  22205. faceColors?: Color4[];
  22206. flat?: boolean;
  22207. sideOrientation?: number;
  22208. frontUVs?: Vector4;
  22209. backUVs?: Vector4;
  22210. }): VertexData;
  22211. /**
  22212. * Creates the VertexData for a TorusKnot
  22213. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22214. * * radius the radius of the torus knot, optional, default 2
  22215. * * tube the thickness of the tube, optional, default 0.5
  22216. * * radialSegments the number of sides on each tube segments, optional, default 32
  22217. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22218. * * p the number of windings around the z axis, optional, default 2
  22219. * * q the number of windings around the x axis, optional, default 3
  22220. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22221. * * 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)
  22222. * * 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)
  22223. * @returns the VertexData of the Torus Knot
  22224. */
  22225. static CreateTorusKnot(options: {
  22226. radius?: number;
  22227. tube?: number;
  22228. radialSegments?: number;
  22229. tubularSegments?: number;
  22230. p?: number;
  22231. q?: number;
  22232. sideOrientation?: number;
  22233. frontUVs?: Vector4;
  22234. backUVs?: Vector4;
  22235. }): VertexData;
  22236. /**
  22237. * Compute normals for given positions and indices
  22238. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22239. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22240. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22241. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22242. * * facetNormals : optional array of facet normals (vector3)
  22243. * * facetPositions : optional array of facet positions (vector3)
  22244. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22245. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22246. * * bInfo : optional bounding info, required for facetPartitioning computation
  22247. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22248. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22249. * * useRightHandedSystem: optional boolean to for right handed system computation
  22250. * * depthSort : optional boolean to enable the facet depth sort computation
  22251. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22252. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22253. */
  22254. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22255. facetNormals?: any;
  22256. facetPositions?: any;
  22257. facetPartitioning?: any;
  22258. ratio?: number;
  22259. bInfo?: any;
  22260. bbSize?: Vector3;
  22261. subDiv?: any;
  22262. useRightHandedSystem?: boolean;
  22263. depthSort?: boolean;
  22264. distanceTo?: Vector3;
  22265. depthSortedFacets?: any;
  22266. }): void;
  22267. /** @hidden */
  22268. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22269. /**
  22270. * Applies VertexData created from the imported parameters to the geometry
  22271. * @param parsedVertexData the parsed data from an imported file
  22272. * @param geometry the geometry to apply the VertexData to
  22273. */
  22274. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22275. }
  22276. }
  22277. declare module BABYLON {
  22278. /**
  22279. * Defines a target to use with MorphTargetManager
  22280. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22281. */
  22282. export class MorphTarget implements IAnimatable {
  22283. /** defines the name of the target */
  22284. name: string;
  22285. /**
  22286. * Gets or sets the list of animations
  22287. */
  22288. animations: Animation[];
  22289. private _scene;
  22290. private _positions;
  22291. private _normals;
  22292. private _tangents;
  22293. private _uvs;
  22294. private _influence;
  22295. private _uniqueId;
  22296. /**
  22297. * Observable raised when the influence changes
  22298. */
  22299. onInfluenceChanged: Observable<boolean>;
  22300. /** @hidden */
  22301. _onDataLayoutChanged: Observable<void>;
  22302. /**
  22303. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22304. */
  22305. influence: number;
  22306. /**
  22307. * Gets or sets the id of the morph Target
  22308. */
  22309. id: string;
  22310. private _animationPropertiesOverride;
  22311. /**
  22312. * Gets or sets the animation properties override
  22313. */
  22314. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22315. /**
  22316. * Creates a new MorphTarget
  22317. * @param name defines the name of the target
  22318. * @param influence defines the influence to use
  22319. * @param scene defines the scene the morphtarget belongs to
  22320. */
  22321. constructor(
  22322. /** defines the name of the target */
  22323. name: string, influence?: number, scene?: Nullable<Scene>);
  22324. /**
  22325. * Gets the unique ID of this manager
  22326. */
  22327. readonly uniqueId: number;
  22328. /**
  22329. * Gets a boolean defining if the target contains position data
  22330. */
  22331. readonly hasPositions: boolean;
  22332. /**
  22333. * Gets a boolean defining if the target contains normal data
  22334. */
  22335. readonly hasNormals: boolean;
  22336. /**
  22337. * Gets a boolean defining if the target contains tangent data
  22338. */
  22339. readonly hasTangents: boolean;
  22340. /**
  22341. * Gets a boolean defining if the target contains texture coordinates data
  22342. */
  22343. readonly hasUVs: boolean;
  22344. /**
  22345. * Affects position data to this target
  22346. * @param data defines the position data to use
  22347. */
  22348. setPositions(data: Nullable<FloatArray>): void;
  22349. /**
  22350. * Gets the position data stored in this target
  22351. * @returns a FloatArray containing the position data (or null if not present)
  22352. */
  22353. getPositions(): Nullable<FloatArray>;
  22354. /**
  22355. * Affects normal data to this target
  22356. * @param data defines the normal data to use
  22357. */
  22358. setNormals(data: Nullable<FloatArray>): void;
  22359. /**
  22360. * Gets the normal data stored in this target
  22361. * @returns a FloatArray containing the normal data (or null if not present)
  22362. */
  22363. getNormals(): Nullable<FloatArray>;
  22364. /**
  22365. * Affects tangent data to this target
  22366. * @param data defines the tangent data to use
  22367. */
  22368. setTangents(data: Nullable<FloatArray>): void;
  22369. /**
  22370. * Gets the tangent data stored in this target
  22371. * @returns a FloatArray containing the tangent data (or null if not present)
  22372. */
  22373. getTangents(): Nullable<FloatArray>;
  22374. /**
  22375. * Affects texture coordinates data to this target
  22376. * @param data defines the texture coordinates data to use
  22377. */
  22378. setUVs(data: Nullable<FloatArray>): void;
  22379. /**
  22380. * Gets the texture coordinates data stored in this target
  22381. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22382. */
  22383. getUVs(): Nullable<FloatArray>;
  22384. /**
  22385. * Clone the current target
  22386. * @returns a new MorphTarget
  22387. */
  22388. clone(): MorphTarget;
  22389. /**
  22390. * Serializes the current target into a Serialization object
  22391. * @returns the serialized object
  22392. */
  22393. serialize(): any;
  22394. /**
  22395. * Returns the string "MorphTarget"
  22396. * @returns "MorphTarget"
  22397. */
  22398. getClassName(): string;
  22399. /**
  22400. * Creates a new target from serialized data
  22401. * @param serializationObject defines the serialized data to use
  22402. * @returns a new MorphTarget
  22403. */
  22404. static Parse(serializationObject: any): MorphTarget;
  22405. /**
  22406. * Creates a MorphTarget from mesh data
  22407. * @param mesh defines the source mesh
  22408. * @param name defines the name to use for the new target
  22409. * @param influence defines the influence to attach to the target
  22410. * @returns a new MorphTarget
  22411. */
  22412. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22413. }
  22414. }
  22415. declare module BABYLON {
  22416. /**
  22417. * This class is used to deform meshes using morphing between different targets
  22418. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22419. */
  22420. export class MorphTargetManager {
  22421. private _targets;
  22422. private _targetInfluenceChangedObservers;
  22423. private _targetDataLayoutChangedObservers;
  22424. private _activeTargets;
  22425. private _scene;
  22426. private _influences;
  22427. private _supportsNormals;
  22428. private _supportsTangents;
  22429. private _supportsUVs;
  22430. private _vertexCount;
  22431. private _uniqueId;
  22432. private _tempInfluences;
  22433. /**
  22434. * Gets or sets a boolean indicating if normals must be morphed
  22435. */
  22436. enableNormalMorphing: boolean;
  22437. /**
  22438. * Gets or sets a boolean indicating if tangents must be morphed
  22439. */
  22440. enableTangentMorphing: boolean;
  22441. /**
  22442. * Gets or sets a boolean indicating if UV must be morphed
  22443. */
  22444. enableUVMorphing: boolean;
  22445. /**
  22446. * Creates a new MorphTargetManager
  22447. * @param scene defines the current scene
  22448. */
  22449. constructor(scene?: Nullable<Scene>);
  22450. /**
  22451. * Gets the unique ID of this manager
  22452. */
  22453. readonly uniqueId: number;
  22454. /**
  22455. * Gets the number of vertices handled by this manager
  22456. */
  22457. readonly vertexCount: number;
  22458. /**
  22459. * Gets a boolean indicating if this manager supports morphing of normals
  22460. */
  22461. readonly supportsNormals: boolean;
  22462. /**
  22463. * Gets a boolean indicating if this manager supports morphing of tangents
  22464. */
  22465. readonly supportsTangents: boolean;
  22466. /**
  22467. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22468. */
  22469. readonly supportsUVs: boolean;
  22470. /**
  22471. * Gets the number of targets stored in this manager
  22472. */
  22473. readonly numTargets: number;
  22474. /**
  22475. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22476. */
  22477. readonly numInfluencers: number;
  22478. /**
  22479. * Gets the list of influences (one per target)
  22480. */
  22481. readonly influences: Float32Array;
  22482. /**
  22483. * Gets the active target at specified index. An active target is a target with an influence > 0
  22484. * @param index defines the index to check
  22485. * @returns the requested target
  22486. */
  22487. getActiveTarget(index: number): MorphTarget;
  22488. /**
  22489. * Gets the target at specified index
  22490. * @param index defines the index to check
  22491. * @returns the requested target
  22492. */
  22493. getTarget(index: number): MorphTarget;
  22494. /**
  22495. * Add a new target to this manager
  22496. * @param target defines the target to add
  22497. */
  22498. addTarget(target: MorphTarget): void;
  22499. /**
  22500. * Removes a target from the manager
  22501. * @param target defines the target to remove
  22502. */
  22503. removeTarget(target: MorphTarget): void;
  22504. /**
  22505. * Clone the current manager
  22506. * @returns a new MorphTargetManager
  22507. */
  22508. clone(): MorphTargetManager;
  22509. /**
  22510. * Serializes the current manager into a Serialization object
  22511. * @returns the serialized object
  22512. */
  22513. serialize(): any;
  22514. private _syncActiveTargets;
  22515. /**
  22516. * Syncrhonize the targets with all the meshes using this morph target manager
  22517. */
  22518. synchronize(): void;
  22519. /**
  22520. * Creates a new MorphTargetManager from serialized data
  22521. * @param serializationObject defines the serialized data
  22522. * @param scene defines the hosting scene
  22523. * @returns the new MorphTargetManager
  22524. */
  22525. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22526. }
  22527. }
  22528. declare module BABYLON {
  22529. /**
  22530. * Class used to represent a specific level of detail of a mesh
  22531. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22532. */
  22533. export class MeshLODLevel {
  22534. /** Defines the distance where this level should start being displayed */
  22535. distance: number;
  22536. /** Defines the mesh to use to render this level */
  22537. mesh: Nullable<Mesh>;
  22538. /**
  22539. * Creates a new LOD level
  22540. * @param distance defines the distance where this level should star being displayed
  22541. * @param mesh defines the mesh to use to render this level
  22542. */
  22543. constructor(
  22544. /** Defines the distance where this level should start being displayed */
  22545. distance: number,
  22546. /** Defines the mesh to use to render this level */
  22547. mesh: Nullable<Mesh>);
  22548. }
  22549. }
  22550. declare module BABYLON {
  22551. /**
  22552. * Mesh representing the gorund
  22553. */
  22554. export class GroundMesh extends Mesh {
  22555. /** If octree should be generated */
  22556. generateOctree: boolean;
  22557. private _heightQuads;
  22558. /** @hidden */
  22559. _subdivisionsX: number;
  22560. /** @hidden */
  22561. _subdivisionsY: number;
  22562. /** @hidden */
  22563. _width: number;
  22564. /** @hidden */
  22565. _height: number;
  22566. /** @hidden */
  22567. _minX: number;
  22568. /** @hidden */
  22569. _maxX: number;
  22570. /** @hidden */
  22571. _minZ: number;
  22572. /** @hidden */
  22573. _maxZ: number;
  22574. constructor(name: string, scene: Scene);
  22575. /**
  22576. * "GroundMesh"
  22577. * @returns "GroundMesh"
  22578. */
  22579. getClassName(): string;
  22580. /**
  22581. * The minimum of x and y subdivisions
  22582. */
  22583. readonly subdivisions: number;
  22584. /**
  22585. * X subdivisions
  22586. */
  22587. readonly subdivisionsX: number;
  22588. /**
  22589. * Y subdivisions
  22590. */
  22591. readonly subdivisionsY: number;
  22592. /**
  22593. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22594. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22595. * @param chunksCount the number of subdivisions for x and y
  22596. * @param octreeBlocksSize (Default: 32)
  22597. */
  22598. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22599. /**
  22600. * Returns a height (y) value in the Worl system :
  22601. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22602. * @param x x coordinate
  22603. * @param z z coordinate
  22604. * @returns the ground y position if (x, z) are outside the ground surface.
  22605. */
  22606. getHeightAtCoordinates(x: number, z: number): number;
  22607. /**
  22608. * Returns a normalized vector (Vector3) orthogonal to the ground
  22609. * at the ground coordinates (x, z) expressed in the World system.
  22610. * @param x x coordinate
  22611. * @param z z coordinate
  22612. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22613. */
  22614. getNormalAtCoordinates(x: number, z: number): Vector3;
  22615. /**
  22616. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22617. * at the ground coordinates (x, z) expressed in the World system.
  22618. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22619. * @param x x coordinate
  22620. * @param z z coordinate
  22621. * @param ref vector to store the result
  22622. * @returns the GroundMesh.
  22623. */
  22624. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22625. /**
  22626. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22627. * if the ground has been updated.
  22628. * This can be used in the render loop.
  22629. * @returns the GroundMesh.
  22630. */
  22631. updateCoordinateHeights(): GroundMesh;
  22632. private _getFacetAt;
  22633. private _initHeightQuads;
  22634. private _computeHeightQuads;
  22635. /**
  22636. * Serializes this ground mesh
  22637. * @param serializationObject object to write serialization to
  22638. */
  22639. serialize(serializationObject: any): void;
  22640. /**
  22641. * Parses a serialized ground mesh
  22642. * @param parsedMesh the serialized mesh
  22643. * @param scene the scene to create the ground mesh in
  22644. * @returns the created ground mesh
  22645. */
  22646. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22647. }
  22648. }
  22649. declare module BABYLON {
  22650. /**
  22651. * Interface for Physics-Joint data
  22652. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22653. */
  22654. export interface PhysicsJointData {
  22655. /**
  22656. * The main pivot of the joint
  22657. */
  22658. mainPivot?: Vector3;
  22659. /**
  22660. * The connected pivot of the joint
  22661. */
  22662. connectedPivot?: Vector3;
  22663. /**
  22664. * The main axis of the joint
  22665. */
  22666. mainAxis?: Vector3;
  22667. /**
  22668. * The connected axis of the joint
  22669. */
  22670. connectedAxis?: Vector3;
  22671. /**
  22672. * The collision of the joint
  22673. */
  22674. collision?: boolean;
  22675. /**
  22676. * Native Oimo/Cannon/Energy data
  22677. */
  22678. nativeParams?: any;
  22679. }
  22680. /**
  22681. * This is a holder class for the physics joint created by the physics plugin
  22682. * It holds a set of functions to control the underlying joint
  22683. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22684. */
  22685. export class PhysicsJoint {
  22686. /**
  22687. * The type of the physics joint
  22688. */
  22689. type: number;
  22690. /**
  22691. * The data for the physics joint
  22692. */
  22693. jointData: PhysicsJointData;
  22694. private _physicsJoint;
  22695. protected _physicsPlugin: IPhysicsEnginePlugin;
  22696. /**
  22697. * Initializes the physics joint
  22698. * @param type The type of the physics joint
  22699. * @param jointData The data for the physics joint
  22700. */
  22701. constructor(
  22702. /**
  22703. * The type of the physics joint
  22704. */
  22705. type: number,
  22706. /**
  22707. * The data for the physics joint
  22708. */
  22709. jointData: PhysicsJointData);
  22710. /**
  22711. * Gets the physics joint
  22712. */
  22713. /**
  22714. * Sets the physics joint
  22715. */
  22716. physicsJoint: any;
  22717. /**
  22718. * Sets the physics plugin
  22719. */
  22720. physicsPlugin: IPhysicsEnginePlugin;
  22721. /**
  22722. * Execute a function that is physics-plugin specific.
  22723. * @param {Function} func the function that will be executed.
  22724. * It accepts two parameters: the physics world and the physics joint
  22725. */
  22726. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22727. /**
  22728. * Distance-Joint type
  22729. */
  22730. static DistanceJoint: number;
  22731. /**
  22732. * Hinge-Joint type
  22733. */
  22734. static HingeJoint: number;
  22735. /**
  22736. * Ball-and-Socket joint type
  22737. */
  22738. static BallAndSocketJoint: number;
  22739. /**
  22740. * Wheel-Joint type
  22741. */
  22742. static WheelJoint: number;
  22743. /**
  22744. * Slider-Joint type
  22745. */
  22746. static SliderJoint: number;
  22747. /**
  22748. * Prismatic-Joint type
  22749. */
  22750. static PrismaticJoint: number;
  22751. /**
  22752. * Universal-Joint type
  22753. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22754. */
  22755. static UniversalJoint: number;
  22756. /**
  22757. * Hinge-Joint 2 type
  22758. */
  22759. static Hinge2Joint: number;
  22760. /**
  22761. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22762. */
  22763. static PointToPointJoint: number;
  22764. /**
  22765. * Spring-Joint type
  22766. */
  22767. static SpringJoint: number;
  22768. /**
  22769. * Lock-Joint type
  22770. */
  22771. static LockJoint: number;
  22772. }
  22773. /**
  22774. * A class representing a physics distance joint
  22775. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22776. */
  22777. export class DistanceJoint extends PhysicsJoint {
  22778. /**
  22779. *
  22780. * @param jointData The data for the Distance-Joint
  22781. */
  22782. constructor(jointData: DistanceJointData);
  22783. /**
  22784. * Update the predefined distance.
  22785. * @param maxDistance The maximum preferred distance
  22786. * @param minDistance The minimum preferred distance
  22787. */
  22788. updateDistance(maxDistance: number, minDistance?: number): void;
  22789. }
  22790. /**
  22791. * Represents a Motor-Enabled Joint
  22792. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22793. */
  22794. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22795. /**
  22796. * Initializes the Motor-Enabled Joint
  22797. * @param type The type of the joint
  22798. * @param jointData The physica joint data for the joint
  22799. */
  22800. constructor(type: number, jointData: PhysicsJointData);
  22801. /**
  22802. * Set the motor values.
  22803. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22804. * @param force the force to apply
  22805. * @param maxForce max force for this motor.
  22806. */
  22807. setMotor(force?: number, maxForce?: number): void;
  22808. /**
  22809. * Set the motor's limits.
  22810. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22811. * @param upperLimit The upper limit of the motor
  22812. * @param lowerLimit The lower limit of the motor
  22813. */
  22814. setLimit(upperLimit: number, lowerLimit?: number): void;
  22815. }
  22816. /**
  22817. * This class represents a single physics Hinge-Joint
  22818. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22819. */
  22820. export class HingeJoint extends MotorEnabledJoint {
  22821. /**
  22822. * Initializes the Hinge-Joint
  22823. * @param jointData The joint data for the Hinge-Joint
  22824. */
  22825. constructor(jointData: PhysicsJointData);
  22826. /**
  22827. * Set the motor values.
  22828. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22829. * @param {number} force the force to apply
  22830. * @param {number} maxForce max force for this motor.
  22831. */
  22832. setMotor(force?: number, maxForce?: number): void;
  22833. /**
  22834. * Set the motor's limits.
  22835. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22836. * @param upperLimit The upper limit of the motor
  22837. * @param lowerLimit The lower limit of the motor
  22838. */
  22839. setLimit(upperLimit: number, lowerLimit?: number): void;
  22840. }
  22841. /**
  22842. * This class represents a dual hinge physics joint (same as wheel joint)
  22843. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22844. */
  22845. export class Hinge2Joint extends MotorEnabledJoint {
  22846. /**
  22847. * Initializes the Hinge2-Joint
  22848. * @param jointData The joint data for the Hinge2-Joint
  22849. */
  22850. constructor(jointData: PhysicsJointData);
  22851. /**
  22852. * Set the motor values.
  22853. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22854. * @param {number} targetSpeed the speed the motor is to reach
  22855. * @param {number} maxForce max force for this motor.
  22856. * @param {motorIndex} the motor's index, 0 or 1.
  22857. */
  22858. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22859. /**
  22860. * Set the motor limits.
  22861. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22862. * @param {number} upperLimit the upper limit
  22863. * @param {number} lowerLimit lower limit
  22864. * @param {motorIndex} the motor's index, 0 or 1.
  22865. */
  22866. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22867. }
  22868. /**
  22869. * Interface for a motor enabled joint
  22870. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22871. */
  22872. export interface IMotorEnabledJoint {
  22873. /**
  22874. * Physics joint
  22875. */
  22876. physicsJoint: any;
  22877. /**
  22878. * Sets the motor of the motor-enabled joint
  22879. * @param force The force of the motor
  22880. * @param maxForce The maximum force of the motor
  22881. * @param motorIndex The index of the motor
  22882. */
  22883. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22884. /**
  22885. * Sets the limit of the motor
  22886. * @param upperLimit The upper limit of the motor
  22887. * @param lowerLimit The lower limit of the motor
  22888. * @param motorIndex The index of the motor
  22889. */
  22890. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22891. }
  22892. /**
  22893. * Joint data for a Distance-Joint
  22894. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22895. */
  22896. export interface DistanceJointData extends PhysicsJointData {
  22897. /**
  22898. * Max distance the 2 joint objects can be apart
  22899. */
  22900. maxDistance: number;
  22901. }
  22902. /**
  22903. * Joint data from a spring joint
  22904. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22905. */
  22906. export interface SpringJointData extends PhysicsJointData {
  22907. /**
  22908. * Length of the spring
  22909. */
  22910. length: number;
  22911. /**
  22912. * Stiffness of the spring
  22913. */
  22914. stiffness: number;
  22915. /**
  22916. * Damping of the spring
  22917. */
  22918. damping: number;
  22919. /** this callback will be called when applying the force to the impostors. */
  22920. forceApplicationCallback: () => void;
  22921. }
  22922. }
  22923. declare module BABYLON {
  22924. /**
  22925. * Holds the data for the raycast result
  22926. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22927. */
  22928. export class PhysicsRaycastResult {
  22929. private _hasHit;
  22930. private _hitDistance;
  22931. private _hitNormalWorld;
  22932. private _hitPointWorld;
  22933. private _rayFromWorld;
  22934. private _rayToWorld;
  22935. /**
  22936. * Gets if there was a hit
  22937. */
  22938. readonly hasHit: boolean;
  22939. /**
  22940. * Gets the distance from the hit
  22941. */
  22942. readonly hitDistance: number;
  22943. /**
  22944. * Gets the hit normal/direction in the world
  22945. */
  22946. readonly hitNormalWorld: Vector3;
  22947. /**
  22948. * Gets the hit point in the world
  22949. */
  22950. readonly hitPointWorld: Vector3;
  22951. /**
  22952. * Gets the ray "start point" of the ray in the world
  22953. */
  22954. readonly rayFromWorld: Vector3;
  22955. /**
  22956. * Gets the ray "end point" of the ray in the world
  22957. */
  22958. readonly rayToWorld: Vector3;
  22959. /**
  22960. * Sets the hit data (normal & point in world space)
  22961. * @param hitNormalWorld defines the normal in world space
  22962. * @param hitPointWorld defines the point in world space
  22963. */
  22964. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22965. /**
  22966. * Sets the distance from the start point to the hit point
  22967. * @param distance
  22968. */
  22969. setHitDistance(distance: number): void;
  22970. /**
  22971. * Calculates the distance manually
  22972. */
  22973. calculateHitDistance(): void;
  22974. /**
  22975. * Resets all the values to default
  22976. * @param from The from point on world space
  22977. * @param to The to point on world space
  22978. */
  22979. reset(from?: Vector3, to?: Vector3): void;
  22980. }
  22981. /**
  22982. * Interface for the size containing width and height
  22983. */
  22984. interface IXYZ {
  22985. /**
  22986. * X
  22987. */
  22988. x: number;
  22989. /**
  22990. * Y
  22991. */
  22992. y: number;
  22993. /**
  22994. * Z
  22995. */
  22996. z: number;
  22997. }
  22998. }
  22999. declare module BABYLON {
  23000. /**
  23001. * Interface used to describe a physics joint
  23002. */
  23003. export interface PhysicsImpostorJoint {
  23004. /** Defines the main impostor to which the joint is linked */
  23005. mainImpostor: PhysicsImpostor;
  23006. /** Defines the impostor that is connected to the main impostor using this joint */
  23007. connectedImpostor: PhysicsImpostor;
  23008. /** Defines the joint itself */
  23009. joint: PhysicsJoint;
  23010. }
  23011. /** @hidden */
  23012. export interface IPhysicsEnginePlugin {
  23013. world: any;
  23014. name: string;
  23015. setGravity(gravity: Vector3): void;
  23016. setTimeStep(timeStep: number): void;
  23017. getTimeStep(): number;
  23018. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23019. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23020. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23021. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23022. removePhysicsBody(impostor: PhysicsImpostor): void;
  23023. generateJoint(joint: PhysicsImpostorJoint): void;
  23024. removeJoint(joint: PhysicsImpostorJoint): void;
  23025. isSupported(): boolean;
  23026. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23027. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23028. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23029. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23030. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23031. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23032. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23033. getBodyMass(impostor: PhysicsImpostor): number;
  23034. getBodyFriction(impostor: PhysicsImpostor): number;
  23035. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23036. getBodyRestitution(impostor: PhysicsImpostor): number;
  23037. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23038. getBodyPressure?(impostor: PhysicsImpostor): number;
  23039. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23040. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23041. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23042. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23043. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23044. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23045. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23046. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23047. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23048. sleepBody(impostor: PhysicsImpostor): void;
  23049. wakeUpBody(impostor: PhysicsImpostor): void;
  23050. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23051. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23052. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23053. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23054. getRadius(impostor: PhysicsImpostor): number;
  23055. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23056. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23057. dispose(): void;
  23058. }
  23059. /**
  23060. * Interface used to define a physics engine
  23061. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23062. */
  23063. export interface IPhysicsEngine {
  23064. /**
  23065. * Gets the gravity vector used by the simulation
  23066. */
  23067. gravity: Vector3;
  23068. /**
  23069. * Sets the gravity vector used by the simulation
  23070. * @param gravity defines the gravity vector to use
  23071. */
  23072. setGravity(gravity: Vector3): void;
  23073. /**
  23074. * Set the time step of the physics engine.
  23075. * Default is 1/60.
  23076. * To slow it down, enter 1/600 for example.
  23077. * To speed it up, 1/30
  23078. * @param newTimeStep the new timestep to apply to this world.
  23079. */
  23080. setTimeStep(newTimeStep: number): void;
  23081. /**
  23082. * Get the time step of the physics engine.
  23083. * @returns the current time step
  23084. */
  23085. getTimeStep(): number;
  23086. /**
  23087. * Set the sub time step of the physics engine.
  23088. * Default is 0 meaning there is no sub steps
  23089. * To increase physics resolution precision, set a small value (like 1 ms)
  23090. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23091. */
  23092. setSubTimeStep(subTimeStep: number): void;
  23093. /**
  23094. * Get the sub time step of the physics engine.
  23095. * @returns the current sub time step
  23096. */
  23097. getSubTimeStep(): number;
  23098. /**
  23099. * Release all resources
  23100. */
  23101. dispose(): void;
  23102. /**
  23103. * Gets the name of the current physics plugin
  23104. * @returns the name of the plugin
  23105. */
  23106. getPhysicsPluginName(): string;
  23107. /**
  23108. * Adding a new impostor for the impostor tracking.
  23109. * This will be done by the impostor itself.
  23110. * @param impostor the impostor to add
  23111. */
  23112. addImpostor(impostor: PhysicsImpostor): void;
  23113. /**
  23114. * Remove an impostor from the engine.
  23115. * This impostor and its mesh will not longer be updated by the physics engine.
  23116. * @param impostor the impostor to remove
  23117. */
  23118. removeImpostor(impostor: PhysicsImpostor): void;
  23119. /**
  23120. * Add a joint to the physics engine
  23121. * @param mainImpostor defines the main impostor to which the joint is added.
  23122. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23123. * @param joint defines the joint that will connect both impostors.
  23124. */
  23125. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23126. /**
  23127. * Removes a joint from the simulation
  23128. * @param mainImpostor defines the impostor used with the joint
  23129. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23130. * @param joint defines the joint to remove
  23131. */
  23132. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23133. /**
  23134. * Gets the current plugin used to run the simulation
  23135. * @returns current plugin
  23136. */
  23137. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23138. /**
  23139. * Gets the list of physic impostors
  23140. * @returns an array of PhysicsImpostor
  23141. */
  23142. getImpostors(): Array<PhysicsImpostor>;
  23143. /**
  23144. * Gets the impostor for a physics enabled object
  23145. * @param object defines the object impersonated by the impostor
  23146. * @returns the PhysicsImpostor or null if not found
  23147. */
  23148. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23149. /**
  23150. * Gets the impostor for a physics body object
  23151. * @param body defines physics body used by the impostor
  23152. * @returns the PhysicsImpostor or null if not found
  23153. */
  23154. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23155. /**
  23156. * Does a raycast in the physics world
  23157. * @param from when should the ray start?
  23158. * @param to when should the ray end?
  23159. * @returns PhysicsRaycastResult
  23160. */
  23161. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23162. /**
  23163. * Called by the scene. No need to call it.
  23164. * @param delta defines the timespam between frames
  23165. */
  23166. _step(delta: number): void;
  23167. }
  23168. }
  23169. declare module BABYLON {
  23170. /**
  23171. * The interface for the physics imposter parameters
  23172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23173. */
  23174. export interface PhysicsImpostorParameters {
  23175. /**
  23176. * The mass of the physics imposter
  23177. */
  23178. mass: number;
  23179. /**
  23180. * The friction of the physics imposter
  23181. */
  23182. friction?: number;
  23183. /**
  23184. * The coefficient of restitution of the physics imposter
  23185. */
  23186. restitution?: number;
  23187. /**
  23188. * The native options of the physics imposter
  23189. */
  23190. nativeOptions?: any;
  23191. /**
  23192. * Specifies if the parent should be ignored
  23193. */
  23194. ignoreParent?: boolean;
  23195. /**
  23196. * Specifies if bi-directional transformations should be disabled
  23197. */
  23198. disableBidirectionalTransformation?: boolean;
  23199. /**
  23200. * The pressure inside the physics imposter, soft object only
  23201. */
  23202. pressure?: number;
  23203. /**
  23204. * The stiffness the physics imposter, soft object only
  23205. */
  23206. stiffness?: number;
  23207. /**
  23208. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23209. */
  23210. velocityIterations?: number;
  23211. /**
  23212. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23213. */
  23214. positionIterations?: number;
  23215. /**
  23216. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23217. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23218. * Add to fix multiple points
  23219. */
  23220. fixedPoints?: number;
  23221. /**
  23222. * The collision margin around a soft object
  23223. */
  23224. margin?: number;
  23225. /**
  23226. * The collision margin around a soft object
  23227. */
  23228. damping?: number;
  23229. /**
  23230. * The path for a rope based on an extrusion
  23231. */
  23232. path?: any;
  23233. /**
  23234. * The shape of an extrusion used for a rope based on an extrusion
  23235. */
  23236. shape?: any;
  23237. }
  23238. /**
  23239. * Interface for a physics-enabled object
  23240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23241. */
  23242. export interface IPhysicsEnabledObject {
  23243. /**
  23244. * The position of the physics-enabled object
  23245. */
  23246. position: Vector3;
  23247. /**
  23248. * The rotation of the physics-enabled object
  23249. */
  23250. rotationQuaternion: Nullable<Quaternion>;
  23251. /**
  23252. * The scale of the physics-enabled object
  23253. */
  23254. scaling: Vector3;
  23255. /**
  23256. * The rotation of the physics-enabled object
  23257. */
  23258. rotation?: Vector3;
  23259. /**
  23260. * The parent of the physics-enabled object
  23261. */
  23262. parent?: any;
  23263. /**
  23264. * The bounding info of the physics-enabled object
  23265. * @returns The bounding info of the physics-enabled object
  23266. */
  23267. getBoundingInfo(): BoundingInfo;
  23268. /**
  23269. * Computes the world matrix
  23270. * @param force Specifies if the world matrix should be computed by force
  23271. * @returns A world matrix
  23272. */
  23273. computeWorldMatrix(force: boolean): Matrix;
  23274. /**
  23275. * Gets the world matrix
  23276. * @returns A world matrix
  23277. */
  23278. getWorldMatrix?(): Matrix;
  23279. /**
  23280. * Gets the child meshes
  23281. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23282. * @returns An array of abstract meshes
  23283. */
  23284. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23285. /**
  23286. * Gets the vertex data
  23287. * @param kind The type of vertex data
  23288. * @returns A nullable array of numbers, or a float32 array
  23289. */
  23290. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23291. /**
  23292. * Gets the indices from the mesh
  23293. * @returns A nullable array of index arrays
  23294. */
  23295. getIndices?(): Nullable<IndicesArray>;
  23296. /**
  23297. * Gets the scene from the mesh
  23298. * @returns the indices array or null
  23299. */
  23300. getScene?(): Scene;
  23301. /**
  23302. * Gets the absolute position from the mesh
  23303. * @returns the absolute position
  23304. */
  23305. getAbsolutePosition(): Vector3;
  23306. /**
  23307. * Gets the absolute pivot point from the mesh
  23308. * @returns the absolute pivot point
  23309. */
  23310. getAbsolutePivotPoint(): Vector3;
  23311. /**
  23312. * Rotates the mesh
  23313. * @param axis The axis of rotation
  23314. * @param amount The amount of rotation
  23315. * @param space The space of the rotation
  23316. * @returns The rotation transform node
  23317. */
  23318. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23319. /**
  23320. * Translates the mesh
  23321. * @param axis The axis of translation
  23322. * @param distance The distance of translation
  23323. * @param space The space of the translation
  23324. * @returns The transform node
  23325. */
  23326. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23327. /**
  23328. * Sets the absolute position of the mesh
  23329. * @param absolutePosition The absolute position of the mesh
  23330. * @returns The transform node
  23331. */
  23332. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23333. /**
  23334. * Gets the class name of the mesh
  23335. * @returns The class name
  23336. */
  23337. getClassName(): string;
  23338. }
  23339. /**
  23340. * Represents a physics imposter
  23341. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23342. */
  23343. export class PhysicsImpostor {
  23344. /**
  23345. * The physics-enabled object used as the physics imposter
  23346. */
  23347. object: IPhysicsEnabledObject;
  23348. /**
  23349. * The type of the physics imposter
  23350. */
  23351. type: number;
  23352. private _options;
  23353. private _scene?;
  23354. /**
  23355. * The default object size of the imposter
  23356. */
  23357. static DEFAULT_OBJECT_SIZE: Vector3;
  23358. /**
  23359. * The identity quaternion of the imposter
  23360. */
  23361. static IDENTITY_QUATERNION: Quaternion;
  23362. /** @hidden */
  23363. _pluginData: any;
  23364. private _physicsEngine;
  23365. private _physicsBody;
  23366. private _bodyUpdateRequired;
  23367. private _onBeforePhysicsStepCallbacks;
  23368. private _onAfterPhysicsStepCallbacks;
  23369. /** @hidden */
  23370. _onPhysicsCollideCallbacks: Array<{
  23371. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23372. otherImpostors: Array<PhysicsImpostor>;
  23373. }>;
  23374. private _deltaPosition;
  23375. private _deltaRotation;
  23376. private _deltaRotationConjugated;
  23377. /** @hidden */
  23378. _isFromLine: boolean;
  23379. private _parent;
  23380. private _isDisposed;
  23381. private static _tmpVecs;
  23382. private static _tmpQuat;
  23383. /**
  23384. * Specifies if the physics imposter is disposed
  23385. */
  23386. readonly isDisposed: boolean;
  23387. /**
  23388. * Gets the mass of the physics imposter
  23389. */
  23390. mass: number;
  23391. /**
  23392. * Gets the coefficient of friction
  23393. */
  23394. /**
  23395. * Sets the coefficient of friction
  23396. */
  23397. friction: number;
  23398. /**
  23399. * Gets the coefficient of restitution
  23400. */
  23401. /**
  23402. * Sets the coefficient of restitution
  23403. */
  23404. restitution: number;
  23405. /**
  23406. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23407. */
  23408. /**
  23409. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23410. */
  23411. pressure: number;
  23412. /**
  23413. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23414. */
  23415. /**
  23416. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23417. */
  23418. stiffness: number;
  23419. /**
  23420. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23421. */
  23422. /**
  23423. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23424. */
  23425. velocityIterations: number;
  23426. /**
  23427. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23428. */
  23429. /**
  23430. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23431. */
  23432. positionIterations: number;
  23433. /**
  23434. * The unique id of the physics imposter
  23435. * set by the physics engine when adding this impostor to the array
  23436. */
  23437. uniqueId: number;
  23438. /**
  23439. * @hidden
  23440. */
  23441. soft: boolean;
  23442. /**
  23443. * @hidden
  23444. */
  23445. segments: number;
  23446. private _joints;
  23447. /**
  23448. * Initializes the physics imposter
  23449. * @param object The physics-enabled object used as the physics imposter
  23450. * @param type The type of the physics imposter
  23451. * @param _options The options for the physics imposter
  23452. * @param _scene The Babylon scene
  23453. */
  23454. constructor(
  23455. /**
  23456. * The physics-enabled object used as the physics imposter
  23457. */
  23458. object: IPhysicsEnabledObject,
  23459. /**
  23460. * The type of the physics imposter
  23461. */
  23462. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23463. /**
  23464. * This function will completly initialize this impostor.
  23465. * It will create a new body - but only if this mesh has no parent.
  23466. * If it has, this impostor will not be used other than to define the impostor
  23467. * of the child mesh.
  23468. * @hidden
  23469. */
  23470. _init(): void;
  23471. private _getPhysicsParent;
  23472. /**
  23473. * Should a new body be generated.
  23474. * @returns boolean specifying if body initialization is required
  23475. */
  23476. isBodyInitRequired(): boolean;
  23477. /**
  23478. * Sets the updated scaling
  23479. * @param updated Specifies if the scaling is updated
  23480. */
  23481. setScalingUpdated(): void;
  23482. /**
  23483. * Force a regeneration of this or the parent's impostor's body.
  23484. * Use under cautious - This will remove all joints already implemented.
  23485. */
  23486. forceUpdate(): void;
  23487. /**
  23488. * Gets the body that holds this impostor. Either its own, or its parent.
  23489. */
  23490. /**
  23491. * Set the physics body. Used mainly by the physics engine/plugin
  23492. */
  23493. physicsBody: any;
  23494. /**
  23495. * Get the parent of the physics imposter
  23496. * @returns Physics imposter or null
  23497. */
  23498. /**
  23499. * Sets the parent of the physics imposter
  23500. */
  23501. parent: Nullable<PhysicsImpostor>;
  23502. /**
  23503. * Resets the update flags
  23504. */
  23505. resetUpdateFlags(): void;
  23506. /**
  23507. * Gets the object extend size
  23508. * @returns the object extend size
  23509. */
  23510. getObjectExtendSize(): Vector3;
  23511. /**
  23512. * Gets the object center
  23513. * @returns The object center
  23514. */
  23515. getObjectCenter(): Vector3;
  23516. /**
  23517. * Get a specific parametes from the options parameter
  23518. * @param paramName The object parameter name
  23519. * @returns The object parameter
  23520. */
  23521. getParam(paramName: string): any;
  23522. /**
  23523. * Sets a specific parameter in the options given to the physics plugin
  23524. * @param paramName The parameter name
  23525. * @param value The value of the parameter
  23526. */
  23527. setParam(paramName: string, value: number): void;
  23528. /**
  23529. * Specifically change the body's mass option. Won't recreate the physics body object
  23530. * @param mass The mass of the physics imposter
  23531. */
  23532. setMass(mass: number): void;
  23533. /**
  23534. * Gets the linear velocity
  23535. * @returns linear velocity or null
  23536. */
  23537. getLinearVelocity(): Nullable<Vector3>;
  23538. /**
  23539. * Sets the linear velocity
  23540. * @param velocity linear velocity or null
  23541. */
  23542. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23543. /**
  23544. * Gets the angular velocity
  23545. * @returns angular velocity or null
  23546. */
  23547. getAngularVelocity(): Nullable<Vector3>;
  23548. /**
  23549. * Sets the angular velocity
  23550. * @param velocity The velocity or null
  23551. */
  23552. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23553. /**
  23554. * Execute a function with the physics plugin native code
  23555. * Provide a function the will have two variables - the world object and the physics body object
  23556. * @param func The function to execute with the physics plugin native code
  23557. */
  23558. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23559. /**
  23560. * Register a function that will be executed before the physics world is stepping forward
  23561. * @param func The function to execute before the physics world is stepped forward
  23562. */
  23563. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23564. /**
  23565. * Unregister a function that will be executed before the physics world is stepping forward
  23566. * @param func The function to execute before the physics world is stepped forward
  23567. */
  23568. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23569. /**
  23570. * Register a function that will be executed after the physics step
  23571. * @param func The function to execute after physics step
  23572. */
  23573. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23574. /**
  23575. * Unregisters a function that will be executed after the physics step
  23576. * @param func The function to execute after physics step
  23577. */
  23578. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23579. /**
  23580. * register a function that will be executed when this impostor collides against a different body
  23581. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23582. * @param func Callback that is executed on collision
  23583. */
  23584. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23585. /**
  23586. * Unregisters the physics imposter on contact
  23587. * @param collideAgainst The physics object to collide against
  23588. * @param func Callback to execute on collision
  23589. */
  23590. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23591. private _tmpQuat;
  23592. private _tmpQuat2;
  23593. /**
  23594. * Get the parent rotation
  23595. * @returns The parent rotation
  23596. */
  23597. getParentsRotation(): Quaternion;
  23598. /**
  23599. * this function is executed by the physics engine.
  23600. */
  23601. beforeStep: () => void;
  23602. /**
  23603. * this function is executed by the physics engine
  23604. */
  23605. afterStep: () => void;
  23606. /**
  23607. * Legacy collision detection event support
  23608. */
  23609. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23610. /**
  23611. * event and body object due to cannon's event-based architecture.
  23612. */
  23613. onCollide: (e: {
  23614. body: any;
  23615. }) => void;
  23616. /**
  23617. * Apply a force
  23618. * @param force The force to apply
  23619. * @param contactPoint The contact point for the force
  23620. * @returns The physics imposter
  23621. */
  23622. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23623. /**
  23624. * Apply an impulse
  23625. * @param force The impulse force
  23626. * @param contactPoint The contact point for the impulse force
  23627. * @returns The physics imposter
  23628. */
  23629. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23630. /**
  23631. * A help function to create a joint
  23632. * @param otherImpostor A physics imposter used to create a joint
  23633. * @param jointType The type of joint
  23634. * @param jointData The data for the joint
  23635. * @returns The physics imposter
  23636. */
  23637. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23638. /**
  23639. * Add a joint to this impostor with a different impostor
  23640. * @param otherImpostor A physics imposter used to add a joint
  23641. * @param joint The joint to add
  23642. * @returns The physics imposter
  23643. */
  23644. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23645. /**
  23646. * Add an anchor to a cloth impostor
  23647. * @param otherImpostor rigid impostor to anchor to
  23648. * @param width ratio across width from 0 to 1
  23649. * @param height ratio up height from 0 to 1
  23650. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23651. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23652. * @returns impostor the soft imposter
  23653. */
  23654. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23655. /**
  23656. * Add a hook to a rope impostor
  23657. * @param otherImpostor rigid impostor to anchor to
  23658. * @param length ratio across rope from 0 to 1
  23659. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23660. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23661. * @returns impostor the rope imposter
  23662. */
  23663. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23664. /**
  23665. * Will keep this body still, in a sleep mode.
  23666. * @returns the physics imposter
  23667. */
  23668. sleep(): PhysicsImpostor;
  23669. /**
  23670. * Wake the body up.
  23671. * @returns The physics imposter
  23672. */
  23673. wakeUp(): PhysicsImpostor;
  23674. /**
  23675. * Clones the physics imposter
  23676. * @param newObject The physics imposter clones to this physics-enabled object
  23677. * @returns A nullable physics imposter
  23678. */
  23679. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23680. /**
  23681. * Disposes the physics imposter
  23682. */
  23683. dispose(): void;
  23684. /**
  23685. * Sets the delta position
  23686. * @param position The delta position amount
  23687. */
  23688. setDeltaPosition(position: Vector3): void;
  23689. /**
  23690. * Sets the delta rotation
  23691. * @param rotation The delta rotation amount
  23692. */
  23693. setDeltaRotation(rotation: Quaternion): void;
  23694. /**
  23695. * Gets the box size of the physics imposter and stores the result in the input parameter
  23696. * @param result Stores the box size
  23697. * @returns The physics imposter
  23698. */
  23699. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23700. /**
  23701. * Gets the radius of the physics imposter
  23702. * @returns Radius of the physics imposter
  23703. */
  23704. getRadius(): number;
  23705. /**
  23706. * Sync a bone with this impostor
  23707. * @param bone The bone to sync to the impostor.
  23708. * @param boneMesh The mesh that the bone is influencing.
  23709. * @param jointPivot The pivot of the joint / bone in local space.
  23710. * @param distToJoint Optional distance from the impostor to the joint.
  23711. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23712. */
  23713. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23714. /**
  23715. * Sync impostor to a bone
  23716. * @param bone The bone that the impostor will be synced to.
  23717. * @param boneMesh The mesh that the bone is influencing.
  23718. * @param jointPivot The pivot of the joint / bone in local space.
  23719. * @param distToJoint Optional distance from the impostor to the joint.
  23720. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23721. * @param boneAxis Optional vector3 axis the bone is aligned with
  23722. */
  23723. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23724. /**
  23725. * No-Imposter type
  23726. */
  23727. static NoImpostor: number;
  23728. /**
  23729. * Sphere-Imposter type
  23730. */
  23731. static SphereImpostor: number;
  23732. /**
  23733. * Box-Imposter type
  23734. */
  23735. static BoxImpostor: number;
  23736. /**
  23737. * Plane-Imposter type
  23738. */
  23739. static PlaneImpostor: number;
  23740. /**
  23741. * Mesh-imposter type
  23742. */
  23743. static MeshImpostor: number;
  23744. /**
  23745. * Capsule-Impostor type (Ammo.js plugin only)
  23746. */
  23747. static CapsuleImpostor: number;
  23748. /**
  23749. * Cylinder-Imposter type
  23750. */
  23751. static CylinderImpostor: number;
  23752. /**
  23753. * Particle-Imposter type
  23754. */
  23755. static ParticleImpostor: number;
  23756. /**
  23757. * Heightmap-Imposter type
  23758. */
  23759. static HeightmapImpostor: number;
  23760. /**
  23761. * ConvexHull-Impostor type (Ammo.js plugin only)
  23762. */
  23763. static ConvexHullImpostor: number;
  23764. /**
  23765. * Custom-Imposter type (Ammo.js plugin only)
  23766. */
  23767. static CustomImpostor: number;
  23768. /**
  23769. * Rope-Imposter type
  23770. */
  23771. static RopeImpostor: number;
  23772. /**
  23773. * Cloth-Imposter type
  23774. */
  23775. static ClothImpostor: number;
  23776. /**
  23777. * Softbody-Imposter type
  23778. */
  23779. static SoftbodyImpostor: number;
  23780. }
  23781. }
  23782. declare module BABYLON {
  23783. /**
  23784. * @hidden
  23785. **/
  23786. export class _CreationDataStorage {
  23787. closePath?: boolean;
  23788. closeArray?: boolean;
  23789. idx: number[];
  23790. dashSize: number;
  23791. gapSize: number;
  23792. path3D: Path3D;
  23793. pathArray: Vector3[][];
  23794. arc: number;
  23795. radius: number;
  23796. cap: number;
  23797. tessellation: number;
  23798. }
  23799. /**
  23800. * @hidden
  23801. **/
  23802. class _InstanceDataStorage {
  23803. visibleInstances: any;
  23804. batchCache: _InstancesBatch;
  23805. instancesBufferSize: number;
  23806. instancesBuffer: Nullable<Buffer>;
  23807. instancesData: Float32Array;
  23808. overridenInstanceCount: number;
  23809. isFrozen: boolean;
  23810. previousBatch: Nullable<_InstancesBatch>;
  23811. hardwareInstancedRendering: boolean;
  23812. sideOrientation: number;
  23813. manualUpdate: boolean;
  23814. }
  23815. /**
  23816. * @hidden
  23817. **/
  23818. export class _InstancesBatch {
  23819. mustReturn: boolean;
  23820. visibleInstances: Nullable<InstancedMesh[]>[];
  23821. renderSelf: boolean[];
  23822. hardwareInstancedRendering: boolean[];
  23823. }
  23824. /**
  23825. * Class used to represent renderable models
  23826. */
  23827. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23828. /**
  23829. * Mesh side orientation : usually the external or front surface
  23830. */
  23831. static readonly FRONTSIDE: number;
  23832. /**
  23833. * Mesh side orientation : usually the internal or back surface
  23834. */
  23835. static readonly BACKSIDE: number;
  23836. /**
  23837. * Mesh side orientation : both internal and external or front and back surfaces
  23838. */
  23839. static readonly DOUBLESIDE: number;
  23840. /**
  23841. * Mesh side orientation : by default, `FRONTSIDE`
  23842. */
  23843. static readonly DEFAULTSIDE: number;
  23844. /**
  23845. * Mesh cap setting : no cap
  23846. */
  23847. static readonly NO_CAP: number;
  23848. /**
  23849. * Mesh cap setting : one cap at the beginning of the mesh
  23850. */
  23851. static readonly CAP_START: number;
  23852. /**
  23853. * Mesh cap setting : one cap at the end of the mesh
  23854. */
  23855. static readonly CAP_END: number;
  23856. /**
  23857. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23858. */
  23859. static readonly CAP_ALL: number;
  23860. /**
  23861. * Mesh pattern setting : no flip or rotate
  23862. */
  23863. static readonly NO_FLIP: number;
  23864. /**
  23865. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23866. */
  23867. static readonly FLIP_TILE: number;
  23868. /**
  23869. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23870. */
  23871. static readonly ROTATE_TILE: number;
  23872. /**
  23873. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23874. */
  23875. static readonly FLIP_ROW: number;
  23876. /**
  23877. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23878. */
  23879. static readonly ROTATE_ROW: number;
  23880. /**
  23881. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23882. */
  23883. static readonly FLIP_N_ROTATE_TILE: number;
  23884. /**
  23885. * Mesh pattern setting : rotate pattern and rotate
  23886. */
  23887. static readonly FLIP_N_ROTATE_ROW: number;
  23888. /**
  23889. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23890. */
  23891. static readonly CENTER: number;
  23892. /**
  23893. * Mesh tile positioning : part tiles on left
  23894. */
  23895. static readonly LEFT: number;
  23896. /**
  23897. * Mesh tile positioning : part tiles on right
  23898. */
  23899. static readonly RIGHT: number;
  23900. /**
  23901. * Mesh tile positioning : part tiles on top
  23902. */
  23903. static readonly TOP: number;
  23904. /**
  23905. * Mesh tile positioning : part tiles on bottom
  23906. */
  23907. static readonly BOTTOM: number;
  23908. /**
  23909. * Gets the default side orientation.
  23910. * @param orientation the orientation to value to attempt to get
  23911. * @returns the default orientation
  23912. * @hidden
  23913. */
  23914. static _GetDefaultSideOrientation(orientation?: number): number;
  23915. private _internalMeshDataInfo;
  23916. /**
  23917. * An event triggered before rendering the mesh
  23918. */
  23919. readonly onBeforeRenderObservable: Observable<Mesh>;
  23920. /**
  23921. * An event triggered before binding the mesh
  23922. */
  23923. readonly onBeforeBindObservable: Observable<Mesh>;
  23924. /**
  23925. * An event triggered after rendering the mesh
  23926. */
  23927. readonly onAfterRenderObservable: Observable<Mesh>;
  23928. /**
  23929. * An event triggered before drawing the mesh
  23930. */
  23931. readonly onBeforeDrawObservable: Observable<Mesh>;
  23932. private _onBeforeDrawObserver;
  23933. /**
  23934. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23935. */
  23936. onBeforeDraw: () => void;
  23937. readonly hasInstances: boolean;
  23938. /**
  23939. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23940. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23941. */
  23942. delayLoadState: number;
  23943. /**
  23944. * Gets the list of instances created from this mesh
  23945. * it is not supposed to be modified manually.
  23946. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23947. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23948. */
  23949. instances: InstancedMesh[];
  23950. /**
  23951. * Gets the file containing delay loading data for this mesh
  23952. */
  23953. delayLoadingFile: string;
  23954. /** @hidden */
  23955. _binaryInfo: any;
  23956. /**
  23957. * User defined function used to change how LOD level selection is done
  23958. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23959. */
  23960. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23961. /**
  23962. * Gets or sets the morph target manager
  23963. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23964. */
  23965. morphTargetManager: Nullable<MorphTargetManager>;
  23966. /** @hidden */
  23967. _creationDataStorage: Nullable<_CreationDataStorage>;
  23968. /** @hidden */
  23969. _geometry: Nullable<Geometry>;
  23970. /** @hidden */
  23971. _delayInfo: Array<string>;
  23972. /** @hidden */
  23973. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23974. /** @hidden */
  23975. _instanceDataStorage: _InstanceDataStorage;
  23976. private _effectiveMaterial;
  23977. /** @hidden */
  23978. _shouldGenerateFlatShading: boolean;
  23979. /** @hidden */
  23980. _originalBuilderSideOrientation: number;
  23981. /**
  23982. * Use this property to change the original side orientation defined at construction time
  23983. */
  23984. overrideMaterialSideOrientation: Nullable<number>;
  23985. /**
  23986. * Gets the source mesh (the one used to clone this one from)
  23987. */
  23988. readonly source: Nullable<Mesh>;
  23989. /**
  23990. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23991. */
  23992. isUnIndexed: boolean;
  23993. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  23994. readonly worldMatrixInstancedBuffer: Float32Array;
  23995. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  23996. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  23997. /**
  23998. * @constructor
  23999. * @param name The value used by scene.getMeshByName() to do a lookup.
  24000. * @param scene The scene to add this mesh to.
  24001. * @param parent The parent of this mesh, if it has one
  24002. * @param source An optional Mesh from which geometry is shared, cloned.
  24003. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24004. * When false, achieved by calling a clone(), also passing False.
  24005. * This will make creation of children, recursive.
  24006. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24007. */
  24008. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24009. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24010. doNotInstantiate: boolean;
  24011. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24012. /**
  24013. * Gets the class name
  24014. * @returns the string "Mesh".
  24015. */
  24016. getClassName(): string;
  24017. /** @hidden */
  24018. readonly _isMesh: boolean;
  24019. /**
  24020. * Returns a description of this mesh
  24021. * @param fullDetails define if full details about this mesh must be used
  24022. * @returns a descriptive string representing this mesh
  24023. */
  24024. toString(fullDetails?: boolean): string;
  24025. /** @hidden */
  24026. _unBindEffect(): void;
  24027. /**
  24028. * Gets a boolean indicating if this mesh has LOD
  24029. */
  24030. readonly hasLODLevels: boolean;
  24031. /**
  24032. * Gets the list of MeshLODLevel associated with the current mesh
  24033. * @returns an array of MeshLODLevel
  24034. */
  24035. getLODLevels(): MeshLODLevel[];
  24036. private _sortLODLevels;
  24037. /**
  24038. * Add a mesh as LOD level triggered at the given distance.
  24039. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24040. * @param distance The distance from the center of the object to show this level
  24041. * @param mesh The mesh to be added as LOD level (can be null)
  24042. * @return This mesh (for chaining)
  24043. */
  24044. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24045. /**
  24046. * Returns the LOD level mesh at the passed distance or null if not found.
  24047. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24048. * @param distance The distance from the center of the object to show this level
  24049. * @returns a Mesh or `null`
  24050. */
  24051. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24052. /**
  24053. * Remove a mesh from the LOD array
  24054. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24055. * @param mesh defines the mesh to be removed
  24056. * @return This mesh (for chaining)
  24057. */
  24058. removeLODLevel(mesh: Mesh): Mesh;
  24059. /**
  24060. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24061. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24062. * @param camera defines the camera to use to compute distance
  24063. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24064. * @return This mesh (for chaining)
  24065. */
  24066. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24067. /**
  24068. * Gets the mesh internal Geometry object
  24069. */
  24070. readonly geometry: Nullable<Geometry>;
  24071. /**
  24072. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24073. * @returns the total number of vertices
  24074. */
  24075. getTotalVertices(): number;
  24076. /**
  24077. * Returns the content of an associated vertex buffer
  24078. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24079. * - VertexBuffer.PositionKind
  24080. * - VertexBuffer.UVKind
  24081. * - VertexBuffer.UV2Kind
  24082. * - VertexBuffer.UV3Kind
  24083. * - VertexBuffer.UV4Kind
  24084. * - VertexBuffer.UV5Kind
  24085. * - VertexBuffer.UV6Kind
  24086. * - VertexBuffer.ColorKind
  24087. * - VertexBuffer.MatricesIndicesKind
  24088. * - VertexBuffer.MatricesIndicesExtraKind
  24089. * - VertexBuffer.MatricesWeightsKind
  24090. * - VertexBuffer.MatricesWeightsExtraKind
  24091. * @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
  24092. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24093. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24094. */
  24095. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24096. /**
  24097. * Returns the mesh VertexBuffer object from the requested `kind`
  24098. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24099. * - VertexBuffer.PositionKind
  24100. * - VertexBuffer.NormalKind
  24101. * - VertexBuffer.UVKind
  24102. * - VertexBuffer.UV2Kind
  24103. * - VertexBuffer.UV3Kind
  24104. * - VertexBuffer.UV4Kind
  24105. * - VertexBuffer.UV5Kind
  24106. * - VertexBuffer.UV6Kind
  24107. * - VertexBuffer.ColorKind
  24108. * - VertexBuffer.MatricesIndicesKind
  24109. * - VertexBuffer.MatricesIndicesExtraKind
  24110. * - VertexBuffer.MatricesWeightsKind
  24111. * - VertexBuffer.MatricesWeightsExtraKind
  24112. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24113. */
  24114. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24115. /**
  24116. * Tests if a specific vertex buffer is associated with this mesh
  24117. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24118. * - VertexBuffer.PositionKind
  24119. * - VertexBuffer.NormalKind
  24120. * - VertexBuffer.UVKind
  24121. * - VertexBuffer.UV2Kind
  24122. * - VertexBuffer.UV3Kind
  24123. * - VertexBuffer.UV4Kind
  24124. * - VertexBuffer.UV5Kind
  24125. * - VertexBuffer.UV6Kind
  24126. * - VertexBuffer.ColorKind
  24127. * - VertexBuffer.MatricesIndicesKind
  24128. * - VertexBuffer.MatricesIndicesExtraKind
  24129. * - VertexBuffer.MatricesWeightsKind
  24130. * - VertexBuffer.MatricesWeightsExtraKind
  24131. * @returns a boolean
  24132. */
  24133. isVerticesDataPresent(kind: string): boolean;
  24134. /**
  24135. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24136. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24137. * - VertexBuffer.PositionKind
  24138. * - VertexBuffer.UVKind
  24139. * - VertexBuffer.UV2Kind
  24140. * - VertexBuffer.UV3Kind
  24141. * - VertexBuffer.UV4Kind
  24142. * - VertexBuffer.UV5Kind
  24143. * - VertexBuffer.UV6Kind
  24144. * - VertexBuffer.ColorKind
  24145. * - VertexBuffer.MatricesIndicesKind
  24146. * - VertexBuffer.MatricesIndicesExtraKind
  24147. * - VertexBuffer.MatricesWeightsKind
  24148. * - VertexBuffer.MatricesWeightsExtraKind
  24149. * @returns a boolean
  24150. */
  24151. isVertexBufferUpdatable(kind: string): boolean;
  24152. /**
  24153. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24154. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24155. * - VertexBuffer.PositionKind
  24156. * - VertexBuffer.NormalKind
  24157. * - VertexBuffer.UVKind
  24158. * - VertexBuffer.UV2Kind
  24159. * - VertexBuffer.UV3Kind
  24160. * - VertexBuffer.UV4Kind
  24161. * - VertexBuffer.UV5Kind
  24162. * - VertexBuffer.UV6Kind
  24163. * - VertexBuffer.ColorKind
  24164. * - VertexBuffer.MatricesIndicesKind
  24165. * - VertexBuffer.MatricesIndicesExtraKind
  24166. * - VertexBuffer.MatricesWeightsKind
  24167. * - VertexBuffer.MatricesWeightsExtraKind
  24168. * @returns an array of strings
  24169. */
  24170. getVerticesDataKinds(): string[];
  24171. /**
  24172. * Returns a positive integer : the total number of indices in this mesh geometry.
  24173. * @returns the numner of indices or zero if the mesh has no geometry.
  24174. */
  24175. getTotalIndices(): number;
  24176. /**
  24177. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24178. * @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.
  24179. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24180. * @returns the indices array or an empty array if the mesh has no geometry
  24181. */
  24182. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24183. readonly isBlocked: boolean;
  24184. /**
  24185. * Determine if the current mesh is ready to be rendered
  24186. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24187. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24188. * @returns true if all associated assets are ready (material, textures, shaders)
  24189. */
  24190. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24191. /**
  24192. * 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.
  24193. */
  24194. readonly areNormalsFrozen: boolean;
  24195. /**
  24196. * 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.
  24197. * @returns the current mesh
  24198. */
  24199. freezeNormals(): Mesh;
  24200. /**
  24201. * 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
  24202. * @returns the current mesh
  24203. */
  24204. unfreezeNormals(): Mesh;
  24205. /**
  24206. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24207. */
  24208. overridenInstanceCount: number;
  24209. /** @hidden */
  24210. _preActivate(): Mesh;
  24211. /** @hidden */
  24212. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24213. /** @hidden */
  24214. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24215. /**
  24216. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24217. * This means the mesh underlying bounding box and sphere are recomputed.
  24218. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24219. * @returns the current mesh
  24220. */
  24221. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24222. /** @hidden */
  24223. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24224. /**
  24225. * This function will subdivide the mesh into multiple submeshes
  24226. * @param count defines the expected number of submeshes
  24227. */
  24228. subdivide(count: number): void;
  24229. /**
  24230. * Copy a FloatArray into a specific associated vertex buffer
  24231. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24232. * - VertexBuffer.PositionKind
  24233. * - VertexBuffer.UVKind
  24234. * - VertexBuffer.UV2Kind
  24235. * - VertexBuffer.UV3Kind
  24236. * - VertexBuffer.UV4Kind
  24237. * - VertexBuffer.UV5Kind
  24238. * - VertexBuffer.UV6Kind
  24239. * - VertexBuffer.ColorKind
  24240. * - VertexBuffer.MatricesIndicesKind
  24241. * - VertexBuffer.MatricesIndicesExtraKind
  24242. * - VertexBuffer.MatricesWeightsKind
  24243. * - VertexBuffer.MatricesWeightsExtraKind
  24244. * @param data defines the data source
  24245. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24246. * @param stride defines the data stride size (can be null)
  24247. * @returns the current mesh
  24248. */
  24249. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24250. /**
  24251. * Delete a vertex buffer associated with this mesh
  24252. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24253. * - VertexBuffer.PositionKind
  24254. * - VertexBuffer.UVKind
  24255. * - VertexBuffer.UV2Kind
  24256. * - VertexBuffer.UV3Kind
  24257. * - VertexBuffer.UV4Kind
  24258. * - VertexBuffer.UV5Kind
  24259. * - VertexBuffer.UV6Kind
  24260. * - VertexBuffer.ColorKind
  24261. * - VertexBuffer.MatricesIndicesKind
  24262. * - VertexBuffer.MatricesIndicesExtraKind
  24263. * - VertexBuffer.MatricesWeightsKind
  24264. * - VertexBuffer.MatricesWeightsExtraKind
  24265. */
  24266. removeVerticesData(kind: string): void;
  24267. /**
  24268. * Flags an associated vertex buffer as updatable
  24269. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24270. * - VertexBuffer.PositionKind
  24271. * - VertexBuffer.UVKind
  24272. * - VertexBuffer.UV2Kind
  24273. * - VertexBuffer.UV3Kind
  24274. * - VertexBuffer.UV4Kind
  24275. * - VertexBuffer.UV5Kind
  24276. * - VertexBuffer.UV6Kind
  24277. * - VertexBuffer.ColorKind
  24278. * - VertexBuffer.MatricesIndicesKind
  24279. * - VertexBuffer.MatricesIndicesExtraKind
  24280. * - VertexBuffer.MatricesWeightsKind
  24281. * - VertexBuffer.MatricesWeightsExtraKind
  24282. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24283. */
  24284. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24285. /**
  24286. * Sets the mesh global Vertex Buffer
  24287. * @param buffer defines the buffer to use
  24288. * @returns the current mesh
  24289. */
  24290. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24291. /**
  24292. * Update a specific associated vertex buffer
  24293. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24294. * - VertexBuffer.PositionKind
  24295. * - VertexBuffer.UVKind
  24296. * - VertexBuffer.UV2Kind
  24297. * - VertexBuffer.UV3Kind
  24298. * - VertexBuffer.UV4Kind
  24299. * - VertexBuffer.UV5Kind
  24300. * - VertexBuffer.UV6Kind
  24301. * - VertexBuffer.ColorKind
  24302. * - VertexBuffer.MatricesIndicesKind
  24303. * - VertexBuffer.MatricesIndicesExtraKind
  24304. * - VertexBuffer.MatricesWeightsKind
  24305. * - VertexBuffer.MatricesWeightsExtraKind
  24306. * @param data defines the data source
  24307. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24308. * @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)
  24309. * @returns the current mesh
  24310. */
  24311. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24312. /**
  24313. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24314. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24315. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24316. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24317. * @returns the current mesh
  24318. */
  24319. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24320. /**
  24321. * Creates a un-shared specific occurence of the geometry for the mesh.
  24322. * @returns the current mesh
  24323. */
  24324. makeGeometryUnique(): Mesh;
  24325. /**
  24326. * Set the index buffer of this mesh
  24327. * @param indices defines the source data
  24328. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24329. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24330. * @returns the current mesh
  24331. */
  24332. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24333. /**
  24334. * Update the current index buffer
  24335. * @param indices defines the source data
  24336. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24337. * @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)
  24338. * @returns the current mesh
  24339. */
  24340. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24341. /**
  24342. * Invert the geometry to move from a right handed system to a left handed one.
  24343. * @returns the current mesh
  24344. */
  24345. toLeftHanded(): Mesh;
  24346. /** @hidden */
  24347. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24348. /** @hidden */
  24349. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24350. /**
  24351. * Registers for this mesh a javascript function called just before the rendering process
  24352. * @param func defines the function to call before rendering this mesh
  24353. * @returns the current mesh
  24354. */
  24355. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24356. /**
  24357. * Disposes a previously registered javascript function called before the rendering
  24358. * @param func defines the function to remove
  24359. * @returns the current mesh
  24360. */
  24361. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24362. /**
  24363. * Registers for this mesh a javascript function called just after the rendering is complete
  24364. * @param func defines the function to call after rendering this mesh
  24365. * @returns the current mesh
  24366. */
  24367. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24368. /**
  24369. * Disposes a previously registered javascript function called after the rendering.
  24370. * @param func defines the function to remove
  24371. * @returns the current mesh
  24372. */
  24373. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24374. /** @hidden */
  24375. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24376. /** @hidden */
  24377. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24378. /** @hidden */
  24379. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24380. /** @hidden */
  24381. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24382. /** @hidden */
  24383. _rebuild(): void;
  24384. /** @hidden */
  24385. _freeze(): void;
  24386. /** @hidden */
  24387. _unFreeze(): void;
  24388. /**
  24389. * 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
  24390. * @param subMesh defines the subMesh to render
  24391. * @param enableAlphaMode defines if alpha mode can be changed
  24392. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24393. * @returns the current mesh
  24394. */
  24395. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24396. private _onBeforeDraw;
  24397. /**
  24398. * Renormalize the mesh and patch it up if there are no weights
  24399. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24400. * However in the case of zero weights then we set just a single influence to 1.
  24401. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24402. */
  24403. cleanMatrixWeights(): void;
  24404. private normalizeSkinFourWeights;
  24405. private normalizeSkinWeightsAndExtra;
  24406. /**
  24407. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24408. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24409. * the user know there was an issue with importing the mesh
  24410. * @returns a validation object with skinned, valid and report string
  24411. */
  24412. validateSkinning(): {
  24413. skinned: boolean;
  24414. valid: boolean;
  24415. report: string;
  24416. };
  24417. /** @hidden */
  24418. _checkDelayState(): Mesh;
  24419. private _queueLoad;
  24420. /**
  24421. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24422. * A mesh is in the frustum if its bounding box intersects the frustum
  24423. * @param frustumPlanes defines the frustum to test
  24424. * @returns true if the mesh is in the frustum planes
  24425. */
  24426. isInFrustum(frustumPlanes: Plane[]): boolean;
  24427. /**
  24428. * Sets the mesh material by the material or multiMaterial `id` property
  24429. * @param id is a string identifying the material or the multiMaterial
  24430. * @returns the current mesh
  24431. */
  24432. setMaterialByID(id: string): Mesh;
  24433. /**
  24434. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24435. * @returns an array of IAnimatable
  24436. */
  24437. getAnimatables(): IAnimatable[];
  24438. /**
  24439. * Modifies the mesh geometry according to the passed transformation matrix.
  24440. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24441. * The mesh normals are modified using the same transformation.
  24442. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24443. * @param transform defines the transform matrix to use
  24444. * @see http://doc.babylonjs.com/resources/baking_transformations
  24445. * @returns the current mesh
  24446. */
  24447. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24448. /**
  24449. * Modifies the mesh geometry according to its own current World Matrix.
  24450. * The mesh World Matrix is then reset.
  24451. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24452. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24453. * @see http://doc.babylonjs.com/resources/baking_transformations
  24454. * @returns the current mesh
  24455. */
  24456. bakeCurrentTransformIntoVertices(): Mesh;
  24457. /** @hidden */
  24458. readonly _positions: Nullable<Vector3[]>;
  24459. /** @hidden */
  24460. _resetPointsArrayCache(): Mesh;
  24461. /** @hidden */
  24462. _generatePointsArray(): boolean;
  24463. /**
  24464. * Returns a new Mesh object generated from the current mesh properties.
  24465. * This method must not get confused with createInstance()
  24466. * @param name is a string, the name given to the new mesh
  24467. * @param newParent can be any Node object (default `null`)
  24468. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24469. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24470. * @returns a new mesh
  24471. */
  24472. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24473. /**
  24474. * Releases resources associated with this mesh.
  24475. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24476. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24477. */
  24478. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24479. /** @hidden */
  24480. _disposeInstanceSpecificData(): void;
  24481. /**
  24482. * Modifies the mesh geometry according to a displacement map.
  24483. * 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.
  24484. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24485. * @param url is a string, the URL from the image file is to be downloaded.
  24486. * @param minHeight is the lower limit of the displacement.
  24487. * @param maxHeight is the upper limit of the displacement.
  24488. * @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.
  24489. * @param uvOffset is an optional vector2 used to offset UV.
  24490. * @param uvScale is an optional vector2 used to scale UV.
  24491. * @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.
  24492. * @returns the Mesh.
  24493. */
  24494. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24495. /**
  24496. * Modifies the mesh geometry according to a displacementMap buffer.
  24497. * 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.
  24498. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24499. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24500. * @param heightMapWidth is the width of the buffer image.
  24501. * @param heightMapHeight is the height of the buffer image.
  24502. * @param minHeight is the lower limit of the displacement.
  24503. * @param maxHeight is the upper limit of the displacement.
  24504. * @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.
  24505. * @param uvOffset is an optional vector2 used to offset UV.
  24506. * @param uvScale is an optional vector2 used to scale UV.
  24507. * @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.
  24508. * @returns the Mesh.
  24509. */
  24510. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24511. /**
  24512. * Modify the mesh to get a flat shading rendering.
  24513. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24514. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24515. * @returns current mesh
  24516. */
  24517. convertToFlatShadedMesh(): Mesh;
  24518. /**
  24519. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24520. * In other words, more vertices, no more indices and a single bigger VBO.
  24521. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24522. * @returns current mesh
  24523. */
  24524. convertToUnIndexedMesh(): Mesh;
  24525. /**
  24526. * Inverses facet orientations.
  24527. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24528. * @param flipNormals will also inverts the normals
  24529. * @returns current mesh
  24530. */
  24531. flipFaces(flipNormals?: boolean): Mesh;
  24532. /**
  24533. * Increase the number of facets and hence vertices in a mesh
  24534. * Vertex normals are interpolated from existing vertex normals
  24535. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24536. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24537. */
  24538. increaseVertices(numberPerEdge: number): void;
  24539. /**
  24540. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24541. * This will undo any application of covertToFlatShadedMesh
  24542. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24543. */
  24544. forceSharedVertices(): void;
  24545. /** @hidden */
  24546. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24547. /** @hidden */
  24548. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24549. /**
  24550. * Creates a new InstancedMesh object from the mesh model.
  24551. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24552. * @param name defines the name of the new instance
  24553. * @returns a new InstancedMesh
  24554. */
  24555. createInstance(name: string): InstancedMesh;
  24556. /**
  24557. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24558. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24559. * @returns the current mesh
  24560. */
  24561. synchronizeInstances(): Mesh;
  24562. /**
  24563. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24564. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24565. * This should be used together with the simplification to avoid disappearing triangles.
  24566. * @param successCallback an optional success callback to be called after the optimization finished.
  24567. * @returns the current mesh
  24568. */
  24569. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24570. /**
  24571. * Serialize current mesh
  24572. * @param serializationObject defines the object which will receive the serialization data
  24573. */
  24574. serialize(serializationObject: any): void;
  24575. /** @hidden */
  24576. _syncGeometryWithMorphTargetManager(): void;
  24577. /** @hidden */
  24578. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24579. /**
  24580. * Returns a new Mesh object parsed from the source provided.
  24581. * @param parsedMesh is the source
  24582. * @param scene defines the hosting scene
  24583. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24584. * @returns a new Mesh
  24585. */
  24586. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24587. /**
  24588. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24589. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24590. * @param name defines the name of the mesh to create
  24591. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24592. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24593. * @param closePath creates a seam between the first and the last points of each path of the path array
  24594. * @param offset is taken in account only if the `pathArray` is containing a single path
  24595. * @param scene defines the hosting scene
  24596. * @param updatable defines if the mesh must be flagged as updatable
  24597. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24598. * @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)
  24599. * @returns a new Mesh
  24600. */
  24601. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24602. /**
  24603. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24604. * @param name defines the name of the mesh to create
  24605. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24606. * @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
  24607. * @param scene defines the hosting scene
  24608. * @param updatable defines if the mesh must be flagged as updatable
  24609. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24610. * @returns a new Mesh
  24611. */
  24612. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24613. /**
  24614. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24615. * @param name defines the name of the mesh to create
  24616. * @param size sets the size (float) of each box side (default 1)
  24617. * @param scene defines the hosting scene
  24618. * @param updatable defines if the mesh must be flagged as updatable
  24619. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24620. * @returns a new Mesh
  24621. */
  24622. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24623. /**
  24624. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24625. * @param name defines the name of the mesh to create
  24626. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24627. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24628. * @param scene defines the hosting scene
  24629. * @param updatable defines if the mesh must be flagged as updatable
  24630. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24631. * @returns a new Mesh
  24632. */
  24633. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24634. /**
  24635. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24636. * @param name defines the name of the mesh to create
  24637. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24638. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24639. * @param scene defines the hosting scene
  24640. * @returns a new Mesh
  24641. */
  24642. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24643. /**
  24644. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24645. * @param name defines the name of the mesh to create
  24646. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24647. * @param diameterTop set the top cap diameter (floats, default 1)
  24648. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24649. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24650. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24651. * @param scene defines the hosting scene
  24652. * @param updatable defines if the mesh must be flagged as updatable
  24653. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24654. * @returns a new Mesh
  24655. */
  24656. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24657. /**
  24658. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24659. * @param name defines the name of the mesh to create
  24660. * @param diameter sets the diameter size (float) of the torus (default 1)
  24661. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24662. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24663. * @param scene defines the hosting scene
  24664. * @param updatable defines if the mesh must be flagged as updatable
  24665. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24666. * @returns a new Mesh
  24667. */
  24668. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24669. /**
  24670. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24671. * @param name defines the name of the mesh to create
  24672. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24673. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24674. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24675. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24676. * @param p the number of windings on X axis (positive integers, default 2)
  24677. * @param q the number of windings on Y axis (positive integers, default 3)
  24678. * @param scene defines the hosting scene
  24679. * @param updatable defines if the mesh must be flagged as updatable
  24680. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24681. * @returns a new Mesh
  24682. */
  24683. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24684. /**
  24685. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24686. * @param name defines the name of the mesh to create
  24687. * @param points is an array successive Vector3
  24688. * @param scene defines the hosting scene
  24689. * @param updatable defines if the mesh must be flagged as updatable
  24690. * @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).
  24691. * @returns a new Mesh
  24692. */
  24693. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24694. /**
  24695. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24696. * @param name defines the name of the mesh to create
  24697. * @param points is an array successive Vector3
  24698. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24699. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24700. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24701. * @param scene defines the hosting scene
  24702. * @param updatable defines if the mesh must be flagged as updatable
  24703. * @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)
  24704. * @returns a new Mesh
  24705. */
  24706. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24707. /**
  24708. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24709. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24710. * 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.
  24711. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24712. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24713. * Remember you can only change the shape positions, not their number when updating a polygon.
  24714. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24715. * @param name defines the name of the mesh to create
  24716. * @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
  24717. * @param scene defines the hosting scene
  24718. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24719. * @param updatable defines if the mesh must be flagged as updatable
  24720. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24721. * @param earcutInjection can be used to inject your own earcut reference
  24722. * @returns a new Mesh
  24723. */
  24724. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24725. /**
  24726. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24727. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24728. * @param name defines the name of the mesh to create
  24729. * @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
  24730. * @param depth defines the height of extrusion
  24731. * @param scene defines the hosting scene
  24732. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24733. * @param updatable defines if the mesh must be flagged as updatable
  24734. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24735. * @param earcutInjection can be used to inject your own earcut reference
  24736. * @returns a new Mesh
  24737. */
  24738. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24739. /**
  24740. * Creates an extruded shape mesh.
  24741. * 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
  24742. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24743. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24744. * @param name defines the name of the mesh to create
  24745. * @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
  24746. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24747. * @param scale is the value to scale the shape
  24748. * @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
  24749. * @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
  24750. * @param scene defines the hosting scene
  24751. * @param updatable defines if the mesh must be flagged as updatable
  24752. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24753. * @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)
  24754. * @returns a new Mesh
  24755. */
  24756. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24757. /**
  24758. * Creates an custom extruded shape mesh.
  24759. * The custom extrusion is a parametric shape.
  24760. * It has no predefined shape. Its final shape will depend on the input parameters.
  24761. * Please consider using the same method from the MeshBuilder class instead
  24762. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24763. * @param name defines the name of the mesh to create
  24764. * @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
  24765. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24766. * @param scaleFunction is a custom Javascript function called on each path point
  24767. * @param rotationFunction is a custom Javascript function called on each path point
  24768. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24769. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24770. * @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
  24771. * @param scene defines the hosting scene
  24772. * @param updatable defines if the mesh must be flagged as updatable
  24773. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24774. * @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)
  24775. * @returns a new Mesh
  24776. */
  24777. 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;
  24778. /**
  24779. * Creates lathe mesh.
  24780. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24781. * Please consider using the same method from the MeshBuilder class instead
  24782. * @param name defines the name of the mesh to create
  24783. * @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
  24784. * @param radius is the radius value of the lathe
  24785. * @param tessellation is the side number of the lathe.
  24786. * @param scene defines the hosting scene
  24787. * @param updatable defines if the mesh must be flagged as updatable
  24788. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24789. * @returns a new Mesh
  24790. */
  24791. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24792. /**
  24793. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24794. * @param name defines the name of the mesh to create
  24795. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24796. * @param scene defines the hosting scene
  24797. * @param updatable defines if the mesh must be flagged as updatable
  24798. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24799. * @returns a new Mesh
  24800. */
  24801. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24802. /**
  24803. * Creates a ground mesh.
  24804. * Please consider using the same method from the MeshBuilder class instead
  24805. * @param name defines the name of the mesh to create
  24806. * @param width set the width of the ground
  24807. * @param height set the height of the ground
  24808. * @param subdivisions sets the number of subdivisions per side
  24809. * @param scene defines the hosting scene
  24810. * @param updatable defines if the mesh must be flagged as updatable
  24811. * @returns a new Mesh
  24812. */
  24813. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24814. /**
  24815. * Creates a tiled ground mesh.
  24816. * Please consider using the same method from the MeshBuilder class instead
  24817. * @param name defines the name of the mesh to create
  24818. * @param xmin set the ground minimum X coordinate
  24819. * @param zmin set the ground minimum Y coordinate
  24820. * @param xmax set the ground maximum X coordinate
  24821. * @param zmax set the ground maximum Z coordinate
  24822. * @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
  24823. * @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
  24824. * @param scene defines the hosting scene
  24825. * @param updatable defines if the mesh must be flagged as updatable
  24826. * @returns a new Mesh
  24827. */
  24828. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24829. w: number;
  24830. h: number;
  24831. }, precision: {
  24832. w: number;
  24833. h: number;
  24834. }, scene: Scene, updatable?: boolean): Mesh;
  24835. /**
  24836. * Creates a ground mesh from a height map.
  24837. * Please consider using the same method from the MeshBuilder class instead
  24838. * @see http://doc.babylonjs.com/babylon101/height_map
  24839. * @param name defines the name of the mesh to create
  24840. * @param url sets the URL of the height map image resource
  24841. * @param width set the ground width size
  24842. * @param height set the ground height size
  24843. * @param subdivisions sets the number of subdivision per side
  24844. * @param minHeight is the minimum altitude on the ground
  24845. * @param maxHeight is the maximum altitude on the ground
  24846. * @param scene defines the hosting scene
  24847. * @param updatable defines if the mesh must be flagged as updatable
  24848. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24849. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24850. * @returns a new Mesh
  24851. */
  24852. 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;
  24853. /**
  24854. * Creates a tube mesh.
  24855. * The tube is a parametric shape.
  24856. * It has no predefined shape. Its final shape will depend on the input parameters.
  24857. * Please consider using the same method from the MeshBuilder class instead
  24858. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24859. * @param name defines the name of the mesh to create
  24860. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24861. * @param radius sets the tube radius size
  24862. * @param tessellation is the number of sides on the tubular surface
  24863. * @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
  24864. * @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
  24865. * @param scene defines the hosting scene
  24866. * @param updatable defines if the mesh must be flagged as updatable
  24867. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24868. * @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)
  24869. * @returns a new Mesh
  24870. */
  24871. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24872. (i: number, distance: number): number;
  24873. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24874. /**
  24875. * Creates a polyhedron mesh.
  24876. * Please consider using the same method from the MeshBuilder class instead.
  24877. * * 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
  24878. * * The parameter `size` (positive float, default 1) sets the polygon size
  24879. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24880. * * 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`
  24881. * * 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
  24882. * * 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)`)
  24883. * * 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
  24884. * * 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
  24885. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24886. * * 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
  24887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24888. * @param name defines the name of the mesh to create
  24889. * @param options defines the options used to create the mesh
  24890. * @param scene defines the hosting scene
  24891. * @returns a new Mesh
  24892. */
  24893. static CreatePolyhedron(name: string, options: {
  24894. type?: number;
  24895. size?: number;
  24896. sizeX?: number;
  24897. sizeY?: number;
  24898. sizeZ?: number;
  24899. custom?: any;
  24900. faceUV?: Vector4[];
  24901. faceColors?: Color4[];
  24902. updatable?: boolean;
  24903. sideOrientation?: number;
  24904. }, scene: Scene): Mesh;
  24905. /**
  24906. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24907. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24908. * * 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`)
  24909. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24910. * * 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
  24911. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24912. * * 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
  24913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24914. * @param name defines the name of the mesh
  24915. * @param options defines the options used to create the mesh
  24916. * @param scene defines the hosting scene
  24917. * @returns a new Mesh
  24918. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24919. */
  24920. static CreateIcoSphere(name: string, options: {
  24921. radius?: number;
  24922. flat?: boolean;
  24923. subdivisions?: number;
  24924. sideOrientation?: number;
  24925. updatable?: boolean;
  24926. }, scene: Scene): Mesh;
  24927. /**
  24928. * Creates a decal mesh.
  24929. * Please consider using the same method from the MeshBuilder class instead.
  24930. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24931. * @param name defines the name of the mesh
  24932. * @param sourceMesh defines the mesh receiving the decal
  24933. * @param position sets the position of the decal in world coordinates
  24934. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24935. * @param size sets the decal scaling
  24936. * @param angle sets the angle to rotate the decal
  24937. * @returns a new Mesh
  24938. */
  24939. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24940. /**
  24941. * Prepare internal position array for software CPU skinning
  24942. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24943. */
  24944. setPositionsForCPUSkinning(): Float32Array;
  24945. /**
  24946. * Prepare internal normal array for software CPU skinning
  24947. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24948. */
  24949. setNormalsForCPUSkinning(): Float32Array;
  24950. /**
  24951. * Updates the vertex buffer by applying transformation from the bones
  24952. * @param skeleton defines the skeleton to apply to current mesh
  24953. * @returns the current mesh
  24954. */
  24955. applySkeleton(skeleton: Skeleton): Mesh;
  24956. /**
  24957. * 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
  24958. * @param meshes defines the list of meshes to scan
  24959. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24960. */
  24961. static MinMax(meshes: AbstractMesh[]): {
  24962. min: Vector3;
  24963. max: Vector3;
  24964. };
  24965. /**
  24966. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24967. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24968. * @returns a vector3
  24969. */
  24970. static Center(meshesOrMinMaxVector: {
  24971. min: Vector3;
  24972. max: Vector3;
  24973. } | AbstractMesh[]): Vector3;
  24974. /**
  24975. * Merge the array of meshes into a single mesh for performance reasons.
  24976. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24977. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24978. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24979. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24980. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24981. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24982. * @returns a new mesh
  24983. */
  24984. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24985. /** @hidden */
  24986. addInstance(instance: InstancedMesh): void;
  24987. /** @hidden */
  24988. removeInstance(instance: InstancedMesh): void;
  24989. }
  24990. }
  24991. declare module BABYLON {
  24992. /**
  24993. * This is the base class of all the camera used in the application.
  24994. * @see http://doc.babylonjs.com/features/cameras
  24995. */
  24996. export class Camera extends Node {
  24997. /** @hidden */
  24998. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24999. /**
  25000. * This is the default projection mode used by the cameras.
  25001. * It helps recreating a feeling of perspective and better appreciate depth.
  25002. * This is the best way to simulate real life cameras.
  25003. */
  25004. static readonly PERSPECTIVE_CAMERA: number;
  25005. /**
  25006. * This helps creating camera with an orthographic mode.
  25007. * 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.
  25008. */
  25009. static readonly ORTHOGRAPHIC_CAMERA: number;
  25010. /**
  25011. * This is the default FOV mode for perspective cameras.
  25012. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25013. */
  25014. static readonly FOVMODE_VERTICAL_FIXED: number;
  25015. /**
  25016. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25017. */
  25018. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25019. /**
  25020. * This specifies ther is no need for a camera rig.
  25021. * Basically only one eye is rendered corresponding to the camera.
  25022. */
  25023. static readonly RIG_MODE_NONE: number;
  25024. /**
  25025. * Simulates a camera Rig with one blue eye and one red eye.
  25026. * This can be use with 3d blue and red glasses.
  25027. */
  25028. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25029. /**
  25030. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25031. */
  25032. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25033. /**
  25034. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25035. */
  25036. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25037. /**
  25038. * Defines that both eyes of the camera will be rendered over under each other.
  25039. */
  25040. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25041. /**
  25042. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25043. */
  25044. static readonly RIG_MODE_VR: number;
  25045. /**
  25046. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25047. */
  25048. static readonly RIG_MODE_WEBVR: number;
  25049. /**
  25050. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25051. */
  25052. static readonly RIG_MODE_CUSTOM: number;
  25053. /**
  25054. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25055. */
  25056. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25057. /**
  25058. * Define the input manager associated with the camera.
  25059. */
  25060. inputs: CameraInputsManager<Camera>;
  25061. /** @hidden */
  25062. _position: Vector3;
  25063. /**
  25064. * Define the current local position of the camera in the scene
  25065. */
  25066. position: Vector3;
  25067. /**
  25068. * The vector the camera should consider as up.
  25069. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25070. */
  25071. upVector: Vector3;
  25072. /**
  25073. * Define the current limit on the left side for an orthographic camera
  25074. * In scene unit
  25075. */
  25076. orthoLeft: Nullable<number>;
  25077. /**
  25078. * Define the current limit on the right side for an orthographic camera
  25079. * In scene unit
  25080. */
  25081. orthoRight: Nullable<number>;
  25082. /**
  25083. * Define the current limit on the bottom side for an orthographic camera
  25084. * In scene unit
  25085. */
  25086. orthoBottom: Nullable<number>;
  25087. /**
  25088. * Define the current limit on the top side for an orthographic camera
  25089. * In scene unit
  25090. */
  25091. orthoTop: Nullable<number>;
  25092. /**
  25093. * Field Of View is set in Radians. (default is 0.8)
  25094. */
  25095. fov: number;
  25096. /**
  25097. * Define the minimum distance the camera can see from.
  25098. * This is important to note that the depth buffer are not infinite and the closer it starts
  25099. * the more your scene might encounter depth fighting issue.
  25100. */
  25101. minZ: number;
  25102. /**
  25103. * Define the maximum distance the camera can see to.
  25104. * This is important to note that the depth buffer are not infinite and the further it end
  25105. * the more your scene might encounter depth fighting issue.
  25106. */
  25107. maxZ: number;
  25108. /**
  25109. * Define the default inertia of the camera.
  25110. * This helps giving a smooth feeling to the camera movement.
  25111. */
  25112. inertia: number;
  25113. /**
  25114. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25115. */
  25116. mode: number;
  25117. /**
  25118. * Define wether the camera is intermediate.
  25119. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25120. */
  25121. isIntermediate: boolean;
  25122. /**
  25123. * Define the viewport of the camera.
  25124. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25125. */
  25126. viewport: Viewport;
  25127. /**
  25128. * Restricts the camera to viewing objects with the same layerMask.
  25129. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25130. */
  25131. layerMask: number;
  25132. /**
  25133. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25134. */
  25135. fovMode: number;
  25136. /**
  25137. * Rig mode of the camera.
  25138. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25139. * This is normally controlled byt the camera themselves as internal use.
  25140. */
  25141. cameraRigMode: number;
  25142. /**
  25143. * Defines the distance between both "eyes" in case of a RIG
  25144. */
  25145. interaxialDistance: number;
  25146. /**
  25147. * Defines if stereoscopic rendering is done side by side or over under.
  25148. */
  25149. isStereoscopicSideBySide: boolean;
  25150. /**
  25151. * 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
  25152. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25153. * else in the scene. (Eg. security camera)
  25154. *
  25155. * 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)
  25156. */
  25157. customRenderTargets: RenderTargetTexture[];
  25158. /**
  25159. * When set, the camera will render to this render target instead of the default canvas
  25160. *
  25161. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25162. */
  25163. outputRenderTarget: Nullable<RenderTargetTexture>;
  25164. /**
  25165. * Observable triggered when the camera view matrix has changed.
  25166. */
  25167. onViewMatrixChangedObservable: Observable<Camera>;
  25168. /**
  25169. * Observable triggered when the camera Projection matrix has changed.
  25170. */
  25171. onProjectionMatrixChangedObservable: Observable<Camera>;
  25172. /**
  25173. * Observable triggered when the inputs have been processed.
  25174. */
  25175. onAfterCheckInputsObservable: Observable<Camera>;
  25176. /**
  25177. * Observable triggered when reset has been called and applied to the camera.
  25178. */
  25179. onRestoreStateObservable: Observable<Camera>;
  25180. /** @hidden */
  25181. _cameraRigParams: any;
  25182. /** @hidden */
  25183. _rigCameras: Camera[];
  25184. /** @hidden */
  25185. _rigPostProcess: Nullable<PostProcess>;
  25186. protected _webvrViewMatrix: Matrix;
  25187. /** @hidden */
  25188. _skipRendering: boolean;
  25189. /** @hidden */
  25190. _projectionMatrix: Matrix;
  25191. /** @hidden */
  25192. _postProcesses: Nullable<PostProcess>[];
  25193. /** @hidden */
  25194. _activeMeshes: SmartArray<AbstractMesh>;
  25195. protected _globalPosition: Vector3;
  25196. /** @hidden */
  25197. _computedViewMatrix: Matrix;
  25198. private _doNotComputeProjectionMatrix;
  25199. private _transformMatrix;
  25200. private _frustumPlanes;
  25201. private _refreshFrustumPlanes;
  25202. private _storedFov;
  25203. private _stateStored;
  25204. /**
  25205. * Instantiates a new camera object.
  25206. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25207. * @see http://doc.babylonjs.com/features/cameras
  25208. * @param name Defines the name of the camera in the scene
  25209. * @param position Defines the position of the camera
  25210. * @param scene Defines the scene the camera belongs too
  25211. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25212. */
  25213. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25214. /**
  25215. * Store current camera state (fov, position, etc..)
  25216. * @returns the camera
  25217. */
  25218. storeState(): Camera;
  25219. /**
  25220. * Restores the camera state values if it has been stored. You must call storeState() first
  25221. */
  25222. protected _restoreStateValues(): boolean;
  25223. /**
  25224. * Restored camera state. You must call storeState() first.
  25225. * @returns true if restored and false otherwise
  25226. */
  25227. restoreState(): boolean;
  25228. /**
  25229. * Gets the class name of the camera.
  25230. * @returns the class name
  25231. */
  25232. getClassName(): string;
  25233. /** @hidden */
  25234. readonly _isCamera: boolean;
  25235. /**
  25236. * Gets a string representation of the camera useful for debug purpose.
  25237. * @param fullDetails Defines that a more verboe level of logging is required
  25238. * @returns the string representation
  25239. */
  25240. toString(fullDetails?: boolean): string;
  25241. /**
  25242. * Gets the current world space position of the camera.
  25243. */
  25244. readonly globalPosition: Vector3;
  25245. /**
  25246. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25247. * @returns the active meshe list
  25248. */
  25249. getActiveMeshes(): SmartArray<AbstractMesh>;
  25250. /**
  25251. * Check wether a mesh is part of the current active mesh list of the camera
  25252. * @param mesh Defines the mesh to check
  25253. * @returns true if active, false otherwise
  25254. */
  25255. isActiveMesh(mesh: Mesh): boolean;
  25256. /**
  25257. * Is this camera ready to be used/rendered
  25258. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25259. * @return true if the camera is ready
  25260. */
  25261. isReady(completeCheck?: boolean): boolean;
  25262. /** @hidden */
  25263. _initCache(): void;
  25264. /** @hidden */
  25265. _updateCache(ignoreParentClass?: boolean): void;
  25266. /** @hidden */
  25267. _isSynchronized(): boolean;
  25268. /** @hidden */
  25269. _isSynchronizedViewMatrix(): boolean;
  25270. /** @hidden */
  25271. _isSynchronizedProjectionMatrix(): boolean;
  25272. /**
  25273. * Attach the input controls to a specific dom element to get the input from.
  25274. * @param element Defines the element the controls should be listened from
  25275. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25276. */
  25277. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25278. /**
  25279. * Detach the current controls from the specified dom element.
  25280. * @param element Defines the element to stop listening the inputs from
  25281. */
  25282. detachControl(element: HTMLElement): void;
  25283. /**
  25284. * Update the camera state according to the different inputs gathered during the frame.
  25285. */
  25286. update(): void;
  25287. /** @hidden */
  25288. _checkInputs(): void;
  25289. /** @hidden */
  25290. readonly rigCameras: Camera[];
  25291. /**
  25292. * Gets the post process used by the rig cameras
  25293. */
  25294. readonly rigPostProcess: Nullable<PostProcess>;
  25295. /**
  25296. * Internal, gets the first post proces.
  25297. * @returns the first post process to be run on this camera.
  25298. */
  25299. _getFirstPostProcess(): Nullable<PostProcess>;
  25300. private _cascadePostProcessesToRigCams;
  25301. /**
  25302. * Attach a post process to the camera.
  25303. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25304. * @param postProcess The post process to attach to the camera
  25305. * @param insertAt The position of the post process in case several of them are in use in the scene
  25306. * @returns the position the post process has been inserted at
  25307. */
  25308. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25309. /**
  25310. * Detach a post process to the camera.
  25311. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25312. * @param postProcess The post process to detach from the camera
  25313. */
  25314. detachPostProcess(postProcess: PostProcess): void;
  25315. /**
  25316. * Gets the current world matrix of the camera
  25317. */
  25318. getWorldMatrix(): Matrix;
  25319. /** @hidden */
  25320. _getViewMatrix(): Matrix;
  25321. /**
  25322. * Gets the current view matrix of the camera.
  25323. * @param force forces the camera to recompute the matrix without looking at the cached state
  25324. * @returns the view matrix
  25325. */
  25326. getViewMatrix(force?: boolean): Matrix;
  25327. /**
  25328. * Freeze the projection matrix.
  25329. * It will prevent the cache check of the camera projection compute and can speed up perf
  25330. * if no parameter of the camera are meant to change
  25331. * @param projection Defines manually a projection if necessary
  25332. */
  25333. freezeProjectionMatrix(projection?: Matrix): void;
  25334. /**
  25335. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25336. */
  25337. unfreezeProjectionMatrix(): void;
  25338. /**
  25339. * Gets the current projection matrix of the camera.
  25340. * @param force forces the camera to recompute the matrix without looking at the cached state
  25341. * @returns the projection matrix
  25342. */
  25343. getProjectionMatrix(force?: boolean): Matrix;
  25344. /**
  25345. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25346. * @returns a Matrix
  25347. */
  25348. getTransformationMatrix(): Matrix;
  25349. private _updateFrustumPlanes;
  25350. /**
  25351. * Checks if a cullable object (mesh...) is in the camera frustum
  25352. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25353. * @param target The object to check
  25354. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25355. * @returns true if the object is in frustum otherwise false
  25356. */
  25357. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25358. /**
  25359. * Checks if a cullable object (mesh...) is in the camera frustum
  25360. * Unlike isInFrustum this cheks the full bounding box
  25361. * @param target The object to check
  25362. * @returns true if the object is in frustum otherwise false
  25363. */
  25364. isCompletelyInFrustum(target: ICullable): boolean;
  25365. /**
  25366. * Gets a ray in the forward direction from the camera.
  25367. * @param length Defines the length of the ray to create
  25368. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25369. * @param origin Defines the start point of the ray which defaults to the camera position
  25370. * @returns the forward ray
  25371. */
  25372. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25373. /**
  25374. * Releases resources associated with this node.
  25375. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25376. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25377. */
  25378. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25379. /** @hidden */
  25380. _isLeftCamera: boolean;
  25381. /**
  25382. * Gets the left camera of a rig setup in case of Rigged Camera
  25383. */
  25384. readonly isLeftCamera: boolean;
  25385. /** @hidden */
  25386. _isRightCamera: boolean;
  25387. /**
  25388. * Gets the right camera of a rig setup in case of Rigged Camera
  25389. */
  25390. readonly isRightCamera: boolean;
  25391. /**
  25392. * Gets the left camera of a rig setup in case of Rigged Camera
  25393. */
  25394. readonly leftCamera: Nullable<FreeCamera>;
  25395. /**
  25396. * Gets the right camera of a rig setup in case of Rigged Camera
  25397. */
  25398. readonly rightCamera: Nullable<FreeCamera>;
  25399. /**
  25400. * Gets the left camera target of a rig setup in case of Rigged Camera
  25401. * @returns the target position
  25402. */
  25403. getLeftTarget(): Nullable<Vector3>;
  25404. /**
  25405. * Gets the right camera target of a rig setup in case of Rigged Camera
  25406. * @returns the target position
  25407. */
  25408. getRightTarget(): Nullable<Vector3>;
  25409. /**
  25410. * @hidden
  25411. */
  25412. setCameraRigMode(mode: number, rigParams: any): void;
  25413. /** @hidden */
  25414. static _setStereoscopicRigMode(camera: Camera): void;
  25415. /** @hidden */
  25416. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25417. /** @hidden */
  25418. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25419. /** @hidden */
  25420. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25421. /** @hidden */
  25422. _getVRProjectionMatrix(): Matrix;
  25423. protected _updateCameraRotationMatrix(): void;
  25424. protected _updateWebVRCameraRotationMatrix(): void;
  25425. /**
  25426. * This function MUST be overwritten by the different WebVR cameras available.
  25427. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25428. * @hidden
  25429. */
  25430. _getWebVRProjectionMatrix(): Matrix;
  25431. /**
  25432. * This function MUST be overwritten by the different WebVR cameras available.
  25433. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25434. * @hidden
  25435. */
  25436. _getWebVRViewMatrix(): Matrix;
  25437. /** @hidden */
  25438. setCameraRigParameter(name: string, value: any): void;
  25439. /**
  25440. * needs to be overridden by children so sub has required properties to be copied
  25441. * @hidden
  25442. */
  25443. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25444. /**
  25445. * May need to be overridden by children
  25446. * @hidden
  25447. */
  25448. _updateRigCameras(): void;
  25449. /** @hidden */
  25450. _setupInputs(): void;
  25451. /**
  25452. * Serialiaze the camera setup to a json represention
  25453. * @returns the JSON representation
  25454. */
  25455. serialize(): any;
  25456. /**
  25457. * Clones the current camera.
  25458. * @param name The cloned camera name
  25459. * @returns the cloned camera
  25460. */
  25461. clone(name: string): Camera;
  25462. /**
  25463. * Gets the direction of the camera relative to a given local axis.
  25464. * @param localAxis Defines the reference axis to provide a relative direction.
  25465. * @return the direction
  25466. */
  25467. getDirection(localAxis: Vector3): Vector3;
  25468. /**
  25469. * Returns the current camera absolute rotation
  25470. */
  25471. readonly absoluteRotation: Quaternion;
  25472. /**
  25473. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25474. * @param localAxis Defines the reference axis to provide a relative direction.
  25475. * @param result Defines the vector to store the result in
  25476. */
  25477. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25478. /**
  25479. * Gets a camera constructor for a given camera type
  25480. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25481. * @param name The name of the camera the result will be able to instantiate
  25482. * @param scene The scene the result will construct the camera in
  25483. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25484. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25485. * @returns a factory method to construc the camera
  25486. */
  25487. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25488. /**
  25489. * Compute the world matrix of the camera.
  25490. * @returns the camera world matrix
  25491. */
  25492. computeWorldMatrix(): Matrix;
  25493. /**
  25494. * Parse a JSON and creates the camera from the parsed information
  25495. * @param parsedCamera The JSON to parse
  25496. * @param scene The scene to instantiate the camera in
  25497. * @returns the newly constructed camera
  25498. */
  25499. static Parse(parsedCamera: any, scene: Scene): Camera;
  25500. }
  25501. }
  25502. declare module BABYLON {
  25503. /**
  25504. * Class containing static functions to help procedurally build meshes
  25505. */
  25506. export class DiscBuilder {
  25507. /**
  25508. * Creates a plane polygonal mesh. By default, this is a disc
  25509. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25510. * * 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
  25511. * * 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
  25512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25513. * * 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
  25514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25515. * @param name defines the name of the mesh
  25516. * @param options defines the options used to create the mesh
  25517. * @param scene defines the hosting scene
  25518. * @returns the plane polygonal mesh
  25519. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25520. */
  25521. static CreateDisc(name: string, options: {
  25522. radius?: number;
  25523. tessellation?: number;
  25524. arc?: number;
  25525. updatable?: boolean;
  25526. sideOrientation?: number;
  25527. frontUVs?: Vector4;
  25528. backUVs?: Vector4;
  25529. }, scene?: Nullable<Scene>): Mesh;
  25530. }
  25531. }
  25532. declare module BABYLON {
  25533. /**
  25534. * This represents all the required information to add a fresnel effect on a material:
  25535. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25536. */
  25537. export class FresnelParameters {
  25538. private _isEnabled;
  25539. /**
  25540. * Define if the fresnel effect is enable or not.
  25541. */
  25542. isEnabled: boolean;
  25543. /**
  25544. * Define the color used on edges (grazing angle)
  25545. */
  25546. leftColor: Color3;
  25547. /**
  25548. * Define the color used on center
  25549. */
  25550. rightColor: Color3;
  25551. /**
  25552. * Define bias applied to computed fresnel term
  25553. */
  25554. bias: number;
  25555. /**
  25556. * Defined the power exponent applied to fresnel term
  25557. */
  25558. power: number;
  25559. /**
  25560. * Clones the current fresnel and its valuues
  25561. * @returns a clone fresnel configuration
  25562. */
  25563. clone(): FresnelParameters;
  25564. /**
  25565. * Serializes the current fresnel parameters to a JSON representation.
  25566. * @return the JSON serialization
  25567. */
  25568. serialize(): any;
  25569. /**
  25570. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25571. * @param parsedFresnelParameters Define the JSON representation
  25572. * @returns the parsed parameters
  25573. */
  25574. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25575. }
  25576. }
  25577. declare module BABYLON {
  25578. /**
  25579. * Base class of materials working in push mode in babylon JS
  25580. * @hidden
  25581. */
  25582. export class PushMaterial extends Material {
  25583. protected _activeEffect: Effect;
  25584. protected _normalMatrix: Matrix;
  25585. /**
  25586. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  25587. * This means that the material can keep using a previous shader while a new one is being compiled.
  25588. * This is mostly used when shader parallel compilation is supported (true by default)
  25589. */
  25590. allowShaderHotSwapping: boolean;
  25591. constructor(name: string, scene: Scene);
  25592. getEffect(): Effect;
  25593. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25594. /**
  25595. * Binds the given world matrix to the active effect
  25596. *
  25597. * @param world the matrix to bind
  25598. */
  25599. bindOnlyWorldMatrix(world: Matrix): void;
  25600. /**
  25601. * Binds the given normal matrix to the active effect
  25602. *
  25603. * @param normalMatrix the matrix to bind
  25604. */
  25605. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  25606. bind(world: Matrix, mesh?: Mesh): void;
  25607. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  25608. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  25609. }
  25610. }
  25611. declare module BABYLON {
  25612. /**
  25613. * This groups all the flags used to control the materials channel.
  25614. */
  25615. export class MaterialFlags {
  25616. private static _DiffuseTextureEnabled;
  25617. /**
  25618. * Are diffuse textures enabled in the application.
  25619. */
  25620. static DiffuseTextureEnabled: boolean;
  25621. private static _AmbientTextureEnabled;
  25622. /**
  25623. * Are ambient textures enabled in the application.
  25624. */
  25625. static AmbientTextureEnabled: boolean;
  25626. private static _OpacityTextureEnabled;
  25627. /**
  25628. * Are opacity textures enabled in the application.
  25629. */
  25630. static OpacityTextureEnabled: boolean;
  25631. private static _ReflectionTextureEnabled;
  25632. /**
  25633. * Are reflection textures enabled in the application.
  25634. */
  25635. static ReflectionTextureEnabled: boolean;
  25636. private static _EmissiveTextureEnabled;
  25637. /**
  25638. * Are emissive textures enabled in the application.
  25639. */
  25640. static EmissiveTextureEnabled: boolean;
  25641. private static _SpecularTextureEnabled;
  25642. /**
  25643. * Are specular textures enabled in the application.
  25644. */
  25645. static SpecularTextureEnabled: boolean;
  25646. private static _BumpTextureEnabled;
  25647. /**
  25648. * Are bump textures enabled in the application.
  25649. */
  25650. static BumpTextureEnabled: boolean;
  25651. private static _LightmapTextureEnabled;
  25652. /**
  25653. * Are lightmap textures enabled in the application.
  25654. */
  25655. static LightmapTextureEnabled: boolean;
  25656. private static _RefractionTextureEnabled;
  25657. /**
  25658. * Are refraction textures enabled in the application.
  25659. */
  25660. static RefractionTextureEnabled: boolean;
  25661. private static _ColorGradingTextureEnabled;
  25662. /**
  25663. * Are color grading textures enabled in the application.
  25664. */
  25665. static ColorGradingTextureEnabled: boolean;
  25666. private static _FresnelEnabled;
  25667. /**
  25668. * Are fresnels enabled in the application.
  25669. */
  25670. static FresnelEnabled: boolean;
  25671. private static _ClearCoatTextureEnabled;
  25672. /**
  25673. * Are clear coat textures enabled in the application.
  25674. */
  25675. static ClearCoatTextureEnabled: boolean;
  25676. private static _ClearCoatBumpTextureEnabled;
  25677. /**
  25678. * Are clear coat bump textures enabled in the application.
  25679. */
  25680. static ClearCoatBumpTextureEnabled: boolean;
  25681. private static _ClearCoatTintTextureEnabled;
  25682. /**
  25683. * Are clear coat tint textures enabled in the application.
  25684. */
  25685. static ClearCoatTintTextureEnabled: boolean;
  25686. private static _SheenTextureEnabled;
  25687. /**
  25688. * Are sheen textures enabled in the application.
  25689. */
  25690. static SheenTextureEnabled: boolean;
  25691. private static _AnisotropicTextureEnabled;
  25692. /**
  25693. * Are anisotropic textures enabled in the application.
  25694. */
  25695. static AnisotropicTextureEnabled: boolean;
  25696. private static _ThicknessTextureEnabled;
  25697. /**
  25698. * Are thickness textures enabled in the application.
  25699. */
  25700. static ThicknessTextureEnabled: boolean;
  25701. }
  25702. }
  25703. declare module BABYLON {
  25704. /** @hidden */
  25705. export var defaultFragmentDeclaration: {
  25706. name: string;
  25707. shader: string;
  25708. };
  25709. }
  25710. declare module BABYLON {
  25711. /** @hidden */
  25712. export var defaultUboDeclaration: {
  25713. name: string;
  25714. shader: string;
  25715. };
  25716. }
  25717. declare module BABYLON {
  25718. /** @hidden */
  25719. export var lightFragmentDeclaration: {
  25720. name: string;
  25721. shader: string;
  25722. };
  25723. }
  25724. declare module BABYLON {
  25725. /** @hidden */
  25726. export var lightUboDeclaration: {
  25727. name: string;
  25728. shader: string;
  25729. };
  25730. }
  25731. declare module BABYLON {
  25732. /** @hidden */
  25733. export var lightsFragmentFunctions: {
  25734. name: string;
  25735. shader: string;
  25736. };
  25737. }
  25738. declare module BABYLON {
  25739. /** @hidden */
  25740. export var shadowsFragmentFunctions: {
  25741. name: string;
  25742. shader: string;
  25743. };
  25744. }
  25745. declare module BABYLON {
  25746. /** @hidden */
  25747. export var fresnelFunction: {
  25748. name: string;
  25749. shader: string;
  25750. };
  25751. }
  25752. declare module BABYLON {
  25753. /** @hidden */
  25754. export var reflectionFunction: {
  25755. name: string;
  25756. shader: string;
  25757. };
  25758. }
  25759. declare module BABYLON {
  25760. /** @hidden */
  25761. export var bumpFragmentFunctions: {
  25762. name: string;
  25763. shader: string;
  25764. };
  25765. }
  25766. declare module BABYLON {
  25767. /** @hidden */
  25768. export var logDepthDeclaration: {
  25769. name: string;
  25770. shader: string;
  25771. };
  25772. }
  25773. declare module BABYLON {
  25774. /** @hidden */
  25775. export var bumpFragment: {
  25776. name: string;
  25777. shader: string;
  25778. };
  25779. }
  25780. declare module BABYLON {
  25781. /** @hidden */
  25782. export var depthPrePass: {
  25783. name: string;
  25784. shader: string;
  25785. };
  25786. }
  25787. declare module BABYLON {
  25788. /** @hidden */
  25789. export var lightFragment: {
  25790. name: string;
  25791. shader: string;
  25792. };
  25793. }
  25794. declare module BABYLON {
  25795. /** @hidden */
  25796. export var logDepthFragment: {
  25797. name: string;
  25798. shader: string;
  25799. };
  25800. }
  25801. declare module BABYLON {
  25802. /** @hidden */
  25803. export var defaultPixelShader: {
  25804. name: string;
  25805. shader: string;
  25806. };
  25807. }
  25808. declare module BABYLON {
  25809. /** @hidden */
  25810. export var defaultVertexDeclaration: {
  25811. name: string;
  25812. shader: string;
  25813. };
  25814. }
  25815. declare module BABYLON {
  25816. /** @hidden */
  25817. export var bumpVertexDeclaration: {
  25818. name: string;
  25819. shader: string;
  25820. };
  25821. }
  25822. declare module BABYLON {
  25823. /** @hidden */
  25824. export var bumpVertex: {
  25825. name: string;
  25826. shader: string;
  25827. };
  25828. }
  25829. declare module BABYLON {
  25830. /** @hidden */
  25831. export var fogVertex: {
  25832. name: string;
  25833. shader: string;
  25834. };
  25835. }
  25836. declare module BABYLON {
  25837. /** @hidden */
  25838. export var shadowsVertex: {
  25839. name: string;
  25840. shader: string;
  25841. };
  25842. }
  25843. declare module BABYLON {
  25844. /** @hidden */
  25845. export var pointCloudVertex: {
  25846. name: string;
  25847. shader: string;
  25848. };
  25849. }
  25850. declare module BABYLON {
  25851. /** @hidden */
  25852. export var logDepthVertex: {
  25853. name: string;
  25854. shader: string;
  25855. };
  25856. }
  25857. declare module BABYLON {
  25858. /** @hidden */
  25859. export var defaultVertexShader: {
  25860. name: string;
  25861. shader: string;
  25862. };
  25863. }
  25864. declare module BABYLON {
  25865. /** @hidden */
  25866. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  25867. MAINUV1: boolean;
  25868. MAINUV2: boolean;
  25869. DIFFUSE: boolean;
  25870. DIFFUSEDIRECTUV: number;
  25871. AMBIENT: boolean;
  25872. AMBIENTDIRECTUV: number;
  25873. OPACITY: boolean;
  25874. OPACITYDIRECTUV: number;
  25875. OPACITYRGB: boolean;
  25876. REFLECTION: boolean;
  25877. EMISSIVE: boolean;
  25878. EMISSIVEDIRECTUV: number;
  25879. SPECULAR: boolean;
  25880. SPECULARDIRECTUV: number;
  25881. BUMP: boolean;
  25882. BUMPDIRECTUV: number;
  25883. PARALLAX: boolean;
  25884. PARALLAXOCCLUSION: boolean;
  25885. SPECULAROVERALPHA: boolean;
  25886. CLIPPLANE: boolean;
  25887. CLIPPLANE2: boolean;
  25888. CLIPPLANE3: boolean;
  25889. CLIPPLANE4: boolean;
  25890. ALPHATEST: boolean;
  25891. DEPTHPREPASS: boolean;
  25892. ALPHAFROMDIFFUSE: boolean;
  25893. POINTSIZE: boolean;
  25894. FOG: boolean;
  25895. SPECULARTERM: boolean;
  25896. DIFFUSEFRESNEL: boolean;
  25897. OPACITYFRESNEL: boolean;
  25898. REFLECTIONFRESNEL: boolean;
  25899. REFRACTIONFRESNEL: boolean;
  25900. EMISSIVEFRESNEL: boolean;
  25901. FRESNEL: boolean;
  25902. NORMAL: boolean;
  25903. UV1: boolean;
  25904. UV2: boolean;
  25905. VERTEXCOLOR: boolean;
  25906. VERTEXALPHA: boolean;
  25907. NUM_BONE_INFLUENCERS: number;
  25908. BonesPerMesh: number;
  25909. BONETEXTURE: boolean;
  25910. INSTANCES: boolean;
  25911. GLOSSINESS: boolean;
  25912. ROUGHNESS: boolean;
  25913. EMISSIVEASILLUMINATION: boolean;
  25914. LINKEMISSIVEWITHDIFFUSE: boolean;
  25915. REFLECTIONFRESNELFROMSPECULAR: boolean;
  25916. LIGHTMAP: boolean;
  25917. LIGHTMAPDIRECTUV: number;
  25918. OBJECTSPACE_NORMALMAP: boolean;
  25919. USELIGHTMAPASSHADOWMAP: boolean;
  25920. REFLECTIONMAP_3D: boolean;
  25921. REFLECTIONMAP_SPHERICAL: boolean;
  25922. REFLECTIONMAP_PLANAR: boolean;
  25923. REFLECTIONMAP_CUBIC: boolean;
  25924. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  25925. REFLECTIONMAP_PROJECTION: boolean;
  25926. REFLECTIONMAP_SKYBOX: boolean;
  25927. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  25928. REFLECTIONMAP_EXPLICIT: boolean;
  25929. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  25930. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  25931. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  25932. INVERTCUBICMAP: boolean;
  25933. LOGARITHMICDEPTH: boolean;
  25934. REFRACTION: boolean;
  25935. REFRACTIONMAP_3D: boolean;
  25936. REFLECTIONOVERALPHA: boolean;
  25937. TWOSIDEDLIGHTING: boolean;
  25938. SHADOWFLOAT: boolean;
  25939. MORPHTARGETS: boolean;
  25940. MORPHTARGETS_NORMAL: boolean;
  25941. MORPHTARGETS_TANGENT: boolean;
  25942. MORPHTARGETS_UV: boolean;
  25943. NUM_MORPH_INFLUENCERS: number;
  25944. NONUNIFORMSCALING: boolean;
  25945. PREMULTIPLYALPHA: boolean;
  25946. IMAGEPROCESSING: boolean;
  25947. VIGNETTE: boolean;
  25948. VIGNETTEBLENDMODEMULTIPLY: boolean;
  25949. VIGNETTEBLENDMODEOPAQUE: boolean;
  25950. TONEMAPPING: boolean;
  25951. TONEMAPPING_ACES: boolean;
  25952. CONTRAST: boolean;
  25953. COLORCURVES: boolean;
  25954. COLORGRADING: boolean;
  25955. COLORGRADING3D: boolean;
  25956. SAMPLER3DGREENDEPTH: boolean;
  25957. SAMPLER3DBGRMAP: boolean;
  25958. IMAGEPROCESSINGPOSTPROCESS: boolean;
  25959. MULTIVIEW: boolean;
  25960. /**
  25961. * If the reflection texture on this material is in linear color space
  25962. * @hidden
  25963. */
  25964. IS_REFLECTION_LINEAR: boolean;
  25965. /**
  25966. * If the refraction texture on this material is in linear color space
  25967. * @hidden
  25968. */
  25969. IS_REFRACTION_LINEAR: boolean;
  25970. EXPOSURE: boolean;
  25971. constructor();
  25972. setReflectionMode(modeToEnable: string): void;
  25973. }
  25974. /**
  25975. * This is the default material used in Babylon. It is the best trade off between quality
  25976. * and performances.
  25977. * @see http://doc.babylonjs.com/babylon101/materials
  25978. */
  25979. export class StandardMaterial extends PushMaterial {
  25980. private _diffuseTexture;
  25981. /**
  25982. * The basic texture of the material as viewed under a light.
  25983. */
  25984. diffuseTexture: Nullable<BaseTexture>;
  25985. private _ambientTexture;
  25986. /**
  25987. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  25988. */
  25989. ambientTexture: Nullable<BaseTexture>;
  25990. private _opacityTexture;
  25991. /**
  25992. * Define the transparency of the material from a texture.
  25993. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  25994. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  25995. */
  25996. opacityTexture: Nullable<BaseTexture>;
  25997. private _reflectionTexture;
  25998. /**
  25999. * Define the texture used to display the reflection.
  26000. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26001. */
  26002. reflectionTexture: Nullable<BaseTexture>;
  26003. private _emissiveTexture;
  26004. /**
  26005. * Define texture of the material as if self lit.
  26006. * This will be mixed in the final result even in the absence of light.
  26007. */
  26008. emissiveTexture: Nullable<BaseTexture>;
  26009. private _specularTexture;
  26010. /**
  26011. * Define how the color and intensity of the highlight given by the light in the material.
  26012. */
  26013. specularTexture: Nullable<BaseTexture>;
  26014. private _bumpTexture;
  26015. /**
  26016. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26017. * 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.
  26018. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26019. */
  26020. bumpTexture: Nullable<BaseTexture>;
  26021. private _lightmapTexture;
  26022. /**
  26023. * Complex lighting can be computationally expensive to compute at runtime.
  26024. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26025. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26026. */
  26027. lightmapTexture: Nullable<BaseTexture>;
  26028. private _refractionTexture;
  26029. /**
  26030. * Define the texture used to display the refraction.
  26031. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26032. */
  26033. refractionTexture: Nullable<BaseTexture>;
  26034. /**
  26035. * The color of the material lit by the environmental background lighting.
  26036. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26037. */
  26038. ambientColor: Color3;
  26039. /**
  26040. * The basic color of the material as viewed under a light.
  26041. */
  26042. diffuseColor: Color3;
  26043. /**
  26044. * Define how the color and intensity of the highlight given by the light in the material.
  26045. */
  26046. specularColor: Color3;
  26047. /**
  26048. * Define the color of the material as if self lit.
  26049. * This will be mixed in the final result even in the absence of light.
  26050. */
  26051. emissiveColor: Color3;
  26052. /**
  26053. * Defines how sharp are the highlights in the material.
  26054. * The bigger the value the sharper giving a more glossy feeling to the result.
  26055. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26056. */
  26057. specularPower: number;
  26058. private _useAlphaFromDiffuseTexture;
  26059. /**
  26060. * Does the transparency come from the diffuse texture alpha channel.
  26061. */
  26062. useAlphaFromDiffuseTexture: boolean;
  26063. private _useEmissiveAsIllumination;
  26064. /**
  26065. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26066. */
  26067. useEmissiveAsIllumination: boolean;
  26068. private _linkEmissiveWithDiffuse;
  26069. /**
  26070. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26071. * the emissive level when the final color is close to one.
  26072. */
  26073. linkEmissiveWithDiffuse: boolean;
  26074. private _useSpecularOverAlpha;
  26075. /**
  26076. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26077. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26078. */
  26079. useSpecularOverAlpha: boolean;
  26080. private _useReflectionOverAlpha;
  26081. /**
  26082. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26083. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26084. */
  26085. useReflectionOverAlpha: boolean;
  26086. private _disableLighting;
  26087. /**
  26088. * Does lights from the scene impacts this material.
  26089. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26090. */
  26091. disableLighting: boolean;
  26092. private _useObjectSpaceNormalMap;
  26093. /**
  26094. * Allows using an object space normal map (instead of tangent space).
  26095. */
  26096. useObjectSpaceNormalMap: boolean;
  26097. private _useParallax;
  26098. /**
  26099. * Is parallax enabled or not.
  26100. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26101. */
  26102. useParallax: boolean;
  26103. private _useParallaxOcclusion;
  26104. /**
  26105. * Is parallax occlusion enabled or not.
  26106. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26107. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26108. */
  26109. useParallaxOcclusion: boolean;
  26110. /**
  26111. * 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.
  26112. */
  26113. parallaxScaleBias: number;
  26114. private _roughness;
  26115. /**
  26116. * Helps to define how blurry the reflections should appears in the material.
  26117. */
  26118. roughness: number;
  26119. /**
  26120. * In case of refraction, define the value of the index of refraction.
  26121. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26122. */
  26123. indexOfRefraction: number;
  26124. /**
  26125. * Invert the refraction texture alongside the y axis.
  26126. * It can be useful with procedural textures or probe for instance.
  26127. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26128. */
  26129. invertRefractionY: boolean;
  26130. /**
  26131. * Defines the alpha limits in alpha test mode.
  26132. */
  26133. alphaCutOff: number;
  26134. private _useLightmapAsShadowmap;
  26135. /**
  26136. * In case of light mapping, define whether the map contains light or shadow informations.
  26137. */
  26138. useLightmapAsShadowmap: boolean;
  26139. private _diffuseFresnelParameters;
  26140. /**
  26141. * Define the diffuse fresnel parameters of the material.
  26142. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26143. */
  26144. diffuseFresnelParameters: FresnelParameters;
  26145. private _opacityFresnelParameters;
  26146. /**
  26147. * Define the opacity fresnel parameters of the material.
  26148. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26149. */
  26150. opacityFresnelParameters: FresnelParameters;
  26151. private _reflectionFresnelParameters;
  26152. /**
  26153. * Define the reflection fresnel parameters of the material.
  26154. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26155. */
  26156. reflectionFresnelParameters: FresnelParameters;
  26157. private _refractionFresnelParameters;
  26158. /**
  26159. * Define the refraction fresnel parameters of the material.
  26160. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26161. */
  26162. refractionFresnelParameters: FresnelParameters;
  26163. private _emissiveFresnelParameters;
  26164. /**
  26165. * Define the emissive fresnel parameters of the material.
  26166. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26167. */
  26168. emissiveFresnelParameters: FresnelParameters;
  26169. private _useReflectionFresnelFromSpecular;
  26170. /**
  26171. * If true automatically deducts the fresnels values from the material specularity.
  26172. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26173. */
  26174. useReflectionFresnelFromSpecular: boolean;
  26175. private _useGlossinessFromSpecularMapAlpha;
  26176. /**
  26177. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26178. */
  26179. useGlossinessFromSpecularMapAlpha: boolean;
  26180. private _maxSimultaneousLights;
  26181. /**
  26182. * Defines the maximum number of lights that can be used in the material
  26183. */
  26184. maxSimultaneousLights: number;
  26185. private _invertNormalMapX;
  26186. /**
  26187. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26188. */
  26189. invertNormalMapX: boolean;
  26190. private _invertNormalMapY;
  26191. /**
  26192. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26193. */
  26194. invertNormalMapY: boolean;
  26195. private _twoSidedLighting;
  26196. /**
  26197. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26198. */
  26199. twoSidedLighting: boolean;
  26200. /**
  26201. * Default configuration related to image processing available in the standard Material.
  26202. */
  26203. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26204. /**
  26205. * Gets the image processing configuration used either in this material.
  26206. */
  26207. /**
  26208. * Sets the Default image processing configuration used either in the this material.
  26209. *
  26210. * If sets to null, the scene one is in use.
  26211. */
  26212. imageProcessingConfiguration: ImageProcessingConfiguration;
  26213. /**
  26214. * Keep track of the image processing observer to allow dispose and replace.
  26215. */
  26216. private _imageProcessingObserver;
  26217. /**
  26218. * Attaches a new image processing configuration to the Standard Material.
  26219. * @param configuration
  26220. */
  26221. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26222. /**
  26223. * Gets wether the color curves effect is enabled.
  26224. */
  26225. /**
  26226. * Sets wether the color curves effect is enabled.
  26227. */
  26228. cameraColorCurvesEnabled: boolean;
  26229. /**
  26230. * Gets wether the color grading effect is enabled.
  26231. */
  26232. /**
  26233. * Gets wether the color grading effect is enabled.
  26234. */
  26235. cameraColorGradingEnabled: boolean;
  26236. /**
  26237. * Gets wether tonemapping is enabled or not.
  26238. */
  26239. /**
  26240. * Sets wether tonemapping is enabled or not
  26241. */
  26242. cameraToneMappingEnabled: boolean;
  26243. /**
  26244. * The camera exposure used on this material.
  26245. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26246. * This corresponds to a photographic exposure.
  26247. */
  26248. /**
  26249. * The camera exposure used on this material.
  26250. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26251. * This corresponds to a photographic exposure.
  26252. */
  26253. cameraExposure: number;
  26254. /**
  26255. * Gets The camera contrast used on this material.
  26256. */
  26257. /**
  26258. * Sets The camera contrast used on this material.
  26259. */
  26260. cameraContrast: number;
  26261. /**
  26262. * Gets the Color Grading 2D Lookup Texture.
  26263. */
  26264. /**
  26265. * Sets the Color Grading 2D Lookup Texture.
  26266. */
  26267. cameraColorGradingTexture: Nullable<BaseTexture>;
  26268. /**
  26269. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26270. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26271. * 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;
  26272. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26273. */
  26274. /**
  26275. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26276. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26277. * 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;
  26278. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26279. */
  26280. cameraColorCurves: Nullable<ColorCurves>;
  26281. /**
  26282. * Custom callback helping to override the default shader used in the material.
  26283. */
  26284. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26285. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26286. protected _worldViewProjectionMatrix: Matrix;
  26287. protected _globalAmbientColor: Color3;
  26288. protected _useLogarithmicDepth: boolean;
  26289. protected _rebuildInParallel: boolean;
  26290. /**
  26291. * Instantiates a new standard material.
  26292. * This is the default material used in Babylon. It is the best trade off between quality
  26293. * and performances.
  26294. * @see http://doc.babylonjs.com/babylon101/materials
  26295. * @param name Define the name of the material in the scene
  26296. * @param scene Define the scene the material belong to
  26297. */
  26298. constructor(name: string, scene: Scene);
  26299. /**
  26300. * Gets a boolean indicating that current material needs to register RTT
  26301. */
  26302. readonly hasRenderTargetTextures: boolean;
  26303. /**
  26304. * Gets the current class name of the material e.g. "StandardMaterial"
  26305. * Mainly use in serialization.
  26306. * @returns the class name
  26307. */
  26308. getClassName(): string;
  26309. /**
  26310. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26311. * You can try switching to logarithmic depth.
  26312. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26313. */
  26314. useLogarithmicDepth: boolean;
  26315. /**
  26316. * Specifies if the material will require alpha blending
  26317. * @returns a boolean specifying if alpha blending is needed
  26318. */
  26319. needAlphaBlending(): boolean;
  26320. /**
  26321. * Specifies if this material should be rendered in alpha test mode
  26322. * @returns a boolean specifying if an alpha test is needed.
  26323. */
  26324. needAlphaTesting(): boolean;
  26325. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26326. /**
  26327. * Get the texture used for alpha test purpose.
  26328. * @returns the diffuse texture in case of the standard material.
  26329. */
  26330. getAlphaTestTexture(): Nullable<BaseTexture>;
  26331. /**
  26332. * Get if the submesh is ready to be used and all its information available.
  26333. * Child classes can use it to update shaders
  26334. * @param mesh defines the mesh to check
  26335. * @param subMesh defines which submesh to check
  26336. * @param useInstances specifies that instances should be used
  26337. * @returns a boolean indicating that the submesh is ready or not
  26338. */
  26339. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26340. /**
  26341. * Builds the material UBO layouts.
  26342. * Used internally during the effect preparation.
  26343. */
  26344. buildUniformLayout(): void;
  26345. /**
  26346. * Unbinds the material from the mesh
  26347. */
  26348. unbind(): void;
  26349. /**
  26350. * Binds the submesh to this material by preparing the effect and shader to draw
  26351. * @param world defines the world transformation matrix
  26352. * @param mesh defines the mesh containing the submesh
  26353. * @param subMesh defines the submesh to bind the material to
  26354. */
  26355. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26356. /**
  26357. * Get the list of animatables in the material.
  26358. * @returns the list of animatables object used in the material
  26359. */
  26360. getAnimatables(): IAnimatable[];
  26361. /**
  26362. * Gets the active textures from the material
  26363. * @returns an array of textures
  26364. */
  26365. getActiveTextures(): BaseTexture[];
  26366. /**
  26367. * Specifies if the material uses a texture
  26368. * @param texture defines the texture to check against the material
  26369. * @returns a boolean specifying if the material uses the texture
  26370. */
  26371. hasTexture(texture: BaseTexture): boolean;
  26372. /**
  26373. * Disposes the material
  26374. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26375. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26376. */
  26377. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26378. /**
  26379. * Makes a duplicate of the material, and gives it a new name
  26380. * @param name defines the new name for the duplicated material
  26381. * @returns the cloned material
  26382. */
  26383. clone(name: string): StandardMaterial;
  26384. /**
  26385. * Serializes this material in a JSON representation
  26386. * @returns the serialized material object
  26387. */
  26388. serialize(): any;
  26389. /**
  26390. * Creates a standard material from parsed material data
  26391. * @param source defines the JSON representation of the material
  26392. * @param scene defines the hosting scene
  26393. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26394. * @returns a new standard material
  26395. */
  26396. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26397. /**
  26398. * Are diffuse textures enabled in the application.
  26399. */
  26400. static DiffuseTextureEnabled: boolean;
  26401. /**
  26402. * Are ambient textures enabled in the application.
  26403. */
  26404. static AmbientTextureEnabled: boolean;
  26405. /**
  26406. * Are opacity textures enabled in the application.
  26407. */
  26408. static OpacityTextureEnabled: boolean;
  26409. /**
  26410. * Are reflection textures enabled in the application.
  26411. */
  26412. static ReflectionTextureEnabled: boolean;
  26413. /**
  26414. * Are emissive textures enabled in the application.
  26415. */
  26416. static EmissiveTextureEnabled: boolean;
  26417. /**
  26418. * Are specular textures enabled in the application.
  26419. */
  26420. static SpecularTextureEnabled: boolean;
  26421. /**
  26422. * Are bump textures enabled in the application.
  26423. */
  26424. static BumpTextureEnabled: boolean;
  26425. /**
  26426. * Are lightmap textures enabled in the application.
  26427. */
  26428. static LightmapTextureEnabled: boolean;
  26429. /**
  26430. * Are refraction textures enabled in the application.
  26431. */
  26432. static RefractionTextureEnabled: boolean;
  26433. /**
  26434. * Are color grading textures enabled in the application.
  26435. */
  26436. static ColorGradingTextureEnabled: boolean;
  26437. /**
  26438. * Are fresnels enabled in the application.
  26439. */
  26440. static FresnelEnabled: boolean;
  26441. }
  26442. }
  26443. declare module BABYLON {
  26444. /**
  26445. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26446. *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.
  26447. * The SPS is also a particle system. It provides some methods to manage the particles.
  26448. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26449. *
  26450. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26451. */
  26452. export class SolidParticleSystem implements IDisposable {
  26453. /**
  26454. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26455. * Example : var p = SPS.particles[i];
  26456. */
  26457. particles: SolidParticle[];
  26458. /**
  26459. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26460. */
  26461. nbParticles: number;
  26462. /**
  26463. * If the particles must ever face the camera (default false). Useful for planar particles.
  26464. */
  26465. billboard: boolean;
  26466. /**
  26467. * Recompute normals when adding a shape
  26468. */
  26469. recomputeNormals: boolean;
  26470. /**
  26471. * This a counter ofr your own usage. It's not set by any SPS functions.
  26472. */
  26473. counter: number;
  26474. /**
  26475. * The SPS name. This name is also given to the underlying mesh.
  26476. */
  26477. name: string;
  26478. /**
  26479. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26480. */
  26481. mesh: Mesh;
  26482. /**
  26483. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26484. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26485. */
  26486. vars: any;
  26487. /**
  26488. * This array is populated when the SPS is set as 'pickable'.
  26489. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26490. * Each element of this array is an object `{idx: int, faceId: int}`.
  26491. * `idx` is the picked particle index in the `SPS.particles` array
  26492. * `faceId` is the picked face index counted within this particle.
  26493. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26494. */
  26495. pickedParticles: {
  26496. idx: number;
  26497. faceId: number;
  26498. }[];
  26499. /**
  26500. * This array is populated when `enableDepthSort` is set to true.
  26501. * Each element of this array is an instance of the class DepthSortedParticle.
  26502. */
  26503. depthSortedParticles: DepthSortedParticle[];
  26504. /**
  26505. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26506. * @hidden
  26507. */
  26508. _bSphereOnly: boolean;
  26509. /**
  26510. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26511. * @hidden
  26512. */
  26513. _bSphereRadiusFactor: number;
  26514. private _scene;
  26515. private _positions;
  26516. private _indices;
  26517. private _normals;
  26518. private _colors;
  26519. private _uvs;
  26520. private _indices32;
  26521. private _positions32;
  26522. private _normals32;
  26523. private _fixedNormal32;
  26524. private _colors32;
  26525. private _uvs32;
  26526. private _index;
  26527. private _updatable;
  26528. private _pickable;
  26529. private _isVisibilityBoxLocked;
  26530. private _alwaysVisible;
  26531. private _depthSort;
  26532. private _expandable;
  26533. private _shapeCounter;
  26534. private _copy;
  26535. private _color;
  26536. private _computeParticleColor;
  26537. private _computeParticleTexture;
  26538. private _computeParticleRotation;
  26539. private _computeParticleVertex;
  26540. private _computeBoundingBox;
  26541. private _depthSortParticles;
  26542. private _camera;
  26543. private _mustUnrotateFixedNormals;
  26544. private _particlesIntersect;
  26545. private _needs32Bits;
  26546. private _isNotBuilt;
  26547. private _lastParticleId;
  26548. private _idxOfId;
  26549. private _multimaterialEnabled;
  26550. private _useModelMaterial;
  26551. private _indicesByMaterial;
  26552. private _materialIndexes;
  26553. private _depthSortFunction;
  26554. private _materialSortFunction;
  26555. private _materials;
  26556. private _multimaterial;
  26557. private _materialIndexesById;
  26558. private _defaultMaterial;
  26559. private _autoUpdateSubMeshes;
  26560. /**
  26561. * Creates a SPS (Solid Particle System) object.
  26562. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26563. * @param scene (Scene) is the scene in which the SPS is added.
  26564. * @param options defines the options of the sps e.g.
  26565. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26566. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26567. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26568. * * 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.
  26569. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  26570. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26571. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26572. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26573. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26574. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26575. */
  26576. constructor(name: string, scene: Scene, options?: {
  26577. updatable?: boolean;
  26578. isPickable?: boolean;
  26579. enableDepthSort?: boolean;
  26580. particleIntersection?: boolean;
  26581. boundingSphereOnly?: boolean;
  26582. bSphereRadiusFactor?: number;
  26583. expandable?: boolean;
  26584. useModelMaterial?: boolean;
  26585. enableMultiMaterial?: boolean;
  26586. });
  26587. /**
  26588. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26589. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26590. * @returns the created mesh
  26591. */
  26592. buildMesh(): Mesh;
  26593. /**
  26594. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26595. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26596. * Thus the particles generated from `digest()` have their property `position` set yet.
  26597. * @param mesh ( Mesh ) is the mesh to be digested
  26598. * @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
  26599. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26600. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26601. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26602. * @returns the current SPS
  26603. */
  26604. digest(mesh: Mesh, options?: {
  26605. facetNb?: number;
  26606. number?: number;
  26607. delta?: number;
  26608. storage?: [];
  26609. }): SolidParticleSystem;
  26610. /**
  26611. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26612. * @hidden
  26613. */
  26614. private _unrotateFixedNormals;
  26615. /**
  26616. * Resets the temporary working copy particle
  26617. * @hidden
  26618. */
  26619. private _resetCopy;
  26620. /**
  26621. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26622. * @param p the current index in the positions array to be updated
  26623. * @param ind the current index in the indices array
  26624. * @param shape a Vector3 array, the shape geometry
  26625. * @param positions the positions array to be updated
  26626. * @param meshInd the shape indices array
  26627. * @param indices the indices array to be updated
  26628. * @param meshUV the shape uv array
  26629. * @param uvs the uv array to be updated
  26630. * @param meshCol the shape color array
  26631. * @param colors the color array to be updated
  26632. * @param meshNor the shape normals array
  26633. * @param normals the normals array to be updated
  26634. * @param idx the particle index
  26635. * @param idxInShape the particle index in its shape
  26636. * @param options the addShape() method passed options
  26637. * @model the particle model
  26638. * @hidden
  26639. */
  26640. private _meshBuilder;
  26641. /**
  26642. * Returns a shape Vector3 array from positions float array
  26643. * @param positions float array
  26644. * @returns a vector3 array
  26645. * @hidden
  26646. */
  26647. private _posToShape;
  26648. /**
  26649. * Returns a shapeUV array from a float uvs (array deep copy)
  26650. * @param uvs as a float array
  26651. * @returns a shapeUV array
  26652. * @hidden
  26653. */
  26654. private _uvsToShapeUV;
  26655. /**
  26656. * Adds a new particle object in the particles array
  26657. * @param idx particle index in particles array
  26658. * @param id particle id
  26659. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26660. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26661. * @param model particle ModelShape object
  26662. * @param shapeId model shape identifier
  26663. * @param idxInShape index of the particle in the current model
  26664. * @param bInfo model bounding info object
  26665. * @param storage target storage array, if any
  26666. * @hidden
  26667. */
  26668. private _addParticle;
  26669. /**
  26670. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26671. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26672. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26673. * @param nb (positive integer) the number of particles to be created from this model
  26674. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26675. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26676. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26677. * @returns the number of shapes in the system
  26678. */
  26679. addShape(mesh: Mesh, nb: number, options?: {
  26680. positionFunction?: any;
  26681. vertexFunction?: any;
  26682. storage?: [];
  26683. }): number;
  26684. /**
  26685. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  26686. * @hidden
  26687. */
  26688. private _rebuildParticle;
  26689. /**
  26690. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26691. * @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.
  26692. * @returns the SPS.
  26693. */
  26694. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26695. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26696. * Returns an array with the removed particles.
  26697. * 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.
  26698. * The SPS can't be empty so at least one particle needs to remain in place.
  26699. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26700. * @param start index of the first particle to remove
  26701. * @param end index of the last particle to remove (included)
  26702. * @returns an array populated with the removed particles
  26703. */
  26704. removeParticles(start: number, end: number): SolidParticle[];
  26705. /**
  26706. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  26707. * @param solidParticleArray an array populated with Solid Particles objects
  26708. * @returns the SPS
  26709. */
  26710. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  26711. /**
  26712. * Creates a new particle and modifies the SPS mesh geometry :
  26713. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  26714. * - calls _addParticle() to populate the particle array
  26715. * factorized code from addShape() and insertParticlesFromArray()
  26716. * @param idx particle index in the particles array
  26717. * @param i particle index in its shape
  26718. * @param modelShape particle ModelShape object
  26719. * @param shape shape vertex array
  26720. * @param meshInd shape indices array
  26721. * @param meshUV shape uv array
  26722. * @param meshCol shape color array
  26723. * @param meshNor shape normals array
  26724. * @param bbInfo shape bounding info
  26725. * @param storage target particle storage
  26726. * @options addShape() passed options
  26727. * @hidden
  26728. */
  26729. private _insertNewParticle;
  26730. /**
  26731. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26732. * This method calls `updateParticle()` for each particle of the SPS.
  26733. * For an animated SPS, it is usually called within the render loop.
  26734. * 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.
  26735. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26736. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26737. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26738. * @returns the SPS.
  26739. */
  26740. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26741. /**
  26742. * Disposes the SPS.
  26743. */
  26744. dispose(): void;
  26745. /**
  26746. * Returns a SolidParticle object from its identifier : particle.id
  26747. * @param id (integer) the particle Id
  26748. * @returns the searched particle or null if not found in the SPS.
  26749. */
  26750. getParticleById(id: number): Nullable<SolidParticle>;
  26751. /**
  26752. * Returns a new array populated with the particles having the passed shapeId.
  26753. * @param shapeId (integer) the shape identifier
  26754. * @returns a new solid particle array
  26755. */
  26756. getParticlesByShapeId(shapeId: number): SolidParticle[];
  26757. /**
  26758. * Populates the passed array "ref" with the particles having the passed shapeId.
  26759. * @param shapeId the shape identifier
  26760. * @returns the SPS
  26761. * @param ref
  26762. */
  26763. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  26764. /**
  26765. * Computes the required SubMeshes according the materials assigned to the particles.
  26766. * @returns the solid particle system.
  26767. * Does nothing if called before the SPS mesh is built.
  26768. */
  26769. computeSubMeshes(): SolidParticleSystem;
  26770. /**
  26771. * Sorts the solid particles by material when MultiMaterial is enabled.
  26772. * Updates the indices32 array.
  26773. * Updates the indicesByMaterial array.
  26774. * Updates the mesh indices array.
  26775. * @returns the SPS
  26776. * @hidden
  26777. */
  26778. private _sortParticlesByMaterial;
  26779. /**
  26780. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  26781. * @hidden
  26782. */
  26783. private _setMaterialIndexesById;
  26784. /**
  26785. * Returns an array with unique values of Materials from the passed array
  26786. * @param array the material array to be checked and filtered
  26787. * @hidden
  26788. */
  26789. private _filterUniqueMaterialId;
  26790. /**
  26791. * Sets a new Standard Material as _defaultMaterial if not already set.
  26792. * @hidden
  26793. */
  26794. private _setDefaultMaterial;
  26795. /**
  26796. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26797. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26798. * @returns the SPS.
  26799. */
  26800. refreshVisibleSize(): SolidParticleSystem;
  26801. /**
  26802. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26803. * @param size the size (float) of the visibility box
  26804. * note : this doesn't lock the SPS mesh bounding box.
  26805. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26806. */
  26807. setVisibilityBox(size: number): void;
  26808. /**
  26809. * Gets whether the SPS as always visible or not
  26810. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26811. */
  26812. /**
  26813. * Sets the SPS as always visible or not
  26814. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26815. */
  26816. isAlwaysVisible: boolean;
  26817. /**
  26818. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26819. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26820. */
  26821. /**
  26822. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26823. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26824. */
  26825. isVisibilityBoxLocked: boolean;
  26826. /**
  26827. * Tells to `setParticles()` to compute the particle rotations or not.
  26828. * Default value : true. The SPS is faster when it's set to false.
  26829. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26830. */
  26831. /**
  26832. * Gets if `setParticles()` computes the particle rotations or not.
  26833. * Default value : true. The SPS is faster when it's set to false.
  26834. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26835. */
  26836. computeParticleRotation: boolean;
  26837. /**
  26838. * Tells to `setParticles()` to compute the particle colors or not.
  26839. * Default value : true. The SPS is faster when it's set to false.
  26840. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26841. */
  26842. /**
  26843. * Gets if `setParticles()` computes the particle colors or not.
  26844. * Default value : true. The SPS is faster when it's set to false.
  26845. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26846. */
  26847. computeParticleColor: boolean;
  26848. /**
  26849. * Gets if `setParticles()` computes the particle textures or not.
  26850. * Default value : true. The SPS is faster when it's set to false.
  26851. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26852. */
  26853. computeParticleTexture: boolean;
  26854. /**
  26855. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26856. * Default value : false. The SPS is faster when it's set to false.
  26857. * Note : the particle custom vertex positions aren't stored values.
  26858. */
  26859. /**
  26860. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26861. * Default value : false. The SPS is faster when it's set to false.
  26862. * Note : the particle custom vertex positions aren't stored values.
  26863. */
  26864. computeParticleVertex: boolean;
  26865. /**
  26866. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26867. */
  26868. /**
  26869. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26870. */
  26871. computeBoundingBox: boolean;
  26872. /**
  26873. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26874. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26875. * Default : `true`
  26876. */
  26877. /**
  26878. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26879. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26880. * Default : `true`
  26881. */
  26882. depthSortParticles: boolean;
  26883. /**
  26884. * Gets if the SPS is created as expandable at construction time.
  26885. * Default : `false`
  26886. */
  26887. readonly expandable: boolean;
  26888. /**
  26889. * Gets if the SPS supports the Multi Materials
  26890. */
  26891. readonly multimaterialEnabled: boolean;
  26892. /**
  26893. * Gets if the SPS uses the model materials for its own multimaterial.
  26894. */
  26895. readonly useModelMaterial: boolean;
  26896. /**
  26897. * The SPS used material array.
  26898. */
  26899. readonly materials: Material[];
  26900. /**
  26901. * Sets the SPS MultiMaterial from the passed materials.
  26902. * Note : the passed array is internally copied and not used then by reference.
  26903. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  26904. */
  26905. setMultiMaterial(materials: Material[]): void;
  26906. /**
  26907. * The SPS computed multimaterial object
  26908. */
  26909. multimaterial: MultiMaterial;
  26910. /**
  26911. * If the subMeshes must be updated on the next call to setParticles()
  26912. */
  26913. autoUpdateSubMeshes: boolean;
  26914. /**
  26915. * This function does nothing. It may be overwritten to set all the particle first values.
  26916. * The SPS doesn't call this function, you may have to call it by your own.
  26917. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26918. */
  26919. initParticles(): void;
  26920. /**
  26921. * This function does nothing. It may be overwritten to recycle a particle.
  26922. * The SPS doesn't call this function, you may have to call it by your own.
  26923. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26924. * @param particle The particle to recycle
  26925. * @returns the recycled particle
  26926. */
  26927. recycleParticle(particle: SolidParticle): SolidParticle;
  26928. /**
  26929. * Updates a particle : this function should be overwritten by the user.
  26930. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26931. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26932. * @example : just set a particle position or velocity and recycle conditions
  26933. * @param particle The particle to update
  26934. * @returns the updated particle
  26935. */
  26936. updateParticle(particle: SolidParticle): SolidParticle;
  26937. /**
  26938. * Updates a vertex of a particle : it can be overwritten by the user.
  26939. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26940. * @param particle the current particle
  26941. * @param vertex the current index of the current particle
  26942. * @param pt the index of the current vertex in the particle shape
  26943. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26944. * @example : just set a vertex particle position
  26945. * @returns the updated vertex
  26946. */
  26947. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26948. /**
  26949. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26950. * This does nothing and may be overwritten by the user.
  26951. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26952. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26953. * @param update the boolean update value actually passed to setParticles()
  26954. */
  26955. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26956. /**
  26957. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26958. * This will be passed three parameters.
  26959. * This does nothing and may be overwritten by the user.
  26960. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26961. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26962. * @param update the boolean update value actually passed to setParticles()
  26963. */
  26964. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26965. }
  26966. }
  26967. declare module BABYLON {
  26968. /**
  26969. * Represents one particle of a solid particle system.
  26970. */
  26971. export class SolidParticle {
  26972. /**
  26973. * particle global index
  26974. */
  26975. idx: number;
  26976. /**
  26977. * particle identifier
  26978. */
  26979. id: number;
  26980. /**
  26981. * The color of the particle
  26982. */
  26983. color: Nullable<Color4>;
  26984. /**
  26985. * The world space position of the particle.
  26986. */
  26987. position: Vector3;
  26988. /**
  26989. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26990. */
  26991. rotation: Vector3;
  26992. /**
  26993. * The world space rotation quaternion of the particle.
  26994. */
  26995. rotationQuaternion: Nullable<Quaternion>;
  26996. /**
  26997. * The scaling of the particle.
  26998. */
  26999. scaling: Vector3;
  27000. /**
  27001. * The uvs of the particle.
  27002. */
  27003. uvs: Vector4;
  27004. /**
  27005. * The current speed of the particle.
  27006. */
  27007. velocity: Vector3;
  27008. /**
  27009. * The pivot point in the particle local space.
  27010. */
  27011. pivot: Vector3;
  27012. /**
  27013. * Must the particle be translated from its pivot point in its local space ?
  27014. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27015. * Default : false
  27016. */
  27017. translateFromPivot: boolean;
  27018. /**
  27019. * Is the particle active or not ?
  27020. */
  27021. alive: boolean;
  27022. /**
  27023. * Is the particle visible or not ?
  27024. */
  27025. isVisible: boolean;
  27026. /**
  27027. * Index of this particle in the global "positions" array (Internal use)
  27028. * @hidden
  27029. */
  27030. _pos: number;
  27031. /**
  27032. * @hidden Index of this particle in the global "indices" array (Internal use)
  27033. */
  27034. _ind: number;
  27035. /**
  27036. * @hidden ModelShape of this particle (Internal use)
  27037. */
  27038. _model: ModelShape;
  27039. /**
  27040. * ModelShape id of this particle
  27041. */
  27042. shapeId: number;
  27043. /**
  27044. * Index of the particle in its shape id
  27045. */
  27046. idxInShape: number;
  27047. /**
  27048. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27049. */
  27050. _modelBoundingInfo: BoundingInfo;
  27051. /**
  27052. * @hidden Particle BoundingInfo object (Internal use)
  27053. */
  27054. _boundingInfo: BoundingInfo;
  27055. /**
  27056. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27057. */
  27058. _sps: SolidParticleSystem;
  27059. /**
  27060. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27061. */
  27062. _stillInvisible: boolean;
  27063. /**
  27064. * @hidden Last computed particle rotation matrix
  27065. */
  27066. _rotationMatrix: number[];
  27067. /**
  27068. * Parent particle Id, if any.
  27069. * Default null.
  27070. */
  27071. parentId: Nullable<number>;
  27072. /**
  27073. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27074. */
  27075. materialIndex: Nullable<number>;
  27076. /**
  27077. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27078. * The possible values are :
  27079. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27080. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27081. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27082. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27083. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27084. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27085. * */
  27086. cullingStrategy: number;
  27087. /**
  27088. * @hidden Internal global position in the SPS.
  27089. */
  27090. _globalPosition: Vector3;
  27091. /**
  27092. * Creates a Solid Particle object.
  27093. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27094. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27095. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27096. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27097. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27098. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27099. * @param shapeId (integer) is the model shape identifier in the SPS.
  27100. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27101. * @param sps defines the sps it is associated to
  27102. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27103. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27104. */
  27105. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27106. /**
  27107. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27108. * @param target the particle target
  27109. * @returns the current particle
  27110. */
  27111. copyToRef(target: SolidParticle): SolidParticle;
  27112. /**
  27113. * Legacy support, changed scale to scaling
  27114. */
  27115. /**
  27116. * Legacy support, changed scale to scaling
  27117. */
  27118. scale: Vector3;
  27119. /**
  27120. * Legacy support, changed quaternion to rotationQuaternion
  27121. */
  27122. /**
  27123. * Legacy support, changed quaternion to rotationQuaternion
  27124. */
  27125. quaternion: Nullable<Quaternion>;
  27126. /**
  27127. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27128. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27129. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27130. * @returns true if it intersects
  27131. */
  27132. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27133. /**
  27134. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27135. * A particle is in the frustum if its bounding box intersects the frustum
  27136. * @param frustumPlanes defines the frustum to test
  27137. * @returns true if the particle is in the frustum planes
  27138. */
  27139. isInFrustum(frustumPlanes: Plane[]): boolean;
  27140. /**
  27141. * get the rotation matrix of the particle
  27142. * @hidden
  27143. */
  27144. getRotationMatrix(m: Matrix): void;
  27145. }
  27146. /**
  27147. * Represents the shape of the model used by one particle of a solid particle system.
  27148. * SPS internal tool, don't use it manually.
  27149. */
  27150. export class ModelShape {
  27151. /**
  27152. * The shape id
  27153. * @hidden
  27154. */
  27155. shapeID: number;
  27156. /**
  27157. * flat array of model positions (internal use)
  27158. * @hidden
  27159. */
  27160. _shape: Vector3[];
  27161. /**
  27162. * flat array of model UVs (internal use)
  27163. * @hidden
  27164. */
  27165. _shapeUV: number[];
  27166. /**
  27167. * color array of the model
  27168. * @hidden
  27169. */
  27170. _shapeColors: number[];
  27171. /**
  27172. * indices array of the model
  27173. * @hidden
  27174. */
  27175. _indices: number[];
  27176. /**
  27177. * normals array of the model
  27178. * @hidden
  27179. */
  27180. _normals: number[];
  27181. /**
  27182. * length of the shape in the model indices array (internal use)
  27183. * @hidden
  27184. */
  27185. _indicesLength: number;
  27186. /**
  27187. * Custom position function (internal use)
  27188. * @hidden
  27189. */
  27190. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27191. /**
  27192. * Custom vertex function (internal use)
  27193. * @hidden
  27194. */
  27195. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27196. /**
  27197. * Model material (internal use)
  27198. * @hidden
  27199. */
  27200. _material: Nullable<Material>;
  27201. /**
  27202. * 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.
  27203. * SPS internal tool, don't use it manually.
  27204. * @hidden
  27205. */
  27206. 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>);
  27207. }
  27208. /**
  27209. * Represents a Depth Sorted Particle in the solid particle system.
  27210. * @hidden
  27211. */
  27212. export class DepthSortedParticle {
  27213. /**
  27214. * Index of the particle in the "indices" array
  27215. */
  27216. ind: number;
  27217. /**
  27218. * Length of the particle shape in the "indices" array
  27219. */
  27220. indicesLength: number;
  27221. /**
  27222. * Squared distance from the particle to the camera
  27223. */
  27224. sqDistance: number;
  27225. /**
  27226. * Material index when used with MultiMaterials
  27227. */
  27228. materialIndex: number;
  27229. /**
  27230. * Creates a new sorted particle
  27231. * @param materialIndex
  27232. */
  27233. constructor(ind: number, indLength: number, materialIndex: number);
  27234. }
  27235. }
  27236. declare module BABYLON {
  27237. /**
  27238. * @hidden
  27239. */
  27240. export class _MeshCollisionData {
  27241. _checkCollisions: boolean;
  27242. _collisionMask: number;
  27243. _collisionGroup: number;
  27244. _collider: Nullable<Collider>;
  27245. _oldPositionForCollisions: Vector3;
  27246. _diffPositionForCollisions: Vector3;
  27247. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27248. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27249. }
  27250. }
  27251. declare module BABYLON {
  27252. /** @hidden */
  27253. class _FacetDataStorage {
  27254. facetPositions: Vector3[];
  27255. facetNormals: Vector3[];
  27256. facetPartitioning: number[][];
  27257. facetNb: number;
  27258. partitioningSubdivisions: number;
  27259. partitioningBBoxRatio: number;
  27260. facetDataEnabled: boolean;
  27261. facetParameters: any;
  27262. bbSize: Vector3;
  27263. subDiv: {
  27264. max: number;
  27265. X: number;
  27266. Y: number;
  27267. Z: number;
  27268. };
  27269. facetDepthSort: boolean;
  27270. facetDepthSortEnabled: boolean;
  27271. depthSortedIndices: IndicesArray;
  27272. depthSortedFacets: {
  27273. ind: number;
  27274. sqDistance: number;
  27275. }[];
  27276. facetDepthSortFunction: (f1: {
  27277. ind: number;
  27278. sqDistance: number;
  27279. }, f2: {
  27280. ind: number;
  27281. sqDistance: number;
  27282. }) => number;
  27283. facetDepthSortFrom: Vector3;
  27284. facetDepthSortOrigin: Vector3;
  27285. invertedMatrix: Matrix;
  27286. }
  27287. /**
  27288. * @hidden
  27289. **/
  27290. class _InternalAbstractMeshDataInfo {
  27291. _hasVertexAlpha: boolean;
  27292. _useVertexColors: boolean;
  27293. _numBoneInfluencers: number;
  27294. _applyFog: boolean;
  27295. _receiveShadows: boolean;
  27296. _facetData: _FacetDataStorage;
  27297. _visibility: number;
  27298. _skeleton: Nullable<Skeleton>;
  27299. _layerMask: number;
  27300. _computeBonesUsingShaders: boolean;
  27301. _isActive: boolean;
  27302. _onlyForInstances: boolean;
  27303. _isActiveIntermediate: boolean;
  27304. _onlyForInstancesIntermediate: boolean;
  27305. _actAsRegularMesh: boolean;
  27306. }
  27307. /**
  27308. * Class used to store all common mesh properties
  27309. */
  27310. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27311. /** No occlusion */
  27312. static OCCLUSION_TYPE_NONE: number;
  27313. /** Occlusion set to optimisitic */
  27314. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27315. /** Occlusion set to strict */
  27316. static OCCLUSION_TYPE_STRICT: number;
  27317. /** Use an accurante occlusion algorithm */
  27318. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27319. /** Use a conservative occlusion algorithm */
  27320. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27321. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27322. * Test order :
  27323. * Is the bounding sphere outside the frustum ?
  27324. * If not, are the bounding box vertices outside the frustum ?
  27325. * It not, then the cullable object is in the frustum.
  27326. */
  27327. static readonly CULLINGSTRATEGY_STANDARD: number;
  27328. /** Culling strategy : Bounding Sphere Only.
  27329. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27330. * It's also less accurate than the standard because some not visible objects can still be selected.
  27331. * Test : is the bounding sphere outside the frustum ?
  27332. * If not, then the cullable object is in the frustum.
  27333. */
  27334. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27335. /** Culling strategy : Optimistic Inclusion.
  27336. * This in an inclusion test first, then the standard exclusion test.
  27337. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27338. * 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.
  27339. * Anyway, it's as accurate as the standard strategy.
  27340. * Test :
  27341. * Is the cullable object bounding sphere center in the frustum ?
  27342. * If not, apply the default culling strategy.
  27343. */
  27344. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27345. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27346. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27347. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27348. * 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.
  27349. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27350. * Test :
  27351. * Is the cullable object bounding sphere center in the frustum ?
  27352. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27353. */
  27354. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27355. /**
  27356. * No billboard
  27357. */
  27358. static readonly BILLBOARDMODE_NONE: number;
  27359. /** Billboard on X axis */
  27360. static readonly BILLBOARDMODE_X: number;
  27361. /** Billboard on Y axis */
  27362. static readonly BILLBOARDMODE_Y: number;
  27363. /** Billboard on Z axis */
  27364. static readonly BILLBOARDMODE_Z: number;
  27365. /** Billboard on all axes */
  27366. static readonly BILLBOARDMODE_ALL: number;
  27367. /** Billboard on using position instead of orientation */
  27368. static readonly BILLBOARDMODE_USE_POSITION: number;
  27369. /** @hidden */
  27370. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27371. /**
  27372. * The culling strategy to use to check whether the mesh must be rendered or not.
  27373. * This value can be changed at any time and will be used on the next render mesh selection.
  27374. * The possible values are :
  27375. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27376. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27377. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27378. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27379. * Please read each static variable documentation to get details about the culling process.
  27380. * */
  27381. cullingStrategy: number;
  27382. /**
  27383. * Gets the number of facets in the mesh
  27384. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27385. */
  27386. readonly facetNb: number;
  27387. /**
  27388. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27389. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27390. */
  27391. partitioningSubdivisions: number;
  27392. /**
  27393. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27394. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27395. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27396. */
  27397. partitioningBBoxRatio: number;
  27398. /**
  27399. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27400. * Works only for updatable meshes.
  27401. * Doesn't work with multi-materials
  27402. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27403. */
  27404. mustDepthSortFacets: boolean;
  27405. /**
  27406. * The location (Vector3) where the facet depth sort must be computed from.
  27407. * By default, the active camera position.
  27408. * Used only when facet depth sort is enabled
  27409. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27410. */
  27411. facetDepthSortFrom: Vector3;
  27412. /**
  27413. * gets a boolean indicating if facetData is enabled
  27414. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27415. */
  27416. readonly isFacetDataEnabled: boolean;
  27417. /** @hidden */
  27418. _updateNonUniformScalingState(value: boolean): boolean;
  27419. /**
  27420. * An event triggered when this mesh collides with another one
  27421. */
  27422. onCollideObservable: Observable<AbstractMesh>;
  27423. /** Set a function to call when this mesh collides with another one */
  27424. onCollide: () => void;
  27425. /**
  27426. * An event triggered when the collision's position changes
  27427. */
  27428. onCollisionPositionChangeObservable: Observable<Vector3>;
  27429. /** Set a function to call when the collision's position changes */
  27430. onCollisionPositionChange: () => void;
  27431. /**
  27432. * An event triggered when material is changed
  27433. */
  27434. onMaterialChangedObservable: Observable<AbstractMesh>;
  27435. /**
  27436. * Gets or sets the orientation for POV movement & rotation
  27437. */
  27438. definedFacingForward: boolean;
  27439. /** @hidden */
  27440. _occlusionQuery: Nullable<WebGLQuery>;
  27441. /** @hidden */
  27442. _renderingGroup: Nullable<RenderingGroup>;
  27443. /**
  27444. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27445. */
  27446. /**
  27447. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27448. */
  27449. visibility: number;
  27450. /** Gets or sets the alpha index used to sort transparent meshes
  27451. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27452. */
  27453. alphaIndex: number;
  27454. /**
  27455. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27456. */
  27457. isVisible: boolean;
  27458. /**
  27459. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27460. */
  27461. isPickable: boolean;
  27462. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27463. showSubMeshesBoundingBox: boolean;
  27464. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27465. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27466. */
  27467. isBlocker: boolean;
  27468. /**
  27469. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27470. */
  27471. enablePointerMoveEvents: boolean;
  27472. /**
  27473. * Specifies the rendering group id for this mesh (0 by default)
  27474. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27475. */
  27476. renderingGroupId: number;
  27477. private _material;
  27478. /** Gets or sets current material */
  27479. material: Nullable<Material>;
  27480. /**
  27481. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27482. * @see http://doc.babylonjs.com/babylon101/shadows
  27483. */
  27484. receiveShadows: boolean;
  27485. /** Defines color to use when rendering outline */
  27486. outlineColor: Color3;
  27487. /** Define width to use when rendering outline */
  27488. outlineWidth: number;
  27489. /** Defines color to use when rendering overlay */
  27490. overlayColor: Color3;
  27491. /** Defines alpha to use when rendering overlay */
  27492. overlayAlpha: number;
  27493. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27494. hasVertexAlpha: boolean;
  27495. /** 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) */
  27496. useVertexColors: boolean;
  27497. /**
  27498. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27499. */
  27500. computeBonesUsingShaders: boolean;
  27501. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27502. numBoneInfluencers: number;
  27503. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27504. applyFog: boolean;
  27505. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27506. useOctreeForRenderingSelection: boolean;
  27507. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27508. useOctreeForPicking: boolean;
  27509. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27510. useOctreeForCollisions: boolean;
  27511. /**
  27512. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27513. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27514. */
  27515. layerMask: number;
  27516. /**
  27517. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27518. */
  27519. alwaysSelectAsActiveMesh: boolean;
  27520. /**
  27521. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27522. */
  27523. doNotSyncBoundingInfo: boolean;
  27524. /**
  27525. * Gets or sets the current action manager
  27526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27527. */
  27528. actionManager: Nullable<AbstractActionManager>;
  27529. private _meshCollisionData;
  27530. /**
  27531. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27532. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27533. */
  27534. ellipsoid: Vector3;
  27535. /**
  27536. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27537. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27538. */
  27539. ellipsoidOffset: Vector3;
  27540. /**
  27541. * Gets or sets a collision mask used to mask collisions (default is -1).
  27542. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27543. */
  27544. collisionMask: number;
  27545. /**
  27546. * Gets or sets the current collision group mask (-1 by default).
  27547. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27548. */
  27549. collisionGroup: number;
  27550. /**
  27551. * Defines edge width used when edgesRenderer is enabled
  27552. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27553. */
  27554. edgesWidth: number;
  27555. /**
  27556. * Defines edge color used when edgesRenderer is enabled
  27557. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27558. */
  27559. edgesColor: Color4;
  27560. /** @hidden */
  27561. _edgesRenderer: Nullable<IEdgesRenderer>;
  27562. /** @hidden */
  27563. _masterMesh: Nullable<AbstractMesh>;
  27564. /** @hidden */
  27565. _boundingInfo: Nullable<BoundingInfo>;
  27566. /** @hidden */
  27567. _renderId: number;
  27568. /**
  27569. * Gets or sets the list of subMeshes
  27570. * @see http://doc.babylonjs.com/how_to/multi_materials
  27571. */
  27572. subMeshes: SubMesh[];
  27573. /** @hidden */
  27574. _intersectionsInProgress: AbstractMesh[];
  27575. /** @hidden */
  27576. _unIndexed: boolean;
  27577. /** @hidden */
  27578. _lightSources: Light[];
  27579. /** Gets the list of lights affecting that mesh */
  27580. readonly lightSources: Light[];
  27581. /** @hidden */
  27582. readonly _positions: Nullable<Vector3[]>;
  27583. /** @hidden */
  27584. _waitingData: {
  27585. lods: Nullable<any>;
  27586. actions: Nullable<any>;
  27587. freezeWorldMatrix: Nullable<boolean>;
  27588. };
  27589. /** @hidden */
  27590. _bonesTransformMatrices: Nullable<Float32Array>;
  27591. /** @hidden */
  27592. _transformMatrixTexture: Nullable<RawTexture>;
  27593. /**
  27594. * Gets or sets a skeleton to apply skining transformations
  27595. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27596. */
  27597. skeleton: Nullable<Skeleton>;
  27598. /**
  27599. * An event triggered when the mesh is rebuilt.
  27600. */
  27601. onRebuildObservable: Observable<AbstractMesh>;
  27602. /**
  27603. * Creates a new AbstractMesh
  27604. * @param name defines the name of the mesh
  27605. * @param scene defines the hosting scene
  27606. */
  27607. constructor(name: string, scene?: Nullable<Scene>);
  27608. /**
  27609. * Returns the string "AbstractMesh"
  27610. * @returns "AbstractMesh"
  27611. */
  27612. getClassName(): string;
  27613. /**
  27614. * Gets a string representation of the current mesh
  27615. * @param fullDetails defines a boolean indicating if full details must be included
  27616. * @returns a string representation of the current mesh
  27617. */
  27618. toString(fullDetails?: boolean): string;
  27619. /**
  27620. * @hidden
  27621. */
  27622. protected _getEffectiveParent(): Nullable<Node>;
  27623. /** @hidden */
  27624. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27625. /** @hidden */
  27626. _rebuild(): void;
  27627. /** @hidden */
  27628. _resyncLightSources(): void;
  27629. /** @hidden */
  27630. _resyncLightSource(light: Light): void;
  27631. /** @hidden */
  27632. _unBindEffect(): void;
  27633. /** @hidden */
  27634. _removeLightSource(light: Light, dispose: boolean): void;
  27635. private _markSubMeshesAsDirty;
  27636. /** @hidden */
  27637. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27638. /** @hidden */
  27639. _markSubMeshesAsAttributesDirty(): void;
  27640. /** @hidden */
  27641. _markSubMeshesAsMiscDirty(): void;
  27642. /**
  27643. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27644. */
  27645. scaling: Vector3;
  27646. /**
  27647. * Returns true if the mesh is blocked. Implemented by child classes
  27648. */
  27649. readonly isBlocked: boolean;
  27650. /**
  27651. * Returns the mesh itself by default. Implemented by child classes
  27652. * @param camera defines the camera to use to pick the right LOD level
  27653. * @returns the currentAbstractMesh
  27654. */
  27655. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27656. /**
  27657. * Returns 0 by default. Implemented by child classes
  27658. * @returns an integer
  27659. */
  27660. getTotalVertices(): number;
  27661. /**
  27662. * Returns a positive integer : the total number of indices in this mesh geometry.
  27663. * @returns the numner of indices or zero if the mesh has no geometry.
  27664. */
  27665. getTotalIndices(): number;
  27666. /**
  27667. * Returns null by default. Implemented by child classes
  27668. * @returns null
  27669. */
  27670. getIndices(): Nullable<IndicesArray>;
  27671. /**
  27672. * Returns the array of the requested vertex data kind. Implemented by child classes
  27673. * @param kind defines the vertex data kind to use
  27674. * @returns null
  27675. */
  27676. getVerticesData(kind: string): Nullable<FloatArray>;
  27677. /**
  27678. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27679. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27680. * Note that a new underlying VertexBuffer object is created each call.
  27681. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27682. * @param kind defines vertex data kind:
  27683. * * VertexBuffer.PositionKind
  27684. * * VertexBuffer.UVKind
  27685. * * VertexBuffer.UV2Kind
  27686. * * VertexBuffer.UV3Kind
  27687. * * VertexBuffer.UV4Kind
  27688. * * VertexBuffer.UV5Kind
  27689. * * VertexBuffer.UV6Kind
  27690. * * VertexBuffer.ColorKind
  27691. * * VertexBuffer.MatricesIndicesKind
  27692. * * VertexBuffer.MatricesIndicesExtraKind
  27693. * * VertexBuffer.MatricesWeightsKind
  27694. * * VertexBuffer.MatricesWeightsExtraKind
  27695. * @param data defines the data source
  27696. * @param updatable defines if the data must be flagged as updatable (or static)
  27697. * @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
  27698. * @returns the current mesh
  27699. */
  27700. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27701. /**
  27702. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27703. * If the mesh has no geometry, it is simply returned as it is.
  27704. * @param kind defines vertex data kind:
  27705. * * VertexBuffer.PositionKind
  27706. * * VertexBuffer.UVKind
  27707. * * VertexBuffer.UV2Kind
  27708. * * VertexBuffer.UV3Kind
  27709. * * VertexBuffer.UV4Kind
  27710. * * VertexBuffer.UV5Kind
  27711. * * VertexBuffer.UV6Kind
  27712. * * VertexBuffer.ColorKind
  27713. * * VertexBuffer.MatricesIndicesKind
  27714. * * VertexBuffer.MatricesIndicesExtraKind
  27715. * * VertexBuffer.MatricesWeightsKind
  27716. * * VertexBuffer.MatricesWeightsExtraKind
  27717. * @param data defines the data source
  27718. * @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
  27719. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27720. * @returns the current mesh
  27721. */
  27722. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27723. /**
  27724. * Sets the mesh indices,
  27725. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27726. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27727. * @param totalVertices Defines the total number of vertices
  27728. * @returns the current mesh
  27729. */
  27730. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27731. /**
  27732. * Gets a boolean indicating if specific vertex data is present
  27733. * @param kind defines the vertex data kind to use
  27734. * @returns true is data kind is present
  27735. */
  27736. isVerticesDataPresent(kind: string): boolean;
  27737. /**
  27738. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27739. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27740. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27741. * @returns a BoundingInfo
  27742. */
  27743. getBoundingInfo(): BoundingInfo;
  27744. /**
  27745. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27746. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27747. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27748. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27749. * @returns the current mesh
  27750. */
  27751. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27752. /**
  27753. * Overwrite the current bounding info
  27754. * @param boundingInfo defines the new bounding info
  27755. * @returns the current mesh
  27756. */
  27757. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27758. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27759. readonly useBones: boolean;
  27760. /** @hidden */
  27761. _preActivate(): void;
  27762. /** @hidden */
  27763. _preActivateForIntermediateRendering(renderId: number): void;
  27764. /** @hidden */
  27765. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27766. /** @hidden */
  27767. _postActivate(): void;
  27768. /** @hidden */
  27769. _freeze(): void;
  27770. /** @hidden */
  27771. _unFreeze(): void;
  27772. /**
  27773. * Gets the current world matrix
  27774. * @returns a Matrix
  27775. */
  27776. getWorldMatrix(): Matrix;
  27777. /** @hidden */
  27778. _getWorldMatrixDeterminant(): number;
  27779. /**
  27780. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27781. */
  27782. readonly isAnInstance: boolean;
  27783. /**
  27784. * Gets a boolean indicating if this mesh has instances
  27785. */
  27786. readonly hasInstances: boolean;
  27787. /**
  27788. * Perform relative position change from the point of view of behind the front of the mesh.
  27789. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27790. * Supports definition of mesh facing forward or backward
  27791. * @param amountRight defines the distance on the right axis
  27792. * @param amountUp defines the distance on the up axis
  27793. * @param amountForward defines the distance on the forward axis
  27794. * @returns the current mesh
  27795. */
  27796. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27797. /**
  27798. * Calculate relative position change from the point of view of behind the front of the mesh.
  27799. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27800. * Supports definition of mesh facing forward or backward
  27801. * @param amountRight defines the distance on the right axis
  27802. * @param amountUp defines the distance on the up axis
  27803. * @param amountForward defines the distance on the forward axis
  27804. * @returns the new displacement vector
  27805. */
  27806. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27807. /**
  27808. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27809. * Supports definition of mesh facing forward or backward
  27810. * @param flipBack defines the flip
  27811. * @param twirlClockwise defines the twirl
  27812. * @param tiltRight defines the tilt
  27813. * @returns the current mesh
  27814. */
  27815. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27816. /**
  27817. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27818. * Supports definition of mesh facing forward or backward.
  27819. * @param flipBack defines the flip
  27820. * @param twirlClockwise defines the twirl
  27821. * @param tiltRight defines the tilt
  27822. * @returns the new rotation vector
  27823. */
  27824. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27825. /**
  27826. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27827. * This means the mesh underlying bounding box and sphere are recomputed.
  27828. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27829. * @returns the current mesh
  27830. */
  27831. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27832. /** @hidden */
  27833. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27834. /** @hidden */
  27835. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27836. /** @hidden */
  27837. _updateBoundingInfo(): AbstractMesh;
  27838. /** @hidden */
  27839. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27840. /** @hidden */
  27841. protected _afterComputeWorldMatrix(): void;
  27842. /** @hidden */
  27843. readonly _effectiveMesh: AbstractMesh;
  27844. /**
  27845. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27846. * A mesh is in the frustum if its bounding box intersects the frustum
  27847. * @param frustumPlanes defines the frustum to test
  27848. * @returns true if the mesh is in the frustum planes
  27849. */
  27850. isInFrustum(frustumPlanes: Plane[]): boolean;
  27851. /**
  27852. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27853. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27854. * @param frustumPlanes defines the frustum to test
  27855. * @returns true if the mesh is completely in the frustum planes
  27856. */
  27857. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27858. /**
  27859. * True if the mesh intersects another mesh or a SolidParticle object
  27860. * @param mesh defines a target mesh or SolidParticle to test
  27861. * @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)
  27862. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27863. * @returns true if there is an intersection
  27864. */
  27865. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27866. /**
  27867. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27868. * @param point defines the point to test
  27869. * @returns true if there is an intersection
  27870. */
  27871. intersectsPoint(point: Vector3): boolean;
  27872. /**
  27873. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27874. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27875. */
  27876. checkCollisions: boolean;
  27877. /**
  27878. * Gets Collider object used to compute collisions (not physics)
  27879. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27880. */
  27881. readonly collider: Nullable<Collider>;
  27882. /**
  27883. * Move the mesh using collision engine
  27884. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27885. * @param displacement defines the requested displacement vector
  27886. * @returns the current mesh
  27887. */
  27888. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27889. private _onCollisionPositionChange;
  27890. /** @hidden */
  27891. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27892. /** @hidden */
  27893. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27894. /** @hidden */
  27895. _checkCollision(collider: Collider): AbstractMesh;
  27896. /** @hidden */
  27897. _generatePointsArray(): boolean;
  27898. /**
  27899. * Checks if the passed Ray intersects with the mesh
  27900. * @param ray defines the ray to use
  27901. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27902. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27903. * @returns the picking info
  27904. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27905. */
  27906. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27907. /**
  27908. * Clones the current mesh
  27909. * @param name defines the mesh name
  27910. * @param newParent defines the new mesh parent
  27911. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27912. * @returns the new mesh
  27913. */
  27914. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27915. /**
  27916. * Disposes all the submeshes of the current meshnp
  27917. * @returns the current mesh
  27918. */
  27919. releaseSubMeshes(): AbstractMesh;
  27920. /**
  27921. * Releases resources associated with this abstract mesh.
  27922. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27923. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27924. */
  27925. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27926. /**
  27927. * Adds the passed mesh as a child to the current mesh
  27928. * @param mesh defines the child mesh
  27929. * @returns the current mesh
  27930. */
  27931. addChild(mesh: AbstractMesh): AbstractMesh;
  27932. /**
  27933. * Removes the passed mesh from the current mesh children list
  27934. * @param mesh defines the child mesh
  27935. * @returns the current mesh
  27936. */
  27937. removeChild(mesh: AbstractMesh): AbstractMesh;
  27938. /** @hidden */
  27939. private _initFacetData;
  27940. /**
  27941. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27942. * This method can be called within the render loop.
  27943. * 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
  27944. * @returns the current mesh
  27945. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27946. */
  27947. updateFacetData(): AbstractMesh;
  27948. /**
  27949. * Returns the facetLocalNormals array.
  27950. * The normals are expressed in the mesh local spac
  27951. * @returns an array of Vector3
  27952. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27953. */
  27954. getFacetLocalNormals(): Vector3[];
  27955. /**
  27956. * Returns the facetLocalPositions array.
  27957. * The facet positions are expressed in the mesh local space
  27958. * @returns an array of Vector3
  27959. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27960. */
  27961. getFacetLocalPositions(): Vector3[];
  27962. /**
  27963. * Returns the facetLocalPartioning array
  27964. * @returns an array of array of numbers
  27965. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27966. */
  27967. getFacetLocalPartitioning(): number[][];
  27968. /**
  27969. * Returns the i-th facet position in the world system.
  27970. * This method allocates a new Vector3 per call
  27971. * @param i defines the facet index
  27972. * @returns a new Vector3
  27973. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27974. */
  27975. getFacetPosition(i: number): Vector3;
  27976. /**
  27977. * Sets the reference Vector3 with the i-th facet position in the world system
  27978. * @param i defines the facet index
  27979. * @param ref defines the target vector
  27980. * @returns the current mesh
  27981. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27982. */
  27983. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27984. /**
  27985. * Returns the i-th facet normal in the world system.
  27986. * This method allocates a new Vector3 per call
  27987. * @param i defines the facet index
  27988. * @returns a new Vector3
  27989. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27990. */
  27991. getFacetNormal(i: number): Vector3;
  27992. /**
  27993. * Sets the reference Vector3 with the i-th facet normal in the world system
  27994. * @param i defines the facet index
  27995. * @param ref defines the target vector
  27996. * @returns the current mesh
  27997. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27998. */
  27999. getFacetNormalToRef(i: number, ref: Vector3): this;
  28000. /**
  28001. * 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)
  28002. * @param x defines x coordinate
  28003. * @param y defines y coordinate
  28004. * @param z defines z coordinate
  28005. * @returns the array of facet indexes
  28006. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28007. */
  28008. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28009. /**
  28010. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28011. * @param projected sets as the (x,y,z) world projection on the facet
  28012. * @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
  28013. * @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
  28014. * @param x defines x coordinate
  28015. * @param y defines y coordinate
  28016. * @param z defines z coordinate
  28017. * @returns the face index if found (or null instead)
  28018. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28019. */
  28020. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28021. /**
  28022. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28023. * @param projected sets as the (x,y,z) local projection on the facet
  28024. * @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
  28025. * @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
  28026. * @param x defines x coordinate
  28027. * @param y defines y coordinate
  28028. * @param z defines z coordinate
  28029. * @returns the face index if found (or null instead)
  28030. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28031. */
  28032. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28033. /**
  28034. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28035. * @returns the parameters
  28036. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28037. */
  28038. getFacetDataParameters(): any;
  28039. /**
  28040. * Disables the feature FacetData and frees the related memory
  28041. * @returns the current mesh
  28042. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28043. */
  28044. disableFacetData(): AbstractMesh;
  28045. /**
  28046. * Updates the AbstractMesh indices array
  28047. * @param indices defines the data source
  28048. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28049. * @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)
  28050. * @returns the current mesh
  28051. */
  28052. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28053. /**
  28054. * Creates new normals data for the mesh
  28055. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28056. * @returns the current mesh
  28057. */
  28058. createNormals(updatable: boolean): AbstractMesh;
  28059. /**
  28060. * Align the mesh with a normal
  28061. * @param normal defines the normal to use
  28062. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28063. * @returns the current mesh
  28064. */
  28065. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28066. /** @hidden */
  28067. _checkOcclusionQuery(): boolean;
  28068. /**
  28069. * Disables the mesh edge rendering mode
  28070. * @returns the currentAbstractMesh
  28071. */
  28072. disableEdgesRendering(): AbstractMesh;
  28073. /**
  28074. * Enables the edge rendering mode on the mesh.
  28075. * This mode makes the mesh edges visible
  28076. * @param epsilon defines the maximal distance between two angles to detect a face
  28077. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28078. * @returns the currentAbstractMesh
  28079. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28080. */
  28081. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28082. }
  28083. }
  28084. declare module BABYLON {
  28085. /**
  28086. * Interface used to define ActionEvent
  28087. */
  28088. export interface IActionEvent {
  28089. /** The mesh or sprite that triggered the action */
  28090. source: any;
  28091. /** The X mouse cursor position at the time of the event */
  28092. pointerX: number;
  28093. /** The Y mouse cursor position at the time of the event */
  28094. pointerY: number;
  28095. /** The mesh that is currently pointed at (can be null) */
  28096. meshUnderPointer: Nullable<AbstractMesh>;
  28097. /** the original (browser) event that triggered the ActionEvent */
  28098. sourceEvent?: any;
  28099. /** additional data for the event */
  28100. additionalData?: any;
  28101. }
  28102. /**
  28103. * ActionEvent is the event being sent when an action is triggered.
  28104. */
  28105. export class ActionEvent implements IActionEvent {
  28106. /** The mesh or sprite that triggered the action */
  28107. source: any;
  28108. /** The X mouse cursor position at the time of the event */
  28109. pointerX: number;
  28110. /** The Y mouse cursor position at the time of the event */
  28111. pointerY: number;
  28112. /** The mesh that is currently pointed at (can be null) */
  28113. meshUnderPointer: Nullable<AbstractMesh>;
  28114. /** the original (browser) event that triggered the ActionEvent */
  28115. sourceEvent?: any;
  28116. /** additional data for the event */
  28117. additionalData?: any;
  28118. /**
  28119. * Creates a new ActionEvent
  28120. * @param source The mesh or sprite that triggered the action
  28121. * @param pointerX The X mouse cursor position at the time of the event
  28122. * @param pointerY The Y mouse cursor position at the time of the event
  28123. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28124. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28125. * @param additionalData additional data for the event
  28126. */
  28127. constructor(
  28128. /** The mesh or sprite that triggered the action */
  28129. source: any,
  28130. /** The X mouse cursor position at the time of the event */
  28131. pointerX: number,
  28132. /** The Y mouse cursor position at the time of the event */
  28133. pointerY: number,
  28134. /** The mesh that is currently pointed at (can be null) */
  28135. meshUnderPointer: Nullable<AbstractMesh>,
  28136. /** the original (browser) event that triggered the ActionEvent */
  28137. sourceEvent?: any,
  28138. /** additional data for the event */
  28139. additionalData?: any);
  28140. /**
  28141. * Helper function to auto-create an ActionEvent from a source mesh.
  28142. * @param source The source mesh that triggered the event
  28143. * @param evt The original (browser) event
  28144. * @param additionalData additional data for the event
  28145. * @returns the new ActionEvent
  28146. */
  28147. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28148. /**
  28149. * Helper function to auto-create an ActionEvent from a source sprite
  28150. * @param source The source sprite that triggered the event
  28151. * @param scene Scene associated with the sprite
  28152. * @param evt The original (browser) event
  28153. * @param additionalData additional data for the event
  28154. * @returns the new ActionEvent
  28155. */
  28156. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28157. /**
  28158. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28159. * @param scene the scene where the event occurred
  28160. * @param evt The original (browser) event
  28161. * @returns the new ActionEvent
  28162. */
  28163. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28164. /**
  28165. * Helper function to auto-create an ActionEvent from a primitive
  28166. * @param prim defines the target primitive
  28167. * @param pointerPos defines the pointer position
  28168. * @param evt The original (browser) event
  28169. * @param additionalData additional data for the event
  28170. * @returns the new ActionEvent
  28171. */
  28172. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28173. }
  28174. }
  28175. declare module BABYLON {
  28176. /**
  28177. * Abstract class used to decouple action Manager from scene and meshes.
  28178. * Do not instantiate.
  28179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28180. */
  28181. export abstract class AbstractActionManager implements IDisposable {
  28182. /** Gets the list of active triggers */
  28183. static Triggers: {
  28184. [key: string]: number;
  28185. };
  28186. /** Gets the cursor to use when hovering items */
  28187. hoverCursor: string;
  28188. /** Gets the list of actions */
  28189. actions: IAction[];
  28190. /**
  28191. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28192. */
  28193. isRecursive: boolean;
  28194. /**
  28195. * Releases all associated resources
  28196. */
  28197. abstract dispose(): void;
  28198. /**
  28199. * Does this action manager has pointer triggers
  28200. */
  28201. abstract readonly hasPointerTriggers: boolean;
  28202. /**
  28203. * Does this action manager has pick triggers
  28204. */
  28205. abstract readonly hasPickTriggers: boolean;
  28206. /**
  28207. * Process a specific trigger
  28208. * @param trigger defines the trigger to process
  28209. * @param evt defines the event details to be processed
  28210. */
  28211. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28212. /**
  28213. * Does this action manager handles actions of any of the given triggers
  28214. * @param triggers defines the triggers to be tested
  28215. * @return a boolean indicating whether one (or more) of the triggers is handled
  28216. */
  28217. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28218. /**
  28219. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28220. * speed.
  28221. * @param triggerA defines the trigger to be tested
  28222. * @param triggerB defines the trigger to be tested
  28223. * @return a boolean indicating whether one (or more) of the triggers is handled
  28224. */
  28225. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28226. /**
  28227. * Does this action manager handles actions of a given trigger
  28228. * @param trigger defines the trigger to be tested
  28229. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28230. * @return whether the trigger is handled
  28231. */
  28232. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28233. /**
  28234. * Serialize this manager to a JSON object
  28235. * @param name defines the property name to store this manager
  28236. * @returns a JSON representation of this manager
  28237. */
  28238. abstract serialize(name: string): any;
  28239. /**
  28240. * Registers an action to this action manager
  28241. * @param action defines the action to be registered
  28242. * @return the action amended (prepared) after registration
  28243. */
  28244. abstract registerAction(action: IAction): Nullable<IAction>;
  28245. /**
  28246. * Unregisters an action to this action manager
  28247. * @param action defines the action to be unregistered
  28248. * @return a boolean indicating whether the action has been unregistered
  28249. */
  28250. abstract unregisterAction(action: IAction): Boolean;
  28251. /**
  28252. * Does exist one action manager with at least one trigger
  28253. **/
  28254. static readonly HasTriggers: boolean;
  28255. /**
  28256. * Does exist one action manager with at least one pick trigger
  28257. **/
  28258. static readonly HasPickTriggers: boolean;
  28259. /**
  28260. * Does exist one action manager that handles actions of a given trigger
  28261. * @param trigger defines the trigger to be tested
  28262. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28263. **/
  28264. static HasSpecificTrigger(trigger: number): boolean;
  28265. }
  28266. }
  28267. declare module BABYLON {
  28268. /**
  28269. * Defines how a node can be built from a string name.
  28270. */
  28271. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28272. /**
  28273. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28274. */
  28275. export class Node implements IBehaviorAware<Node> {
  28276. /** @hidden */
  28277. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28278. private static _NodeConstructors;
  28279. /**
  28280. * Add a new node constructor
  28281. * @param type defines the type name of the node to construct
  28282. * @param constructorFunc defines the constructor function
  28283. */
  28284. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28285. /**
  28286. * Returns a node constructor based on type name
  28287. * @param type defines the type name
  28288. * @param name defines the new node name
  28289. * @param scene defines the hosting scene
  28290. * @param options defines optional options to transmit to constructors
  28291. * @returns the new constructor or null
  28292. */
  28293. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28294. /**
  28295. * Gets or sets the name of the node
  28296. */
  28297. name: string;
  28298. /**
  28299. * Gets or sets the id of the node
  28300. */
  28301. id: string;
  28302. /**
  28303. * Gets or sets the unique id of the node
  28304. */
  28305. uniqueId: number;
  28306. /**
  28307. * Gets or sets a string used to store user defined state for the node
  28308. */
  28309. state: string;
  28310. /**
  28311. * Gets or sets an object used to store user defined information for the node
  28312. */
  28313. metadata: any;
  28314. /**
  28315. * For internal use only. Please do not use.
  28316. */
  28317. reservedDataStore: any;
  28318. /**
  28319. * List of inspectable custom properties (used by the Inspector)
  28320. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28321. */
  28322. inspectableCustomProperties: IInspectable[];
  28323. private _doNotSerialize;
  28324. /**
  28325. * Gets or sets a boolean used to define if the node must be serialized
  28326. */
  28327. doNotSerialize: boolean;
  28328. /** @hidden */
  28329. _isDisposed: boolean;
  28330. /**
  28331. * Gets a list of Animations associated with the node
  28332. */
  28333. animations: Animation[];
  28334. protected _ranges: {
  28335. [name: string]: Nullable<AnimationRange>;
  28336. };
  28337. /**
  28338. * Callback raised when the node is ready to be used
  28339. */
  28340. onReady: Nullable<(node: Node) => void>;
  28341. private _isEnabled;
  28342. private _isParentEnabled;
  28343. private _isReady;
  28344. /** @hidden */
  28345. _currentRenderId: number;
  28346. private _parentUpdateId;
  28347. /** @hidden */
  28348. _childUpdateId: number;
  28349. /** @hidden */
  28350. _waitingParentId: Nullable<string>;
  28351. /** @hidden */
  28352. _scene: Scene;
  28353. /** @hidden */
  28354. _cache: any;
  28355. private _parentNode;
  28356. private _children;
  28357. /** @hidden */
  28358. _worldMatrix: Matrix;
  28359. /** @hidden */
  28360. _worldMatrixDeterminant: number;
  28361. /** @hidden */
  28362. _worldMatrixDeterminantIsDirty: boolean;
  28363. /** @hidden */
  28364. private _sceneRootNodesIndex;
  28365. /**
  28366. * Gets a boolean indicating if the node has been disposed
  28367. * @returns true if the node was disposed
  28368. */
  28369. isDisposed(): boolean;
  28370. /**
  28371. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28372. * @see https://doc.babylonjs.com/how_to/parenting
  28373. */
  28374. parent: Nullable<Node>;
  28375. /** @hidden */
  28376. _addToSceneRootNodes(): void;
  28377. /** @hidden */
  28378. _removeFromSceneRootNodes(): void;
  28379. private _animationPropertiesOverride;
  28380. /**
  28381. * Gets or sets the animation properties override
  28382. */
  28383. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  28384. /**
  28385. * Gets a string idenfifying the name of the class
  28386. * @returns "Node" string
  28387. */
  28388. getClassName(): string;
  28389. /** @hidden */
  28390. readonly _isNode: boolean;
  28391. /**
  28392. * An event triggered when the mesh is disposed
  28393. */
  28394. onDisposeObservable: Observable<Node>;
  28395. private _onDisposeObserver;
  28396. /**
  28397. * Sets a callback that will be raised when the node will be disposed
  28398. */
  28399. onDispose: () => void;
  28400. /**
  28401. * Creates a new Node
  28402. * @param name the name and id to be given to this node
  28403. * @param scene the scene this node will be added to
  28404. */
  28405. constructor(name: string, scene?: Nullable<Scene>);
  28406. /**
  28407. * Gets the scene of the node
  28408. * @returns a scene
  28409. */
  28410. getScene(): Scene;
  28411. /**
  28412. * Gets the engine of the node
  28413. * @returns a Engine
  28414. */
  28415. getEngine(): Engine;
  28416. private _behaviors;
  28417. /**
  28418. * Attach a behavior to the node
  28419. * @see http://doc.babylonjs.com/features/behaviour
  28420. * @param behavior defines the behavior to attach
  28421. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28422. * @returns the current Node
  28423. */
  28424. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28425. /**
  28426. * Remove an attached behavior
  28427. * @see http://doc.babylonjs.com/features/behaviour
  28428. * @param behavior defines the behavior to attach
  28429. * @returns the current Node
  28430. */
  28431. removeBehavior(behavior: Behavior<Node>): Node;
  28432. /**
  28433. * Gets the list of attached behaviors
  28434. * @see http://doc.babylonjs.com/features/behaviour
  28435. */
  28436. readonly behaviors: Behavior<Node>[];
  28437. /**
  28438. * Gets an attached behavior by name
  28439. * @param name defines the name of the behavior to look for
  28440. * @see http://doc.babylonjs.com/features/behaviour
  28441. * @returns null if behavior was not found else the requested behavior
  28442. */
  28443. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28444. /**
  28445. * Returns the latest update of the World matrix
  28446. * @returns a Matrix
  28447. */
  28448. getWorldMatrix(): Matrix;
  28449. /** @hidden */
  28450. _getWorldMatrixDeterminant(): number;
  28451. /**
  28452. * Returns directly the latest state of the mesh World matrix.
  28453. * A Matrix is returned.
  28454. */
  28455. readonly worldMatrixFromCache: Matrix;
  28456. /** @hidden */
  28457. _initCache(): void;
  28458. /** @hidden */
  28459. updateCache(force?: boolean): void;
  28460. /** @hidden */
  28461. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28462. /** @hidden */
  28463. _updateCache(ignoreParentClass?: boolean): void;
  28464. /** @hidden */
  28465. _isSynchronized(): boolean;
  28466. /** @hidden */
  28467. _markSyncedWithParent(): void;
  28468. /** @hidden */
  28469. isSynchronizedWithParent(): boolean;
  28470. /** @hidden */
  28471. isSynchronized(): boolean;
  28472. /**
  28473. * Is this node ready to be used/rendered
  28474. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28475. * @return true if the node is ready
  28476. */
  28477. isReady(completeCheck?: boolean): boolean;
  28478. /**
  28479. * Is this node enabled?
  28480. * 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
  28481. * @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
  28482. * @return whether this node (and its parent) is enabled
  28483. */
  28484. isEnabled(checkAncestors?: boolean): boolean;
  28485. /** @hidden */
  28486. protected _syncParentEnabledState(): void;
  28487. /**
  28488. * Set the enabled state of this node
  28489. * @param value defines the new enabled state
  28490. */
  28491. setEnabled(value: boolean): void;
  28492. /**
  28493. * Is this node a descendant of the given node?
  28494. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28495. * @param ancestor defines the parent node to inspect
  28496. * @returns a boolean indicating if this node is a descendant of the given node
  28497. */
  28498. isDescendantOf(ancestor: Node): boolean;
  28499. /** @hidden */
  28500. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28501. /**
  28502. * Will return all nodes that have this node as ascendant
  28503. * @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
  28504. * @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
  28505. * @return all children nodes of all types
  28506. */
  28507. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28508. /**
  28509. * Get all child-meshes of this node
  28510. * @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)
  28511. * @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
  28512. * @returns an array of AbstractMesh
  28513. */
  28514. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28515. /**
  28516. * Get all direct children of this node
  28517. * @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
  28518. * @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)
  28519. * @returns an array of Node
  28520. */
  28521. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28522. /** @hidden */
  28523. _setReady(state: boolean): void;
  28524. /**
  28525. * Get an animation by name
  28526. * @param name defines the name of the animation to look for
  28527. * @returns null if not found else the requested animation
  28528. */
  28529. getAnimationByName(name: string): Nullable<Animation>;
  28530. /**
  28531. * Creates an animation range for this node
  28532. * @param name defines the name of the range
  28533. * @param from defines the starting key
  28534. * @param to defines the end key
  28535. */
  28536. createAnimationRange(name: string, from: number, to: number): void;
  28537. /**
  28538. * Delete a specific animation range
  28539. * @param name defines the name of the range to delete
  28540. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28541. */
  28542. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28543. /**
  28544. * Get an animation range by name
  28545. * @param name defines the name of the animation range to look for
  28546. * @returns null if not found else the requested animation range
  28547. */
  28548. getAnimationRange(name: string): Nullable<AnimationRange>;
  28549. /**
  28550. * Gets the list of all animation ranges defined on this node
  28551. * @returns an array
  28552. */
  28553. getAnimationRanges(): Nullable<AnimationRange>[];
  28554. /**
  28555. * Will start the animation sequence
  28556. * @param name defines the range frames for animation sequence
  28557. * @param loop defines if the animation should loop (false by default)
  28558. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28559. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28560. * @returns the object created for this animation. If range does not exist, it will return null
  28561. */
  28562. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28563. /**
  28564. * Serialize animation ranges into a JSON compatible object
  28565. * @returns serialization object
  28566. */
  28567. serializeAnimationRanges(): any;
  28568. /**
  28569. * Computes the world matrix of the node
  28570. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28571. * @returns the world matrix
  28572. */
  28573. computeWorldMatrix(force?: boolean): Matrix;
  28574. /**
  28575. * Releases resources associated with this node.
  28576. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28577. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28578. */
  28579. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28580. /**
  28581. * Parse animation range data from a serialization object and store them into a given node
  28582. * @param node defines where to store the animation ranges
  28583. * @param parsedNode defines the serialization object to read data from
  28584. * @param scene defines the hosting scene
  28585. */
  28586. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28587. /**
  28588. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28589. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28590. * @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
  28591. * @returns the new bounding vectors
  28592. */
  28593. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28594. min: Vector3;
  28595. max: Vector3;
  28596. };
  28597. }
  28598. }
  28599. declare module BABYLON {
  28600. /**
  28601. * @hidden
  28602. */
  28603. export class _IAnimationState {
  28604. key: number;
  28605. repeatCount: number;
  28606. workValue?: any;
  28607. loopMode?: number;
  28608. offsetValue?: any;
  28609. highLimitValue?: any;
  28610. }
  28611. /**
  28612. * Class used to store any kind of animation
  28613. */
  28614. export class Animation {
  28615. /**Name of the animation */
  28616. name: string;
  28617. /**Property to animate */
  28618. targetProperty: string;
  28619. /**The frames per second of the animation */
  28620. framePerSecond: number;
  28621. /**The data type of the animation */
  28622. dataType: number;
  28623. /**The loop mode of the animation */
  28624. loopMode?: number | undefined;
  28625. /**Specifies if blending should be enabled */
  28626. enableBlending?: boolean | undefined;
  28627. /**
  28628. * Use matrix interpolation instead of using direct key value when animating matrices
  28629. */
  28630. static AllowMatricesInterpolation: boolean;
  28631. /**
  28632. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28633. */
  28634. static AllowMatrixDecomposeForInterpolation: boolean;
  28635. /**
  28636. * Stores the key frames of the animation
  28637. */
  28638. private _keys;
  28639. /**
  28640. * Stores the easing function of the animation
  28641. */
  28642. private _easingFunction;
  28643. /**
  28644. * @hidden Internal use only
  28645. */
  28646. _runtimeAnimations: RuntimeAnimation[];
  28647. /**
  28648. * The set of event that will be linked to this animation
  28649. */
  28650. private _events;
  28651. /**
  28652. * Stores an array of target property paths
  28653. */
  28654. targetPropertyPath: string[];
  28655. /**
  28656. * Stores the blending speed of the animation
  28657. */
  28658. blendingSpeed: number;
  28659. /**
  28660. * Stores the animation ranges for the animation
  28661. */
  28662. private _ranges;
  28663. /**
  28664. * @hidden Internal use
  28665. */
  28666. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28667. /**
  28668. * Sets up an animation
  28669. * @param property The property to animate
  28670. * @param animationType The animation type to apply
  28671. * @param framePerSecond The frames per second of the animation
  28672. * @param easingFunction The easing function used in the animation
  28673. * @returns The created animation
  28674. */
  28675. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28676. /**
  28677. * Create and start an animation on a node
  28678. * @param name defines the name of the global animation that will be run on all nodes
  28679. * @param node defines the root node where the animation will take place
  28680. * @param targetProperty defines property to animate
  28681. * @param framePerSecond defines the number of frame per second yo use
  28682. * @param totalFrame defines the number of frames in total
  28683. * @param from defines the initial value
  28684. * @param to defines the final value
  28685. * @param loopMode defines which loop mode you want to use (off by default)
  28686. * @param easingFunction defines the easing function to use (linear by default)
  28687. * @param onAnimationEnd defines the callback to call when animation end
  28688. * @returns the animatable created for this animation
  28689. */
  28690. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28691. /**
  28692. * Create and start an animation on a node and its descendants
  28693. * @param name defines the name of the global animation that will be run on all nodes
  28694. * @param node defines the root node where the animation will take place
  28695. * @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
  28696. * @param targetProperty defines property to animate
  28697. * @param framePerSecond defines the number of frame per second to use
  28698. * @param totalFrame defines the number of frames in total
  28699. * @param from defines the initial value
  28700. * @param to defines the final value
  28701. * @param loopMode defines which loop mode you want to use (off by default)
  28702. * @param easingFunction defines the easing function to use (linear by default)
  28703. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28704. * @returns the list of animatables created for all nodes
  28705. * @example https://www.babylonjs-playground.com/#MH0VLI
  28706. */
  28707. 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[]>;
  28708. /**
  28709. * Creates a new animation, merges it with the existing animations and starts it
  28710. * @param name Name of the animation
  28711. * @param node Node which contains the scene that begins the animations
  28712. * @param targetProperty Specifies which property to animate
  28713. * @param framePerSecond The frames per second of the animation
  28714. * @param totalFrame The total number of frames
  28715. * @param from The frame at the beginning of the animation
  28716. * @param to The frame at the end of the animation
  28717. * @param loopMode Specifies the loop mode of the animation
  28718. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28719. * @param onAnimationEnd Callback to run once the animation is complete
  28720. * @returns Nullable animation
  28721. */
  28722. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28723. /**
  28724. * Transition property of an host to the target Value
  28725. * @param property The property to transition
  28726. * @param targetValue The target Value of the property
  28727. * @param host The object where the property to animate belongs
  28728. * @param scene Scene used to run the animation
  28729. * @param frameRate Framerate (in frame/s) to use
  28730. * @param transition The transition type we want to use
  28731. * @param duration The duration of the animation, in milliseconds
  28732. * @param onAnimationEnd Callback trigger at the end of the animation
  28733. * @returns Nullable animation
  28734. */
  28735. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28736. /**
  28737. * Return the array of runtime animations currently using this animation
  28738. */
  28739. readonly runtimeAnimations: RuntimeAnimation[];
  28740. /**
  28741. * Specifies if any of the runtime animations are currently running
  28742. */
  28743. readonly hasRunningRuntimeAnimations: boolean;
  28744. /**
  28745. * Initializes the animation
  28746. * @param name Name of the animation
  28747. * @param targetProperty Property to animate
  28748. * @param framePerSecond The frames per second of the animation
  28749. * @param dataType The data type of the animation
  28750. * @param loopMode The loop mode of the animation
  28751. * @param enableBlending Specifies if blending should be enabled
  28752. */
  28753. constructor(
  28754. /**Name of the animation */
  28755. name: string,
  28756. /**Property to animate */
  28757. targetProperty: string,
  28758. /**The frames per second of the animation */
  28759. framePerSecond: number,
  28760. /**The data type of the animation */
  28761. dataType: number,
  28762. /**The loop mode of the animation */
  28763. loopMode?: number | undefined,
  28764. /**Specifies if blending should be enabled */
  28765. enableBlending?: boolean | undefined);
  28766. /**
  28767. * Converts the animation to a string
  28768. * @param fullDetails support for multiple levels of logging within scene loading
  28769. * @returns String form of the animation
  28770. */
  28771. toString(fullDetails?: boolean): string;
  28772. /**
  28773. * Add an event to this animation
  28774. * @param event Event to add
  28775. */
  28776. addEvent(event: AnimationEvent): void;
  28777. /**
  28778. * Remove all events found at the given frame
  28779. * @param frame The frame to remove events from
  28780. */
  28781. removeEvents(frame: number): void;
  28782. /**
  28783. * Retrieves all the events from the animation
  28784. * @returns Events from the animation
  28785. */
  28786. getEvents(): AnimationEvent[];
  28787. /**
  28788. * Creates an animation range
  28789. * @param name Name of the animation range
  28790. * @param from Starting frame of the animation range
  28791. * @param to Ending frame of the animation
  28792. */
  28793. createRange(name: string, from: number, to: number): void;
  28794. /**
  28795. * Deletes an animation range by name
  28796. * @param name Name of the animation range to delete
  28797. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28798. */
  28799. deleteRange(name: string, deleteFrames?: boolean): void;
  28800. /**
  28801. * Gets the animation range by name, or null if not defined
  28802. * @param name Name of the animation range
  28803. * @returns Nullable animation range
  28804. */
  28805. getRange(name: string): Nullable<AnimationRange>;
  28806. /**
  28807. * Gets the key frames from the animation
  28808. * @returns The key frames of the animation
  28809. */
  28810. getKeys(): Array<IAnimationKey>;
  28811. /**
  28812. * Gets the highest frame rate of the animation
  28813. * @returns Highest frame rate of the animation
  28814. */
  28815. getHighestFrame(): number;
  28816. /**
  28817. * Gets the easing function of the animation
  28818. * @returns Easing function of the animation
  28819. */
  28820. getEasingFunction(): IEasingFunction;
  28821. /**
  28822. * Sets the easing function of the animation
  28823. * @param easingFunction A custom mathematical formula for animation
  28824. */
  28825. setEasingFunction(easingFunction: EasingFunction): void;
  28826. /**
  28827. * Interpolates a scalar linearly
  28828. * @param startValue Start value of the animation curve
  28829. * @param endValue End value of the animation curve
  28830. * @param gradient Scalar amount to interpolate
  28831. * @returns Interpolated scalar value
  28832. */
  28833. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28834. /**
  28835. * Interpolates a scalar cubically
  28836. * @param startValue Start value of the animation curve
  28837. * @param outTangent End tangent of the animation
  28838. * @param endValue End value of the animation curve
  28839. * @param inTangent Start tangent of the animation curve
  28840. * @param gradient Scalar amount to interpolate
  28841. * @returns Interpolated scalar value
  28842. */
  28843. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28844. /**
  28845. * Interpolates a quaternion using a spherical linear interpolation
  28846. * @param startValue Start value of the animation curve
  28847. * @param endValue End value of the animation curve
  28848. * @param gradient Scalar amount to interpolate
  28849. * @returns Interpolated quaternion value
  28850. */
  28851. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28852. /**
  28853. * Interpolates a quaternion cubically
  28854. * @param startValue Start value of the animation curve
  28855. * @param outTangent End tangent of the animation curve
  28856. * @param endValue End value of the animation curve
  28857. * @param inTangent Start tangent of the animation curve
  28858. * @param gradient Scalar amount to interpolate
  28859. * @returns Interpolated quaternion value
  28860. */
  28861. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28862. /**
  28863. * Interpolates a Vector3 linearl
  28864. * @param startValue Start value of the animation curve
  28865. * @param endValue End value of the animation curve
  28866. * @param gradient Scalar amount to interpolate
  28867. * @returns Interpolated scalar value
  28868. */
  28869. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28870. /**
  28871. * Interpolates a Vector3 cubically
  28872. * @param startValue Start value of the animation curve
  28873. * @param outTangent End tangent of the animation
  28874. * @param endValue End value of the animation curve
  28875. * @param inTangent Start tangent of the animation curve
  28876. * @param gradient Scalar amount to interpolate
  28877. * @returns InterpolatedVector3 value
  28878. */
  28879. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28880. /**
  28881. * Interpolates a Vector2 linearly
  28882. * @param startValue Start value of the animation curve
  28883. * @param endValue End value of the animation curve
  28884. * @param gradient Scalar amount to interpolate
  28885. * @returns Interpolated Vector2 value
  28886. */
  28887. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28888. /**
  28889. * Interpolates a Vector2 cubically
  28890. * @param startValue Start value of the animation curve
  28891. * @param outTangent End tangent of the animation
  28892. * @param endValue End value of the animation curve
  28893. * @param inTangent Start tangent of the animation curve
  28894. * @param gradient Scalar amount to interpolate
  28895. * @returns Interpolated Vector2 value
  28896. */
  28897. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28898. /**
  28899. * Interpolates a size linearly
  28900. * @param startValue Start value of the animation curve
  28901. * @param endValue End value of the animation curve
  28902. * @param gradient Scalar amount to interpolate
  28903. * @returns Interpolated Size value
  28904. */
  28905. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28906. /**
  28907. * Interpolates a Color3 linearly
  28908. * @param startValue Start value of the animation curve
  28909. * @param endValue End value of the animation curve
  28910. * @param gradient Scalar amount to interpolate
  28911. * @returns Interpolated Color3 value
  28912. */
  28913. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28914. /**
  28915. * Interpolates a Color4 linearly
  28916. * @param startValue Start value of the animation curve
  28917. * @param endValue End value of the animation curve
  28918. * @param gradient Scalar amount to interpolate
  28919. * @returns Interpolated Color3 value
  28920. */
  28921. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  28922. /**
  28923. * @hidden Internal use only
  28924. */
  28925. _getKeyValue(value: any): any;
  28926. /**
  28927. * @hidden Internal use only
  28928. */
  28929. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28930. /**
  28931. * Defines the function to use to interpolate matrices
  28932. * @param startValue defines the start matrix
  28933. * @param endValue defines the end matrix
  28934. * @param gradient defines the gradient between both matrices
  28935. * @param result defines an optional target matrix where to store the interpolation
  28936. * @returns the interpolated matrix
  28937. */
  28938. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28939. /**
  28940. * Makes a copy of the animation
  28941. * @returns Cloned animation
  28942. */
  28943. clone(): Animation;
  28944. /**
  28945. * Sets the key frames of the animation
  28946. * @param values The animation key frames to set
  28947. */
  28948. setKeys(values: Array<IAnimationKey>): void;
  28949. /**
  28950. * Serializes the animation to an object
  28951. * @returns Serialized object
  28952. */
  28953. serialize(): any;
  28954. /**
  28955. * Float animation type
  28956. */
  28957. static readonly ANIMATIONTYPE_FLOAT: number;
  28958. /**
  28959. * Vector3 animation type
  28960. */
  28961. static readonly ANIMATIONTYPE_VECTOR3: number;
  28962. /**
  28963. * Quaternion animation type
  28964. */
  28965. static readonly ANIMATIONTYPE_QUATERNION: number;
  28966. /**
  28967. * Matrix animation type
  28968. */
  28969. static readonly ANIMATIONTYPE_MATRIX: number;
  28970. /**
  28971. * Color3 animation type
  28972. */
  28973. static readonly ANIMATIONTYPE_COLOR3: number;
  28974. /**
  28975. * Color3 animation type
  28976. */
  28977. static readonly ANIMATIONTYPE_COLOR4: number;
  28978. /**
  28979. * Vector2 animation type
  28980. */
  28981. static readonly ANIMATIONTYPE_VECTOR2: number;
  28982. /**
  28983. * Size animation type
  28984. */
  28985. static readonly ANIMATIONTYPE_SIZE: number;
  28986. /**
  28987. * Relative Loop Mode
  28988. */
  28989. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28990. /**
  28991. * Cycle Loop Mode
  28992. */
  28993. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28994. /**
  28995. * Constant Loop Mode
  28996. */
  28997. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28998. /** @hidden */
  28999. static _UniversalLerp(left: any, right: any, amount: number): any;
  29000. /**
  29001. * Parses an animation object and creates an animation
  29002. * @param parsedAnimation Parsed animation object
  29003. * @returns Animation object
  29004. */
  29005. static Parse(parsedAnimation: any): Animation;
  29006. /**
  29007. * Appends the serialized animations from the source animations
  29008. * @param source Source containing the animations
  29009. * @param destination Target to store the animations
  29010. */
  29011. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29012. }
  29013. }
  29014. declare module BABYLON {
  29015. /**
  29016. * Interface containing an array of animations
  29017. */
  29018. export interface IAnimatable {
  29019. /**
  29020. * Array of animations
  29021. */
  29022. animations: Nullable<Array<Animation>>;
  29023. }
  29024. }
  29025. declare module BABYLON {
  29026. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29027. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29028. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29029. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29030. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29031. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29032. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29033. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29034. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29035. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29036. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29037. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29038. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29039. /**
  29040. * Decorator used to define property that can be serialized as reference to a camera
  29041. * @param sourceName defines the name of the property to decorate
  29042. */
  29043. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29044. /**
  29045. * Class used to help serialization objects
  29046. */
  29047. export class SerializationHelper {
  29048. /** @hidden */
  29049. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29050. /** @hidden */
  29051. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29052. /** @hidden */
  29053. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29054. /** @hidden */
  29055. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29056. /**
  29057. * Appends the serialized animations from the source animations
  29058. * @param source Source containing the animations
  29059. * @param destination Target to store the animations
  29060. */
  29061. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29062. /**
  29063. * Static function used to serialized a specific entity
  29064. * @param entity defines the entity to serialize
  29065. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29066. * @returns a JSON compatible object representing the serialization of the entity
  29067. */
  29068. static Serialize<T>(entity: T, serializationObject?: any): any;
  29069. /**
  29070. * Creates a new entity from a serialization data object
  29071. * @param creationFunction defines a function used to instanciated the new entity
  29072. * @param source defines the source serialization data
  29073. * @param scene defines the hosting scene
  29074. * @param rootUrl defines the root url for resources
  29075. * @returns a new entity
  29076. */
  29077. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29078. /**
  29079. * Clones an object
  29080. * @param creationFunction defines the function used to instanciate the new object
  29081. * @param source defines the source object
  29082. * @returns the cloned object
  29083. */
  29084. static Clone<T>(creationFunction: () => T, source: T): T;
  29085. /**
  29086. * Instanciates a new object based on a source one (some data will be shared between both object)
  29087. * @param creationFunction defines the function used to instanciate the new object
  29088. * @param source defines the source object
  29089. * @returns the new object
  29090. */
  29091. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29092. }
  29093. }
  29094. declare module BABYLON {
  29095. /**
  29096. * Class used to manipulate GUIDs
  29097. */
  29098. export class GUID {
  29099. /**
  29100. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29101. * Be aware Math.random() could cause collisions, but:
  29102. * "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"
  29103. * @returns a pseudo random id
  29104. */
  29105. static RandomId(): string;
  29106. }
  29107. }
  29108. declare module BABYLON {
  29109. /**
  29110. * Base class of all the textures in babylon.
  29111. * It groups all the common properties the materials, post process, lights... might need
  29112. * in order to make a correct use of the texture.
  29113. */
  29114. export class BaseTexture implements IAnimatable {
  29115. /**
  29116. * Default anisotropic filtering level for the application.
  29117. * It is set to 4 as a good tradeoff between perf and quality.
  29118. */
  29119. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29120. /**
  29121. * Gets or sets the unique id of the texture
  29122. */
  29123. uniqueId: number;
  29124. /**
  29125. * Define the name of the texture.
  29126. */
  29127. name: string;
  29128. /**
  29129. * Gets or sets an object used to store user defined information.
  29130. */
  29131. metadata: any;
  29132. /**
  29133. * For internal use only. Please do not use.
  29134. */
  29135. reservedDataStore: any;
  29136. private _hasAlpha;
  29137. /**
  29138. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29139. */
  29140. hasAlpha: boolean;
  29141. /**
  29142. * Defines if the alpha value should be determined via the rgb values.
  29143. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29144. */
  29145. getAlphaFromRGB: boolean;
  29146. /**
  29147. * Intensity or strength of the texture.
  29148. * It is commonly used by materials to fine tune the intensity of the texture
  29149. */
  29150. level: number;
  29151. /**
  29152. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29153. * This is part of the texture as textures usually maps to one uv set.
  29154. */
  29155. coordinatesIndex: number;
  29156. private _coordinatesMode;
  29157. /**
  29158. * How a texture is mapped.
  29159. *
  29160. * | Value | Type | Description |
  29161. * | ----- | ----------------------------------- | ----------- |
  29162. * | 0 | EXPLICIT_MODE | |
  29163. * | 1 | SPHERICAL_MODE | |
  29164. * | 2 | PLANAR_MODE | |
  29165. * | 3 | CUBIC_MODE | |
  29166. * | 4 | PROJECTION_MODE | |
  29167. * | 5 | SKYBOX_MODE | |
  29168. * | 6 | INVCUBIC_MODE | |
  29169. * | 7 | EQUIRECTANGULAR_MODE | |
  29170. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29171. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29172. */
  29173. coordinatesMode: number;
  29174. /**
  29175. * | Value | Type | Description |
  29176. * | ----- | ------------------ | ----------- |
  29177. * | 0 | CLAMP_ADDRESSMODE | |
  29178. * | 1 | WRAP_ADDRESSMODE | |
  29179. * | 2 | MIRROR_ADDRESSMODE | |
  29180. */
  29181. wrapU: number;
  29182. /**
  29183. * | Value | Type | Description |
  29184. * | ----- | ------------------ | ----------- |
  29185. * | 0 | CLAMP_ADDRESSMODE | |
  29186. * | 1 | WRAP_ADDRESSMODE | |
  29187. * | 2 | MIRROR_ADDRESSMODE | |
  29188. */
  29189. wrapV: number;
  29190. /**
  29191. * | Value | Type | Description |
  29192. * | ----- | ------------------ | ----------- |
  29193. * | 0 | CLAMP_ADDRESSMODE | |
  29194. * | 1 | WRAP_ADDRESSMODE | |
  29195. * | 2 | MIRROR_ADDRESSMODE | |
  29196. */
  29197. wrapR: number;
  29198. /**
  29199. * With compliant hardware and browser (supporting anisotropic filtering)
  29200. * this defines the level of anisotropic filtering in the texture.
  29201. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29202. */
  29203. anisotropicFilteringLevel: number;
  29204. /**
  29205. * Define if the texture is a cube texture or if false a 2d texture.
  29206. */
  29207. isCube: boolean;
  29208. /**
  29209. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29210. */
  29211. is3D: boolean;
  29212. /**
  29213. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29214. */
  29215. is2DArray: boolean;
  29216. /**
  29217. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29218. * HDR texture are usually stored in linear space.
  29219. * This only impacts the PBR and Background materials
  29220. */
  29221. gammaSpace: boolean;
  29222. /**
  29223. * Gets or sets whether or not the texture contains RGBD data.
  29224. */
  29225. isRGBD: boolean;
  29226. /**
  29227. * Is Z inverted in the texture (useful in a cube texture).
  29228. */
  29229. invertZ: boolean;
  29230. /**
  29231. * Are mip maps generated for this texture or not.
  29232. */
  29233. readonly noMipmap: boolean;
  29234. /**
  29235. * @hidden
  29236. */
  29237. lodLevelInAlpha: boolean;
  29238. /**
  29239. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29240. */
  29241. lodGenerationOffset: number;
  29242. /**
  29243. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29244. */
  29245. lodGenerationScale: number;
  29246. /**
  29247. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29248. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29249. * average roughness values.
  29250. */
  29251. linearSpecularLOD: boolean;
  29252. /**
  29253. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29254. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29255. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29256. */
  29257. irradianceTexture: Nullable<BaseTexture>;
  29258. /**
  29259. * Define if the texture is a render target.
  29260. */
  29261. isRenderTarget: boolean;
  29262. /**
  29263. * Define the unique id of the texture in the scene.
  29264. */
  29265. readonly uid: string;
  29266. /**
  29267. * Return a string representation of the texture.
  29268. * @returns the texture as a string
  29269. */
  29270. toString(): string;
  29271. /**
  29272. * Get the class name of the texture.
  29273. * @returns "BaseTexture"
  29274. */
  29275. getClassName(): string;
  29276. /**
  29277. * Define the list of animation attached to the texture.
  29278. */
  29279. animations: Animation[];
  29280. /**
  29281. * An event triggered when the texture is disposed.
  29282. */
  29283. onDisposeObservable: Observable<BaseTexture>;
  29284. private _onDisposeObserver;
  29285. /**
  29286. * Callback triggered when the texture has been disposed.
  29287. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29288. */
  29289. onDispose: () => void;
  29290. /**
  29291. * Define the current state of the loading sequence when in delayed load mode.
  29292. */
  29293. delayLoadState: number;
  29294. private _scene;
  29295. /** @hidden */
  29296. _texture: Nullable<InternalTexture>;
  29297. private _uid;
  29298. /**
  29299. * Define if the texture is preventinga material to render or not.
  29300. * If not and the texture is not ready, the engine will use a default black texture instead.
  29301. */
  29302. readonly isBlocking: boolean;
  29303. /**
  29304. * Instantiates a new BaseTexture.
  29305. * Base class of all the textures in babylon.
  29306. * It groups all the common properties the materials, post process, lights... might need
  29307. * in order to make a correct use of the texture.
  29308. * @param scene Define the scene the texture blongs to
  29309. */
  29310. constructor(scene: Nullable<Scene>);
  29311. /**
  29312. * Get the scene the texture belongs to.
  29313. * @returns the scene or null if undefined
  29314. */
  29315. getScene(): Nullable<Scene>;
  29316. /**
  29317. * Get the texture transform matrix used to offset tile the texture for istance.
  29318. * @returns the transformation matrix
  29319. */
  29320. getTextureMatrix(): Matrix;
  29321. /**
  29322. * Get the texture reflection matrix used to rotate/transform the reflection.
  29323. * @returns the reflection matrix
  29324. */
  29325. getReflectionTextureMatrix(): Matrix;
  29326. /**
  29327. * Get the underlying lower level texture from Babylon.
  29328. * @returns the insternal texture
  29329. */
  29330. getInternalTexture(): Nullable<InternalTexture>;
  29331. /**
  29332. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29333. * @returns true if ready or not blocking
  29334. */
  29335. isReadyOrNotBlocking(): boolean;
  29336. /**
  29337. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29338. * @returns true if fully ready
  29339. */
  29340. isReady(): boolean;
  29341. private _cachedSize;
  29342. /**
  29343. * Get the size of the texture.
  29344. * @returns the texture size.
  29345. */
  29346. getSize(): ISize;
  29347. /**
  29348. * Get the base size of the texture.
  29349. * It can be different from the size if the texture has been resized for POT for instance
  29350. * @returns the base size
  29351. */
  29352. getBaseSize(): ISize;
  29353. /**
  29354. * Update the sampling mode of the texture.
  29355. * Default is Trilinear mode.
  29356. *
  29357. * | Value | Type | Description |
  29358. * | ----- | ------------------ | ----------- |
  29359. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29360. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29361. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29362. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29363. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29364. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29365. * | 7 | NEAREST_LINEAR | |
  29366. * | 8 | NEAREST_NEAREST | |
  29367. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29368. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29369. * | 11 | LINEAR_LINEAR | |
  29370. * | 12 | LINEAR_NEAREST | |
  29371. *
  29372. * > _mag_: magnification filter (close to the viewer)
  29373. * > _min_: minification filter (far from the viewer)
  29374. * > _mip_: filter used between mip map levels
  29375. *@param samplingMode Define the new sampling mode of the texture
  29376. */
  29377. updateSamplingMode(samplingMode: number): void;
  29378. /**
  29379. * Scales the texture if is `canRescale()`
  29380. * @param ratio the resize factor we want to use to rescale
  29381. */
  29382. scale(ratio: number): void;
  29383. /**
  29384. * Get if the texture can rescale.
  29385. */
  29386. readonly canRescale: boolean;
  29387. /** @hidden */
  29388. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29389. /** @hidden */
  29390. _rebuild(): void;
  29391. /**
  29392. * Triggers the load sequence in delayed load mode.
  29393. */
  29394. delayLoad(): void;
  29395. /**
  29396. * Clones the texture.
  29397. * @returns the cloned texture
  29398. */
  29399. clone(): Nullable<BaseTexture>;
  29400. /**
  29401. * Get the texture underlying type (INT, FLOAT...)
  29402. */
  29403. readonly textureType: number;
  29404. /**
  29405. * Get the texture underlying format (RGB, RGBA...)
  29406. */
  29407. readonly textureFormat: number;
  29408. /**
  29409. * Indicates that textures need to be re-calculated for all materials
  29410. */
  29411. protected _markAllSubMeshesAsTexturesDirty(): void;
  29412. /**
  29413. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29414. * This will returns an RGBA array buffer containing either in values (0-255) or
  29415. * float values (0-1) depending of the underlying buffer type.
  29416. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29417. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29418. * @param buffer defines a user defined buffer to fill with data (can be null)
  29419. * @returns The Array buffer containing the pixels data.
  29420. */
  29421. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29422. /**
  29423. * Release and destroy the underlying lower level texture aka internalTexture.
  29424. */
  29425. releaseInternalTexture(): void;
  29426. /** @hidden */
  29427. readonly _lodTextureHigh: Nullable<BaseTexture>;
  29428. /** @hidden */
  29429. readonly _lodTextureMid: Nullable<BaseTexture>;
  29430. /** @hidden */
  29431. readonly _lodTextureLow: Nullable<BaseTexture>;
  29432. /**
  29433. * Dispose the texture and release its associated resources.
  29434. */
  29435. dispose(): void;
  29436. /**
  29437. * Serialize the texture into a JSON representation that can be parsed later on.
  29438. * @returns the JSON representation of the texture
  29439. */
  29440. serialize(): any;
  29441. /**
  29442. * Helper function to be called back once a list of texture contains only ready textures.
  29443. * @param textures Define the list of textures to wait for
  29444. * @param callback Define the callback triggered once the entire list will be ready
  29445. */
  29446. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29447. }
  29448. }
  29449. declare module BABYLON {
  29450. /**
  29451. * Options to be used when creating an effect.
  29452. */
  29453. export interface IEffectCreationOptions {
  29454. /**
  29455. * Atrributes that will be used in the shader.
  29456. */
  29457. attributes: string[];
  29458. /**
  29459. * Uniform varible names that will be set in the shader.
  29460. */
  29461. uniformsNames: string[];
  29462. /**
  29463. * Uniform buffer variable names that will be set in the shader.
  29464. */
  29465. uniformBuffersNames: string[];
  29466. /**
  29467. * Sampler texture variable names that will be set in the shader.
  29468. */
  29469. samplers: string[];
  29470. /**
  29471. * Define statements that will be set in the shader.
  29472. */
  29473. defines: any;
  29474. /**
  29475. * Possible fallbacks for this effect to improve performance when needed.
  29476. */
  29477. fallbacks: Nullable<IEffectFallbacks>;
  29478. /**
  29479. * Callback that will be called when the shader is compiled.
  29480. */
  29481. onCompiled: Nullable<(effect: Effect) => void>;
  29482. /**
  29483. * Callback that will be called if an error occurs during shader compilation.
  29484. */
  29485. onError: Nullable<(effect: Effect, errors: string) => void>;
  29486. /**
  29487. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29488. */
  29489. indexParameters?: any;
  29490. /**
  29491. * Max number of lights that can be used in the shader.
  29492. */
  29493. maxSimultaneousLights?: number;
  29494. /**
  29495. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29496. */
  29497. transformFeedbackVaryings?: Nullable<string[]>;
  29498. }
  29499. /**
  29500. * Effect containing vertex and fragment shader that can be executed on an object.
  29501. */
  29502. export class Effect implements IDisposable {
  29503. /**
  29504. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29505. */
  29506. static ShadersRepository: string;
  29507. /**
  29508. * Name of the effect.
  29509. */
  29510. name: any;
  29511. /**
  29512. * String container all the define statements that should be set on the shader.
  29513. */
  29514. defines: string;
  29515. /**
  29516. * Callback that will be called when the shader is compiled.
  29517. */
  29518. onCompiled: Nullable<(effect: Effect) => void>;
  29519. /**
  29520. * Callback that will be called if an error occurs during shader compilation.
  29521. */
  29522. onError: Nullable<(effect: Effect, errors: string) => void>;
  29523. /**
  29524. * Callback that will be called when effect is bound.
  29525. */
  29526. onBind: Nullable<(effect: Effect) => void>;
  29527. /**
  29528. * Unique ID of the effect.
  29529. */
  29530. uniqueId: number;
  29531. /**
  29532. * Observable that will be called when the shader is compiled.
  29533. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29534. */
  29535. onCompileObservable: Observable<Effect>;
  29536. /**
  29537. * Observable that will be called if an error occurs during shader compilation.
  29538. */
  29539. onErrorObservable: Observable<Effect>;
  29540. /** @hidden */
  29541. _onBindObservable: Nullable<Observable<Effect>>;
  29542. /**
  29543. * Observable that will be called when effect is bound.
  29544. */
  29545. readonly onBindObservable: Observable<Effect>;
  29546. /** @hidden */
  29547. _bonesComputationForcedToCPU: boolean;
  29548. private static _uniqueIdSeed;
  29549. private _engine;
  29550. private _uniformBuffersNames;
  29551. private _uniformsNames;
  29552. private _samplerList;
  29553. private _samplers;
  29554. private _isReady;
  29555. private _compilationError;
  29556. private _allFallbacksProcessed;
  29557. private _attributesNames;
  29558. private _attributes;
  29559. private _uniforms;
  29560. /**
  29561. * Key for the effect.
  29562. * @hidden
  29563. */
  29564. _key: string;
  29565. private _indexParameters;
  29566. private _fallbacks;
  29567. private _vertexSourceCode;
  29568. private _fragmentSourceCode;
  29569. private _vertexSourceCodeOverride;
  29570. private _fragmentSourceCodeOverride;
  29571. private _transformFeedbackVaryings;
  29572. /**
  29573. * Compiled shader to webGL program.
  29574. * @hidden
  29575. */
  29576. _pipelineContext: Nullable<IPipelineContext>;
  29577. private _valueCache;
  29578. private static _baseCache;
  29579. /**
  29580. * Instantiates an effect.
  29581. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29582. * @param baseName Name of the effect.
  29583. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29584. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29585. * @param samplers List of sampler variables that will be passed to the shader.
  29586. * @param engine Engine to be used to render the effect
  29587. * @param defines Define statements to be added to the shader.
  29588. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29589. * @param onCompiled Callback that will be called when the shader is compiled.
  29590. * @param onError Callback that will be called if an error occurs during shader compilation.
  29591. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29592. */
  29593. 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);
  29594. private _useFinalCode;
  29595. /**
  29596. * Unique key for this effect
  29597. */
  29598. readonly key: string;
  29599. /**
  29600. * If the effect has been compiled and prepared.
  29601. * @returns if the effect is compiled and prepared.
  29602. */
  29603. isReady(): boolean;
  29604. private _isReadyInternal;
  29605. /**
  29606. * The engine the effect was initialized with.
  29607. * @returns the engine.
  29608. */
  29609. getEngine(): Engine;
  29610. /**
  29611. * The pipeline context for this effect
  29612. * @returns the associated pipeline context
  29613. */
  29614. getPipelineContext(): Nullable<IPipelineContext>;
  29615. /**
  29616. * The set of names of attribute variables for the shader.
  29617. * @returns An array of attribute names.
  29618. */
  29619. getAttributesNames(): string[];
  29620. /**
  29621. * Returns the attribute at the given index.
  29622. * @param index The index of the attribute.
  29623. * @returns The location of the attribute.
  29624. */
  29625. getAttributeLocation(index: number): number;
  29626. /**
  29627. * Returns the attribute based on the name of the variable.
  29628. * @param name of the attribute to look up.
  29629. * @returns the attribute location.
  29630. */
  29631. getAttributeLocationByName(name: string): number;
  29632. /**
  29633. * The number of attributes.
  29634. * @returns the numnber of attributes.
  29635. */
  29636. getAttributesCount(): number;
  29637. /**
  29638. * Gets the index of a uniform variable.
  29639. * @param uniformName of the uniform to look up.
  29640. * @returns the index.
  29641. */
  29642. getUniformIndex(uniformName: string): number;
  29643. /**
  29644. * Returns the attribute based on the name of the variable.
  29645. * @param uniformName of the uniform to look up.
  29646. * @returns the location of the uniform.
  29647. */
  29648. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29649. /**
  29650. * Returns an array of sampler variable names
  29651. * @returns The array of sampler variable neames.
  29652. */
  29653. getSamplers(): string[];
  29654. /**
  29655. * The error from the last compilation.
  29656. * @returns the error string.
  29657. */
  29658. getCompilationError(): string;
  29659. /**
  29660. * Gets a boolean indicating that all fallbacks were used during compilation
  29661. * @returns true if all fallbacks were used
  29662. */
  29663. allFallbacksProcessed(): boolean;
  29664. /**
  29665. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29666. * @param func The callback to be used.
  29667. */
  29668. executeWhenCompiled(func: (effect: Effect) => void): void;
  29669. private _checkIsReady;
  29670. private _loadShader;
  29671. /**
  29672. * Recompiles the webGL program
  29673. * @param vertexSourceCode The source code for the vertex shader.
  29674. * @param fragmentSourceCode The source code for the fragment shader.
  29675. * @param onCompiled Callback called when completed.
  29676. * @param onError Callback called on error.
  29677. * @hidden
  29678. */
  29679. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29680. /**
  29681. * Prepares the effect
  29682. * @hidden
  29683. */
  29684. _prepareEffect(): void;
  29685. private _processCompilationErrors;
  29686. /**
  29687. * Checks if the effect is supported. (Must be called after compilation)
  29688. */
  29689. readonly isSupported: boolean;
  29690. /**
  29691. * Binds a texture to the engine to be used as output of the shader.
  29692. * @param channel Name of the output variable.
  29693. * @param texture Texture to bind.
  29694. * @hidden
  29695. */
  29696. _bindTexture(channel: string, texture: InternalTexture): void;
  29697. /**
  29698. * Sets a texture on the engine to be used in the shader.
  29699. * @param channel Name of the sampler variable.
  29700. * @param texture Texture to set.
  29701. */
  29702. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29703. /**
  29704. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29705. * @param channel Name of the sampler variable.
  29706. * @param texture Texture to set.
  29707. */
  29708. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29709. /**
  29710. * Sets an array of textures on the engine to be used in the shader.
  29711. * @param channel Name of the variable.
  29712. * @param textures Textures to set.
  29713. */
  29714. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29715. /**
  29716. * 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)
  29717. * @param channel Name of the sampler variable.
  29718. * @param postProcess Post process to get the input texture from.
  29719. */
  29720. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29721. /**
  29722. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29723. * 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)
  29724. * @param channel Name of the sampler variable.
  29725. * @param postProcess Post process to get the output texture from.
  29726. */
  29727. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29728. /** @hidden */
  29729. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29730. /** @hidden */
  29731. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29732. /** @hidden */
  29733. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29734. /** @hidden */
  29735. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29736. /**
  29737. * Binds a buffer to a uniform.
  29738. * @param buffer Buffer to bind.
  29739. * @param name Name of the uniform variable to bind to.
  29740. */
  29741. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29742. /**
  29743. * Binds block to a uniform.
  29744. * @param blockName Name of the block to bind.
  29745. * @param index Index to bind.
  29746. */
  29747. bindUniformBlock(blockName: string, index: number): void;
  29748. /**
  29749. * Sets an interger value on a uniform variable.
  29750. * @param uniformName Name of the variable.
  29751. * @param value Value to be set.
  29752. * @returns this effect.
  29753. */
  29754. setInt(uniformName: string, value: number): Effect;
  29755. /**
  29756. * Sets an int array on a uniform variable.
  29757. * @param uniformName Name of the variable.
  29758. * @param array array to be set.
  29759. * @returns this effect.
  29760. */
  29761. setIntArray(uniformName: string, array: Int32Array): Effect;
  29762. /**
  29763. * 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)
  29764. * @param uniformName Name of the variable.
  29765. * @param array array to be set.
  29766. * @returns this effect.
  29767. */
  29768. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29769. /**
  29770. * 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)
  29771. * @param uniformName Name of the variable.
  29772. * @param array array to be set.
  29773. * @returns this effect.
  29774. */
  29775. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29776. /**
  29777. * 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)
  29778. * @param uniformName Name of the variable.
  29779. * @param array array to be set.
  29780. * @returns this effect.
  29781. */
  29782. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29783. /**
  29784. * Sets an float array on a uniform variable.
  29785. * @param uniformName Name of the variable.
  29786. * @param array array to be set.
  29787. * @returns this effect.
  29788. */
  29789. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29790. /**
  29791. * 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)
  29792. * @param uniformName Name of the variable.
  29793. * @param array array to be set.
  29794. * @returns this effect.
  29795. */
  29796. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29797. /**
  29798. * 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)
  29799. * @param uniformName Name of the variable.
  29800. * @param array array to be set.
  29801. * @returns this effect.
  29802. */
  29803. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29804. /**
  29805. * 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)
  29806. * @param uniformName Name of the variable.
  29807. * @param array array to be set.
  29808. * @returns this effect.
  29809. */
  29810. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29811. /**
  29812. * Sets an array on a uniform variable.
  29813. * @param uniformName Name of the variable.
  29814. * @param array array to be set.
  29815. * @returns this effect.
  29816. */
  29817. setArray(uniformName: string, array: number[]): Effect;
  29818. /**
  29819. * 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)
  29820. * @param uniformName Name of the variable.
  29821. * @param array array to be set.
  29822. * @returns this effect.
  29823. */
  29824. setArray2(uniformName: string, array: number[]): Effect;
  29825. /**
  29826. * 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)
  29827. * @param uniformName Name of the variable.
  29828. * @param array array to be set.
  29829. * @returns this effect.
  29830. */
  29831. setArray3(uniformName: string, array: number[]): Effect;
  29832. /**
  29833. * 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)
  29834. * @param uniformName Name of the variable.
  29835. * @param array array to be set.
  29836. * @returns this effect.
  29837. */
  29838. setArray4(uniformName: string, array: number[]): Effect;
  29839. /**
  29840. * Sets matrices on a uniform variable.
  29841. * @param uniformName Name of the variable.
  29842. * @param matrices matrices to be set.
  29843. * @returns this effect.
  29844. */
  29845. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29846. /**
  29847. * Sets matrix on a uniform variable.
  29848. * @param uniformName Name of the variable.
  29849. * @param matrix matrix to be set.
  29850. * @returns this effect.
  29851. */
  29852. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29853. /**
  29854. * 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)
  29855. * @param uniformName Name of the variable.
  29856. * @param matrix matrix to be set.
  29857. * @returns this effect.
  29858. */
  29859. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29860. /**
  29861. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29862. * @param uniformName Name of the variable.
  29863. * @param matrix matrix to be set.
  29864. * @returns this effect.
  29865. */
  29866. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29867. /**
  29868. * Sets a float on a uniform variable.
  29869. * @param uniformName Name of the variable.
  29870. * @param value value to be set.
  29871. * @returns this effect.
  29872. */
  29873. setFloat(uniformName: string, value: number): Effect;
  29874. /**
  29875. * Sets a boolean on a uniform variable.
  29876. * @param uniformName Name of the variable.
  29877. * @param bool value to be set.
  29878. * @returns this effect.
  29879. */
  29880. setBool(uniformName: string, bool: boolean): Effect;
  29881. /**
  29882. * Sets a Vector2 on a uniform variable.
  29883. * @param uniformName Name of the variable.
  29884. * @param vector2 vector2 to be set.
  29885. * @returns this effect.
  29886. */
  29887. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29888. /**
  29889. * Sets a float2 on a uniform variable.
  29890. * @param uniformName Name of the variable.
  29891. * @param x First float in float2.
  29892. * @param y Second float in float2.
  29893. * @returns this effect.
  29894. */
  29895. setFloat2(uniformName: string, x: number, y: number): Effect;
  29896. /**
  29897. * Sets a Vector3 on a uniform variable.
  29898. * @param uniformName Name of the variable.
  29899. * @param vector3 Value to be set.
  29900. * @returns this effect.
  29901. */
  29902. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29903. /**
  29904. * Sets a float3 on a uniform variable.
  29905. * @param uniformName Name of the variable.
  29906. * @param x First float in float3.
  29907. * @param y Second float in float3.
  29908. * @param z Third float in float3.
  29909. * @returns this effect.
  29910. */
  29911. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29912. /**
  29913. * Sets a Vector4 on a uniform variable.
  29914. * @param uniformName Name of the variable.
  29915. * @param vector4 Value to be set.
  29916. * @returns this effect.
  29917. */
  29918. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29919. /**
  29920. * Sets a float4 on a uniform variable.
  29921. * @param uniformName Name of the variable.
  29922. * @param x First float in float4.
  29923. * @param y Second float in float4.
  29924. * @param z Third float in float4.
  29925. * @param w Fourth float in float4.
  29926. * @returns this effect.
  29927. */
  29928. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29929. /**
  29930. * Sets a Color3 on a uniform variable.
  29931. * @param uniformName Name of the variable.
  29932. * @param color3 Value to be set.
  29933. * @returns this effect.
  29934. */
  29935. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29936. /**
  29937. * Sets a Color4 on a uniform variable.
  29938. * @param uniformName Name of the variable.
  29939. * @param color3 Value to be set.
  29940. * @param alpha Alpha value to be set.
  29941. * @returns this effect.
  29942. */
  29943. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29944. /**
  29945. * Sets a Color4 on a uniform variable
  29946. * @param uniformName defines the name of the variable
  29947. * @param color4 defines the value to be set
  29948. * @returns this effect.
  29949. */
  29950. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29951. /** Release all associated resources */
  29952. dispose(): void;
  29953. /**
  29954. * This function will add a new shader to the shader store
  29955. * @param name the name of the shader
  29956. * @param pixelShader optional pixel shader content
  29957. * @param vertexShader optional vertex shader content
  29958. */
  29959. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29960. /**
  29961. * Store of each shader (The can be looked up using effect.key)
  29962. */
  29963. static ShadersStore: {
  29964. [key: string]: string;
  29965. };
  29966. /**
  29967. * Store of each included file for a shader (The can be looked up using effect.key)
  29968. */
  29969. static IncludesShadersStore: {
  29970. [key: string]: string;
  29971. };
  29972. /**
  29973. * Resets the cache of effects.
  29974. */
  29975. static ResetCache(): void;
  29976. }
  29977. }
  29978. declare module BABYLON {
  29979. /**
  29980. * Interface used to describe the capabilities of the engine relatively to the current browser
  29981. */
  29982. export interface EngineCapabilities {
  29983. /** Maximum textures units per fragment shader */
  29984. maxTexturesImageUnits: number;
  29985. /** Maximum texture units per vertex shader */
  29986. maxVertexTextureImageUnits: number;
  29987. /** Maximum textures units in the entire pipeline */
  29988. maxCombinedTexturesImageUnits: number;
  29989. /** Maximum texture size */
  29990. maxTextureSize: number;
  29991. /** Maximum texture samples */
  29992. maxSamples?: number;
  29993. /** Maximum cube texture size */
  29994. maxCubemapTextureSize: number;
  29995. /** Maximum render texture size */
  29996. maxRenderTextureSize: number;
  29997. /** Maximum number of vertex attributes */
  29998. maxVertexAttribs: number;
  29999. /** Maximum number of varyings */
  30000. maxVaryingVectors: number;
  30001. /** Maximum number of uniforms per vertex shader */
  30002. maxVertexUniformVectors: number;
  30003. /** Maximum number of uniforms per fragment shader */
  30004. maxFragmentUniformVectors: number;
  30005. /** Defines if standard derivates (dx/dy) are supported */
  30006. standardDerivatives: boolean;
  30007. /** Defines if s3tc texture compression is supported */
  30008. s3tc?: WEBGL_compressed_texture_s3tc;
  30009. /** Defines if pvrtc texture compression is supported */
  30010. pvrtc: any;
  30011. /** Defines if etc1 texture compression is supported */
  30012. etc1: any;
  30013. /** Defines if etc2 texture compression is supported */
  30014. etc2: any;
  30015. /** Defines if astc texture compression is supported */
  30016. astc: any;
  30017. /** Defines if float textures are supported */
  30018. textureFloat: boolean;
  30019. /** Defines if vertex array objects are supported */
  30020. vertexArrayObject: boolean;
  30021. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30022. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30023. /** Gets the maximum level of anisotropy supported */
  30024. maxAnisotropy: number;
  30025. /** Defines if instancing is supported */
  30026. instancedArrays: boolean;
  30027. /** Defines if 32 bits indices are supported */
  30028. uintIndices: boolean;
  30029. /** Defines if high precision shaders are supported */
  30030. highPrecisionShaderSupported: boolean;
  30031. /** Defines if depth reading in the fragment shader is supported */
  30032. fragmentDepthSupported: boolean;
  30033. /** Defines if float texture linear filtering is supported*/
  30034. textureFloatLinearFiltering: boolean;
  30035. /** Defines if rendering to float textures is supported */
  30036. textureFloatRender: boolean;
  30037. /** Defines if half float textures are supported*/
  30038. textureHalfFloat: boolean;
  30039. /** Defines if half float texture linear filtering is supported*/
  30040. textureHalfFloatLinearFiltering: boolean;
  30041. /** Defines if rendering to half float textures is supported */
  30042. textureHalfFloatRender: boolean;
  30043. /** Defines if textureLOD shader command is supported */
  30044. textureLOD: boolean;
  30045. /** Defines if draw buffers extension is supported */
  30046. drawBuffersExtension: boolean;
  30047. /** Defines if depth textures are supported */
  30048. depthTextureExtension: boolean;
  30049. /** Defines if float color buffer are supported */
  30050. colorBufferFloat: boolean;
  30051. /** Gets disjoint timer query extension (null if not supported) */
  30052. timerQuery?: EXT_disjoint_timer_query;
  30053. /** Defines if timestamp can be used with timer query */
  30054. canUseTimestampForTimerQuery: boolean;
  30055. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30056. multiview?: any;
  30057. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30058. oculusMultiview?: any;
  30059. /** Function used to let the system compiles shaders in background */
  30060. parallelShaderCompile?: {
  30061. COMPLETION_STATUS_KHR: number;
  30062. };
  30063. /** Max number of texture samples for MSAA */
  30064. maxMSAASamples: number;
  30065. /** Defines if the blend min max extension is supported */
  30066. blendMinMax: boolean;
  30067. }
  30068. }
  30069. declare module BABYLON {
  30070. /**
  30071. * @hidden
  30072. **/
  30073. export class DepthCullingState {
  30074. private _isDepthTestDirty;
  30075. private _isDepthMaskDirty;
  30076. private _isDepthFuncDirty;
  30077. private _isCullFaceDirty;
  30078. private _isCullDirty;
  30079. private _isZOffsetDirty;
  30080. private _isFrontFaceDirty;
  30081. private _depthTest;
  30082. private _depthMask;
  30083. private _depthFunc;
  30084. private _cull;
  30085. private _cullFace;
  30086. private _zOffset;
  30087. private _frontFace;
  30088. /**
  30089. * Initializes the state.
  30090. */
  30091. constructor();
  30092. readonly isDirty: boolean;
  30093. zOffset: number;
  30094. cullFace: Nullable<number>;
  30095. cull: Nullable<boolean>;
  30096. depthFunc: Nullable<number>;
  30097. depthMask: boolean;
  30098. depthTest: boolean;
  30099. frontFace: Nullable<number>;
  30100. reset(): void;
  30101. apply(gl: WebGLRenderingContext): void;
  30102. }
  30103. }
  30104. declare module BABYLON {
  30105. /**
  30106. * @hidden
  30107. **/
  30108. export class StencilState {
  30109. /** 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 */
  30110. static readonly ALWAYS: number;
  30111. /** Passed to stencilOperation to specify that stencil value must be kept */
  30112. static readonly KEEP: number;
  30113. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30114. static readonly REPLACE: number;
  30115. private _isStencilTestDirty;
  30116. private _isStencilMaskDirty;
  30117. private _isStencilFuncDirty;
  30118. private _isStencilOpDirty;
  30119. private _stencilTest;
  30120. private _stencilMask;
  30121. private _stencilFunc;
  30122. private _stencilFuncRef;
  30123. private _stencilFuncMask;
  30124. private _stencilOpStencilFail;
  30125. private _stencilOpDepthFail;
  30126. private _stencilOpStencilDepthPass;
  30127. readonly isDirty: boolean;
  30128. stencilFunc: number;
  30129. stencilFuncRef: number;
  30130. stencilFuncMask: number;
  30131. stencilOpStencilFail: number;
  30132. stencilOpDepthFail: number;
  30133. stencilOpStencilDepthPass: number;
  30134. stencilMask: number;
  30135. stencilTest: boolean;
  30136. constructor();
  30137. reset(): void;
  30138. apply(gl: WebGLRenderingContext): void;
  30139. }
  30140. }
  30141. declare module BABYLON {
  30142. /**
  30143. * @hidden
  30144. **/
  30145. export class AlphaState {
  30146. private _isAlphaBlendDirty;
  30147. private _isBlendFunctionParametersDirty;
  30148. private _isBlendEquationParametersDirty;
  30149. private _isBlendConstantsDirty;
  30150. private _alphaBlend;
  30151. private _blendFunctionParameters;
  30152. private _blendEquationParameters;
  30153. private _blendConstants;
  30154. /**
  30155. * Initializes the state.
  30156. */
  30157. constructor();
  30158. readonly isDirty: boolean;
  30159. alphaBlend: boolean;
  30160. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30161. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30162. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30163. reset(): void;
  30164. apply(gl: WebGLRenderingContext): void;
  30165. }
  30166. }
  30167. declare module BABYLON {
  30168. /** @hidden */
  30169. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30170. attributeProcessor(attribute: string): string;
  30171. varyingProcessor(varying: string, isFragment: boolean): string;
  30172. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30173. }
  30174. }
  30175. declare module BABYLON {
  30176. /**
  30177. * Interface for attribute information associated with buffer instanciation
  30178. */
  30179. export interface InstancingAttributeInfo {
  30180. /**
  30181. * Index/offset of the attribute in the vertex shader
  30182. */
  30183. index: number;
  30184. /**
  30185. * size of the attribute, 1, 2, 3 or 4
  30186. */
  30187. attributeSize: number;
  30188. /**
  30189. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30190. * default is FLOAT
  30191. */
  30192. attributeType: number;
  30193. /**
  30194. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30195. */
  30196. normalized: boolean;
  30197. /**
  30198. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30199. */
  30200. offset: number;
  30201. /**
  30202. * Name of the GLSL attribute, for debugging purpose only
  30203. */
  30204. attributeName: string;
  30205. }
  30206. }
  30207. declare module BABYLON {
  30208. interface ThinEngine {
  30209. /**
  30210. * Update a video texture
  30211. * @param texture defines the texture to update
  30212. * @param video defines the video element to use
  30213. * @param invertY defines if data must be stored with Y axis inverted
  30214. */
  30215. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30216. }
  30217. }
  30218. declare module BABYLON {
  30219. /**
  30220. * Settings for finer control over video usage
  30221. */
  30222. export interface VideoTextureSettings {
  30223. /**
  30224. * Applies `autoplay` to video, if specified
  30225. */
  30226. autoPlay?: boolean;
  30227. /**
  30228. * Applies `loop` to video, if specified
  30229. */
  30230. loop?: boolean;
  30231. /**
  30232. * Automatically updates internal texture from video at every frame in the render loop
  30233. */
  30234. autoUpdateTexture: boolean;
  30235. /**
  30236. * Image src displayed during the video loading or until the user interacts with the video.
  30237. */
  30238. poster?: string;
  30239. }
  30240. /**
  30241. * If you want to display a video in your scene, this is the special texture for that.
  30242. * This special texture works similar to other textures, with the exception of a few parameters.
  30243. * @see https://doc.babylonjs.com/how_to/video_texture
  30244. */
  30245. export class VideoTexture extends Texture {
  30246. /**
  30247. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30248. */
  30249. readonly autoUpdateTexture: boolean;
  30250. /**
  30251. * The video instance used by the texture internally
  30252. */
  30253. readonly video: HTMLVideoElement;
  30254. private _onUserActionRequestedObservable;
  30255. /**
  30256. * Event triggerd when a dom action is required by the user to play the video.
  30257. * This happens due to recent changes in browser policies preventing video to auto start.
  30258. */
  30259. readonly onUserActionRequestedObservable: Observable<Texture>;
  30260. private _generateMipMaps;
  30261. private _engine;
  30262. private _stillImageCaptured;
  30263. private _displayingPosterTexture;
  30264. private _settings;
  30265. private _createInternalTextureOnEvent;
  30266. private _frameId;
  30267. /**
  30268. * Creates a video texture.
  30269. * If you want to display a video in your scene, this is the special texture for that.
  30270. * This special texture works similar to other textures, with the exception of a few parameters.
  30271. * @see https://doc.babylonjs.com/how_to/video_texture
  30272. * @param name optional name, will detect from video source, if not defined
  30273. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30274. * @param scene is obviously the current scene.
  30275. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30276. * @param invertY is false by default but can be used to invert video on Y axis
  30277. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30278. * @param settings allows finer control over video usage
  30279. */
  30280. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30281. private _getName;
  30282. private _getVideo;
  30283. private _createInternalTexture;
  30284. private reset;
  30285. /**
  30286. * @hidden Internal method to initiate `update`.
  30287. */
  30288. _rebuild(): void;
  30289. /**
  30290. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30291. */
  30292. update(): void;
  30293. /**
  30294. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30295. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30296. */
  30297. updateTexture(isVisible: boolean): void;
  30298. protected _updateInternalTexture: () => void;
  30299. /**
  30300. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30301. * @param url New url.
  30302. */
  30303. updateURL(url: string): void;
  30304. /**
  30305. * Dispose the texture and release its associated resources.
  30306. */
  30307. dispose(): void;
  30308. /**
  30309. * Creates a video texture straight from a stream.
  30310. * @param scene Define the scene the texture should be created in
  30311. * @param stream Define the stream the texture should be created from
  30312. * @returns The created video texture as a promise
  30313. */
  30314. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30315. /**
  30316. * Creates a video texture straight from your WebCam video feed.
  30317. * @param scene Define the scene the texture should be created in
  30318. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30319. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30320. * @returns The created video texture as a promise
  30321. */
  30322. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30323. minWidth: number;
  30324. maxWidth: number;
  30325. minHeight: number;
  30326. maxHeight: number;
  30327. deviceId: string;
  30328. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30329. /**
  30330. * Creates a video texture straight from your WebCam video feed.
  30331. * @param scene Define the scene the texture should be created in
  30332. * @param onReady Define a callback to triggered once the texture will be ready
  30333. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30334. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30335. */
  30336. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30337. minWidth: number;
  30338. maxWidth: number;
  30339. minHeight: number;
  30340. maxHeight: number;
  30341. deviceId: string;
  30342. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30343. }
  30344. }
  30345. declare module BABYLON {
  30346. /**
  30347. * Defines the interface used by objects working like Scene
  30348. * @hidden
  30349. */
  30350. interface ISceneLike {
  30351. _addPendingData(data: any): void;
  30352. _removePendingData(data: any): void;
  30353. offlineProvider: IOfflineProvider;
  30354. }
  30355. /** Interface defining initialization parameters for Engine class */
  30356. export interface EngineOptions extends WebGLContextAttributes {
  30357. /**
  30358. * Defines if the engine should no exceed a specified device ratio
  30359. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30360. */
  30361. limitDeviceRatio?: number;
  30362. /**
  30363. * Defines if webvr should be enabled automatically
  30364. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30365. */
  30366. autoEnableWebVR?: boolean;
  30367. /**
  30368. * Defines if webgl2 should be turned off even if supported
  30369. * @see http://doc.babylonjs.com/features/webgl2
  30370. */
  30371. disableWebGL2Support?: boolean;
  30372. /**
  30373. * Defines if webaudio should be initialized as well
  30374. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30375. */
  30376. audioEngine?: boolean;
  30377. /**
  30378. * Defines if animations should run using a deterministic lock step
  30379. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30380. */
  30381. deterministicLockstep?: boolean;
  30382. /** Defines the maximum steps to use with deterministic lock step mode */
  30383. lockstepMaxSteps?: number;
  30384. /** Defines the seconds between each deterministic lock step */
  30385. timeStep?: number;
  30386. /**
  30387. * Defines that engine should ignore context lost events
  30388. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30389. */
  30390. doNotHandleContextLost?: boolean;
  30391. /**
  30392. * Defines that engine should ignore modifying touch action attribute and style
  30393. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30394. */
  30395. doNotHandleTouchAction?: boolean;
  30396. /**
  30397. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30398. */
  30399. useHighPrecisionFloats?: boolean;
  30400. }
  30401. /**
  30402. * The base engine class (root of all engines)
  30403. */
  30404. export class ThinEngine {
  30405. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30406. static ExceptionList: ({
  30407. key: string;
  30408. capture: string;
  30409. captureConstraint: number;
  30410. targets: string[];
  30411. } | {
  30412. key: string;
  30413. capture: null;
  30414. captureConstraint: null;
  30415. targets: string[];
  30416. })[];
  30417. /** @hidden */
  30418. static _TextureLoaders: IInternalTextureLoader[];
  30419. /**
  30420. * Returns the current npm package of the sdk
  30421. */
  30422. static readonly NpmPackage: string;
  30423. /**
  30424. * Returns the current version of the framework
  30425. */
  30426. static readonly Version: string;
  30427. /**
  30428. * Returns a string describing the current engine
  30429. */
  30430. readonly description: string;
  30431. /**
  30432. * Gets or sets the epsilon value used by collision engine
  30433. */
  30434. static CollisionsEpsilon: number;
  30435. /**
  30436. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30437. */
  30438. static ShadersRepository: string;
  30439. /** @hidden */
  30440. _shaderProcessor: IShaderProcessor;
  30441. /**
  30442. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30443. */
  30444. forcePOTTextures: boolean;
  30445. /**
  30446. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30447. */
  30448. isFullscreen: boolean;
  30449. /**
  30450. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30451. */
  30452. cullBackFaces: boolean;
  30453. /**
  30454. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30455. */
  30456. renderEvenInBackground: boolean;
  30457. /**
  30458. * Gets or sets a boolean indicating that cache can be kept between frames
  30459. */
  30460. preventCacheWipeBetweenFrames: boolean;
  30461. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30462. validateShaderPrograms: boolean;
  30463. /**
  30464. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30465. * This can provide greater z depth for distant objects.
  30466. */
  30467. useReverseDepthBuffer: boolean;
  30468. /**
  30469. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30470. */
  30471. disableUniformBuffers: boolean;
  30472. /** @hidden */
  30473. _uniformBuffers: UniformBuffer[];
  30474. /**
  30475. * Gets a boolean indicating that the engine supports uniform buffers
  30476. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30477. */
  30478. readonly supportsUniformBuffers: boolean;
  30479. /** @hidden */
  30480. _gl: WebGLRenderingContext;
  30481. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30482. protected _windowIsBackground: boolean;
  30483. protected _webGLVersion: number;
  30484. protected _creationOptions: EngineOptions;
  30485. protected _highPrecisionShadersAllowed: boolean;
  30486. /** @hidden */
  30487. readonly _shouldUseHighPrecisionShader: boolean;
  30488. /**
  30489. * Gets a boolean indicating that only power of 2 textures are supported
  30490. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30491. */
  30492. readonly needPOTTextures: boolean;
  30493. /** @hidden */
  30494. _badOS: boolean;
  30495. /** @hidden */
  30496. _badDesktopOS: boolean;
  30497. private _hardwareScalingLevel;
  30498. /** @hidden */
  30499. _caps: EngineCapabilities;
  30500. private _isStencilEnable;
  30501. protected _colorWrite: boolean;
  30502. private _glVersion;
  30503. private _glRenderer;
  30504. private _glVendor;
  30505. /** @hidden */
  30506. _videoTextureSupported: boolean;
  30507. protected _renderingQueueLaunched: boolean;
  30508. protected _activeRenderLoops: (() => void)[];
  30509. /**
  30510. * Observable signaled when a context lost event is raised
  30511. */
  30512. onContextLostObservable: Observable<ThinEngine>;
  30513. /**
  30514. * Observable signaled when a context restored event is raised
  30515. */
  30516. onContextRestoredObservable: Observable<ThinEngine>;
  30517. private _onContextLost;
  30518. private _onContextRestored;
  30519. protected _contextWasLost: boolean;
  30520. /** @hidden */
  30521. _doNotHandleContextLost: boolean;
  30522. /**
  30523. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30524. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30525. */
  30526. doNotHandleContextLost: boolean;
  30527. /**
  30528. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30529. */
  30530. disableVertexArrayObjects: boolean;
  30531. /** @hidden */
  30532. protected _depthCullingState: DepthCullingState;
  30533. /** @hidden */
  30534. protected _stencilState: StencilState;
  30535. /** @hidden */
  30536. protected _alphaState: AlphaState;
  30537. /** @hidden */
  30538. _internalTexturesCache: InternalTexture[];
  30539. /** @hidden */
  30540. protected _activeChannel: number;
  30541. private _currentTextureChannel;
  30542. /** @hidden */
  30543. protected _boundTexturesCache: {
  30544. [key: string]: Nullable<InternalTexture>;
  30545. };
  30546. /** @hidden */
  30547. protected _currentEffect: Nullable<Effect>;
  30548. /** @hidden */
  30549. protected _currentProgram: Nullable<WebGLProgram>;
  30550. private _compiledEffects;
  30551. private _vertexAttribArraysEnabled;
  30552. /** @hidden */
  30553. protected _cachedViewport: Nullable<IViewportLike>;
  30554. private _cachedVertexArrayObject;
  30555. /** @hidden */
  30556. protected _cachedVertexBuffers: any;
  30557. /** @hidden */
  30558. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30559. /** @hidden */
  30560. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30561. /** @hidden */
  30562. _currentRenderTarget: Nullable<InternalTexture>;
  30563. private _uintIndicesCurrentlySet;
  30564. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30565. /** @hidden */
  30566. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30567. private _currentBufferPointers;
  30568. private _currentInstanceLocations;
  30569. private _currentInstanceBuffers;
  30570. private _textureUnits;
  30571. /** @hidden */
  30572. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30573. /** @hidden */
  30574. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30575. /** @hidden */
  30576. _boundRenderFunction: any;
  30577. private _vaoRecordInProgress;
  30578. private _mustWipeVertexAttributes;
  30579. private _emptyTexture;
  30580. private _emptyCubeTexture;
  30581. private _emptyTexture3D;
  30582. private _emptyTexture2DArray;
  30583. /** @hidden */
  30584. _frameHandler: number;
  30585. private _nextFreeTextureSlots;
  30586. private _maxSimultaneousTextures;
  30587. private _activeRequests;
  30588. protected _texturesSupported: string[];
  30589. /** @hidden */
  30590. _textureFormatInUse: Nullable<string>;
  30591. protected readonly _supportsHardwareTextureRescaling: boolean;
  30592. /**
  30593. * Gets the list of texture formats supported
  30594. */
  30595. readonly texturesSupported: Array<string>;
  30596. /**
  30597. * Gets the list of texture formats in use
  30598. */
  30599. readonly textureFormatInUse: Nullable<string>;
  30600. /**
  30601. * Gets the current viewport
  30602. */
  30603. readonly currentViewport: Nullable<IViewportLike>;
  30604. /**
  30605. * Gets the default empty texture
  30606. */
  30607. readonly emptyTexture: InternalTexture;
  30608. /**
  30609. * Gets the default empty 3D texture
  30610. */
  30611. readonly emptyTexture3D: InternalTexture;
  30612. /**
  30613. * Gets the default empty 2D array texture
  30614. */
  30615. readonly emptyTexture2DArray: InternalTexture;
  30616. /**
  30617. * Gets the default empty cube texture
  30618. */
  30619. readonly emptyCubeTexture: InternalTexture;
  30620. /**
  30621. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30622. */
  30623. readonly premultipliedAlpha: boolean;
  30624. /**
  30625. * Observable event triggered before each texture is initialized
  30626. */
  30627. onBeforeTextureInitObservable: Observable<Texture>;
  30628. /**
  30629. * Creates a new engine
  30630. * @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
  30631. * @param antialias defines enable antialiasing (default: false)
  30632. * @param options defines further options to be sent to the getContext() function
  30633. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30634. */
  30635. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30636. private _rebuildInternalTextures;
  30637. private _rebuildEffects;
  30638. /**
  30639. * Gets a boolean indicating if all created effects are ready
  30640. * @returns true if all effects are ready
  30641. */
  30642. areAllEffectsReady(): boolean;
  30643. protected _rebuildBuffers(): void;
  30644. private _initGLContext;
  30645. /**
  30646. * Gets version of the current webGL context
  30647. */
  30648. readonly webGLVersion: number;
  30649. /**
  30650. * Gets a string idenfifying the name of the class
  30651. * @returns "Engine" string
  30652. */
  30653. getClassName(): string;
  30654. /**
  30655. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30656. */
  30657. readonly isStencilEnable: boolean;
  30658. /** @hidden */
  30659. _prepareWorkingCanvas(): void;
  30660. /**
  30661. * Reset the texture cache to empty state
  30662. */
  30663. resetTextureCache(): void;
  30664. /**
  30665. * Gets an object containing information about the current webGL context
  30666. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30667. */
  30668. getGlInfo(): {
  30669. vendor: string;
  30670. renderer: string;
  30671. version: string;
  30672. };
  30673. /**
  30674. * Defines the hardware scaling level.
  30675. * By default the hardware scaling level is computed from the window device ratio.
  30676. * 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.
  30677. * @param level defines the level to use
  30678. */
  30679. setHardwareScalingLevel(level: number): void;
  30680. /**
  30681. * Gets the current hardware scaling level.
  30682. * By default the hardware scaling level is computed from the window device ratio.
  30683. * 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.
  30684. * @returns a number indicating the current hardware scaling level
  30685. */
  30686. getHardwareScalingLevel(): number;
  30687. /**
  30688. * Gets the list of loaded textures
  30689. * @returns an array containing all loaded textures
  30690. */
  30691. getLoadedTexturesCache(): InternalTexture[];
  30692. /**
  30693. * Gets the object containing all engine capabilities
  30694. * @returns the EngineCapabilities object
  30695. */
  30696. getCaps(): EngineCapabilities;
  30697. /**
  30698. * stop executing a render loop function and remove it from the execution array
  30699. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30700. */
  30701. stopRenderLoop(renderFunction?: () => void): void;
  30702. /** @hidden */
  30703. _renderLoop(): void;
  30704. /**
  30705. * Gets the HTML canvas attached with the current webGL context
  30706. * @returns a HTML canvas
  30707. */
  30708. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30709. /**
  30710. * Gets host window
  30711. * @returns the host window object
  30712. */
  30713. getHostWindow(): Nullable<Window>;
  30714. /**
  30715. * Gets the current render width
  30716. * @param useScreen defines if screen size must be used (or the current render target if any)
  30717. * @returns a number defining the current render width
  30718. */
  30719. getRenderWidth(useScreen?: boolean): number;
  30720. /**
  30721. * Gets the current render height
  30722. * @param useScreen defines if screen size must be used (or the current render target if any)
  30723. * @returns a number defining the current render height
  30724. */
  30725. getRenderHeight(useScreen?: boolean): number;
  30726. /**
  30727. * Can be used to override the current requestAnimationFrame requester.
  30728. * @hidden
  30729. */
  30730. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30731. /**
  30732. * Register and execute a render loop. The engine can have more than one render function
  30733. * @param renderFunction defines the function to continuously execute
  30734. */
  30735. runRenderLoop(renderFunction: () => void): void;
  30736. /**
  30737. * Clear the current render buffer or the current render target (if any is set up)
  30738. * @param color defines the color to use
  30739. * @param backBuffer defines if the back buffer must be cleared
  30740. * @param depth defines if the depth buffer must be cleared
  30741. * @param stencil defines if the stencil buffer must be cleared
  30742. */
  30743. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30744. private _viewportCached;
  30745. /** @hidden */
  30746. _viewport(x: number, y: number, width: number, height: number): void;
  30747. /**
  30748. * Set the WebGL's viewport
  30749. * @param viewport defines the viewport element to be used
  30750. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30751. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30752. */
  30753. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30754. /**
  30755. * Begin a new frame
  30756. */
  30757. beginFrame(): void;
  30758. /**
  30759. * Enf the current frame
  30760. */
  30761. endFrame(): void;
  30762. /**
  30763. * Resize the view according to the canvas' size
  30764. */
  30765. resize(): void;
  30766. /**
  30767. * Force a specific size of the canvas
  30768. * @param width defines the new canvas' width
  30769. * @param height defines the new canvas' height
  30770. */
  30771. setSize(width: number, height: number): void;
  30772. /**
  30773. * Binds the frame buffer to the specified texture.
  30774. * @param texture The texture to render to or null for the default canvas
  30775. * @param faceIndex The face of the texture to render to in case of cube texture
  30776. * @param requiredWidth The width of the target to render to
  30777. * @param requiredHeight The height of the target to render to
  30778. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30779. * @param depthStencilTexture The depth stencil texture to use to render
  30780. * @param lodLevel defines le lod level to bind to the frame buffer
  30781. */
  30782. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30783. /** @hidden */
  30784. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30785. /**
  30786. * Unbind the current render target texture from the webGL context
  30787. * @param texture defines the render target texture to unbind
  30788. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30789. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30790. */
  30791. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30792. /**
  30793. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30794. */
  30795. flushFramebuffer(): void;
  30796. /**
  30797. * Unbind the current render target and bind the default framebuffer
  30798. */
  30799. restoreDefaultFramebuffer(): void;
  30800. /** @hidden */
  30801. protected _resetVertexBufferBinding(): void;
  30802. /**
  30803. * Creates a vertex buffer
  30804. * @param data the data for the vertex buffer
  30805. * @returns the new WebGL static buffer
  30806. */
  30807. createVertexBuffer(data: DataArray): DataBuffer;
  30808. private _createVertexBuffer;
  30809. /**
  30810. * Creates a dynamic vertex buffer
  30811. * @param data the data for the dynamic vertex buffer
  30812. * @returns the new WebGL dynamic buffer
  30813. */
  30814. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30815. protected _resetIndexBufferBinding(): void;
  30816. /**
  30817. * Creates a new index buffer
  30818. * @param indices defines the content of the index buffer
  30819. * @param updatable defines if the index buffer must be updatable
  30820. * @returns a new webGL buffer
  30821. */
  30822. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30823. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30824. /**
  30825. * Bind a webGL buffer to the webGL context
  30826. * @param buffer defines the buffer to bind
  30827. */
  30828. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30829. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30830. private bindBuffer;
  30831. /**
  30832. * update the bound buffer with the given data
  30833. * @param data defines the data to update
  30834. */
  30835. updateArrayBuffer(data: Float32Array): void;
  30836. private _vertexAttribPointer;
  30837. private _bindIndexBufferWithCache;
  30838. private _bindVertexBuffersAttributes;
  30839. /**
  30840. * Records a vertex array object
  30841. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30842. * @param vertexBuffers defines the list of vertex buffers to store
  30843. * @param indexBuffer defines the index buffer to store
  30844. * @param effect defines the effect to store
  30845. * @returns the new vertex array object
  30846. */
  30847. recordVertexArrayObject(vertexBuffers: {
  30848. [key: string]: VertexBuffer;
  30849. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30850. /**
  30851. * Bind a specific vertex array object
  30852. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30853. * @param vertexArrayObject defines the vertex array object to bind
  30854. * @param indexBuffer defines the index buffer to bind
  30855. */
  30856. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30857. /**
  30858. * Bind webGl buffers directly to the webGL context
  30859. * @param vertexBuffer defines the vertex buffer to bind
  30860. * @param indexBuffer defines the index buffer to bind
  30861. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30862. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30863. * @param effect defines the effect associated with the vertex buffer
  30864. */
  30865. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30866. private _unbindVertexArrayObject;
  30867. /**
  30868. * Bind a list of vertex buffers to the webGL context
  30869. * @param vertexBuffers defines the list of vertex buffers to bind
  30870. * @param indexBuffer defines the index buffer to bind
  30871. * @param effect defines the effect associated with the vertex buffers
  30872. */
  30873. bindBuffers(vertexBuffers: {
  30874. [key: string]: Nullable<VertexBuffer>;
  30875. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30876. /**
  30877. * Unbind all instance attributes
  30878. */
  30879. unbindInstanceAttributes(): void;
  30880. /**
  30881. * Release and free the memory of a vertex array object
  30882. * @param vao defines the vertex array object to delete
  30883. */
  30884. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30885. /** @hidden */
  30886. _releaseBuffer(buffer: DataBuffer): boolean;
  30887. protected _deleteBuffer(buffer: DataBuffer): void;
  30888. /**
  30889. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30890. * @param instancesBuffer defines the webGL buffer to update and bind
  30891. * @param data defines the data to store in the buffer
  30892. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30893. */
  30894. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30895. /**
  30896. * Apply all cached states (depth, culling, stencil and alpha)
  30897. */
  30898. applyStates(): void;
  30899. /**
  30900. * Send a draw order
  30901. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30902. * @param indexStart defines the starting index
  30903. * @param indexCount defines the number of index to draw
  30904. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30905. */
  30906. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30907. /**
  30908. * Draw a list of points
  30909. * @param verticesStart defines the index of first vertex to draw
  30910. * @param verticesCount defines the count of vertices to draw
  30911. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30912. */
  30913. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30914. /**
  30915. * Draw a list of unindexed primitives
  30916. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30917. * @param verticesStart defines the index of first vertex to draw
  30918. * @param verticesCount defines the count of vertices to draw
  30919. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30920. */
  30921. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30922. /**
  30923. * Draw a list of indexed primitives
  30924. * @param fillMode defines the primitive to use
  30925. * @param indexStart defines the starting index
  30926. * @param indexCount defines the number of index to draw
  30927. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30928. */
  30929. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30930. /**
  30931. * Draw a list of unindexed primitives
  30932. * @param fillMode defines the primitive to use
  30933. * @param verticesStart defines the index of first vertex to draw
  30934. * @param verticesCount defines the count of vertices to draw
  30935. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30936. */
  30937. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30938. private _drawMode;
  30939. /** @hidden */
  30940. protected _reportDrawCall(): void;
  30941. /** @hidden */
  30942. _releaseEffect(effect: Effect): void;
  30943. /** @hidden */
  30944. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30945. /**
  30946. * Create a new effect (used to store vertex/fragment shaders)
  30947. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30948. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30949. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30950. * @param samplers defines an array of string used to represent textures
  30951. * @param defines defines the string containing the defines to use to compile the shaders
  30952. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30953. * @param onCompiled defines a function to call when the effect creation is successful
  30954. * @param onError defines a function to call when the effect creation has failed
  30955. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30956. * @returns the new Effect
  30957. */
  30958. 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;
  30959. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30960. private _compileShader;
  30961. private _compileRawShader;
  30962. /**
  30963. * Directly creates a webGL program
  30964. * @param pipelineContext defines the pipeline context to attach to
  30965. * @param vertexCode defines the vertex shader code to use
  30966. * @param fragmentCode defines the fragment shader code to use
  30967. * @param context defines the webGL context to use (if not set, the current one will be used)
  30968. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30969. * @returns the new webGL program
  30970. */
  30971. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30972. /**
  30973. * Creates a webGL program
  30974. * @param pipelineContext defines the pipeline context to attach to
  30975. * @param vertexCode defines the vertex shader code to use
  30976. * @param fragmentCode defines the fragment shader code to use
  30977. * @param defines defines the string containing the defines to use to compile the shaders
  30978. * @param context defines the webGL context to use (if not set, the current one will be used)
  30979. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30980. * @returns the new webGL program
  30981. */
  30982. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30983. /**
  30984. * Creates a new pipeline context
  30985. * @returns the new pipeline
  30986. */
  30987. createPipelineContext(): IPipelineContext;
  30988. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30989. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30990. /** @hidden */
  30991. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30992. /** @hidden */
  30993. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30994. /** @hidden */
  30995. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30996. /**
  30997. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30998. * @param pipelineContext defines the pipeline context to use
  30999. * @param uniformsNames defines the list of uniform names
  31000. * @returns an array of webGL uniform locations
  31001. */
  31002. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31003. /**
  31004. * Gets the lsit of active attributes for a given webGL program
  31005. * @param pipelineContext defines the pipeline context to use
  31006. * @param attributesNames defines the list of attribute names to get
  31007. * @returns an array of indices indicating the offset of each attribute
  31008. */
  31009. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31010. /**
  31011. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31012. * @param effect defines the effect to activate
  31013. */
  31014. enableEffect(effect: Nullable<Effect>): void;
  31015. /**
  31016. * Set the value of an uniform to a number (int)
  31017. * @param uniform defines the webGL uniform location where to store the value
  31018. * @param value defines the int number to store
  31019. */
  31020. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31021. /**
  31022. * Set the value of an uniform to an array of int32
  31023. * @param uniform defines the webGL uniform location where to store the value
  31024. * @param array defines the array of int32 to store
  31025. */
  31026. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31027. /**
  31028. * Set the value of an uniform to an array of int32 (stored as vec2)
  31029. * @param uniform defines the webGL uniform location where to store the value
  31030. * @param array defines the array of int32 to store
  31031. */
  31032. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31033. /**
  31034. * Set the value of an uniform to an array of int32 (stored as vec3)
  31035. * @param uniform defines the webGL uniform location where to store the value
  31036. * @param array defines the array of int32 to store
  31037. */
  31038. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31039. /**
  31040. * Set the value of an uniform to an array of int32 (stored as vec4)
  31041. * @param uniform defines the webGL uniform location where to store the value
  31042. * @param array defines the array of int32 to store
  31043. */
  31044. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31045. /**
  31046. * Set the value of an uniform to an array of number
  31047. * @param uniform defines the webGL uniform location where to store the value
  31048. * @param array defines the array of number to store
  31049. */
  31050. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31051. /**
  31052. * Set the value of an uniform to an array of number (stored as vec2)
  31053. * @param uniform defines the webGL uniform location where to store the value
  31054. * @param array defines the array of number to store
  31055. */
  31056. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31057. /**
  31058. * Set the value of an uniform to an array of number (stored as vec3)
  31059. * @param uniform defines the webGL uniform location where to store the value
  31060. * @param array defines the array of number to store
  31061. */
  31062. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31063. /**
  31064. * Set the value of an uniform to an array of number (stored as vec4)
  31065. * @param uniform defines the webGL uniform location where to store the value
  31066. * @param array defines the array of number to store
  31067. */
  31068. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31069. /**
  31070. * Set the value of an uniform to an array of float32 (stored as matrices)
  31071. * @param uniform defines the webGL uniform location where to store the value
  31072. * @param matrices defines the array of float32 to store
  31073. */
  31074. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31075. /**
  31076. * Set the value of an uniform to a matrix (3x3)
  31077. * @param uniform defines the webGL uniform location where to store the value
  31078. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31079. */
  31080. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31081. /**
  31082. * Set the value of an uniform to a matrix (2x2)
  31083. * @param uniform defines the webGL uniform location where to store the value
  31084. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31085. */
  31086. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31087. /**
  31088. * Set the value of an uniform to a number (float)
  31089. * @param uniform defines the webGL uniform location where to store the value
  31090. * @param value defines the float number to store
  31091. */
  31092. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31093. /**
  31094. * Set the value of an uniform to a vec2
  31095. * @param uniform defines the webGL uniform location where to store the value
  31096. * @param x defines the 1st component of the value
  31097. * @param y defines the 2nd component of the value
  31098. */
  31099. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31100. /**
  31101. * Set the value of an uniform to a vec3
  31102. * @param uniform defines the webGL uniform location where to store the value
  31103. * @param x defines the 1st component of the value
  31104. * @param y defines the 2nd component of the value
  31105. * @param z defines the 3rd component of the value
  31106. */
  31107. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31108. /**
  31109. * Set the value of an uniform to a vec4
  31110. * @param uniform defines the webGL uniform location where to store the value
  31111. * @param x defines the 1st component of the value
  31112. * @param y defines the 2nd component of the value
  31113. * @param z defines the 3rd component of the value
  31114. * @param w defines the 4th component of the value
  31115. */
  31116. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31117. /**
  31118. * Gets the depth culling state manager
  31119. */
  31120. readonly depthCullingState: DepthCullingState;
  31121. /**
  31122. * Gets the alpha state manager
  31123. */
  31124. readonly alphaState: AlphaState;
  31125. /**
  31126. * Gets the stencil state manager
  31127. */
  31128. readonly stencilState: StencilState;
  31129. /**
  31130. * Clears the list of texture accessible through engine.
  31131. * This can help preventing texture load conflict due to name collision.
  31132. */
  31133. clearInternalTexturesCache(): void;
  31134. /**
  31135. * Force the entire cache to be cleared
  31136. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31137. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31138. */
  31139. wipeCaches(bruteForce?: boolean): void;
  31140. /** @hidden */
  31141. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31142. min: number;
  31143. mag: number;
  31144. };
  31145. /** @hidden */
  31146. _createTexture(): WebGLTexture;
  31147. /**
  31148. * Usually called from Texture.ts.
  31149. * Passed information to create a WebGLTexture
  31150. * @param urlArg defines a value which contains one of the following:
  31151. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31152. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31153. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31154. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31155. * @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)
  31156. * @param scene needed for loading to the correct scene
  31157. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31158. * @param onLoad optional callback to be called upon successful completion
  31159. * @param onError optional callback to be called upon failure
  31160. * @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
  31161. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31162. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31163. * @param forcedExtension defines the extension to use to pick the right loader
  31164. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31165. * @param mimeType defines an optional mime type
  31166. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31167. */
  31168. 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;
  31169. /**
  31170. * @hidden
  31171. */
  31172. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31173. /**
  31174. * Creates a raw texture
  31175. * @param data defines the data to store in the texture
  31176. * @param width defines the width of the texture
  31177. * @param height defines the height of the texture
  31178. * @param format defines the format of the data
  31179. * @param generateMipMaps defines if the engine should generate the mip levels
  31180. * @param invertY defines if data must be stored with Y axis inverted
  31181. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31182. * @param compression defines the compression used (null by default)
  31183. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31184. * @returns the raw texture inside an InternalTexture
  31185. */
  31186. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31187. /**
  31188. * Creates a new raw cube texture
  31189. * @param data defines the array of data to use to create each face
  31190. * @param size defines the size of the textures
  31191. * @param format defines the format of the data
  31192. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31193. * @param generateMipMaps defines if the engine should generate the mip levels
  31194. * @param invertY defines if data must be stored with Y axis inverted
  31195. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31196. * @param compression defines the compression used (null by default)
  31197. * @returns the cube texture as an InternalTexture
  31198. */
  31199. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31200. /**
  31201. * Creates a new raw 3D texture
  31202. * @param data defines the data used to create the texture
  31203. * @param width defines the width of the texture
  31204. * @param height defines the height of the texture
  31205. * @param depth defines the depth of the texture
  31206. * @param format defines the format of the texture
  31207. * @param generateMipMaps defines if the engine must generate mip levels
  31208. * @param invertY defines if data must be stored with Y axis inverted
  31209. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31210. * @param compression defines the compressed used (can be null)
  31211. * @param textureType defines the compressed used (can be null)
  31212. * @returns a new raw 3D texture (stored in an InternalTexture)
  31213. */
  31214. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31215. /**
  31216. * Creates a new raw 2D array texture
  31217. * @param data defines the data used to create the texture
  31218. * @param width defines the width of the texture
  31219. * @param height defines the height of the texture
  31220. * @param depth defines the number of layers of the texture
  31221. * @param format defines the format of the texture
  31222. * @param generateMipMaps defines if the engine must generate mip levels
  31223. * @param invertY defines if data must be stored with Y axis inverted
  31224. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31225. * @param compression defines the compressed used (can be null)
  31226. * @param textureType defines the compressed used (can be null)
  31227. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31228. */
  31229. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31230. private _unpackFlipYCached;
  31231. /**
  31232. * In case you are sharing the context with other applications, it might
  31233. * be interested to not cache the unpack flip y state to ensure a consistent
  31234. * value would be set.
  31235. */
  31236. enableUnpackFlipYCached: boolean;
  31237. /** @hidden */
  31238. _unpackFlipY(value: boolean): void;
  31239. /** @hidden */
  31240. _getUnpackAlignement(): number;
  31241. /**
  31242. * Update the sampling mode of a given texture
  31243. * @param samplingMode defines the required sampling mode
  31244. * @param texture defines the texture to update
  31245. */
  31246. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31247. /** @hidden */
  31248. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31249. width: number;
  31250. height: number;
  31251. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31252. /** @hidden */
  31253. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31254. /** @hidden */
  31255. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31256. /** @hidden */
  31257. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31258. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31259. private _prepareWebGLTexture;
  31260. /** @hidden */
  31261. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31262. /** @hidden */
  31263. _releaseFramebufferObjects(texture: InternalTexture): void;
  31264. /** @hidden */
  31265. _releaseTexture(texture: InternalTexture): void;
  31266. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31267. protected _setProgram(program: WebGLProgram): void;
  31268. protected _boundUniforms: {
  31269. [key: number]: WebGLUniformLocation;
  31270. };
  31271. /**
  31272. * Binds an effect to the webGL context
  31273. * @param effect defines the effect to bind
  31274. */
  31275. bindSamplers(effect: Effect): void;
  31276. private _activateCurrentTexture;
  31277. /** @hidden */
  31278. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31279. /** @hidden */
  31280. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31281. /**
  31282. * Unbind all textures from the webGL context
  31283. */
  31284. unbindAllTextures(): void;
  31285. /**
  31286. * Sets a texture to the according uniform.
  31287. * @param channel The texture channel
  31288. * @param uniform The uniform to set
  31289. * @param texture The texture to apply
  31290. */
  31291. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31292. private _bindSamplerUniformToChannel;
  31293. private _getTextureWrapMode;
  31294. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31295. /**
  31296. * Sets an array of texture to the webGL context
  31297. * @param channel defines the channel where the texture array must be set
  31298. * @param uniform defines the associated uniform location
  31299. * @param textures defines the array of textures to bind
  31300. */
  31301. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31302. /** @hidden */
  31303. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31304. private _setTextureParameterFloat;
  31305. private _setTextureParameterInteger;
  31306. /**
  31307. * Unbind all vertex attributes from the webGL context
  31308. */
  31309. unbindAllAttributes(): void;
  31310. /**
  31311. * 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
  31312. */
  31313. releaseEffects(): void;
  31314. /**
  31315. * Dispose and release all associated resources
  31316. */
  31317. dispose(): void;
  31318. /**
  31319. * Attach a new callback raised when context lost event is fired
  31320. * @param callback defines the callback to call
  31321. */
  31322. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31323. /**
  31324. * Attach a new callback raised when context restored event is fired
  31325. * @param callback defines the callback to call
  31326. */
  31327. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31328. /**
  31329. * Get the current error code of the webGL context
  31330. * @returns the error code
  31331. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31332. */
  31333. getError(): number;
  31334. private _canRenderToFloatFramebuffer;
  31335. private _canRenderToHalfFloatFramebuffer;
  31336. private _canRenderToFramebuffer;
  31337. /** @hidden */
  31338. _getWebGLTextureType(type: number): number;
  31339. /** @hidden */
  31340. _getInternalFormat(format: number): number;
  31341. /** @hidden */
  31342. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31343. /** @hidden */
  31344. _getRGBAMultiSampleBufferFormat(type: number): number;
  31345. /** @hidden */
  31346. _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;
  31347. /**
  31348. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31349. * @returns true if the engine can be created
  31350. * @ignorenaming
  31351. */
  31352. static isSupported(): boolean;
  31353. /**
  31354. * Find the next highest power of two.
  31355. * @param x Number to start search from.
  31356. * @return Next highest power of two.
  31357. */
  31358. static CeilingPOT(x: number): number;
  31359. /**
  31360. * Find the next lowest power of two.
  31361. * @param x Number to start search from.
  31362. * @return Next lowest power of two.
  31363. */
  31364. static FloorPOT(x: number): number;
  31365. /**
  31366. * Find the nearest power of two.
  31367. * @param x Number to start search from.
  31368. * @return Next nearest power of two.
  31369. */
  31370. static NearestPOT(x: number): number;
  31371. /**
  31372. * Get the closest exponent of two
  31373. * @param value defines the value to approximate
  31374. * @param max defines the maximum value to return
  31375. * @param mode defines how to define the closest value
  31376. * @returns closest exponent of two of the given value
  31377. */
  31378. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31379. /**
  31380. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31381. * @param func - the function to be called
  31382. * @param requester - the object that will request the next frame. Falls back to window.
  31383. * @returns frame number
  31384. */
  31385. static QueueNewFrame(func: () => void, requester?: any): number;
  31386. /**
  31387. * Gets host document
  31388. * @returns the host document object
  31389. */
  31390. getHostDocument(): Document;
  31391. }
  31392. }
  31393. declare module BABYLON {
  31394. /**
  31395. * Class representing spherical harmonics coefficients to the 3rd degree
  31396. */
  31397. export class SphericalHarmonics {
  31398. /**
  31399. * Defines whether or not the harmonics have been prescaled for rendering.
  31400. */
  31401. preScaled: boolean;
  31402. /**
  31403. * The l0,0 coefficients of the spherical harmonics
  31404. */
  31405. l00: Vector3;
  31406. /**
  31407. * The l1,-1 coefficients of the spherical harmonics
  31408. */
  31409. l1_1: Vector3;
  31410. /**
  31411. * The l1,0 coefficients of the spherical harmonics
  31412. */
  31413. l10: Vector3;
  31414. /**
  31415. * The l1,1 coefficients of the spherical harmonics
  31416. */
  31417. l11: Vector3;
  31418. /**
  31419. * The l2,-2 coefficients of the spherical harmonics
  31420. */
  31421. l2_2: Vector3;
  31422. /**
  31423. * The l2,-1 coefficients of the spherical harmonics
  31424. */
  31425. l2_1: Vector3;
  31426. /**
  31427. * The l2,0 coefficients of the spherical harmonics
  31428. */
  31429. l20: Vector3;
  31430. /**
  31431. * The l2,1 coefficients of the spherical harmonics
  31432. */
  31433. l21: Vector3;
  31434. /**
  31435. * The l2,2 coefficients of the spherical harmonics
  31436. */
  31437. l22: Vector3;
  31438. /**
  31439. * Adds a light to the spherical harmonics
  31440. * @param direction the direction of the light
  31441. * @param color the color of the light
  31442. * @param deltaSolidAngle the delta solid angle of the light
  31443. */
  31444. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31445. /**
  31446. * Scales the spherical harmonics by the given amount
  31447. * @param scale the amount to scale
  31448. */
  31449. scaleInPlace(scale: number): void;
  31450. /**
  31451. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31452. *
  31453. * ```
  31454. * E_lm = A_l * L_lm
  31455. * ```
  31456. *
  31457. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31458. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31459. * the scaling factors are given in equation 9.
  31460. */
  31461. convertIncidentRadianceToIrradiance(): void;
  31462. /**
  31463. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31464. *
  31465. * ```
  31466. * L = (1/pi) * E * rho
  31467. * ```
  31468. *
  31469. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31470. */
  31471. convertIrradianceToLambertianRadiance(): void;
  31472. /**
  31473. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31474. * required operations at run time.
  31475. *
  31476. * This is simply done by scaling back the SH with Ylm constants parameter.
  31477. * The trigonometric part being applied by the shader at run time.
  31478. */
  31479. preScaleForRendering(): void;
  31480. /**
  31481. * Constructs a spherical harmonics from an array.
  31482. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31483. * @returns the spherical harmonics
  31484. */
  31485. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31486. /**
  31487. * Gets the spherical harmonics from polynomial
  31488. * @param polynomial the spherical polynomial
  31489. * @returns the spherical harmonics
  31490. */
  31491. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31492. }
  31493. /**
  31494. * Class representing spherical polynomial coefficients to the 3rd degree
  31495. */
  31496. export class SphericalPolynomial {
  31497. private _harmonics;
  31498. /**
  31499. * The spherical harmonics used to create the polynomials.
  31500. */
  31501. readonly preScaledHarmonics: SphericalHarmonics;
  31502. /**
  31503. * The x coefficients of the spherical polynomial
  31504. */
  31505. x: Vector3;
  31506. /**
  31507. * The y coefficients of the spherical polynomial
  31508. */
  31509. y: Vector3;
  31510. /**
  31511. * The z coefficients of the spherical polynomial
  31512. */
  31513. z: Vector3;
  31514. /**
  31515. * The xx coefficients of the spherical polynomial
  31516. */
  31517. xx: Vector3;
  31518. /**
  31519. * The yy coefficients of the spherical polynomial
  31520. */
  31521. yy: Vector3;
  31522. /**
  31523. * The zz coefficients of the spherical polynomial
  31524. */
  31525. zz: Vector3;
  31526. /**
  31527. * The xy coefficients of the spherical polynomial
  31528. */
  31529. xy: Vector3;
  31530. /**
  31531. * The yz coefficients of the spherical polynomial
  31532. */
  31533. yz: Vector3;
  31534. /**
  31535. * The zx coefficients of the spherical polynomial
  31536. */
  31537. zx: Vector3;
  31538. /**
  31539. * Adds an ambient color to the spherical polynomial
  31540. * @param color the color to add
  31541. */
  31542. addAmbient(color: Color3): void;
  31543. /**
  31544. * Scales the spherical polynomial by the given amount
  31545. * @param scale the amount to scale
  31546. */
  31547. scaleInPlace(scale: number): void;
  31548. /**
  31549. * Gets the spherical polynomial from harmonics
  31550. * @param harmonics the spherical harmonics
  31551. * @returns the spherical polynomial
  31552. */
  31553. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31554. /**
  31555. * Constructs a spherical polynomial from an array.
  31556. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31557. * @returns the spherical polynomial
  31558. */
  31559. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31560. }
  31561. }
  31562. declare module BABYLON {
  31563. /**
  31564. * Defines the source of the internal texture
  31565. */
  31566. export enum InternalTextureSource {
  31567. /**
  31568. * The source of the texture data is unknown
  31569. */
  31570. Unknown = 0,
  31571. /**
  31572. * Texture data comes from an URL
  31573. */
  31574. Url = 1,
  31575. /**
  31576. * Texture data is only used for temporary storage
  31577. */
  31578. Temp = 2,
  31579. /**
  31580. * Texture data comes from raw data (ArrayBuffer)
  31581. */
  31582. Raw = 3,
  31583. /**
  31584. * Texture content is dynamic (video or dynamic texture)
  31585. */
  31586. Dynamic = 4,
  31587. /**
  31588. * Texture content is generated by rendering to it
  31589. */
  31590. RenderTarget = 5,
  31591. /**
  31592. * Texture content is part of a multi render target process
  31593. */
  31594. MultiRenderTarget = 6,
  31595. /**
  31596. * Texture data comes from a cube data file
  31597. */
  31598. Cube = 7,
  31599. /**
  31600. * Texture data comes from a raw cube data
  31601. */
  31602. CubeRaw = 8,
  31603. /**
  31604. * Texture data come from a prefiltered cube data file
  31605. */
  31606. CubePrefiltered = 9,
  31607. /**
  31608. * Texture content is raw 3D data
  31609. */
  31610. Raw3D = 10,
  31611. /**
  31612. * Texture content is raw 2D array data
  31613. */
  31614. Raw2DArray = 11,
  31615. /**
  31616. * Texture content is a depth texture
  31617. */
  31618. Depth = 12,
  31619. /**
  31620. * Texture data comes from a raw cube data encoded with RGBD
  31621. */
  31622. CubeRawRGBD = 13
  31623. }
  31624. /**
  31625. * Class used to store data associated with WebGL texture data for the engine
  31626. * This class should not be used directly
  31627. */
  31628. export class InternalTexture {
  31629. /** @hidden */
  31630. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31631. /**
  31632. * Defines if the texture is ready
  31633. */
  31634. isReady: boolean;
  31635. /**
  31636. * Defines if the texture is a cube texture
  31637. */
  31638. isCube: boolean;
  31639. /**
  31640. * Defines if the texture contains 3D data
  31641. */
  31642. is3D: boolean;
  31643. /**
  31644. * Defines if the texture contains 2D array data
  31645. */
  31646. is2DArray: boolean;
  31647. /**
  31648. * Defines if the texture contains multiview data
  31649. */
  31650. isMultiview: boolean;
  31651. /**
  31652. * Gets the URL used to load this texture
  31653. */
  31654. url: string;
  31655. /**
  31656. * Gets the sampling mode of the texture
  31657. */
  31658. samplingMode: number;
  31659. /**
  31660. * Gets a boolean indicating if the texture needs mipmaps generation
  31661. */
  31662. generateMipMaps: boolean;
  31663. /**
  31664. * Gets the number of samples used by the texture (WebGL2+ only)
  31665. */
  31666. samples: number;
  31667. /**
  31668. * Gets the type of the texture (int, float...)
  31669. */
  31670. type: number;
  31671. /**
  31672. * Gets the format of the texture (RGB, RGBA...)
  31673. */
  31674. format: number;
  31675. /**
  31676. * Observable called when the texture is loaded
  31677. */
  31678. onLoadedObservable: Observable<InternalTexture>;
  31679. /**
  31680. * Gets the width of the texture
  31681. */
  31682. width: number;
  31683. /**
  31684. * Gets the height of the texture
  31685. */
  31686. height: number;
  31687. /**
  31688. * Gets the depth of the texture
  31689. */
  31690. depth: number;
  31691. /**
  31692. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31693. */
  31694. baseWidth: number;
  31695. /**
  31696. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31697. */
  31698. baseHeight: number;
  31699. /**
  31700. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31701. */
  31702. baseDepth: number;
  31703. /**
  31704. * Gets a boolean indicating if the texture is inverted on Y axis
  31705. */
  31706. invertY: boolean;
  31707. /** @hidden */
  31708. _invertVScale: boolean;
  31709. /** @hidden */
  31710. _associatedChannel: number;
  31711. /** @hidden */
  31712. _source: InternalTextureSource;
  31713. /** @hidden */
  31714. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31715. /** @hidden */
  31716. _bufferView: Nullable<ArrayBufferView>;
  31717. /** @hidden */
  31718. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31719. /** @hidden */
  31720. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31721. /** @hidden */
  31722. _size: number;
  31723. /** @hidden */
  31724. _extension: string;
  31725. /** @hidden */
  31726. _files: Nullable<string[]>;
  31727. /** @hidden */
  31728. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31729. /** @hidden */
  31730. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31731. /** @hidden */
  31732. _framebuffer: Nullable<WebGLFramebuffer>;
  31733. /** @hidden */
  31734. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31735. /** @hidden */
  31736. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31737. /** @hidden */
  31738. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31739. /** @hidden */
  31740. _attachments: Nullable<number[]>;
  31741. /** @hidden */
  31742. _cachedCoordinatesMode: Nullable<number>;
  31743. /** @hidden */
  31744. _cachedWrapU: Nullable<number>;
  31745. /** @hidden */
  31746. _cachedWrapV: Nullable<number>;
  31747. /** @hidden */
  31748. _cachedWrapR: Nullable<number>;
  31749. /** @hidden */
  31750. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31751. /** @hidden */
  31752. _isDisabled: boolean;
  31753. /** @hidden */
  31754. _compression: Nullable<string>;
  31755. /** @hidden */
  31756. _generateStencilBuffer: boolean;
  31757. /** @hidden */
  31758. _generateDepthBuffer: boolean;
  31759. /** @hidden */
  31760. _comparisonFunction: number;
  31761. /** @hidden */
  31762. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31763. /** @hidden */
  31764. _lodGenerationScale: number;
  31765. /** @hidden */
  31766. _lodGenerationOffset: number;
  31767. /** @hidden */
  31768. _colorTextureArray: Nullable<WebGLTexture>;
  31769. /** @hidden */
  31770. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31771. /** @hidden */
  31772. _lodTextureHigh: Nullable<BaseTexture>;
  31773. /** @hidden */
  31774. _lodTextureMid: Nullable<BaseTexture>;
  31775. /** @hidden */
  31776. _lodTextureLow: Nullable<BaseTexture>;
  31777. /** @hidden */
  31778. _isRGBD: boolean;
  31779. /** @hidden */
  31780. _linearSpecularLOD: boolean;
  31781. /** @hidden */
  31782. _irradianceTexture: Nullable<BaseTexture>;
  31783. /** @hidden */
  31784. _webGLTexture: Nullable<WebGLTexture>;
  31785. /** @hidden */
  31786. _references: number;
  31787. private _engine;
  31788. /**
  31789. * Gets the Engine the texture belongs to.
  31790. * @returns The babylon engine
  31791. */
  31792. getEngine(): ThinEngine;
  31793. /**
  31794. * Gets the data source type of the texture
  31795. */
  31796. readonly source: InternalTextureSource;
  31797. /**
  31798. * Creates a new InternalTexture
  31799. * @param engine defines the engine to use
  31800. * @param source defines the type of data that will be used
  31801. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31802. */
  31803. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31804. /**
  31805. * Increments the number of references (ie. the number of Texture that point to it)
  31806. */
  31807. incrementReferences(): void;
  31808. /**
  31809. * Change the size of the texture (not the size of the content)
  31810. * @param width defines the new width
  31811. * @param height defines the new height
  31812. * @param depth defines the new depth (1 by default)
  31813. */
  31814. updateSize(width: int, height: int, depth?: int): void;
  31815. /** @hidden */
  31816. _rebuild(): void;
  31817. /** @hidden */
  31818. _swapAndDie(target: InternalTexture): void;
  31819. /**
  31820. * Dispose the current allocated resources
  31821. */
  31822. dispose(): void;
  31823. }
  31824. }
  31825. declare module BABYLON {
  31826. /**
  31827. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31828. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31829. */
  31830. export class Analyser {
  31831. /**
  31832. * Gets or sets the smoothing
  31833. * @ignorenaming
  31834. */
  31835. SMOOTHING: number;
  31836. /**
  31837. * Gets or sets the FFT table size
  31838. * @ignorenaming
  31839. */
  31840. FFT_SIZE: number;
  31841. /**
  31842. * Gets or sets the bar graph amplitude
  31843. * @ignorenaming
  31844. */
  31845. BARGRAPHAMPLITUDE: number;
  31846. /**
  31847. * Gets or sets the position of the debug canvas
  31848. * @ignorenaming
  31849. */
  31850. DEBUGCANVASPOS: {
  31851. x: number;
  31852. y: number;
  31853. };
  31854. /**
  31855. * Gets or sets the debug canvas size
  31856. * @ignorenaming
  31857. */
  31858. DEBUGCANVASSIZE: {
  31859. width: number;
  31860. height: number;
  31861. };
  31862. private _byteFreqs;
  31863. private _byteTime;
  31864. private _floatFreqs;
  31865. private _webAudioAnalyser;
  31866. private _debugCanvas;
  31867. private _debugCanvasContext;
  31868. private _scene;
  31869. private _registerFunc;
  31870. private _audioEngine;
  31871. /**
  31872. * Creates a new analyser
  31873. * @param scene defines hosting scene
  31874. */
  31875. constructor(scene: Scene);
  31876. /**
  31877. * Get the number of data values you will have to play with for the visualization
  31878. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31879. * @returns a number
  31880. */
  31881. getFrequencyBinCount(): number;
  31882. /**
  31883. * Gets the current frequency data as a byte array
  31884. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31885. * @returns a Uint8Array
  31886. */
  31887. getByteFrequencyData(): Uint8Array;
  31888. /**
  31889. * Gets the current waveform as a byte array
  31890. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31891. * @returns a Uint8Array
  31892. */
  31893. getByteTimeDomainData(): Uint8Array;
  31894. /**
  31895. * Gets the current frequency data as a float array
  31896. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31897. * @returns a Float32Array
  31898. */
  31899. getFloatFrequencyData(): Float32Array;
  31900. /**
  31901. * Renders the debug canvas
  31902. */
  31903. drawDebugCanvas(): void;
  31904. /**
  31905. * Stops rendering the debug canvas and removes it
  31906. */
  31907. stopDebugCanvas(): void;
  31908. /**
  31909. * Connects two audio nodes
  31910. * @param inputAudioNode defines first node to connect
  31911. * @param outputAudioNode defines second node to connect
  31912. */
  31913. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31914. /**
  31915. * Releases all associated resources
  31916. */
  31917. dispose(): void;
  31918. }
  31919. }
  31920. declare module BABYLON {
  31921. /**
  31922. * This represents an audio engine and it is responsible
  31923. * to play, synchronize and analyse sounds throughout the application.
  31924. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31925. */
  31926. export interface IAudioEngine extends IDisposable {
  31927. /**
  31928. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31929. */
  31930. readonly canUseWebAudio: boolean;
  31931. /**
  31932. * Gets the current AudioContext if available.
  31933. */
  31934. readonly audioContext: Nullable<AudioContext>;
  31935. /**
  31936. * The master gain node defines the global audio volume of your audio engine.
  31937. */
  31938. readonly masterGain: GainNode;
  31939. /**
  31940. * Gets whether or not mp3 are supported by your browser.
  31941. */
  31942. readonly isMP3supported: boolean;
  31943. /**
  31944. * Gets whether or not ogg are supported by your browser.
  31945. */
  31946. readonly isOGGsupported: boolean;
  31947. /**
  31948. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31949. * @ignoreNaming
  31950. */
  31951. WarnedWebAudioUnsupported: boolean;
  31952. /**
  31953. * Defines if the audio engine relies on a custom unlocked button.
  31954. * In this case, the embedded button will not be displayed.
  31955. */
  31956. useCustomUnlockedButton: boolean;
  31957. /**
  31958. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31959. */
  31960. readonly unlocked: boolean;
  31961. /**
  31962. * Event raised when audio has been unlocked on the browser.
  31963. */
  31964. onAudioUnlockedObservable: Observable<AudioEngine>;
  31965. /**
  31966. * Event raised when audio has been locked on the browser.
  31967. */
  31968. onAudioLockedObservable: Observable<AudioEngine>;
  31969. /**
  31970. * Flags the audio engine in Locked state.
  31971. * This happens due to new browser policies preventing audio to autoplay.
  31972. */
  31973. lock(): void;
  31974. /**
  31975. * Unlocks the audio engine once a user action has been done on the dom.
  31976. * This is helpful to resume play once browser policies have been satisfied.
  31977. */
  31978. unlock(): void;
  31979. }
  31980. /**
  31981. * This represents the default audio engine used in babylon.
  31982. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31983. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31984. */
  31985. export class AudioEngine implements IAudioEngine {
  31986. private _audioContext;
  31987. private _audioContextInitialized;
  31988. private _muteButton;
  31989. private _hostElement;
  31990. /**
  31991. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31992. */
  31993. canUseWebAudio: boolean;
  31994. /**
  31995. * The master gain node defines the global audio volume of your audio engine.
  31996. */
  31997. masterGain: GainNode;
  31998. /**
  31999. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32000. * @ignoreNaming
  32001. */
  32002. WarnedWebAudioUnsupported: boolean;
  32003. /**
  32004. * Gets whether or not mp3 are supported by your browser.
  32005. */
  32006. isMP3supported: boolean;
  32007. /**
  32008. * Gets whether or not ogg are supported by your browser.
  32009. */
  32010. isOGGsupported: boolean;
  32011. /**
  32012. * Gets whether audio has been unlocked on the device.
  32013. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32014. * a user interaction has happened.
  32015. */
  32016. unlocked: boolean;
  32017. /**
  32018. * Defines if the audio engine relies on a custom unlocked button.
  32019. * In this case, the embedded button will not be displayed.
  32020. */
  32021. useCustomUnlockedButton: boolean;
  32022. /**
  32023. * Event raised when audio has been unlocked on the browser.
  32024. */
  32025. onAudioUnlockedObservable: Observable<AudioEngine>;
  32026. /**
  32027. * Event raised when audio has been locked on the browser.
  32028. */
  32029. onAudioLockedObservable: Observable<AudioEngine>;
  32030. /**
  32031. * Gets the current AudioContext if available.
  32032. */
  32033. readonly audioContext: Nullable<AudioContext>;
  32034. private _connectedAnalyser;
  32035. /**
  32036. * Instantiates a new audio engine.
  32037. *
  32038. * There should be only one per page as some browsers restrict the number
  32039. * of audio contexts you can create.
  32040. * @param hostElement defines the host element where to display the mute icon if necessary
  32041. */
  32042. constructor(hostElement?: Nullable<HTMLElement>);
  32043. /**
  32044. * Flags the audio engine in Locked state.
  32045. * This happens due to new browser policies preventing audio to autoplay.
  32046. */
  32047. lock(): void;
  32048. /**
  32049. * Unlocks the audio engine once a user action has been done on the dom.
  32050. * This is helpful to resume play once browser policies have been satisfied.
  32051. */
  32052. unlock(): void;
  32053. private _resumeAudioContext;
  32054. private _initializeAudioContext;
  32055. private _tryToRun;
  32056. private _triggerRunningState;
  32057. private _triggerSuspendedState;
  32058. private _displayMuteButton;
  32059. private _moveButtonToTopLeft;
  32060. private _onResize;
  32061. private _hideMuteButton;
  32062. /**
  32063. * Destroy and release the resources associated with the audio ccontext.
  32064. */
  32065. dispose(): void;
  32066. /**
  32067. * Gets the global volume sets on the master gain.
  32068. * @returns the global volume if set or -1 otherwise
  32069. */
  32070. getGlobalVolume(): number;
  32071. /**
  32072. * Sets the global volume of your experience (sets on the master gain).
  32073. * @param newVolume Defines the new global volume of the application
  32074. */
  32075. setGlobalVolume(newVolume: number): void;
  32076. /**
  32077. * Connect the audio engine to an audio analyser allowing some amazing
  32078. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32079. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32080. * @param analyser The analyser to connect to the engine
  32081. */
  32082. connectToAnalyser(analyser: Analyser): void;
  32083. }
  32084. }
  32085. declare module BABYLON {
  32086. /**
  32087. * Interface used to present a loading screen while loading a scene
  32088. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32089. */
  32090. export interface ILoadingScreen {
  32091. /**
  32092. * Function called to display the loading screen
  32093. */
  32094. displayLoadingUI: () => void;
  32095. /**
  32096. * Function called to hide the loading screen
  32097. */
  32098. hideLoadingUI: () => void;
  32099. /**
  32100. * Gets or sets the color to use for the background
  32101. */
  32102. loadingUIBackgroundColor: string;
  32103. /**
  32104. * Gets or sets the text to display while loading
  32105. */
  32106. loadingUIText: string;
  32107. }
  32108. /**
  32109. * Class used for the default loading screen
  32110. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32111. */
  32112. export class DefaultLoadingScreen implements ILoadingScreen {
  32113. private _renderingCanvas;
  32114. private _loadingText;
  32115. private _loadingDivBackgroundColor;
  32116. private _loadingDiv;
  32117. private _loadingTextDiv;
  32118. /** Gets or sets the logo url to use for the default loading screen */
  32119. static DefaultLogoUrl: string;
  32120. /** Gets or sets the spinner url to use for the default loading screen */
  32121. static DefaultSpinnerUrl: string;
  32122. /**
  32123. * Creates a new default loading screen
  32124. * @param _renderingCanvas defines the canvas used to render the scene
  32125. * @param _loadingText defines the default text to display
  32126. * @param _loadingDivBackgroundColor defines the default background color
  32127. */
  32128. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32129. /**
  32130. * Function called to display the loading screen
  32131. */
  32132. displayLoadingUI(): void;
  32133. /**
  32134. * Function called to hide the loading screen
  32135. */
  32136. hideLoadingUI(): void;
  32137. /**
  32138. * Gets or sets the text to display while loading
  32139. */
  32140. loadingUIText: string;
  32141. /**
  32142. * Gets or sets the color to use for the background
  32143. */
  32144. loadingUIBackgroundColor: string;
  32145. private _resizeLoadingUI;
  32146. }
  32147. }
  32148. declare module BABYLON {
  32149. /**
  32150. * Interface for any object that can request an animation frame
  32151. */
  32152. export interface ICustomAnimationFrameRequester {
  32153. /**
  32154. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32155. */
  32156. renderFunction?: Function;
  32157. /**
  32158. * Called to request the next frame to render to
  32159. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32160. */
  32161. requestAnimationFrame: Function;
  32162. /**
  32163. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32164. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32165. */
  32166. requestID?: number;
  32167. }
  32168. }
  32169. declare module BABYLON {
  32170. /**
  32171. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32172. */
  32173. export class PerformanceMonitor {
  32174. private _enabled;
  32175. private _rollingFrameTime;
  32176. private _lastFrameTimeMs;
  32177. /**
  32178. * constructor
  32179. * @param frameSampleSize The number of samples required to saturate the sliding window
  32180. */
  32181. constructor(frameSampleSize?: number);
  32182. /**
  32183. * Samples current frame
  32184. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32185. */
  32186. sampleFrame(timeMs?: number): void;
  32187. /**
  32188. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32189. */
  32190. readonly averageFrameTime: number;
  32191. /**
  32192. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32193. */
  32194. readonly averageFrameTimeVariance: number;
  32195. /**
  32196. * Returns the frame time of the most recent frame
  32197. */
  32198. readonly instantaneousFrameTime: number;
  32199. /**
  32200. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32201. */
  32202. readonly averageFPS: number;
  32203. /**
  32204. * Returns the average framerate in frames per second using the most recent frame time
  32205. */
  32206. readonly instantaneousFPS: number;
  32207. /**
  32208. * Returns true if enough samples have been taken to completely fill the sliding window
  32209. */
  32210. readonly isSaturated: boolean;
  32211. /**
  32212. * Enables contributions to the sliding window sample set
  32213. */
  32214. enable(): void;
  32215. /**
  32216. * Disables contributions to the sliding window sample set
  32217. * Samples will not be interpolated over the disabled period
  32218. */
  32219. disable(): void;
  32220. /**
  32221. * Returns true if sampling is enabled
  32222. */
  32223. readonly isEnabled: boolean;
  32224. /**
  32225. * Resets performance monitor
  32226. */
  32227. reset(): void;
  32228. }
  32229. /**
  32230. * RollingAverage
  32231. *
  32232. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32233. */
  32234. export class RollingAverage {
  32235. /**
  32236. * Current average
  32237. */
  32238. average: number;
  32239. /**
  32240. * Current variance
  32241. */
  32242. variance: number;
  32243. protected _samples: Array<number>;
  32244. protected _sampleCount: number;
  32245. protected _pos: number;
  32246. protected _m2: number;
  32247. /**
  32248. * constructor
  32249. * @param length The number of samples required to saturate the sliding window
  32250. */
  32251. constructor(length: number);
  32252. /**
  32253. * Adds a sample to the sample set
  32254. * @param v The sample value
  32255. */
  32256. add(v: number): void;
  32257. /**
  32258. * Returns previously added values or null if outside of history or outside the sliding window domain
  32259. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32260. * @return Value previously recorded with add() or null if outside of range
  32261. */
  32262. history(i: number): number;
  32263. /**
  32264. * Returns true if enough samples have been taken to completely fill the sliding window
  32265. * @return true if sample-set saturated
  32266. */
  32267. isSaturated(): boolean;
  32268. /**
  32269. * Resets the rolling average (equivalent to 0 samples taken so far)
  32270. */
  32271. reset(): void;
  32272. /**
  32273. * Wraps a value around the sample range boundaries
  32274. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32275. * @return Wrapped position in sample range
  32276. */
  32277. protected _wrapPosition(i: number): number;
  32278. }
  32279. }
  32280. declare module BABYLON {
  32281. /**
  32282. * This class is used to track a performance counter which is number based.
  32283. * The user has access to many properties which give statistics of different nature.
  32284. *
  32285. * The implementer can track two kinds of Performance Counter: time and count.
  32286. * 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.
  32287. * 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.
  32288. */
  32289. export class PerfCounter {
  32290. /**
  32291. * Gets or sets a global boolean to turn on and off all the counters
  32292. */
  32293. static Enabled: boolean;
  32294. /**
  32295. * Returns the smallest value ever
  32296. */
  32297. readonly min: number;
  32298. /**
  32299. * Returns the biggest value ever
  32300. */
  32301. readonly max: number;
  32302. /**
  32303. * Returns the average value since the performance counter is running
  32304. */
  32305. readonly average: number;
  32306. /**
  32307. * Returns the average value of the last second the counter was monitored
  32308. */
  32309. readonly lastSecAverage: number;
  32310. /**
  32311. * Returns the current value
  32312. */
  32313. readonly current: number;
  32314. /**
  32315. * Gets the accumulated total
  32316. */
  32317. readonly total: number;
  32318. /**
  32319. * Gets the total value count
  32320. */
  32321. readonly count: number;
  32322. /**
  32323. * Creates a new counter
  32324. */
  32325. constructor();
  32326. /**
  32327. * Call this method to start monitoring a new frame.
  32328. * 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.
  32329. */
  32330. fetchNewFrame(): void;
  32331. /**
  32332. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32333. * @param newCount the count value to add to the monitored count
  32334. * @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.
  32335. */
  32336. addCount(newCount: number, fetchResult: boolean): void;
  32337. /**
  32338. * Start monitoring this performance counter
  32339. */
  32340. beginMonitoring(): void;
  32341. /**
  32342. * Compute the time lapsed since the previous beginMonitoring() call.
  32343. * @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
  32344. */
  32345. endMonitoring(newFrame?: boolean): void;
  32346. private _fetchResult;
  32347. private _startMonitoringTime;
  32348. private _min;
  32349. private _max;
  32350. private _average;
  32351. private _current;
  32352. private _totalValueCount;
  32353. private _totalAccumulated;
  32354. private _lastSecAverage;
  32355. private _lastSecAccumulated;
  32356. private _lastSecTime;
  32357. private _lastSecValueCount;
  32358. }
  32359. }
  32360. declare module BABYLON {
  32361. /**
  32362. * Defines the interface used by display changed events
  32363. */
  32364. export interface IDisplayChangedEventArgs {
  32365. /** Gets the vrDisplay object (if any) */
  32366. vrDisplay: Nullable<any>;
  32367. /** Gets a boolean indicating if webVR is supported */
  32368. vrSupported: boolean;
  32369. }
  32370. /**
  32371. * Defines the interface used by objects containing a viewport (like a camera)
  32372. */
  32373. interface IViewportOwnerLike {
  32374. /**
  32375. * Gets or sets the viewport
  32376. */
  32377. viewport: IViewportLike;
  32378. }
  32379. /**
  32380. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32381. */
  32382. export class Engine extends ThinEngine {
  32383. /** Defines that alpha blending is disabled */
  32384. static readonly ALPHA_DISABLE: number;
  32385. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32386. static readonly ALPHA_ADD: number;
  32387. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32388. static readonly ALPHA_COMBINE: number;
  32389. /** Defines that alpha blending to DEST - SRC * DEST */
  32390. static readonly ALPHA_SUBTRACT: number;
  32391. /** Defines that alpha blending to SRC * DEST */
  32392. static readonly ALPHA_MULTIPLY: number;
  32393. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32394. static readonly ALPHA_MAXIMIZED: number;
  32395. /** Defines that alpha blending to SRC + DEST */
  32396. static readonly ALPHA_ONEONE: number;
  32397. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32398. static readonly ALPHA_PREMULTIPLIED: number;
  32399. /**
  32400. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32401. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32402. */
  32403. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32404. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32405. static readonly ALPHA_INTERPOLATE: number;
  32406. /**
  32407. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32408. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32409. */
  32410. static readonly ALPHA_SCREENMODE: number;
  32411. /** Defines that the ressource is not delayed*/
  32412. static readonly DELAYLOADSTATE_NONE: number;
  32413. /** Defines that the ressource was successfully delay loaded */
  32414. static readonly DELAYLOADSTATE_LOADED: number;
  32415. /** Defines that the ressource is currently delay loading */
  32416. static readonly DELAYLOADSTATE_LOADING: number;
  32417. /** Defines that the ressource is delayed and has not started loading */
  32418. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32419. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32420. static readonly NEVER: number;
  32421. /** 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 */
  32422. static readonly ALWAYS: number;
  32423. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32424. static readonly LESS: number;
  32425. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32426. static readonly EQUAL: number;
  32427. /** 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 */
  32428. static readonly LEQUAL: number;
  32429. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32430. static readonly GREATER: number;
  32431. /** 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 */
  32432. static readonly GEQUAL: number;
  32433. /** 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 */
  32434. static readonly NOTEQUAL: number;
  32435. /** Passed to stencilOperation to specify that stencil value must be kept */
  32436. static readonly KEEP: number;
  32437. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32438. static readonly REPLACE: number;
  32439. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32440. static readonly INCR: number;
  32441. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32442. static readonly DECR: number;
  32443. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32444. static readonly INVERT: number;
  32445. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32446. static readonly INCR_WRAP: number;
  32447. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32448. static readonly DECR_WRAP: number;
  32449. /** Texture is not repeating outside of 0..1 UVs */
  32450. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32451. /** Texture is repeating outside of 0..1 UVs */
  32452. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32453. /** Texture is repeating and mirrored */
  32454. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32455. /** ALPHA */
  32456. static readonly TEXTUREFORMAT_ALPHA: number;
  32457. /** LUMINANCE */
  32458. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32459. /** LUMINANCE_ALPHA */
  32460. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32461. /** RGB */
  32462. static readonly TEXTUREFORMAT_RGB: number;
  32463. /** RGBA */
  32464. static readonly TEXTUREFORMAT_RGBA: number;
  32465. /** RED */
  32466. static readonly TEXTUREFORMAT_RED: number;
  32467. /** RED (2nd reference) */
  32468. static readonly TEXTUREFORMAT_R: number;
  32469. /** RG */
  32470. static readonly TEXTUREFORMAT_RG: number;
  32471. /** RED_INTEGER */
  32472. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32473. /** RED_INTEGER (2nd reference) */
  32474. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32475. /** RG_INTEGER */
  32476. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32477. /** RGB_INTEGER */
  32478. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32479. /** RGBA_INTEGER */
  32480. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32481. /** UNSIGNED_BYTE */
  32482. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32483. /** UNSIGNED_BYTE (2nd reference) */
  32484. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32485. /** FLOAT */
  32486. static readonly TEXTURETYPE_FLOAT: number;
  32487. /** HALF_FLOAT */
  32488. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32489. /** BYTE */
  32490. static readonly TEXTURETYPE_BYTE: number;
  32491. /** SHORT */
  32492. static readonly TEXTURETYPE_SHORT: number;
  32493. /** UNSIGNED_SHORT */
  32494. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32495. /** INT */
  32496. static readonly TEXTURETYPE_INT: number;
  32497. /** UNSIGNED_INT */
  32498. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32499. /** UNSIGNED_SHORT_4_4_4_4 */
  32500. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32501. /** UNSIGNED_SHORT_5_5_5_1 */
  32502. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32503. /** UNSIGNED_SHORT_5_6_5 */
  32504. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32505. /** UNSIGNED_INT_2_10_10_10_REV */
  32506. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32507. /** UNSIGNED_INT_24_8 */
  32508. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32509. /** UNSIGNED_INT_10F_11F_11F_REV */
  32510. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32511. /** UNSIGNED_INT_5_9_9_9_REV */
  32512. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32513. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32514. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32515. /** nearest is mag = nearest and min = nearest and mip = linear */
  32516. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32517. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32518. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32519. /** Trilinear is mag = linear and min = linear and mip = linear */
  32520. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32521. /** nearest is mag = nearest and min = nearest and mip = linear */
  32522. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32523. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32524. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32525. /** Trilinear is mag = linear and min = linear and mip = linear */
  32526. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32527. /** mag = nearest and min = nearest and mip = nearest */
  32528. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32529. /** mag = nearest and min = linear and mip = nearest */
  32530. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32531. /** mag = nearest and min = linear and mip = linear */
  32532. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32533. /** mag = nearest and min = linear and mip = none */
  32534. static readonly TEXTURE_NEAREST_LINEAR: number;
  32535. /** mag = nearest and min = nearest and mip = none */
  32536. static readonly TEXTURE_NEAREST_NEAREST: number;
  32537. /** mag = linear and min = nearest and mip = nearest */
  32538. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32539. /** mag = linear and min = nearest and mip = linear */
  32540. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32541. /** mag = linear and min = linear and mip = none */
  32542. static readonly TEXTURE_LINEAR_LINEAR: number;
  32543. /** mag = linear and min = nearest and mip = none */
  32544. static readonly TEXTURE_LINEAR_NEAREST: number;
  32545. /** Explicit coordinates mode */
  32546. static readonly TEXTURE_EXPLICIT_MODE: number;
  32547. /** Spherical coordinates mode */
  32548. static readonly TEXTURE_SPHERICAL_MODE: number;
  32549. /** Planar coordinates mode */
  32550. static readonly TEXTURE_PLANAR_MODE: number;
  32551. /** Cubic coordinates mode */
  32552. static readonly TEXTURE_CUBIC_MODE: number;
  32553. /** Projection coordinates mode */
  32554. static readonly TEXTURE_PROJECTION_MODE: number;
  32555. /** Skybox coordinates mode */
  32556. static readonly TEXTURE_SKYBOX_MODE: number;
  32557. /** Inverse Cubic coordinates mode */
  32558. static readonly TEXTURE_INVCUBIC_MODE: number;
  32559. /** Equirectangular coordinates mode */
  32560. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32561. /** Equirectangular Fixed coordinates mode */
  32562. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32563. /** Equirectangular Fixed Mirrored coordinates mode */
  32564. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32565. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32566. static readonly SCALEMODE_FLOOR: number;
  32567. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32568. static readonly SCALEMODE_NEAREST: number;
  32569. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32570. static readonly SCALEMODE_CEILING: number;
  32571. /**
  32572. * Returns the current npm package of the sdk
  32573. */
  32574. static readonly NpmPackage: string;
  32575. /**
  32576. * Returns the current version of the framework
  32577. */
  32578. static readonly Version: string;
  32579. /** Gets the list of created engines */
  32580. static readonly Instances: Engine[];
  32581. /**
  32582. * Gets the latest created engine
  32583. */
  32584. static readonly LastCreatedEngine: Nullable<Engine>;
  32585. /**
  32586. * Gets the latest created scene
  32587. */
  32588. static readonly LastCreatedScene: Nullable<Scene>;
  32589. /**
  32590. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32591. * @param flag defines which part of the materials must be marked as dirty
  32592. * @param predicate defines a predicate used to filter which materials should be affected
  32593. */
  32594. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32595. /**
  32596. * Method called to create the default loading screen.
  32597. * This can be overriden in your own app.
  32598. * @param canvas The rendering canvas element
  32599. * @returns The loading screen
  32600. */
  32601. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32602. /**
  32603. * Method called to create the default rescale post process on each engine.
  32604. */
  32605. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32606. /**
  32607. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32608. **/
  32609. enableOfflineSupport: boolean;
  32610. /**
  32611. * 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)
  32612. **/
  32613. disableManifestCheck: boolean;
  32614. /**
  32615. * Gets the list of created scenes
  32616. */
  32617. scenes: Scene[];
  32618. /**
  32619. * Event raised when a new scene is created
  32620. */
  32621. onNewSceneAddedObservable: Observable<Scene>;
  32622. /**
  32623. * Gets the list of created postprocesses
  32624. */
  32625. postProcesses: PostProcess[];
  32626. /**
  32627. * Gets a boolean indicating if the pointer is currently locked
  32628. */
  32629. isPointerLock: boolean;
  32630. /**
  32631. * Observable event triggered each time the rendering canvas is resized
  32632. */
  32633. onResizeObservable: Observable<Engine>;
  32634. /**
  32635. * Observable event triggered each time the canvas loses focus
  32636. */
  32637. onCanvasBlurObservable: Observable<Engine>;
  32638. /**
  32639. * Observable event triggered each time the canvas gains focus
  32640. */
  32641. onCanvasFocusObservable: Observable<Engine>;
  32642. /**
  32643. * Observable event triggered each time the canvas receives pointerout event
  32644. */
  32645. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32646. /**
  32647. * Observable raised when the engine begins a new frame
  32648. */
  32649. onBeginFrameObservable: Observable<Engine>;
  32650. /**
  32651. * If set, will be used to request the next animation frame for the render loop
  32652. */
  32653. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32654. /**
  32655. * Observable raised when the engine ends the current frame
  32656. */
  32657. onEndFrameObservable: Observable<Engine>;
  32658. /**
  32659. * Observable raised when the engine is about to compile a shader
  32660. */
  32661. onBeforeShaderCompilationObservable: Observable<Engine>;
  32662. /**
  32663. * Observable raised when the engine has jsut compiled a shader
  32664. */
  32665. onAfterShaderCompilationObservable: Observable<Engine>;
  32666. /**
  32667. * Gets the audio engine
  32668. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32669. * @ignorenaming
  32670. */
  32671. static audioEngine: IAudioEngine;
  32672. /**
  32673. * Default AudioEngine factory responsible of creating the Audio Engine.
  32674. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32675. */
  32676. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32677. /**
  32678. * Default offline support factory responsible of creating a tool used to store data locally.
  32679. * By default, this will create a Database object if the workload has been embedded.
  32680. */
  32681. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32682. private _loadingScreen;
  32683. private _pointerLockRequested;
  32684. private _dummyFramebuffer;
  32685. private _rescalePostProcess;
  32686. /** @hidden */
  32687. protected _alphaMode: number;
  32688. /** @hidden */
  32689. protected _alphaEquation: number;
  32690. private _deterministicLockstep;
  32691. private _lockstepMaxSteps;
  32692. private _timeStep;
  32693. protected readonly _supportsHardwareTextureRescaling: boolean;
  32694. private _fps;
  32695. private _deltaTime;
  32696. /** @hidden */
  32697. _drawCalls: PerfCounter;
  32698. /**
  32699. * Turn this value on if you want to pause FPS computation when in background
  32700. */
  32701. disablePerformanceMonitorInBackground: boolean;
  32702. private _performanceMonitor;
  32703. /**
  32704. * Gets the performance monitor attached to this engine
  32705. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32706. */
  32707. readonly performanceMonitor: PerformanceMonitor;
  32708. private _onFocus;
  32709. private _onBlur;
  32710. private _onCanvasPointerOut;
  32711. private _onCanvasBlur;
  32712. private _onCanvasFocus;
  32713. private _onFullscreenChange;
  32714. private _onPointerLockChange;
  32715. /**
  32716. * Gets the HTML element used to attach event listeners
  32717. * @returns a HTML element
  32718. */
  32719. getInputElement(): Nullable<HTMLElement>;
  32720. /**
  32721. * Creates a new engine
  32722. * @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
  32723. * @param antialias defines enable antialiasing (default: false)
  32724. * @param options defines further options to be sent to the getContext() function
  32725. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32726. */
  32727. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32728. /**
  32729. * Gets current aspect ratio
  32730. * @param viewportOwner defines the camera to use to get the aspect ratio
  32731. * @param useScreen defines if screen size must be used (or the current render target if any)
  32732. * @returns a number defining the aspect ratio
  32733. */
  32734. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32735. /**
  32736. * Gets current screen aspect ratio
  32737. * @returns a number defining the aspect ratio
  32738. */
  32739. getScreenAspectRatio(): number;
  32740. /**
  32741. * Gets the client rect of the HTML canvas attached with the current webGL context
  32742. * @returns a client rectanglee
  32743. */
  32744. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32745. /**
  32746. * Gets the client rect of the HTML element used for events
  32747. * @returns a client rectanglee
  32748. */
  32749. getInputElementClientRect(): Nullable<ClientRect>;
  32750. /**
  32751. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32752. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32753. * @returns true if engine is in deterministic lock step mode
  32754. */
  32755. isDeterministicLockStep(): boolean;
  32756. /**
  32757. * Gets the max steps when engine is running in deterministic lock step
  32758. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32759. * @returns the max steps
  32760. */
  32761. getLockstepMaxSteps(): number;
  32762. /**
  32763. * Returns the time in ms between steps when using deterministic lock step.
  32764. * @returns time step in (ms)
  32765. */
  32766. getTimeStep(): number;
  32767. /**
  32768. * Force the mipmap generation for the given render target texture
  32769. * @param texture defines the render target texture to use
  32770. */
  32771. generateMipMapsForCubemap(texture: InternalTexture): void;
  32772. /** States */
  32773. /**
  32774. * Set various states to the webGL context
  32775. * @param culling defines backface culling state
  32776. * @param zOffset defines the value to apply to zOffset (0 by default)
  32777. * @param force defines if states must be applied even if cache is up to date
  32778. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32779. */
  32780. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32781. /**
  32782. * Set the z offset to apply to current rendering
  32783. * @param value defines the offset to apply
  32784. */
  32785. setZOffset(value: number): void;
  32786. /**
  32787. * Gets the current value of the zOffset
  32788. * @returns the current zOffset state
  32789. */
  32790. getZOffset(): number;
  32791. /**
  32792. * Enable or disable depth buffering
  32793. * @param enable defines the state to set
  32794. */
  32795. setDepthBuffer(enable: boolean): void;
  32796. /**
  32797. * Gets a boolean indicating if depth writing is enabled
  32798. * @returns the current depth writing state
  32799. */
  32800. getDepthWrite(): boolean;
  32801. /**
  32802. * Enable or disable depth writing
  32803. * @param enable defines the state to set
  32804. */
  32805. setDepthWrite(enable: boolean): void;
  32806. /**
  32807. * Enable or disable color writing
  32808. * @param enable defines the state to set
  32809. */
  32810. setColorWrite(enable: boolean): void;
  32811. /**
  32812. * Gets a boolean indicating if color writing is enabled
  32813. * @returns the current color writing state
  32814. */
  32815. getColorWrite(): boolean;
  32816. /**
  32817. * Sets alpha constants used by some alpha blending modes
  32818. * @param r defines the red component
  32819. * @param g defines the green component
  32820. * @param b defines the blue component
  32821. * @param a defines the alpha component
  32822. */
  32823. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32824. /**
  32825. * Sets the current alpha mode
  32826. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32827. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32828. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32829. */
  32830. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32831. /**
  32832. * Gets the current alpha mode
  32833. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32834. * @returns the current alpha mode
  32835. */
  32836. getAlphaMode(): number;
  32837. /**
  32838. * Sets the current alpha equation
  32839. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32840. */
  32841. setAlphaEquation(equation: number): void;
  32842. /**
  32843. * Gets the current alpha equation.
  32844. * @returns the current alpha equation
  32845. */
  32846. getAlphaEquation(): number;
  32847. /**
  32848. * Gets a boolean indicating if stencil buffer is enabled
  32849. * @returns the current stencil buffer state
  32850. */
  32851. getStencilBuffer(): boolean;
  32852. /**
  32853. * Enable or disable the stencil buffer
  32854. * @param enable defines if the stencil buffer must be enabled or disabled
  32855. */
  32856. setStencilBuffer(enable: boolean): void;
  32857. /**
  32858. * Gets the current stencil mask
  32859. * @returns a number defining the new stencil mask to use
  32860. */
  32861. getStencilMask(): number;
  32862. /**
  32863. * Sets the current stencil mask
  32864. * @param mask defines the new stencil mask to use
  32865. */
  32866. setStencilMask(mask: number): void;
  32867. /**
  32868. * Gets the current stencil function
  32869. * @returns a number defining the stencil function to use
  32870. */
  32871. getStencilFunction(): number;
  32872. /**
  32873. * Gets the current stencil reference value
  32874. * @returns a number defining the stencil reference value to use
  32875. */
  32876. getStencilFunctionReference(): number;
  32877. /**
  32878. * Gets the current stencil mask
  32879. * @returns a number defining the stencil mask to use
  32880. */
  32881. getStencilFunctionMask(): number;
  32882. /**
  32883. * Sets the current stencil function
  32884. * @param stencilFunc defines the new stencil function to use
  32885. */
  32886. setStencilFunction(stencilFunc: number): void;
  32887. /**
  32888. * Sets the current stencil reference
  32889. * @param reference defines the new stencil reference to use
  32890. */
  32891. setStencilFunctionReference(reference: number): void;
  32892. /**
  32893. * Sets the current stencil mask
  32894. * @param mask defines the new stencil mask to use
  32895. */
  32896. setStencilFunctionMask(mask: number): void;
  32897. /**
  32898. * Gets the current stencil operation when stencil fails
  32899. * @returns a number defining stencil operation to use when stencil fails
  32900. */
  32901. getStencilOperationFail(): number;
  32902. /**
  32903. * Gets the current stencil operation when depth fails
  32904. * @returns a number defining stencil operation to use when depth fails
  32905. */
  32906. getStencilOperationDepthFail(): number;
  32907. /**
  32908. * Gets the current stencil operation when stencil passes
  32909. * @returns a number defining stencil operation to use when stencil passes
  32910. */
  32911. getStencilOperationPass(): number;
  32912. /**
  32913. * Sets the stencil operation to use when stencil fails
  32914. * @param operation defines the stencil operation to use when stencil fails
  32915. */
  32916. setStencilOperationFail(operation: number): void;
  32917. /**
  32918. * Sets the stencil operation to use when depth fails
  32919. * @param operation defines the stencil operation to use when depth fails
  32920. */
  32921. setStencilOperationDepthFail(operation: number): void;
  32922. /**
  32923. * Sets the stencil operation to use when stencil passes
  32924. * @param operation defines the stencil operation to use when stencil passes
  32925. */
  32926. setStencilOperationPass(operation: number): void;
  32927. /**
  32928. * Sets a boolean indicating if the dithering state is enabled or disabled
  32929. * @param value defines the dithering state
  32930. */
  32931. setDitheringState(value: boolean): void;
  32932. /**
  32933. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32934. * @param value defines the rasterizer state
  32935. */
  32936. setRasterizerState(value: boolean): void;
  32937. /**
  32938. * Gets the current depth function
  32939. * @returns a number defining the depth function
  32940. */
  32941. getDepthFunction(): Nullable<number>;
  32942. /**
  32943. * Sets the current depth function
  32944. * @param depthFunc defines the function to use
  32945. */
  32946. setDepthFunction(depthFunc: number): void;
  32947. /**
  32948. * Sets the current depth function to GREATER
  32949. */
  32950. setDepthFunctionToGreater(): void;
  32951. /**
  32952. * Sets the current depth function to GEQUAL
  32953. */
  32954. setDepthFunctionToGreaterOrEqual(): void;
  32955. /**
  32956. * Sets the current depth function to LESS
  32957. */
  32958. setDepthFunctionToLess(): void;
  32959. /**
  32960. * Sets the current depth function to LEQUAL
  32961. */
  32962. setDepthFunctionToLessOrEqual(): void;
  32963. private _cachedStencilBuffer;
  32964. private _cachedStencilFunction;
  32965. private _cachedStencilMask;
  32966. private _cachedStencilOperationPass;
  32967. private _cachedStencilOperationFail;
  32968. private _cachedStencilOperationDepthFail;
  32969. private _cachedStencilReference;
  32970. /**
  32971. * Caches the the state of the stencil buffer
  32972. */
  32973. cacheStencilState(): void;
  32974. /**
  32975. * Restores the state of the stencil buffer
  32976. */
  32977. restoreStencilState(): void;
  32978. /**
  32979. * Directly set the WebGL Viewport
  32980. * @param x defines the x coordinate of the viewport (in screen space)
  32981. * @param y defines the y coordinate of the viewport (in screen space)
  32982. * @param width defines the width of the viewport (in screen space)
  32983. * @param height defines the height of the viewport (in screen space)
  32984. * @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
  32985. */
  32986. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32987. /**
  32988. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32989. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32990. * @param y defines the y-coordinate of the corner of the clear rectangle
  32991. * @param width defines the width of the clear rectangle
  32992. * @param height defines the height of the clear rectangle
  32993. * @param clearColor defines the clear color
  32994. */
  32995. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32996. /**
  32997. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32998. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32999. * @param y defines the y-coordinate of the corner of the clear rectangle
  33000. * @param width defines the width of the clear rectangle
  33001. * @param height defines the height of the clear rectangle
  33002. */
  33003. enableScissor(x: number, y: number, width: number, height: number): void;
  33004. /**
  33005. * Disable previously set scissor test rectangle
  33006. */
  33007. disableScissor(): void;
  33008. protected _reportDrawCall(): void;
  33009. /**
  33010. * Initializes a webVR display and starts listening to display change events
  33011. * The onVRDisplayChangedObservable will be notified upon these changes
  33012. * @returns The onVRDisplayChangedObservable
  33013. */
  33014. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33015. /** @hidden */
  33016. _prepareVRComponent(): void;
  33017. /** @hidden */
  33018. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33019. /** @hidden */
  33020. _submitVRFrame(): void;
  33021. /**
  33022. * Call this function to leave webVR mode
  33023. * Will do nothing if webVR is not supported or if there is no webVR device
  33024. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33025. */
  33026. disableVR(): void;
  33027. /**
  33028. * Gets a boolean indicating that the system is in VR mode and is presenting
  33029. * @returns true if VR mode is engaged
  33030. */
  33031. isVRPresenting(): boolean;
  33032. /** @hidden */
  33033. _requestVRFrame(): void;
  33034. /** @hidden */
  33035. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33036. /**
  33037. * Gets the source code of the vertex shader associated with a specific webGL program
  33038. * @param program defines the program to use
  33039. * @returns a string containing the source code of the vertex shader associated with the program
  33040. */
  33041. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33042. /**
  33043. * Gets the source code of the fragment shader associated with a specific webGL program
  33044. * @param program defines the program to use
  33045. * @returns a string containing the source code of the fragment shader associated with the program
  33046. */
  33047. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33048. /**
  33049. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33050. * @param x defines the x coordinate of the rectangle where pixels must be read
  33051. * @param y defines the y coordinate of the rectangle where pixels must be read
  33052. * @param width defines the width of the rectangle where pixels must be read
  33053. * @param height defines the height of the rectangle where pixels must be read
  33054. * @returns a Uint8Array containing RGBA colors
  33055. */
  33056. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  33057. /**
  33058. * Sets a depth stencil texture from a render target to the according uniform.
  33059. * @param channel The texture channel
  33060. * @param uniform The uniform to set
  33061. * @param texture The render target texture containing the depth stencil texture to apply
  33062. */
  33063. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33064. /**
  33065. * Sets a texture to the webGL context from a postprocess
  33066. * @param channel defines the channel to use
  33067. * @param postProcess defines the source postprocess
  33068. */
  33069. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33070. /**
  33071. * Binds the output of the passed in post process to the texture channel specified
  33072. * @param channel The channel the texture should be bound to
  33073. * @param postProcess The post process which's output should be bound
  33074. */
  33075. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33076. /** @hidden */
  33077. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33078. protected _rebuildBuffers(): void;
  33079. /** @hidden */
  33080. _renderFrame(): void;
  33081. _renderLoop(): void;
  33082. /** @hidden */
  33083. _renderViews(): boolean;
  33084. /**
  33085. * Toggle full screen mode
  33086. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33087. */
  33088. switchFullscreen(requestPointerLock: boolean): void;
  33089. /**
  33090. * Enters full screen mode
  33091. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33092. */
  33093. enterFullscreen(requestPointerLock: boolean): void;
  33094. /**
  33095. * Exits full screen mode
  33096. */
  33097. exitFullscreen(): void;
  33098. /**
  33099. * Enters Pointerlock mode
  33100. */
  33101. enterPointerlock(): void;
  33102. /**
  33103. * Exits Pointerlock mode
  33104. */
  33105. exitPointerlock(): void;
  33106. /**
  33107. * Begin a new frame
  33108. */
  33109. beginFrame(): void;
  33110. /**
  33111. * Enf the current frame
  33112. */
  33113. endFrame(): void;
  33114. resize(): void;
  33115. /**
  33116. * Set the compressed texture format to use, based on the formats you have, and the formats
  33117. * supported by the hardware / browser.
  33118. *
  33119. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33120. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33121. * to API arguments needed to compressed textures. This puts the burden on the container
  33122. * generator to house the arcane code for determining these for current & future formats.
  33123. *
  33124. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33125. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33126. *
  33127. * Note: The result of this call is not taken into account when a texture is base64.
  33128. *
  33129. * @param formatsAvailable defines the list of those format families you have created
  33130. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33131. *
  33132. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33133. * @returns The extension selected.
  33134. */
  33135. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33136. /**
  33137. * Force a specific size of the canvas
  33138. * @param width defines the new canvas' width
  33139. * @param height defines the new canvas' height
  33140. */
  33141. setSize(width: number, height: number): void;
  33142. /**
  33143. * Updates a dynamic vertex buffer.
  33144. * @param vertexBuffer the vertex buffer to update
  33145. * @param data the data used to update the vertex buffer
  33146. * @param byteOffset the byte offset of the data
  33147. * @param byteLength the byte length of the data
  33148. */
  33149. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33150. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33151. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33152. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33153. _releaseTexture(texture: InternalTexture): void;
  33154. /**
  33155. * @hidden
  33156. * Rescales a texture
  33157. * @param source input texutre
  33158. * @param destination destination texture
  33159. * @param scene scene to use to render the resize
  33160. * @param internalFormat format to use when resizing
  33161. * @param onComplete callback to be called when resize has completed
  33162. */
  33163. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33164. /**
  33165. * Gets the current framerate
  33166. * @returns a number representing the framerate
  33167. */
  33168. getFps(): number;
  33169. /**
  33170. * Gets the time spent between current and previous frame
  33171. * @returns a number representing the delta time in ms
  33172. */
  33173. getDeltaTime(): number;
  33174. private _measureFps;
  33175. /** @hidden */
  33176. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33177. /**
  33178. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  33179. * @param renderTarget The render target to set the frame buffer for
  33180. */
  33181. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  33182. /**
  33183. * Update a dynamic index buffer
  33184. * @param indexBuffer defines the target index buffer
  33185. * @param indices defines the data to update
  33186. * @param offset defines the offset in the target index buffer where update should start
  33187. */
  33188. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33189. /**
  33190. * Updates the sample count of a render target texture
  33191. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33192. * @param texture defines the texture to update
  33193. * @param samples defines the sample count to set
  33194. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33195. */
  33196. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33197. /**
  33198. * Updates a depth texture Comparison Mode and Function.
  33199. * If the comparison Function is equal to 0, the mode will be set to none.
  33200. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33201. * @param texture The texture to set the comparison function for
  33202. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33203. */
  33204. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33205. /**
  33206. * Creates a webGL buffer to use with instanciation
  33207. * @param capacity defines the size of the buffer
  33208. * @returns the webGL buffer
  33209. */
  33210. createInstancesBuffer(capacity: number): DataBuffer;
  33211. /**
  33212. * Delete a webGL buffer used with instanciation
  33213. * @param buffer defines the webGL buffer to delete
  33214. */
  33215. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33216. /** @hidden */
  33217. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33218. dispose(): void;
  33219. private _disableTouchAction;
  33220. /**
  33221. * Display the loading screen
  33222. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33223. */
  33224. displayLoadingUI(): void;
  33225. /**
  33226. * Hide the loading screen
  33227. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33228. */
  33229. hideLoadingUI(): void;
  33230. /**
  33231. * Gets the current loading screen object
  33232. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33233. */
  33234. /**
  33235. * Sets the current loading screen object
  33236. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33237. */
  33238. loadingScreen: ILoadingScreen;
  33239. /**
  33240. * Sets the current loading screen text
  33241. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33242. */
  33243. loadingUIText: string;
  33244. /**
  33245. * Sets the current loading screen background color
  33246. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33247. */
  33248. loadingUIBackgroundColor: string;
  33249. /** Pointerlock and fullscreen */
  33250. /**
  33251. * Ask the browser to promote the current element to pointerlock mode
  33252. * @param element defines the DOM element to promote
  33253. */
  33254. static _RequestPointerlock(element: HTMLElement): void;
  33255. /**
  33256. * Asks the browser to exit pointerlock mode
  33257. */
  33258. static _ExitPointerlock(): void;
  33259. /**
  33260. * Ask the browser to promote the current element to fullscreen rendering mode
  33261. * @param element defines the DOM element to promote
  33262. */
  33263. static _RequestFullscreen(element: HTMLElement): void;
  33264. /**
  33265. * Asks the browser to exit fullscreen mode
  33266. */
  33267. static _ExitFullscreen(): void;
  33268. }
  33269. }
  33270. declare module BABYLON {
  33271. /**
  33272. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33273. * during the life time of the application.
  33274. */
  33275. export class EngineStore {
  33276. /** Gets the list of created engines */
  33277. static Instances: Engine[];
  33278. /** @hidden */
  33279. static _LastCreatedScene: Nullable<Scene>;
  33280. /**
  33281. * Gets the latest created engine
  33282. */
  33283. static readonly LastCreatedEngine: Nullable<Engine>;
  33284. /**
  33285. * Gets the latest created scene
  33286. */
  33287. static readonly LastCreatedScene: Nullable<Scene>;
  33288. /**
  33289. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33290. * @ignorenaming
  33291. */
  33292. static UseFallbackTexture: boolean;
  33293. /**
  33294. * Texture content used if a texture cannot loaded
  33295. * @ignorenaming
  33296. */
  33297. static FallbackTexture: string;
  33298. }
  33299. }
  33300. declare module BABYLON {
  33301. /**
  33302. * Helper class that provides a small promise polyfill
  33303. */
  33304. export class PromisePolyfill {
  33305. /**
  33306. * Static function used to check if the polyfill is required
  33307. * If this is the case then the function will inject the polyfill to window.Promise
  33308. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33309. */
  33310. static Apply(force?: boolean): void;
  33311. }
  33312. }
  33313. declare module BABYLON {
  33314. /**
  33315. * Interface for screenshot methods with describe argument called `size` as object with options
  33316. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33317. */
  33318. export interface IScreenshotSize {
  33319. /**
  33320. * number in pixels for canvas height
  33321. */
  33322. height?: number;
  33323. /**
  33324. * multiplier allowing render at a higher or lower resolution
  33325. * If value is defined then height and width will be ignored and taken from camera
  33326. */
  33327. precision?: number;
  33328. /**
  33329. * number in pixels for canvas width
  33330. */
  33331. width?: number;
  33332. }
  33333. }
  33334. declare module BABYLON {
  33335. interface IColor4Like {
  33336. r: float;
  33337. g: float;
  33338. b: float;
  33339. a: float;
  33340. }
  33341. /**
  33342. * Class containing a set of static utilities functions
  33343. */
  33344. export class Tools {
  33345. /**
  33346. * Gets or sets the base URL to use to load assets
  33347. */
  33348. static BaseUrl: string;
  33349. /**
  33350. * Enable/Disable Custom HTTP Request Headers globally.
  33351. * default = false
  33352. * @see CustomRequestHeaders
  33353. */
  33354. static UseCustomRequestHeaders: boolean;
  33355. /**
  33356. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33357. * i.e. when loading files, where the server/service expects an Authorization header
  33358. */
  33359. static CustomRequestHeaders: {
  33360. [key: string]: string;
  33361. };
  33362. /**
  33363. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33364. */
  33365. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  33366. /**
  33367. * Default behaviour for cors in the application.
  33368. * It can be a string if the expected behavior is identical in the entire app.
  33369. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33370. */
  33371. static CorsBehavior: string | ((url: string | string[]) => string);
  33372. /**
  33373. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33374. * @ignorenaming
  33375. */
  33376. static UseFallbackTexture: boolean;
  33377. /**
  33378. * Use this object to register external classes like custom textures or material
  33379. * to allow the laoders to instantiate them
  33380. */
  33381. static RegisteredExternalClasses: {
  33382. [key: string]: Object;
  33383. };
  33384. /**
  33385. * Texture content used if a texture cannot loaded
  33386. * @ignorenaming
  33387. */
  33388. static fallbackTexture: string;
  33389. /**
  33390. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33391. * @param u defines the coordinate on X axis
  33392. * @param v defines the coordinate on Y axis
  33393. * @param width defines the width of the source data
  33394. * @param height defines the height of the source data
  33395. * @param pixels defines the source byte array
  33396. * @param color defines the output color
  33397. */
  33398. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33399. /**
  33400. * Interpolates between a and b via alpha
  33401. * @param a The lower value (returned when alpha = 0)
  33402. * @param b The upper value (returned when alpha = 1)
  33403. * @param alpha The interpolation-factor
  33404. * @return The mixed value
  33405. */
  33406. static Mix(a: number, b: number, alpha: number): number;
  33407. /**
  33408. * Tries to instantiate a new object from a given class name
  33409. * @param className defines the class name to instantiate
  33410. * @returns the new object or null if the system was not able to do the instantiation
  33411. */
  33412. static Instantiate(className: string): any;
  33413. /**
  33414. * Provides a slice function that will work even on IE
  33415. * @param data defines the array to slice
  33416. * @param start defines the start of the data (optional)
  33417. * @param end defines the end of the data (optional)
  33418. * @returns the new sliced array
  33419. */
  33420. static Slice<T>(data: T, start?: number, end?: number): T;
  33421. /**
  33422. * Polyfill for setImmediate
  33423. * @param action defines the action to execute after the current execution block
  33424. */
  33425. static SetImmediate(action: () => void): void;
  33426. /**
  33427. * Function indicating if a number is an exponent of 2
  33428. * @param value defines the value to test
  33429. * @returns true if the value is an exponent of 2
  33430. */
  33431. static IsExponentOfTwo(value: number): boolean;
  33432. private static _tmpFloatArray;
  33433. /**
  33434. * Returns the nearest 32-bit single precision float representation of a Number
  33435. * @param value A Number. If the parameter is of a different type, it will get converted
  33436. * to a number or to NaN if it cannot be converted
  33437. * @returns number
  33438. */
  33439. static FloatRound(value: number): number;
  33440. /**
  33441. * Extracts the filename from a path
  33442. * @param path defines the path to use
  33443. * @returns the filename
  33444. */
  33445. static GetFilename(path: string): string;
  33446. /**
  33447. * Extracts the "folder" part of a path (everything before the filename).
  33448. * @param uri The URI to extract the info from
  33449. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33450. * @returns The "folder" part of the path
  33451. */
  33452. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33453. /**
  33454. * Extracts text content from a DOM element hierarchy
  33455. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33456. */
  33457. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33458. /**
  33459. * Convert an angle in radians to degrees
  33460. * @param angle defines the angle to convert
  33461. * @returns the angle in degrees
  33462. */
  33463. static ToDegrees(angle: number): number;
  33464. /**
  33465. * Convert an angle in degrees to radians
  33466. * @param angle defines the angle to convert
  33467. * @returns the angle in radians
  33468. */
  33469. static ToRadians(angle: number): number;
  33470. /**
  33471. * Returns an array if obj is not an array
  33472. * @param obj defines the object to evaluate as an array
  33473. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33474. * @returns either obj directly if obj is an array or a new array containing obj
  33475. */
  33476. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33477. /**
  33478. * Gets the pointer prefix to use
  33479. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33480. */
  33481. static GetPointerPrefix(): string;
  33482. /**
  33483. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33484. * @param url define the url we are trying
  33485. * @param element define the dom element where to configure the cors policy
  33486. */
  33487. static SetCorsBehavior(url: string | string[], element: {
  33488. crossOrigin: string | null;
  33489. }): void;
  33490. /**
  33491. * Removes unwanted characters from an url
  33492. * @param url defines the url to clean
  33493. * @returns the cleaned url
  33494. */
  33495. static CleanUrl(url: string): string;
  33496. /**
  33497. * Gets or sets a function used to pre-process url before using them to load assets
  33498. */
  33499. static PreprocessUrl: (url: string) => string;
  33500. /**
  33501. * Loads an image as an HTMLImageElement.
  33502. * @param input url string, ArrayBuffer, or Blob to load
  33503. * @param onLoad callback called when the image successfully loads
  33504. * @param onError callback called when the image fails to load
  33505. * @param offlineProvider offline provider for caching
  33506. * @param mimeType optional mime type
  33507. * @returns the HTMLImageElement of the loaded image
  33508. */
  33509. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33510. /**
  33511. * Loads a file from a url
  33512. * @param url url string, ArrayBuffer, or Blob to load
  33513. * @param onSuccess callback called when the file successfully loads
  33514. * @param onProgress callback called while file is loading (if the server supports this mode)
  33515. * @param offlineProvider defines the offline provider for caching
  33516. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33517. * @param onError callback called when the file fails to load
  33518. * @returns a file request object
  33519. */
  33520. 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;
  33521. /**
  33522. * Loads a file from a url
  33523. * @param url the file url to load
  33524. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33525. */
  33526. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33527. /**
  33528. * Load a script (identified by an url). When the url returns, the
  33529. * content of this file is added into a new script element, attached to the DOM (body element)
  33530. * @param scriptUrl defines the url of the script to laod
  33531. * @param onSuccess defines the callback called when the script is loaded
  33532. * @param onError defines the callback to call if an error occurs
  33533. * @param scriptId defines the id of the script element
  33534. */
  33535. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33536. /**
  33537. * Load an asynchronous script (identified by an url). When the url returns, the
  33538. * content of this file is added into a new script element, attached to the DOM (body element)
  33539. * @param scriptUrl defines the url of the script to laod
  33540. * @param scriptId defines the id of the script element
  33541. * @returns a promise request object
  33542. */
  33543. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33544. /**
  33545. * Loads a file from a blob
  33546. * @param fileToLoad defines the blob to use
  33547. * @param callback defines the callback to call when data is loaded
  33548. * @param progressCallback defines the callback to call during loading process
  33549. * @returns a file request object
  33550. */
  33551. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33552. /**
  33553. * Reads a file from a File object
  33554. * @param file defines the file to load
  33555. * @param onSuccess defines the callback to call when data is loaded
  33556. * @param onProgress defines the callback to call during loading process
  33557. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33558. * @param onError defines the callback to call when an error occurs
  33559. * @returns a file request object
  33560. */
  33561. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33562. /**
  33563. * Creates a data url from a given string content
  33564. * @param content defines the content to convert
  33565. * @returns the new data url link
  33566. */
  33567. static FileAsURL(content: string): string;
  33568. /**
  33569. * Format the given number to a specific decimal format
  33570. * @param value defines the number to format
  33571. * @param decimals defines the number of decimals to use
  33572. * @returns the formatted string
  33573. */
  33574. static Format(value: number, decimals?: number): string;
  33575. /**
  33576. * Tries to copy an object by duplicating every property
  33577. * @param source defines the source object
  33578. * @param destination defines the target object
  33579. * @param doNotCopyList defines a list of properties to avoid
  33580. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33581. */
  33582. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33583. /**
  33584. * Gets a boolean indicating if the given object has no own property
  33585. * @param obj defines the object to test
  33586. * @returns true if object has no own property
  33587. */
  33588. static IsEmpty(obj: any): boolean;
  33589. /**
  33590. * Function used to register events at window level
  33591. * @param windowElement defines the Window object to use
  33592. * @param events defines the events to register
  33593. */
  33594. static RegisterTopRootEvents(windowElement: Window, events: {
  33595. name: string;
  33596. handler: Nullable<(e: FocusEvent) => any>;
  33597. }[]): void;
  33598. /**
  33599. * Function used to unregister events from window level
  33600. * @param windowElement defines the Window object to use
  33601. * @param events defines the events to unregister
  33602. */
  33603. static UnregisterTopRootEvents(windowElement: Window, events: {
  33604. name: string;
  33605. handler: Nullable<(e: FocusEvent) => any>;
  33606. }[]): void;
  33607. /**
  33608. * @ignore
  33609. */
  33610. static _ScreenshotCanvas: HTMLCanvasElement;
  33611. /**
  33612. * Dumps the current bound framebuffer
  33613. * @param width defines the rendering width
  33614. * @param height defines the rendering height
  33615. * @param engine defines the hosting engine
  33616. * @param successCallback defines the callback triggered once the data are available
  33617. * @param mimeType defines the mime type of the result
  33618. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33619. */
  33620. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33621. /**
  33622. * Converts the canvas data to blob.
  33623. * This acts as a polyfill for browsers not supporting the to blob function.
  33624. * @param canvas Defines the canvas to extract the data from
  33625. * @param successCallback Defines the callback triggered once the data are available
  33626. * @param mimeType Defines the mime type of the result
  33627. */
  33628. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33629. /**
  33630. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33631. * @param successCallback defines the callback triggered once the data are available
  33632. * @param mimeType defines the mime type of the result
  33633. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33634. */
  33635. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33636. /**
  33637. * Downloads a blob in the browser
  33638. * @param blob defines the blob to download
  33639. * @param fileName defines the name of the downloaded file
  33640. */
  33641. static Download(blob: Blob, fileName: string): void;
  33642. /**
  33643. * Captures a screenshot of the current rendering
  33644. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33645. * @param engine defines the rendering engine
  33646. * @param camera defines the source camera
  33647. * @param size This parameter can be set to a single number or to an object with the
  33648. * following (optional) properties: precision, width, height. If a single number is passed,
  33649. * it will be used for both width and height. If an object is passed, the screenshot size
  33650. * will be derived from the parameters. The precision property is a multiplier allowing
  33651. * rendering at a higher or lower resolution
  33652. * @param successCallback defines the callback receives a single parameter which contains the
  33653. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33654. * src parameter of an <img> to display it
  33655. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33656. * Check your browser for supported MIME types
  33657. */
  33658. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33659. /**
  33660. * Captures a screenshot of the current rendering
  33661. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33662. * @param engine defines the rendering engine
  33663. * @param camera defines the source camera
  33664. * @param size This parameter can be set to a single number or to an object with the
  33665. * following (optional) properties: precision, width, height. If a single number is passed,
  33666. * it will be used for both width and height. If an object is passed, the screenshot size
  33667. * will be derived from the parameters. The precision property is a multiplier allowing
  33668. * rendering at a higher or lower resolution
  33669. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33670. * Check your browser for supported MIME types
  33671. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33672. * to the src parameter of an <img> to display it
  33673. */
  33674. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33675. /**
  33676. * Generates an image screenshot from the specified camera.
  33677. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33678. * @param engine The engine to use for rendering
  33679. * @param camera The camera to use for rendering
  33680. * @param size This parameter can be set to a single number or to an object with the
  33681. * following (optional) properties: precision, width, height. If a single number is passed,
  33682. * it will be used for both width and height. If an object is passed, the screenshot size
  33683. * will be derived from the parameters. The precision property is a multiplier allowing
  33684. * rendering at a higher or lower resolution
  33685. * @param successCallback The callback receives a single parameter which contains the
  33686. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33687. * src parameter of an <img> to display it
  33688. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33689. * Check your browser for supported MIME types
  33690. * @param samples Texture samples (default: 1)
  33691. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33692. * @param fileName A name for for the downloaded file.
  33693. */
  33694. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33695. /**
  33696. * Generates an image screenshot from the specified camera.
  33697. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33698. * @param engine The engine to use for rendering
  33699. * @param camera The camera to use for rendering
  33700. * @param size This parameter can be set to a single number or to an object with the
  33701. * following (optional) properties: precision, width, height. If a single number is passed,
  33702. * it will be used for both width and height. If an object is passed, the screenshot size
  33703. * will be derived from the parameters. The precision property is a multiplier allowing
  33704. * rendering at a higher or lower resolution
  33705. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33706. * Check your browser for supported MIME types
  33707. * @param samples Texture samples (default: 1)
  33708. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33709. * @param fileName A name for for the downloaded file.
  33710. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33711. * to the src parameter of an <img> to display it
  33712. */
  33713. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33714. /**
  33715. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33716. * Be aware Math.random() could cause collisions, but:
  33717. * "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"
  33718. * @returns a pseudo random id
  33719. */
  33720. static RandomId(): string;
  33721. /**
  33722. * Test if the given uri is a base64 string
  33723. * @param uri The uri to test
  33724. * @return True if the uri is a base64 string or false otherwise
  33725. */
  33726. static IsBase64(uri: string): boolean;
  33727. /**
  33728. * Decode the given base64 uri.
  33729. * @param uri The uri to decode
  33730. * @return The decoded base64 data.
  33731. */
  33732. static DecodeBase64(uri: string): ArrayBuffer;
  33733. /**
  33734. * Gets the absolute url.
  33735. * @param url the input url
  33736. * @return the absolute url
  33737. */
  33738. static GetAbsoluteUrl(url: string): string;
  33739. /**
  33740. * No log
  33741. */
  33742. static readonly NoneLogLevel: number;
  33743. /**
  33744. * Only message logs
  33745. */
  33746. static readonly MessageLogLevel: number;
  33747. /**
  33748. * Only warning logs
  33749. */
  33750. static readonly WarningLogLevel: number;
  33751. /**
  33752. * Only error logs
  33753. */
  33754. static readonly ErrorLogLevel: number;
  33755. /**
  33756. * All logs
  33757. */
  33758. static readonly AllLogLevel: number;
  33759. /**
  33760. * Gets a value indicating the number of loading errors
  33761. * @ignorenaming
  33762. */
  33763. static readonly errorsCount: number;
  33764. /**
  33765. * Callback called when a new log is added
  33766. */
  33767. static OnNewCacheEntry: (entry: string) => void;
  33768. /**
  33769. * Log a message to the console
  33770. * @param message defines the message to log
  33771. */
  33772. static Log(message: string): void;
  33773. /**
  33774. * Write a warning message to the console
  33775. * @param message defines the message to log
  33776. */
  33777. static Warn(message: string): void;
  33778. /**
  33779. * Write an error message to the console
  33780. * @param message defines the message to log
  33781. */
  33782. static Error(message: string): void;
  33783. /**
  33784. * Gets current log cache (list of logs)
  33785. */
  33786. static readonly LogCache: string;
  33787. /**
  33788. * Clears the log cache
  33789. */
  33790. static ClearLogCache(): void;
  33791. /**
  33792. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33793. */
  33794. static LogLevels: number;
  33795. /**
  33796. * Checks if the window object exists
  33797. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33798. */
  33799. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33800. /**
  33801. * No performance log
  33802. */
  33803. static readonly PerformanceNoneLogLevel: number;
  33804. /**
  33805. * Use user marks to log performance
  33806. */
  33807. static readonly PerformanceUserMarkLogLevel: number;
  33808. /**
  33809. * Log performance to the console
  33810. */
  33811. static readonly PerformanceConsoleLogLevel: number;
  33812. private static _performance;
  33813. /**
  33814. * Sets the current performance log level
  33815. */
  33816. static PerformanceLogLevel: number;
  33817. private static _StartPerformanceCounterDisabled;
  33818. private static _EndPerformanceCounterDisabled;
  33819. private static _StartUserMark;
  33820. private static _EndUserMark;
  33821. private static _StartPerformanceConsole;
  33822. private static _EndPerformanceConsole;
  33823. /**
  33824. * Starts a performance counter
  33825. */
  33826. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33827. /**
  33828. * Ends a specific performance coutner
  33829. */
  33830. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33831. /**
  33832. * Gets either window.performance.now() if supported or Date.now() else
  33833. */
  33834. static readonly Now: number;
  33835. /**
  33836. * This method will return the name of the class used to create the instance of the given object.
  33837. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33838. * @param object the object to get the class name from
  33839. * @param isType defines if the object is actually a type
  33840. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33841. */
  33842. static GetClassName(object: any, isType?: boolean): string;
  33843. /**
  33844. * Gets the first element of an array satisfying a given predicate
  33845. * @param array defines the array to browse
  33846. * @param predicate defines the predicate to use
  33847. * @returns null if not found or the element
  33848. */
  33849. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33850. /**
  33851. * This method will return the name of the full name of the class, including its owning module (if any).
  33852. * 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).
  33853. * @param object the object to get the class name from
  33854. * @param isType defines if the object is actually a type
  33855. * @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.
  33856. * @ignorenaming
  33857. */
  33858. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33859. /**
  33860. * Returns a promise that resolves after the given amount of time.
  33861. * @param delay Number of milliseconds to delay
  33862. * @returns Promise that resolves after the given amount of time
  33863. */
  33864. static DelayAsync(delay: number): Promise<void>;
  33865. }
  33866. /**
  33867. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33868. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33869. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33870. * @param name The name of the class, case should be preserved
  33871. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33872. */
  33873. export function className(name: string, module?: string): (target: Object) => void;
  33874. /**
  33875. * An implementation of a loop for asynchronous functions.
  33876. */
  33877. export class AsyncLoop {
  33878. /**
  33879. * Defines the number of iterations for the loop
  33880. */
  33881. iterations: number;
  33882. /**
  33883. * Defines the current index of the loop.
  33884. */
  33885. index: number;
  33886. private _done;
  33887. private _fn;
  33888. private _successCallback;
  33889. /**
  33890. * Constructor.
  33891. * @param iterations the number of iterations.
  33892. * @param func the function to run each iteration
  33893. * @param successCallback the callback that will be called upon succesful execution
  33894. * @param offset starting offset.
  33895. */
  33896. constructor(
  33897. /**
  33898. * Defines the number of iterations for the loop
  33899. */
  33900. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33901. /**
  33902. * Execute the next iteration. Must be called after the last iteration was finished.
  33903. */
  33904. executeNext(): void;
  33905. /**
  33906. * Break the loop and run the success callback.
  33907. */
  33908. breakLoop(): void;
  33909. /**
  33910. * Create and run an async loop.
  33911. * @param iterations the number of iterations.
  33912. * @param fn the function to run each iteration
  33913. * @param successCallback the callback that will be called upon succesful execution
  33914. * @param offset starting offset.
  33915. * @returns the created async loop object
  33916. */
  33917. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33918. /**
  33919. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33920. * @param iterations total number of iterations
  33921. * @param syncedIterations number of synchronous iterations in each async iteration.
  33922. * @param fn the function to call each iteration.
  33923. * @param callback a success call back that will be called when iterating stops.
  33924. * @param breakFunction a break condition (optional)
  33925. * @param timeout timeout settings for the setTimeout function. default - 0.
  33926. * @returns the created async loop object
  33927. */
  33928. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33929. }
  33930. }
  33931. declare module BABYLON {
  33932. /**
  33933. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33934. * The underlying implementation relies on an associative array to ensure the best performances.
  33935. * The value can be anything including 'null' but except 'undefined'
  33936. */
  33937. export class StringDictionary<T> {
  33938. /**
  33939. * This will clear this dictionary and copy the content from the 'source' one.
  33940. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33941. * @param source the dictionary to take the content from and copy to this dictionary
  33942. */
  33943. copyFrom(source: StringDictionary<T>): void;
  33944. /**
  33945. * Get a value based from its key
  33946. * @param key the given key to get the matching value from
  33947. * @return the value if found, otherwise undefined is returned
  33948. */
  33949. get(key: string): T | undefined;
  33950. /**
  33951. * Get a value from its key or add it if it doesn't exist.
  33952. * This method will ensure you that a given key/data will be present in the dictionary.
  33953. * @param key the given key to get the matching value from
  33954. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33955. * The factory will only be invoked if there's no data for the given key.
  33956. * @return the value corresponding to the key.
  33957. */
  33958. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33959. /**
  33960. * Get a value from its key if present in the dictionary otherwise add it
  33961. * @param key the key to get the value from
  33962. * @param val if there's no such key/value pair in the dictionary add it with this value
  33963. * @return the value corresponding to the key
  33964. */
  33965. getOrAdd(key: string, val: T): T;
  33966. /**
  33967. * Check if there's a given key in the dictionary
  33968. * @param key the key to check for
  33969. * @return true if the key is present, false otherwise
  33970. */
  33971. contains(key: string): boolean;
  33972. /**
  33973. * Add a new key and its corresponding value
  33974. * @param key the key to add
  33975. * @param value the value corresponding to the key
  33976. * @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
  33977. */
  33978. add(key: string, value: T): boolean;
  33979. /**
  33980. * Update a specific value associated to a key
  33981. * @param key defines the key to use
  33982. * @param value defines the value to store
  33983. * @returns true if the value was updated (or false if the key was not found)
  33984. */
  33985. set(key: string, value: T): boolean;
  33986. /**
  33987. * Get the element of the given key and remove it from the dictionary
  33988. * @param key defines the key to search
  33989. * @returns the value associated with the key or null if not found
  33990. */
  33991. getAndRemove(key: string): Nullable<T>;
  33992. /**
  33993. * Remove a key/value from the dictionary.
  33994. * @param key the key to remove
  33995. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33996. */
  33997. remove(key: string): boolean;
  33998. /**
  33999. * Clear the whole content of the dictionary
  34000. */
  34001. clear(): void;
  34002. /**
  34003. * Gets the current count
  34004. */
  34005. readonly count: number;
  34006. /**
  34007. * Execute a callback on each key/val of the dictionary.
  34008. * Note that you can remove any element in this dictionary in the callback implementation
  34009. * @param callback the callback to execute on a given key/value pair
  34010. */
  34011. forEach(callback: (key: string, val: T) => void): void;
  34012. /**
  34013. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34014. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34015. * Note that you can remove any element in this dictionary in the callback implementation
  34016. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34017. * @returns the first item
  34018. */
  34019. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34020. private _count;
  34021. private _data;
  34022. }
  34023. }
  34024. declare module BABYLON {
  34025. /** @hidden */
  34026. export interface ICollisionCoordinator {
  34027. createCollider(): Collider;
  34028. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34029. init(scene: Scene): void;
  34030. }
  34031. /** @hidden */
  34032. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34033. private _scene;
  34034. private _scaledPosition;
  34035. private _scaledVelocity;
  34036. private _finalPosition;
  34037. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34038. createCollider(): Collider;
  34039. init(scene: Scene): void;
  34040. private _collideWithWorld;
  34041. }
  34042. }
  34043. declare module BABYLON {
  34044. /**
  34045. * Class used to manage all inputs for the scene.
  34046. */
  34047. export class InputManager {
  34048. /** The distance in pixel that you have to move to prevent some events */
  34049. static DragMovementThreshold: number;
  34050. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34051. static LongPressDelay: number;
  34052. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34053. static DoubleClickDelay: number;
  34054. /** If you need to check double click without raising a single click at first click, enable this flag */
  34055. static ExclusiveDoubleClickMode: boolean;
  34056. private _wheelEventName;
  34057. private _onPointerMove;
  34058. private _onPointerDown;
  34059. private _onPointerUp;
  34060. private _initClickEvent;
  34061. private _initActionManager;
  34062. private _delayedSimpleClick;
  34063. private _delayedSimpleClickTimeout;
  34064. private _previousDelayedSimpleClickTimeout;
  34065. private _meshPickProceed;
  34066. private _previousButtonPressed;
  34067. private _currentPickResult;
  34068. private _previousPickResult;
  34069. private _totalPointersPressed;
  34070. private _doubleClickOccured;
  34071. private _pointerOverMesh;
  34072. private _pickedDownMesh;
  34073. private _pickedUpMesh;
  34074. private _pointerX;
  34075. private _pointerY;
  34076. private _unTranslatedPointerX;
  34077. private _unTranslatedPointerY;
  34078. private _startingPointerPosition;
  34079. private _previousStartingPointerPosition;
  34080. private _startingPointerTime;
  34081. private _previousStartingPointerTime;
  34082. private _pointerCaptures;
  34083. private _onKeyDown;
  34084. private _onKeyUp;
  34085. private _onCanvasFocusObserver;
  34086. private _onCanvasBlurObserver;
  34087. private _scene;
  34088. /**
  34089. * Creates a new InputManager
  34090. * @param scene defines the hosting scene
  34091. */
  34092. constructor(scene: Scene);
  34093. /**
  34094. * Gets the mesh that is currently under the pointer
  34095. */
  34096. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34097. /**
  34098. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34099. */
  34100. readonly unTranslatedPointer: Vector2;
  34101. /**
  34102. * Gets or sets the current on-screen X position of the pointer
  34103. */
  34104. pointerX: number;
  34105. /**
  34106. * Gets or sets the current on-screen Y position of the pointer
  34107. */
  34108. pointerY: number;
  34109. private _updatePointerPosition;
  34110. private _processPointerMove;
  34111. private _setRayOnPointerInfo;
  34112. private _checkPrePointerObservable;
  34113. /**
  34114. * Use this method to simulate a pointer move on a mesh
  34115. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34116. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34117. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34118. */
  34119. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34120. /**
  34121. * Use this method to simulate a pointer down on a mesh
  34122. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34123. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34124. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34125. */
  34126. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34127. private _processPointerDown;
  34128. /** @hidden */
  34129. _isPointerSwiping(): boolean;
  34130. /**
  34131. * Use this method to simulate a pointer up on a mesh
  34132. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34133. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34134. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34135. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34136. */
  34137. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34138. private _processPointerUp;
  34139. /**
  34140. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34141. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34142. * @returns true if the pointer was captured
  34143. */
  34144. isPointerCaptured(pointerId?: number): boolean;
  34145. /**
  34146. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34147. * @param attachUp defines if you want to attach events to pointerup
  34148. * @param attachDown defines if you want to attach events to pointerdown
  34149. * @param attachMove defines if you want to attach events to pointermove
  34150. */
  34151. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34152. /**
  34153. * Detaches all event handlers
  34154. */
  34155. detachControl(): void;
  34156. /**
  34157. * Force the value of meshUnderPointer
  34158. * @param mesh defines the mesh to use
  34159. */
  34160. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34161. /**
  34162. * Gets the mesh under the pointer
  34163. * @returns a Mesh or null if no mesh is under the pointer
  34164. */
  34165. getPointerOverMesh(): Nullable<AbstractMesh>;
  34166. }
  34167. }
  34168. declare module BABYLON {
  34169. /**
  34170. * Helper class used to generate session unique ID
  34171. */
  34172. export class UniqueIdGenerator {
  34173. private static _UniqueIdCounter;
  34174. /**
  34175. * Gets an unique (relatively to the current scene) Id
  34176. */
  34177. static readonly UniqueId: number;
  34178. }
  34179. }
  34180. declare module BABYLON {
  34181. /**
  34182. * This class defines the direct association between an animation and a target
  34183. */
  34184. export class TargetedAnimation {
  34185. /**
  34186. * Animation to perform
  34187. */
  34188. animation: Animation;
  34189. /**
  34190. * Target to animate
  34191. */
  34192. target: any;
  34193. /**
  34194. * Serialize the object
  34195. * @returns the JSON object representing the current entity
  34196. */
  34197. serialize(): any;
  34198. }
  34199. /**
  34200. * Use this class to create coordinated animations on multiple targets
  34201. */
  34202. export class AnimationGroup implements IDisposable {
  34203. /** The name of the animation group */
  34204. name: string;
  34205. private _scene;
  34206. private _targetedAnimations;
  34207. private _animatables;
  34208. private _from;
  34209. private _to;
  34210. private _isStarted;
  34211. private _isPaused;
  34212. private _speedRatio;
  34213. private _loopAnimation;
  34214. /**
  34215. * Gets or sets the unique id of the node
  34216. */
  34217. uniqueId: number;
  34218. /**
  34219. * This observable will notify when one animation have ended
  34220. */
  34221. onAnimationEndObservable: Observable<TargetedAnimation>;
  34222. /**
  34223. * Observer raised when one animation loops
  34224. */
  34225. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34226. /**
  34227. * Observer raised when all animations have looped
  34228. */
  34229. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34230. /**
  34231. * This observable will notify when all animations have ended.
  34232. */
  34233. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34234. /**
  34235. * This observable will notify when all animations have paused.
  34236. */
  34237. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34238. /**
  34239. * This observable will notify when all animations are playing.
  34240. */
  34241. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34242. /**
  34243. * Gets the first frame
  34244. */
  34245. readonly from: number;
  34246. /**
  34247. * Gets the last frame
  34248. */
  34249. readonly to: number;
  34250. /**
  34251. * Define if the animations are started
  34252. */
  34253. readonly isStarted: boolean;
  34254. /**
  34255. * Gets a value indicating that the current group is playing
  34256. */
  34257. readonly isPlaying: boolean;
  34258. /**
  34259. * Gets or sets the speed ratio to use for all animations
  34260. */
  34261. /**
  34262. * Gets or sets the speed ratio to use for all animations
  34263. */
  34264. speedRatio: number;
  34265. /**
  34266. * Gets or sets if all animations should loop or not
  34267. */
  34268. loopAnimation: boolean;
  34269. /**
  34270. * Gets the targeted animations for this animation group
  34271. */
  34272. readonly targetedAnimations: Array<TargetedAnimation>;
  34273. /**
  34274. * returning the list of animatables controlled by this animation group.
  34275. */
  34276. readonly animatables: Array<Animatable>;
  34277. /**
  34278. * Instantiates a new Animation Group.
  34279. * This helps managing several animations at once.
  34280. * @see http://doc.babylonjs.com/how_to/group
  34281. * @param name Defines the name of the group
  34282. * @param scene Defines the scene the group belongs to
  34283. */
  34284. constructor(
  34285. /** The name of the animation group */
  34286. name: string, scene?: Nullable<Scene>);
  34287. /**
  34288. * Add an animation (with its target) in the group
  34289. * @param animation defines the animation we want to add
  34290. * @param target defines the target of the animation
  34291. * @returns the TargetedAnimation object
  34292. */
  34293. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34294. /**
  34295. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34296. * It can add constant keys at begin or end
  34297. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34298. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34299. * @returns the animation group
  34300. */
  34301. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34302. private _animationLoopCount;
  34303. private _animationLoopFlags;
  34304. private _processLoop;
  34305. /**
  34306. * Start all animations on given targets
  34307. * @param loop defines if animations must loop
  34308. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34309. * @param from defines the from key (optional)
  34310. * @param to defines the to key (optional)
  34311. * @returns the current animation group
  34312. */
  34313. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34314. /**
  34315. * Pause all animations
  34316. * @returns the animation group
  34317. */
  34318. pause(): AnimationGroup;
  34319. /**
  34320. * Play all animations to initial state
  34321. * This function will start() the animations if they were not started or will restart() them if they were paused
  34322. * @param loop defines if animations must loop
  34323. * @returns the animation group
  34324. */
  34325. play(loop?: boolean): AnimationGroup;
  34326. /**
  34327. * Reset all animations to initial state
  34328. * @returns the animation group
  34329. */
  34330. reset(): AnimationGroup;
  34331. /**
  34332. * Restart animations from key 0
  34333. * @returns the animation group
  34334. */
  34335. restart(): AnimationGroup;
  34336. /**
  34337. * Stop all animations
  34338. * @returns the animation group
  34339. */
  34340. stop(): AnimationGroup;
  34341. /**
  34342. * Set animation weight for all animatables
  34343. * @param weight defines the weight to use
  34344. * @return the animationGroup
  34345. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34346. */
  34347. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34348. /**
  34349. * Synchronize and normalize all animatables with a source animatable
  34350. * @param root defines the root animatable to synchronize with
  34351. * @return the animationGroup
  34352. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34353. */
  34354. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34355. /**
  34356. * Goes to a specific frame in this animation group
  34357. * @param frame the frame number to go to
  34358. * @return the animationGroup
  34359. */
  34360. goToFrame(frame: number): AnimationGroup;
  34361. /**
  34362. * Dispose all associated resources
  34363. */
  34364. dispose(): void;
  34365. private _checkAnimationGroupEnded;
  34366. /**
  34367. * Clone the current animation group and returns a copy
  34368. * @param newName defines the name of the new group
  34369. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34370. * @returns the new aniamtion group
  34371. */
  34372. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34373. /**
  34374. * Serializes the animationGroup to an object
  34375. * @returns Serialized object
  34376. */
  34377. serialize(): any;
  34378. /**
  34379. * Returns a new AnimationGroup object parsed from the source provided.
  34380. * @param parsedAnimationGroup defines the source
  34381. * @param scene defines the scene that will receive the animationGroup
  34382. * @returns a new AnimationGroup
  34383. */
  34384. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34385. /**
  34386. * Returns the string "AnimationGroup"
  34387. * @returns "AnimationGroup"
  34388. */
  34389. getClassName(): string;
  34390. /**
  34391. * Creates a detailled string about the object
  34392. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34393. * @returns a string representing the object
  34394. */
  34395. toString(fullDetails?: boolean): string;
  34396. }
  34397. }
  34398. declare module BABYLON {
  34399. /**
  34400. * Define an interface for all classes that will hold resources
  34401. */
  34402. export interface IDisposable {
  34403. /**
  34404. * Releases all held resources
  34405. */
  34406. dispose(): void;
  34407. }
  34408. /** Interface defining initialization parameters for Scene class */
  34409. export interface SceneOptions {
  34410. /**
  34411. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34412. * It will improve performance when the number of geometries becomes important.
  34413. */
  34414. useGeometryUniqueIdsMap?: boolean;
  34415. /**
  34416. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34417. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34418. */
  34419. useMaterialMeshMap?: boolean;
  34420. /**
  34421. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34422. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34423. */
  34424. useClonedMeshhMap?: boolean;
  34425. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34426. virtual?: boolean;
  34427. }
  34428. /**
  34429. * Represents a scene to be rendered by the engine.
  34430. * @see http://doc.babylonjs.com/features/scene
  34431. */
  34432. export class Scene extends AbstractScene implements IAnimatable {
  34433. /** The fog is deactivated */
  34434. static readonly FOGMODE_NONE: number;
  34435. /** The fog density is following an exponential function */
  34436. static readonly FOGMODE_EXP: number;
  34437. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34438. static readonly FOGMODE_EXP2: number;
  34439. /** The fog density is following a linear function. */
  34440. static readonly FOGMODE_LINEAR: number;
  34441. /**
  34442. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34443. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34444. */
  34445. static MinDeltaTime: number;
  34446. /**
  34447. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34448. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34449. */
  34450. static MaxDeltaTime: number;
  34451. /**
  34452. * Factory used to create the default material.
  34453. * @param name The name of the material to create
  34454. * @param scene The scene to create the material for
  34455. * @returns The default material
  34456. */
  34457. static DefaultMaterialFactory(scene: Scene): Material;
  34458. /**
  34459. * Factory used to create the a collision coordinator.
  34460. * @returns The collision coordinator
  34461. */
  34462. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34463. /** @hidden */
  34464. _inputManager: InputManager;
  34465. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34466. cameraToUseForPointers: Nullable<Camera>;
  34467. /** @hidden */
  34468. readonly _isScene: boolean;
  34469. /**
  34470. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34471. */
  34472. autoClear: boolean;
  34473. /**
  34474. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34475. */
  34476. autoClearDepthAndStencil: boolean;
  34477. /**
  34478. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34479. */
  34480. clearColor: Color4;
  34481. /**
  34482. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34483. */
  34484. ambientColor: Color3;
  34485. /**
  34486. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34487. * It should only be one of the following (if not the default embedded one):
  34488. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34489. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34490. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34491. * The material properties need to be setup according to the type of texture in use.
  34492. */
  34493. environmentBRDFTexture: BaseTexture;
  34494. /** @hidden */
  34495. protected _environmentTexture: Nullable<BaseTexture>;
  34496. /**
  34497. * Texture used in all pbr material as the reflection texture.
  34498. * As in the majority of the scene they are the same (exception for multi room and so on),
  34499. * this is easier to reference from here than from all the materials.
  34500. */
  34501. /**
  34502. * Texture used in all pbr material as the reflection texture.
  34503. * As in the majority of the scene they are the same (exception for multi room and so on),
  34504. * this is easier to set here than in all the materials.
  34505. */
  34506. environmentTexture: Nullable<BaseTexture>;
  34507. /** @hidden */
  34508. protected _environmentIntensity: number;
  34509. /**
  34510. * Intensity of the environment in all pbr material.
  34511. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34512. * As in the majority of the scene they are the same (exception for multi room and so on),
  34513. * this is easier to reference from here than from all the materials.
  34514. */
  34515. /**
  34516. * Intensity of the environment in all pbr material.
  34517. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34518. * As in the majority of the scene they are the same (exception for multi room and so on),
  34519. * this is easier to set here than in all the materials.
  34520. */
  34521. environmentIntensity: number;
  34522. /** @hidden */
  34523. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34524. /**
  34525. * Default image processing configuration used either in the rendering
  34526. * Forward main pass or through the imageProcessingPostProcess if present.
  34527. * As in the majority of the scene they are the same (exception for multi camera),
  34528. * this is easier to reference from here than from all the materials and post process.
  34529. *
  34530. * No setter as we it is a shared configuration, you can set the values instead.
  34531. */
  34532. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34533. private _forceWireframe;
  34534. /**
  34535. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34536. */
  34537. forceWireframe: boolean;
  34538. private _forcePointsCloud;
  34539. /**
  34540. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34541. */
  34542. forcePointsCloud: boolean;
  34543. /**
  34544. * Gets or sets the active clipplane 1
  34545. */
  34546. clipPlane: Nullable<Plane>;
  34547. /**
  34548. * Gets or sets the active clipplane 2
  34549. */
  34550. clipPlane2: Nullable<Plane>;
  34551. /**
  34552. * Gets or sets the active clipplane 3
  34553. */
  34554. clipPlane3: Nullable<Plane>;
  34555. /**
  34556. * Gets or sets the active clipplane 4
  34557. */
  34558. clipPlane4: Nullable<Plane>;
  34559. /**
  34560. * Gets or sets a boolean indicating if animations are enabled
  34561. */
  34562. animationsEnabled: boolean;
  34563. private _animationPropertiesOverride;
  34564. /**
  34565. * Gets or sets the animation properties override
  34566. */
  34567. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34568. /**
  34569. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34570. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34571. */
  34572. useConstantAnimationDeltaTime: boolean;
  34573. /**
  34574. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34575. * Please note that it requires to run a ray cast through the scene on every frame
  34576. */
  34577. constantlyUpdateMeshUnderPointer: boolean;
  34578. /**
  34579. * Defines the HTML cursor to use when hovering over interactive elements
  34580. */
  34581. hoverCursor: string;
  34582. /**
  34583. * Defines the HTML default cursor to use (empty by default)
  34584. */
  34585. defaultCursor: string;
  34586. /**
  34587. * Defines wether cursors are handled by the scene.
  34588. */
  34589. doNotHandleCursors: boolean;
  34590. /**
  34591. * This is used to call preventDefault() on pointer down
  34592. * in order to block unwanted artifacts like system double clicks
  34593. */
  34594. preventDefaultOnPointerDown: boolean;
  34595. /**
  34596. * This is used to call preventDefault() on pointer up
  34597. * in order to block unwanted artifacts like system double clicks
  34598. */
  34599. preventDefaultOnPointerUp: boolean;
  34600. /**
  34601. * Gets or sets user defined metadata
  34602. */
  34603. metadata: any;
  34604. /**
  34605. * For internal use only. Please do not use.
  34606. */
  34607. reservedDataStore: any;
  34608. /**
  34609. * Gets the name of the plugin used to load this scene (null by default)
  34610. */
  34611. loadingPluginName: string;
  34612. /**
  34613. * Use this array to add regular expressions used to disable offline support for specific urls
  34614. */
  34615. disableOfflineSupportExceptionRules: RegExp[];
  34616. /**
  34617. * An event triggered when the scene is disposed.
  34618. */
  34619. onDisposeObservable: Observable<Scene>;
  34620. private _onDisposeObserver;
  34621. /** Sets a function to be executed when this scene is disposed. */
  34622. onDispose: () => void;
  34623. /**
  34624. * An event triggered before rendering the scene (right after animations and physics)
  34625. */
  34626. onBeforeRenderObservable: Observable<Scene>;
  34627. private _onBeforeRenderObserver;
  34628. /** Sets a function to be executed before rendering this scene */
  34629. beforeRender: Nullable<() => void>;
  34630. /**
  34631. * An event triggered after rendering the scene
  34632. */
  34633. onAfterRenderObservable: Observable<Scene>;
  34634. /**
  34635. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34636. */
  34637. onAfterRenderCameraObservable: Observable<Camera>;
  34638. private _onAfterRenderObserver;
  34639. /** Sets a function to be executed after rendering this scene */
  34640. afterRender: Nullable<() => void>;
  34641. /**
  34642. * An event triggered before animating the scene
  34643. */
  34644. onBeforeAnimationsObservable: Observable<Scene>;
  34645. /**
  34646. * An event triggered after animations processing
  34647. */
  34648. onAfterAnimationsObservable: Observable<Scene>;
  34649. /**
  34650. * An event triggered before draw calls are ready to be sent
  34651. */
  34652. onBeforeDrawPhaseObservable: Observable<Scene>;
  34653. /**
  34654. * An event triggered after draw calls have been sent
  34655. */
  34656. onAfterDrawPhaseObservable: Observable<Scene>;
  34657. /**
  34658. * An event triggered when the scene is ready
  34659. */
  34660. onReadyObservable: Observable<Scene>;
  34661. /**
  34662. * An event triggered before rendering a camera
  34663. */
  34664. onBeforeCameraRenderObservable: Observable<Camera>;
  34665. private _onBeforeCameraRenderObserver;
  34666. /** Sets a function to be executed before rendering a camera*/
  34667. beforeCameraRender: () => void;
  34668. /**
  34669. * An event triggered after rendering a camera
  34670. */
  34671. onAfterCameraRenderObservable: Observable<Camera>;
  34672. private _onAfterCameraRenderObserver;
  34673. /** Sets a function to be executed after rendering a camera*/
  34674. afterCameraRender: () => void;
  34675. /**
  34676. * An event triggered when active meshes evaluation is about to start
  34677. */
  34678. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34679. /**
  34680. * An event triggered when active meshes evaluation is done
  34681. */
  34682. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34683. /**
  34684. * An event triggered when particles rendering is about to start
  34685. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34686. */
  34687. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34688. /**
  34689. * An event triggered when particles rendering is done
  34690. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34691. */
  34692. onAfterParticlesRenderingObservable: Observable<Scene>;
  34693. /**
  34694. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34695. */
  34696. onDataLoadedObservable: Observable<Scene>;
  34697. /**
  34698. * An event triggered when a camera is created
  34699. */
  34700. onNewCameraAddedObservable: Observable<Camera>;
  34701. /**
  34702. * An event triggered when a camera is removed
  34703. */
  34704. onCameraRemovedObservable: Observable<Camera>;
  34705. /**
  34706. * An event triggered when a light is created
  34707. */
  34708. onNewLightAddedObservable: Observable<Light>;
  34709. /**
  34710. * An event triggered when a light is removed
  34711. */
  34712. onLightRemovedObservable: Observable<Light>;
  34713. /**
  34714. * An event triggered when a geometry is created
  34715. */
  34716. onNewGeometryAddedObservable: Observable<Geometry>;
  34717. /**
  34718. * An event triggered when a geometry is removed
  34719. */
  34720. onGeometryRemovedObservable: Observable<Geometry>;
  34721. /**
  34722. * An event triggered when a transform node is created
  34723. */
  34724. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34725. /**
  34726. * An event triggered when a transform node is removed
  34727. */
  34728. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34729. /**
  34730. * An event triggered when a mesh is created
  34731. */
  34732. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34733. /**
  34734. * An event triggered when a mesh is removed
  34735. */
  34736. onMeshRemovedObservable: Observable<AbstractMesh>;
  34737. /**
  34738. * An event triggered when a skeleton is created
  34739. */
  34740. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34741. /**
  34742. * An event triggered when a skeleton is removed
  34743. */
  34744. onSkeletonRemovedObservable: Observable<Skeleton>;
  34745. /**
  34746. * An event triggered when a material is created
  34747. */
  34748. onNewMaterialAddedObservable: Observable<Material>;
  34749. /**
  34750. * An event triggered when a material is removed
  34751. */
  34752. onMaterialRemovedObservable: Observable<Material>;
  34753. /**
  34754. * An event triggered when a texture is created
  34755. */
  34756. onNewTextureAddedObservable: Observable<BaseTexture>;
  34757. /**
  34758. * An event triggered when a texture is removed
  34759. */
  34760. onTextureRemovedObservable: Observable<BaseTexture>;
  34761. /**
  34762. * An event triggered when render targets are about to be rendered
  34763. * Can happen multiple times per frame.
  34764. */
  34765. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34766. /**
  34767. * An event triggered when render targets were rendered.
  34768. * Can happen multiple times per frame.
  34769. */
  34770. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34771. /**
  34772. * An event triggered before calculating deterministic simulation step
  34773. */
  34774. onBeforeStepObservable: Observable<Scene>;
  34775. /**
  34776. * An event triggered after calculating deterministic simulation step
  34777. */
  34778. onAfterStepObservable: Observable<Scene>;
  34779. /**
  34780. * An event triggered when the activeCamera property is updated
  34781. */
  34782. onActiveCameraChanged: Observable<Scene>;
  34783. /**
  34784. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34785. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34786. * 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)
  34787. */
  34788. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34789. /**
  34790. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34791. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34792. * 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)
  34793. */
  34794. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34795. /**
  34796. * This Observable will when a mesh has been imported into the scene.
  34797. */
  34798. onMeshImportedObservable: Observable<AbstractMesh>;
  34799. /**
  34800. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34801. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34802. */
  34803. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34804. /** @hidden */
  34805. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34806. /**
  34807. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34808. */
  34809. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34810. /**
  34811. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34812. */
  34813. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34814. /**
  34815. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34816. */
  34817. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34818. /** Callback called when a pointer move is detected */
  34819. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34820. /** Callback called when a pointer down is detected */
  34821. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34822. /** Callback called when a pointer up is detected */
  34823. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34824. /** Callback called when a pointer pick is detected */
  34825. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34826. /**
  34827. * 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).
  34828. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34829. */
  34830. onPrePointerObservable: Observable<PointerInfoPre>;
  34831. /**
  34832. * Observable event triggered each time an input event is received from the rendering canvas
  34833. */
  34834. onPointerObservable: Observable<PointerInfo>;
  34835. /**
  34836. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34837. */
  34838. readonly unTranslatedPointer: Vector2;
  34839. /**
  34840. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34841. */
  34842. static DragMovementThreshold: number;
  34843. /**
  34844. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34845. */
  34846. static LongPressDelay: number;
  34847. /**
  34848. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34849. */
  34850. static DoubleClickDelay: number;
  34851. /** If you need to check double click without raising a single click at first click, enable this flag */
  34852. static ExclusiveDoubleClickMode: boolean;
  34853. /** @hidden */
  34854. _mirroredCameraPosition: Nullable<Vector3>;
  34855. /**
  34856. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34857. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34858. */
  34859. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34860. /**
  34861. * Observable event triggered each time an keyboard event is received from the hosting window
  34862. */
  34863. onKeyboardObservable: Observable<KeyboardInfo>;
  34864. private _useRightHandedSystem;
  34865. /**
  34866. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34867. */
  34868. useRightHandedSystem: boolean;
  34869. private _timeAccumulator;
  34870. private _currentStepId;
  34871. private _currentInternalStep;
  34872. /**
  34873. * Sets the step Id used by deterministic lock step
  34874. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34875. * @param newStepId defines the step Id
  34876. */
  34877. setStepId(newStepId: number): void;
  34878. /**
  34879. * Gets the step Id used by deterministic lock step
  34880. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34881. * @returns the step Id
  34882. */
  34883. getStepId(): number;
  34884. /**
  34885. * Gets the internal step used by deterministic lock step
  34886. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34887. * @returns the internal step
  34888. */
  34889. getInternalStep(): number;
  34890. private _fogEnabled;
  34891. /**
  34892. * Gets or sets a boolean indicating if fog is enabled on this scene
  34893. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34894. * (Default is true)
  34895. */
  34896. fogEnabled: boolean;
  34897. private _fogMode;
  34898. /**
  34899. * Gets or sets the fog mode to use
  34900. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34901. * | mode | value |
  34902. * | --- | --- |
  34903. * | FOGMODE_NONE | 0 |
  34904. * | FOGMODE_EXP | 1 |
  34905. * | FOGMODE_EXP2 | 2 |
  34906. * | FOGMODE_LINEAR | 3 |
  34907. */
  34908. fogMode: number;
  34909. /**
  34910. * Gets or sets the fog color to use
  34911. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34912. * (Default is Color3(0.2, 0.2, 0.3))
  34913. */
  34914. fogColor: Color3;
  34915. /**
  34916. * Gets or sets the fog density to use
  34917. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34918. * (Default is 0.1)
  34919. */
  34920. fogDensity: number;
  34921. /**
  34922. * Gets or sets the fog start distance to use
  34923. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34924. * (Default is 0)
  34925. */
  34926. fogStart: number;
  34927. /**
  34928. * Gets or sets the fog end distance to use
  34929. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34930. * (Default is 1000)
  34931. */
  34932. fogEnd: number;
  34933. private _shadowsEnabled;
  34934. /**
  34935. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34936. */
  34937. shadowsEnabled: boolean;
  34938. private _lightsEnabled;
  34939. /**
  34940. * Gets or sets a boolean indicating if lights are enabled on this scene
  34941. */
  34942. lightsEnabled: boolean;
  34943. /** All of the active cameras added to this scene. */
  34944. activeCameras: Camera[];
  34945. /** @hidden */
  34946. _activeCamera: Nullable<Camera>;
  34947. /** Gets or sets the current active camera */
  34948. activeCamera: Nullable<Camera>;
  34949. private _defaultMaterial;
  34950. /** The default material used on meshes when no material is affected */
  34951. /** The default material used on meshes when no material is affected */
  34952. defaultMaterial: Material;
  34953. private _texturesEnabled;
  34954. /**
  34955. * Gets or sets a boolean indicating if textures are enabled on this scene
  34956. */
  34957. texturesEnabled: boolean;
  34958. /**
  34959. * Gets or sets a boolean indicating if particles are enabled on this scene
  34960. */
  34961. particlesEnabled: boolean;
  34962. /**
  34963. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34964. */
  34965. spritesEnabled: boolean;
  34966. private _skeletonsEnabled;
  34967. /**
  34968. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34969. */
  34970. skeletonsEnabled: boolean;
  34971. /**
  34972. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34973. */
  34974. lensFlaresEnabled: boolean;
  34975. /**
  34976. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34977. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34978. */
  34979. collisionsEnabled: boolean;
  34980. private _collisionCoordinator;
  34981. /** @hidden */
  34982. readonly collisionCoordinator: ICollisionCoordinator;
  34983. /**
  34984. * Defines the gravity applied to this scene (used only for collisions)
  34985. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34986. */
  34987. gravity: Vector3;
  34988. /**
  34989. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34990. */
  34991. postProcessesEnabled: boolean;
  34992. /**
  34993. * The list of postprocesses added to the scene
  34994. */
  34995. postProcesses: PostProcess[];
  34996. /**
  34997. * Gets the current postprocess manager
  34998. */
  34999. postProcessManager: PostProcessManager;
  35000. /**
  35001. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35002. */
  35003. renderTargetsEnabled: boolean;
  35004. /**
  35005. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35006. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35007. */
  35008. dumpNextRenderTargets: boolean;
  35009. /**
  35010. * The list of user defined render targets added to the scene
  35011. */
  35012. customRenderTargets: RenderTargetTexture[];
  35013. /**
  35014. * Defines if texture loading must be delayed
  35015. * If true, textures will only be loaded when they need to be rendered
  35016. */
  35017. useDelayedTextureLoading: boolean;
  35018. /**
  35019. * Gets the list of meshes imported to the scene through SceneLoader
  35020. */
  35021. importedMeshesFiles: String[];
  35022. /**
  35023. * Gets or sets a boolean indicating if probes are enabled on this scene
  35024. */
  35025. probesEnabled: boolean;
  35026. /**
  35027. * Gets or sets the current offline provider to use to store scene data
  35028. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35029. */
  35030. offlineProvider: IOfflineProvider;
  35031. /**
  35032. * Gets or sets the action manager associated with the scene
  35033. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35034. */
  35035. actionManager: AbstractActionManager;
  35036. private _meshesForIntersections;
  35037. /**
  35038. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35039. */
  35040. proceduralTexturesEnabled: boolean;
  35041. private _engine;
  35042. private _totalVertices;
  35043. /** @hidden */
  35044. _activeIndices: PerfCounter;
  35045. /** @hidden */
  35046. _activeParticles: PerfCounter;
  35047. /** @hidden */
  35048. _activeBones: PerfCounter;
  35049. private _animationRatio;
  35050. /** @hidden */
  35051. _animationTimeLast: number;
  35052. /** @hidden */
  35053. _animationTime: number;
  35054. /**
  35055. * Gets or sets a general scale for animation speed
  35056. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35057. */
  35058. animationTimeScale: number;
  35059. /** @hidden */
  35060. _cachedMaterial: Nullable<Material>;
  35061. /** @hidden */
  35062. _cachedEffect: Nullable<Effect>;
  35063. /** @hidden */
  35064. _cachedVisibility: Nullable<number>;
  35065. private _renderId;
  35066. private _frameId;
  35067. private _executeWhenReadyTimeoutId;
  35068. private _intermediateRendering;
  35069. private _viewUpdateFlag;
  35070. private _projectionUpdateFlag;
  35071. /** @hidden */
  35072. _toBeDisposed: Nullable<IDisposable>[];
  35073. private _activeRequests;
  35074. /** @hidden */
  35075. _pendingData: any[];
  35076. private _isDisposed;
  35077. /**
  35078. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35079. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35080. */
  35081. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35082. private _activeMeshes;
  35083. private _processedMaterials;
  35084. private _renderTargets;
  35085. /** @hidden */
  35086. _activeParticleSystems: SmartArray<IParticleSystem>;
  35087. private _activeSkeletons;
  35088. private _softwareSkinnedMeshes;
  35089. private _renderingManager;
  35090. /** @hidden */
  35091. _activeAnimatables: Animatable[];
  35092. private _transformMatrix;
  35093. private _sceneUbo;
  35094. /** @hidden */
  35095. _viewMatrix: Matrix;
  35096. private _projectionMatrix;
  35097. /** @hidden */
  35098. _forcedViewPosition: Nullable<Vector3>;
  35099. /** @hidden */
  35100. _frustumPlanes: Plane[];
  35101. /**
  35102. * Gets the list of frustum planes (built from the active camera)
  35103. */
  35104. readonly frustumPlanes: Plane[];
  35105. /**
  35106. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35107. * This is useful if there are more lights that the maximum simulteanous authorized
  35108. */
  35109. requireLightSorting: boolean;
  35110. /** @hidden */
  35111. readonly useMaterialMeshMap: boolean;
  35112. /** @hidden */
  35113. readonly useClonedMeshhMap: boolean;
  35114. private _externalData;
  35115. private _uid;
  35116. /**
  35117. * @hidden
  35118. * Backing store of defined scene components.
  35119. */
  35120. _components: ISceneComponent[];
  35121. /**
  35122. * @hidden
  35123. * Backing store of defined scene components.
  35124. */
  35125. _serializableComponents: ISceneSerializableComponent[];
  35126. /**
  35127. * List of components to register on the next registration step.
  35128. */
  35129. private _transientComponents;
  35130. /**
  35131. * Registers the transient components if needed.
  35132. */
  35133. private _registerTransientComponents;
  35134. /**
  35135. * @hidden
  35136. * Add a component to the scene.
  35137. * Note that the ccomponent could be registered on th next frame if this is called after
  35138. * the register component stage.
  35139. * @param component Defines the component to add to the scene
  35140. */
  35141. _addComponent(component: ISceneComponent): void;
  35142. /**
  35143. * @hidden
  35144. * Gets a component from the scene.
  35145. * @param name defines the name of the component to retrieve
  35146. * @returns the component or null if not present
  35147. */
  35148. _getComponent(name: string): Nullable<ISceneComponent>;
  35149. /**
  35150. * @hidden
  35151. * Defines the actions happening before camera updates.
  35152. */
  35153. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35154. /**
  35155. * @hidden
  35156. * Defines the actions happening before clear the canvas.
  35157. */
  35158. _beforeClearStage: Stage<SimpleStageAction>;
  35159. /**
  35160. * @hidden
  35161. * Defines the actions when collecting render targets for the frame.
  35162. */
  35163. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35164. /**
  35165. * @hidden
  35166. * Defines the actions happening for one camera in the frame.
  35167. */
  35168. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35169. /**
  35170. * @hidden
  35171. * Defines the actions happening during the per mesh ready checks.
  35172. */
  35173. _isReadyForMeshStage: Stage<MeshStageAction>;
  35174. /**
  35175. * @hidden
  35176. * Defines the actions happening before evaluate active mesh checks.
  35177. */
  35178. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35179. /**
  35180. * @hidden
  35181. * Defines the actions happening during the evaluate sub mesh checks.
  35182. */
  35183. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35184. /**
  35185. * @hidden
  35186. * Defines the actions happening during the active mesh stage.
  35187. */
  35188. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35189. /**
  35190. * @hidden
  35191. * Defines the actions happening during the per camera render target step.
  35192. */
  35193. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35194. /**
  35195. * @hidden
  35196. * Defines the actions happening just before the active camera is drawing.
  35197. */
  35198. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35199. /**
  35200. * @hidden
  35201. * Defines the actions happening just before a render target is drawing.
  35202. */
  35203. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35204. /**
  35205. * @hidden
  35206. * Defines the actions happening just before a rendering group is drawing.
  35207. */
  35208. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35209. /**
  35210. * @hidden
  35211. * Defines the actions happening just before a mesh is drawing.
  35212. */
  35213. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35214. /**
  35215. * @hidden
  35216. * Defines the actions happening just after a mesh has been drawn.
  35217. */
  35218. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35219. /**
  35220. * @hidden
  35221. * Defines the actions happening just after a rendering group has been drawn.
  35222. */
  35223. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35224. /**
  35225. * @hidden
  35226. * Defines the actions happening just after the active camera has been drawn.
  35227. */
  35228. _afterCameraDrawStage: Stage<CameraStageAction>;
  35229. /**
  35230. * @hidden
  35231. * Defines the actions happening just after a render target has been drawn.
  35232. */
  35233. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35234. /**
  35235. * @hidden
  35236. * Defines the actions happening just after rendering all cameras and computing intersections.
  35237. */
  35238. _afterRenderStage: Stage<SimpleStageAction>;
  35239. /**
  35240. * @hidden
  35241. * Defines the actions happening when a pointer move event happens.
  35242. */
  35243. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35244. /**
  35245. * @hidden
  35246. * Defines the actions happening when a pointer down event happens.
  35247. */
  35248. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35249. /**
  35250. * @hidden
  35251. * Defines the actions happening when a pointer up event happens.
  35252. */
  35253. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35254. /**
  35255. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35256. */
  35257. private geometriesByUniqueId;
  35258. /**
  35259. * Creates a new Scene
  35260. * @param engine defines the engine to use to render this scene
  35261. * @param options defines the scene options
  35262. */
  35263. constructor(engine: Engine, options?: SceneOptions);
  35264. /**
  35265. * Gets a string idenfifying the name of the class
  35266. * @returns "Scene" string
  35267. */
  35268. getClassName(): string;
  35269. private _defaultMeshCandidates;
  35270. /**
  35271. * @hidden
  35272. */
  35273. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35274. private _defaultSubMeshCandidates;
  35275. /**
  35276. * @hidden
  35277. */
  35278. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35279. /**
  35280. * Sets the default candidate providers for the scene.
  35281. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35282. * and getCollidingSubMeshCandidates to their default function
  35283. */
  35284. setDefaultCandidateProviders(): void;
  35285. /**
  35286. * Gets the mesh that is currently under the pointer
  35287. */
  35288. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35289. /**
  35290. * Gets or sets the current on-screen X position of the pointer
  35291. */
  35292. pointerX: number;
  35293. /**
  35294. * Gets or sets the current on-screen Y position of the pointer
  35295. */
  35296. pointerY: number;
  35297. /**
  35298. * Gets the cached material (ie. the latest rendered one)
  35299. * @returns the cached material
  35300. */
  35301. getCachedMaterial(): Nullable<Material>;
  35302. /**
  35303. * Gets the cached effect (ie. the latest rendered one)
  35304. * @returns the cached effect
  35305. */
  35306. getCachedEffect(): Nullable<Effect>;
  35307. /**
  35308. * Gets the cached visibility state (ie. the latest rendered one)
  35309. * @returns the cached visibility state
  35310. */
  35311. getCachedVisibility(): Nullable<number>;
  35312. /**
  35313. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35314. * @param material defines the current material
  35315. * @param effect defines the current effect
  35316. * @param visibility defines the current visibility state
  35317. * @returns true if one parameter is not cached
  35318. */
  35319. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35320. /**
  35321. * Gets the engine associated with the scene
  35322. * @returns an Engine
  35323. */
  35324. getEngine(): Engine;
  35325. /**
  35326. * Gets the total number of vertices rendered per frame
  35327. * @returns the total number of vertices rendered per frame
  35328. */
  35329. getTotalVertices(): number;
  35330. /**
  35331. * Gets the performance counter for total vertices
  35332. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35333. */
  35334. readonly totalVerticesPerfCounter: PerfCounter;
  35335. /**
  35336. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35337. * @returns the total number of active indices rendered per frame
  35338. */
  35339. getActiveIndices(): number;
  35340. /**
  35341. * Gets the performance counter for active indices
  35342. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35343. */
  35344. readonly totalActiveIndicesPerfCounter: PerfCounter;
  35345. /**
  35346. * Gets the total number of active particles rendered per frame
  35347. * @returns the total number of active particles rendered per frame
  35348. */
  35349. getActiveParticles(): number;
  35350. /**
  35351. * Gets the performance counter for active particles
  35352. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35353. */
  35354. readonly activeParticlesPerfCounter: PerfCounter;
  35355. /**
  35356. * Gets the total number of active bones rendered per frame
  35357. * @returns the total number of active bones rendered per frame
  35358. */
  35359. getActiveBones(): number;
  35360. /**
  35361. * Gets the performance counter for active bones
  35362. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35363. */
  35364. readonly activeBonesPerfCounter: PerfCounter;
  35365. /**
  35366. * Gets the array of active meshes
  35367. * @returns an array of AbstractMesh
  35368. */
  35369. getActiveMeshes(): SmartArray<AbstractMesh>;
  35370. /**
  35371. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35372. * @returns a number
  35373. */
  35374. getAnimationRatio(): number;
  35375. /**
  35376. * Gets an unique Id for the current render phase
  35377. * @returns a number
  35378. */
  35379. getRenderId(): number;
  35380. /**
  35381. * Gets an unique Id for the current frame
  35382. * @returns a number
  35383. */
  35384. getFrameId(): number;
  35385. /** Call this function if you want to manually increment the render Id*/
  35386. incrementRenderId(): void;
  35387. private _createUbo;
  35388. /**
  35389. * Use this method to simulate a pointer move on a mesh
  35390. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35391. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35392. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35393. * @returns the current scene
  35394. */
  35395. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35396. /**
  35397. * Use this method to simulate a pointer down on a mesh
  35398. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35399. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35400. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35401. * @returns the current scene
  35402. */
  35403. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35404. /**
  35405. * Use this method to simulate a pointer up on a mesh
  35406. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35407. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35408. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35409. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35410. * @returns the current scene
  35411. */
  35412. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35413. /**
  35414. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35415. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35416. * @returns true if the pointer was captured
  35417. */
  35418. isPointerCaptured(pointerId?: number): boolean;
  35419. /**
  35420. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35421. * @param attachUp defines if you want to attach events to pointerup
  35422. * @param attachDown defines if you want to attach events to pointerdown
  35423. * @param attachMove defines if you want to attach events to pointermove
  35424. */
  35425. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35426. /** Detaches all event handlers*/
  35427. detachControl(): void;
  35428. /**
  35429. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35430. * Delay loaded resources are not taking in account
  35431. * @return true if all required resources are ready
  35432. */
  35433. isReady(): boolean;
  35434. /** Resets all cached information relative to material (including effect and visibility) */
  35435. resetCachedMaterial(): void;
  35436. /**
  35437. * Registers a function to be called before every frame render
  35438. * @param func defines the function to register
  35439. */
  35440. registerBeforeRender(func: () => void): void;
  35441. /**
  35442. * Unregisters a function called before every frame render
  35443. * @param func defines the function to unregister
  35444. */
  35445. unregisterBeforeRender(func: () => void): void;
  35446. /**
  35447. * Registers a function to be called after every frame render
  35448. * @param func defines the function to register
  35449. */
  35450. registerAfterRender(func: () => void): void;
  35451. /**
  35452. * Unregisters a function called after every frame render
  35453. * @param func defines the function to unregister
  35454. */
  35455. unregisterAfterRender(func: () => void): void;
  35456. private _executeOnceBeforeRender;
  35457. /**
  35458. * The provided function will run before render once and will be disposed afterwards.
  35459. * A timeout delay can be provided so that the function will be executed in N ms.
  35460. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35461. * @param func The function to be executed.
  35462. * @param timeout optional delay in ms
  35463. */
  35464. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35465. /** @hidden */
  35466. _addPendingData(data: any): void;
  35467. /** @hidden */
  35468. _removePendingData(data: any): void;
  35469. /**
  35470. * Returns the number of items waiting to be loaded
  35471. * @returns the number of items waiting to be loaded
  35472. */
  35473. getWaitingItemsCount(): number;
  35474. /**
  35475. * Returns a boolean indicating if the scene is still loading data
  35476. */
  35477. readonly isLoading: boolean;
  35478. /**
  35479. * Registers a function to be executed when the scene is ready
  35480. * @param {Function} func - the function to be executed
  35481. */
  35482. executeWhenReady(func: () => void): void;
  35483. /**
  35484. * Returns a promise that resolves when the scene is ready
  35485. * @returns A promise that resolves when the scene is ready
  35486. */
  35487. whenReadyAsync(): Promise<void>;
  35488. /** @hidden */
  35489. _checkIsReady(): void;
  35490. /**
  35491. * Gets all animatable attached to the scene
  35492. */
  35493. readonly animatables: Animatable[];
  35494. /**
  35495. * Resets the last animation time frame.
  35496. * Useful to override when animations start running when loading a scene for the first time.
  35497. */
  35498. resetLastAnimationTimeFrame(): void;
  35499. /**
  35500. * Gets the current view matrix
  35501. * @returns a Matrix
  35502. */
  35503. getViewMatrix(): Matrix;
  35504. /**
  35505. * Gets the current projection matrix
  35506. * @returns a Matrix
  35507. */
  35508. getProjectionMatrix(): Matrix;
  35509. /**
  35510. * Gets the current transform matrix
  35511. * @returns a Matrix made of View * Projection
  35512. */
  35513. getTransformMatrix(): Matrix;
  35514. /**
  35515. * Sets the current transform matrix
  35516. * @param viewL defines the View matrix to use
  35517. * @param projectionL defines the Projection matrix to use
  35518. * @param viewR defines the right View matrix to use (if provided)
  35519. * @param projectionR defines the right Projection matrix to use (if provided)
  35520. */
  35521. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35522. /**
  35523. * Gets the uniform buffer used to store scene data
  35524. * @returns a UniformBuffer
  35525. */
  35526. getSceneUniformBuffer(): UniformBuffer;
  35527. /**
  35528. * Gets an unique (relatively to the current scene) Id
  35529. * @returns an unique number for the scene
  35530. */
  35531. getUniqueId(): number;
  35532. /**
  35533. * Add a mesh to the list of scene's meshes
  35534. * @param newMesh defines the mesh to add
  35535. * @param recursive if all child meshes should also be added to the scene
  35536. */
  35537. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35538. /**
  35539. * Remove a mesh for the list of scene's meshes
  35540. * @param toRemove defines the mesh to remove
  35541. * @param recursive if all child meshes should also be removed from the scene
  35542. * @returns the index where the mesh was in the mesh list
  35543. */
  35544. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35545. /**
  35546. * Add a transform node to the list of scene's transform nodes
  35547. * @param newTransformNode defines the transform node to add
  35548. */
  35549. addTransformNode(newTransformNode: TransformNode): void;
  35550. /**
  35551. * Remove a transform node for the list of scene's transform nodes
  35552. * @param toRemove defines the transform node to remove
  35553. * @returns the index where the transform node was in the transform node list
  35554. */
  35555. removeTransformNode(toRemove: TransformNode): number;
  35556. /**
  35557. * Remove a skeleton for the list of scene's skeletons
  35558. * @param toRemove defines the skeleton to remove
  35559. * @returns the index where the skeleton was in the skeleton list
  35560. */
  35561. removeSkeleton(toRemove: Skeleton): number;
  35562. /**
  35563. * Remove a morph target for the list of scene's morph targets
  35564. * @param toRemove defines the morph target to remove
  35565. * @returns the index where the morph target was in the morph target list
  35566. */
  35567. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35568. /**
  35569. * Remove a light for the list of scene's lights
  35570. * @param toRemove defines the light to remove
  35571. * @returns the index where the light was in the light list
  35572. */
  35573. removeLight(toRemove: Light): number;
  35574. /**
  35575. * Remove a camera for the list of scene's cameras
  35576. * @param toRemove defines the camera to remove
  35577. * @returns the index where the camera was in the camera list
  35578. */
  35579. removeCamera(toRemove: Camera): number;
  35580. /**
  35581. * Remove a particle system for the list of scene's particle systems
  35582. * @param toRemove defines the particle system to remove
  35583. * @returns the index where the particle system was in the particle system list
  35584. */
  35585. removeParticleSystem(toRemove: IParticleSystem): number;
  35586. /**
  35587. * Remove a animation for the list of scene's animations
  35588. * @param toRemove defines the animation to remove
  35589. * @returns the index where the animation was in the animation list
  35590. */
  35591. removeAnimation(toRemove: Animation): number;
  35592. /**
  35593. * Will stop the animation of the given target
  35594. * @param target - the target
  35595. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35596. * @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)
  35597. */
  35598. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35599. /**
  35600. * Removes the given animation group from this scene.
  35601. * @param toRemove The animation group to remove
  35602. * @returns The index of the removed animation group
  35603. */
  35604. removeAnimationGroup(toRemove: AnimationGroup): number;
  35605. /**
  35606. * Removes the given multi-material from this scene.
  35607. * @param toRemove The multi-material to remove
  35608. * @returns The index of the removed multi-material
  35609. */
  35610. removeMultiMaterial(toRemove: MultiMaterial): number;
  35611. /**
  35612. * Removes the given material from this scene.
  35613. * @param toRemove The material to remove
  35614. * @returns The index of the removed material
  35615. */
  35616. removeMaterial(toRemove: Material): number;
  35617. /**
  35618. * Removes the given action manager from this scene.
  35619. * @param toRemove The action manager to remove
  35620. * @returns The index of the removed action manager
  35621. */
  35622. removeActionManager(toRemove: AbstractActionManager): number;
  35623. /**
  35624. * Removes the given texture from this scene.
  35625. * @param toRemove The texture to remove
  35626. * @returns The index of the removed texture
  35627. */
  35628. removeTexture(toRemove: BaseTexture): number;
  35629. /**
  35630. * Adds the given light to this scene
  35631. * @param newLight The light to add
  35632. */
  35633. addLight(newLight: Light): void;
  35634. /**
  35635. * Sorts the list list based on light priorities
  35636. */
  35637. sortLightsByPriority(): void;
  35638. /**
  35639. * Adds the given camera to this scene
  35640. * @param newCamera The camera to add
  35641. */
  35642. addCamera(newCamera: Camera): void;
  35643. /**
  35644. * Adds the given skeleton to this scene
  35645. * @param newSkeleton The skeleton to add
  35646. */
  35647. addSkeleton(newSkeleton: Skeleton): void;
  35648. /**
  35649. * Adds the given particle system to this scene
  35650. * @param newParticleSystem The particle system to add
  35651. */
  35652. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35653. /**
  35654. * Adds the given animation to this scene
  35655. * @param newAnimation The animation to add
  35656. */
  35657. addAnimation(newAnimation: Animation): void;
  35658. /**
  35659. * Adds the given animation group to this scene.
  35660. * @param newAnimationGroup The animation group to add
  35661. */
  35662. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35663. /**
  35664. * Adds the given multi-material to this scene
  35665. * @param newMultiMaterial The multi-material to add
  35666. */
  35667. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35668. /**
  35669. * Adds the given material to this scene
  35670. * @param newMaterial The material to add
  35671. */
  35672. addMaterial(newMaterial: Material): void;
  35673. /**
  35674. * Adds the given morph target to this scene
  35675. * @param newMorphTargetManager The morph target to add
  35676. */
  35677. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35678. /**
  35679. * Adds the given geometry to this scene
  35680. * @param newGeometry The geometry to add
  35681. */
  35682. addGeometry(newGeometry: Geometry): void;
  35683. /**
  35684. * Adds the given action manager to this scene
  35685. * @param newActionManager The action manager to add
  35686. */
  35687. addActionManager(newActionManager: AbstractActionManager): void;
  35688. /**
  35689. * Adds the given texture to this scene.
  35690. * @param newTexture The texture to add
  35691. */
  35692. addTexture(newTexture: BaseTexture): void;
  35693. /**
  35694. * Switch active camera
  35695. * @param newCamera defines the new active camera
  35696. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35697. */
  35698. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35699. /**
  35700. * sets the active camera of the scene using its ID
  35701. * @param id defines the camera's ID
  35702. * @return the new active camera or null if none found.
  35703. */
  35704. setActiveCameraByID(id: string): Nullable<Camera>;
  35705. /**
  35706. * sets the active camera of the scene using its name
  35707. * @param name defines the camera's name
  35708. * @returns the new active camera or null if none found.
  35709. */
  35710. setActiveCameraByName(name: string): Nullable<Camera>;
  35711. /**
  35712. * get an animation group using its name
  35713. * @param name defines the material's name
  35714. * @return the animation group or null if none found.
  35715. */
  35716. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35717. /**
  35718. * Get a material using its unique id
  35719. * @param uniqueId defines the material's unique id
  35720. * @return the material or null if none found.
  35721. */
  35722. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35723. /**
  35724. * get a material using its id
  35725. * @param id defines the material's ID
  35726. * @return the material or null if none found.
  35727. */
  35728. getMaterialByID(id: string): Nullable<Material>;
  35729. /**
  35730. * Gets a the last added material using a given id
  35731. * @param id defines the material's ID
  35732. * @return the last material with the given id or null if none found.
  35733. */
  35734. getLastMaterialByID(id: string): Nullable<Material>;
  35735. /**
  35736. * Gets a material using its name
  35737. * @param name defines the material's name
  35738. * @return the material or null if none found.
  35739. */
  35740. getMaterialByName(name: string): Nullable<Material>;
  35741. /**
  35742. * Get a texture using its unique id
  35743. * @param uniqueId defines the texture's unique id
  35744. * @return the texture or null if none found.
  35745. */
  35746. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35747. /**
  35748. * Gets a camera using its id
  35749. * @param id defines the id to look for
  35750. * @returns the camera or null if not found
  35751. */
  35752. getCameraByID(id: string): Nullable<Camera>;
  35753. /**
  35754. * Gets a camera using its unique id
  35755. * @param uniqueId defines the unique id to look for
  35756. * @returns the camera or null if not found
  35757. */
  35758. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35759. /**
  35760. * Gets a camera using its name
  35761. * @param name defines the camera's name
  35762. * @return the camera or null if none found.
  35763. */
  35764. getCameraByName(name: string): Nullable<Camera>;
  35765. /**
  35766. * Gets a bone using its id
  35767. * @param id defines the bone's id
  35768. * @return the bone or null if not found
  35769. */
  35770. getBoneByID(id: string): Nullable<Bone>;
  35771. /**
  35772. * Gets a bone using its id
  35773. * @param name defines the bone's name
  35774. * @return the bone or null if not found
  35775. */
  35776. getBoneByName(name: string): Nullable<Bone>;
  35777. /**
  35778. * Gets a light node using its name
  35779. * @param name defines the the light's name
  35780. * @return the light or null if none found.
  35781. */
  35782. getLightByName(name: string): Nullable<Light>;
  35783. /**
  35784. * Gets a light node using its id
  35785. * @param id defines the light's id
  35786. * @return the light or null if none found.
  35787. */
  35788. getLightByID(id: string): Nullable<Light>;
  35789. /**
  35790. * Gets a light node using its scene-generated unique ID
  35791. * @param uniqueId defines the light's unique id
  35792. * @return the light or null if none found.
  35793. */
  35794. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35795. /**
  35796. * Gets a particle system by id
  35797. * @param id defines the particle system id
  35798. * @return the corresponding system or null if none found
  35799. */
  35800. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35801. /**
  35802. * Gets a geometry using its ID
  35803. * @param id defines the geometry's id
  35804. * @return the geometry or null if none found.
  35805. */
  35806. getGeometryByID(id: string): Nullable<Geometry>;
  35807. private _getGeometryByUniqueID;
  35808. /**
  35809. * Add a new geometry to this scene
  35810. * @param geometry defines the geometry to be added to the scene.
  35811. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35812. * @return a boolean defining if the geometry was added or not
  35813. */
  35814. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35815. /**
  35816. * Removes an existing geometry
  35817. * @param geometry defines the geometry to be removed from the scene
  35818. * @return a boolean defining if the geometry was removed or not
  35819. */
  35820. removeGeometry(geometry: Geometry): boolean;
  35821. /**
  35822. * Gets the list of geometries attached to the scene
  35823. * @returns an array of Geometry
  35824. */
  35825. getGeometries(): Geometry[];
  35826. /**
  35827. * Gets the first added mesh found of a given ID
  35828. * @param id defines the id to search for
  35829. * @return the mesh found or null if not found at all
  35830. */
  35831. getMeshByID(id: string): Nullable<AbstractMesh>;
  35832. /**
  35833. * Gets a list of meshes using their id
  35834. * @param id defines the id to search for
  35835. * @returns a list of meshes
  35836. */
  35837. getMeshesByID(id: string): Array<AbstractMesh>;
  35838. /**
  35839. * Gets the first added transform node found of a given ID
  35840. * @param id defines the id to search for
  35841. * @return the found transform node or null if not found at all.
  35842. */
  35843. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35844. /**
  35845. * Gets a transform node with its auto-generated unique id
  35846. * @param uniqueId efines the unique id to search for
  35847. * @return the found transform node or null if not found at all.
  35848. */
  35849. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35850. /**
  35851. * Gets a list of transform nodes using their id
  35852. * @param id defines the id to search for
  35853. * @returns a list of transform nodes
  35854. */
  35855. getTransformNodesByID(id: string): Array<TransformNode>;
  35856. /**
  35857. * Gets a mesh with its auto-generated unique id
  35858. * @param uniqueId defines the unique id to search for
  35859. * @return the found mesh or null if not found at all.
  35860. */
  35861. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35862. /**
  35863. * Gets a the last added mesh using a given id
  35864. * @param id defines the id to search for
  35865. * @return the found mesh or null if not found at all.
  35866. */
  35867. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35868. /**
  35869. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35870. * @param id defines the id to search for
  35871. * @return the found node or null if not found at all
  35872. */
  35873. getLastEntryByID(id: string): Nullable<Node>;
  35874. /**
  35875. * Gets a node (Mesh, Camera, Light) using a given id
  35876. * @param id defines the id to search for
  35877. * @return the found node or null if not found at all
  35878. */
  35879. getNodeByID(id: string): Nullable<Node>;
  35880. /**
  35881. * Gets a node (Mesh, Camera, Light) using a given name
  35882. * @param name defines the name to search for
  35883. * @return the found node or null if not found at all.
  35884. */
  35885. getNodeByName(name: string): Nullable<Node>;
  35886. /**
  35887. * Gets a mesh using a given name
  35888. * @param name defines the name to search for
  35889. * @return the found mesh or null if not found at all.
  35890. */
  35891. getMeshByName(name: string): Nullable<AbstractMesh>;
  35892. /**
  35893. * Gets a transform node using a given name
  35894. * @param name defines the name to search for
  35895. * @return the found transform node or null if not found at all.
  35896. */
  35897. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35898. /**
  35899. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35900. * @param id defines the id to search for
  35901. * @return the found skeleton or null if not found at all.
  35902. */
  35903. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35904. /**
  35905. * Gets a skeleton using a given auto generated unique id
  35906. * @param uniqueId defines the unique id to search for
  35907. * @return the found skeleton or null if not found at all.
  35908. */
  35909. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35910. /**
  35911. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35912. * @param id defines the id to search for
  35913. * @return the found skeleton or null if not found at all.
  35914. */
  35915. getSkeletonById(id: string): Nullable<Skeleton>;
  35916. /**
  35917. * Gets a skeleton using a given name
  35918. * @param name defines the name to search for
  35919. * @return the found skeleton or null if not found at all.
  35920. */
  35921. getSkeletonByName(name: string): Nullable<Skeleton>;
  35922. /**
  35923. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35924. * @param id defines the id to search for
  35925. * @return the found morph target manager or null if not found at all.
  35926. */
  35927. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35928. /**
  35929. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35930. * @param id defines the id to search for
  35931. * @return the found morph target or null if not found at all.
  35932. */
  35933. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35934. /**
  35935. * Gets a boolean indicating if the given mesh is active
  35936. * @param mesh defines the mesh to look for
  35937. * @returns true if the mesh is in the active list
  35938. */
  35939. isActiveMesh(mesh: AbstractMesh): boolean;
  35940. /**
  35941. * Return a unique id as a string which can serve as an identifier for the scene
  35942. */
  35943. readonly uid: string;
  35944. /**
  35945. * Add an externaly attached data from its key.
  35946. * This method call will fail and return false, if such key already exists.
  35947. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35948. * @param key the unique key that identifies the data
  35949. * @param data the data object to associate to the key for this Engine instance
  35950. * @return true if no such key were already present and the data was added successfully, false otherwise
  35951. */
  35952. addExternalData<T>(key: string, data: T): boolean;
  35953. /**
  35954. * Get an externaly attached data from its key
  35955. * @param key the unique key that identifies the data
  35956. * @return the associated data, if present (can be null), or undefined if not present
  35957. */
  35958. getExternalData<T>(key: string): Nullable<T>;
  35959. /**
  35960. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35961. * @param key the unique key that identifies the data
  35962. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35963. * @return the associated data, can be null if the factory returned null.
  35964. */
  35965. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35966. /**
  35967. * Remove an externaly attached data from the Engine instance
  35968. * @param key the unique key that identifies the data
  35969. * @return true if the data was successfully removed, false if it doesn't exist
  35970. */
  35971. removeExternalData(key: string): boolean;
  35972. private _evaluateSubMesh;
  35973. /**
  35974. * Clear the processed materials smart array preventing retention point in material dispose.
  35975. */
  35976. freeProcessedMaterials(): void;
  35977. private _preventFreeActiveMeshesAndRenderingGroups;
  35978. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35979. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35980. * when disposing several meshes in a row or a hierarchy of meshes.
  35981. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35982. */
  35983. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35984. /**
  35985. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35986. */
  35987. freeActiveMeshes(): void;
  35988. /**
  35989. * Clear the info related to rendering groups preventing retention points during dispose.
  35990. */
  35991. freeRenderingGroups(): void;
  35992. /** @hidden */
  35993. _isInIntermediateRendering(): boolean;
  35994. /**
  35995. * Lambda returning the list of potentially active meshes.
  35996. */
  35997. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35998. /**
  35999. * Lambda returning the list of potentially active sub meshes.
  36000. */
  36001. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36002. /**
  36003. * Lambda returning the list of potentially intersecting sub meshes.
  36004. */
  36005. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36006. /**
  36007. * Lambda returning the list of potentially colliding sub meshes.
  36008. */
  36009. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36010. private _activeMeshesFrozen;
  36011. private _skipEvaluateActiveMeshesCompletely;
  36012. /**
  36013. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36014. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36015. * @returns the current scene
  36016. */
  36017. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36018. /**
  36019. * Use this function to restart evaluating active meshes on every frame
  36020. * @returns the current scene
  36021. */
  36022. unfreezeActiveMeshes(): Scene;
  36023. private _evaluateActiveMeshes;
  36024. private _activeMesh;
  36025. /**
  36026. * Update the transform matrix to update from the current active camera
  36027. * @param force defines a boolean used to force the update even if cache is up to date
  36028. */
  36029. updateTransformMatrix(force?: boolean): void;
  36030. private _bindFrameBuffer;
  36031. /** @hidden */
  36032. _allowPostProcessClearColor: boolean;
  36033. /** @hidden */
  36034. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36035. private _processSubCameras;
  36036. private _checkIntersections;
  36037. /** @hidden */
  36038. _advancePhysicsEngineStep(step: number): void;
  36039. /**
  36040. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36041. */
  36042. getDeterministicFrameTime: () => number;
  36043. /** @hidden */
  36044. _animate(): void;
  36045. /** Execute all animations (for a frame) */
  36046. animate(): void;
  36047. /**
  36048. * Render the scene
  36049. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36050. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36051. */
  36052. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36053. /**
  36054. * Freeze all materials
  36055. * A frozen material will not be updatable but should be faster to render
  36056. */
  36057. freezeMaterials(): void;
  36058. /**
  36059. * Unfreeze all materials
  36060. * A frozen material will not be updatable but should be faster to render
  36061. */
  36062. unfreezeMaterials(): void;
  36063. /**
  36064. * Releases all held ressources
  36065. */
  36066. dispose(): void;
  36067. /**
  36068. * Gets if the scene is already disposed
  36069. */
  36070. readonly isDisposed: boolean;
  36071. /**
  36072. * Call this function to reduce memory footprint of the scene.
  36073. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36074. */
  36075. clearCachedVertexData(): void;
  36076. /**
  36077. * This function will remove the local cached buffer data from texture.
  36078. * It will save memory but will prevent the texture from being rebuilt
  36079. */
  36080. cleanCachedTextureBuffer(): void;
  36081. /**
  36082. * Get the world extend vectors with an optional filter
  36083. *
  36084. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36085. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36086. */
  36087. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36088. min: Vector3;
  36089. max: Vector3;
  36090. };
  36091. /**
  36092. * Creates a ray that can be used to pick in the scene
  36093. * @param x defines the x coordinate of the origin (on-screen)
  36094. * @param y defines the y coordinate of the origin (on-screen)
  36095. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36096. * @param camera defines the camera to use for the picking
  36097. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36098. * @returns a Ray
  36099. */
  36100. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36101. /**
  36102. * Creates a ray that can be used to pick in the scene
  36103. * @param x defines the x coordinate of the origin (on-screen)
  36104. * @param y defines the y coordinate of the origin (on-screen)
  36105. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36106. * @param result defines the ray where to store the picking ray
  36107. * @param camera defines the camera to use for the picking
  36108. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36109. * @returns the current scene
  36110. */
  36111. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36112. /**
  36113. * Creates a ray that can be used to pick in the scene
  36114. * @param x defines the x coordinate of the origin (on-screen)
  36115. * @param y defines the y coordinate of the origin (on-screen)
  36116. * @param camera defines the camera to use for the picking
  36117. * @returns a Ray
  36118. */
  36119. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36120. /**
  36121. * Creates a ray that can be used to pick in the scene
  36122. * @param x defines the x coordinate of the origin (on-screen)
  36123. * @param y defines the y coordinate of the origin (on-screen)
  36124. * @param result defines the ray where to store the picking ray
  36125. * @param camera defines the camera to use for the picking
  36126. * @returns the current scene
  36127. */
  36128. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36129. /** Launch a ray to try to pick a mesh in the scene
  36130. * @param x position on screen
  36131. * @param y position on screen
  36132. * @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
  36133. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36134. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36135. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36136. * @returns a PickingInfo
  36137. */
  36138. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36139. /** Use the given ray to pick a mesh in the scene
  36140. * @param ray The ray to use to pick meshes
  36141. * @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
  36142. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36143. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36144. * @returns a PickingInfo
  36145. */
  36146. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36147. /**
  36148. * Launch a ray to try to pick a mesh in the scene
  36149. * @param x X position on screen
  36150. * @param y Y position on screen
  36151. * @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
  36152. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36153. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36154. * @returns an array of PickingInfo
  36155. */
  36156. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36157. /**
  36158. * Launch a ray to try to pick a mesh in the scene
  36159. * @param ray Ray to use
  36160. * @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
  36161. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36162. * @returns an array of PickingInfo
  36163. */
  36164. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36165. /**
  36166. * Force the value of meshUnderPointer
  36167. * @param mesh defines the mesh to use
  36168. */
  36169. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36170. /**
  36171. * Gets the mesh under the pointer
  36172. * @returns a Mesh or null if no mesh is under the pointer
  36173. */
  36174. getPointerOverMesh(): Nullable<AbstractMesh>;
  36175. /** @hidden */
  36176. _rebuildGeometries(): void;
  36177. /** @hidden */
  36178. _rebuildTextures(): void;
  36179. private _getByTags;
  36180. /**
  36181. * Get a list of meshes by tags
  36182. * @param tagsQuery defines the tags query to use
  36183. * @param forEach defines a predicate used to filter results
  36184. * @returns an array of Mesh
  36185. */
  36186. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36187. /**
  36188. * Get a list of cameras by tags
  36189. * @param tagsQuery defines the tags query to use
  36190. * @param forEach defines a predicate used to filter results
  36191. * @returns an array of Camera
  36192. */
  36193. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36194. /**
  36195. * Get a list of lights by tags
  36196. * @param tagsQuery defines the tags query to use
  36197. * @param forEach defines a predicate used to filter results
  36198. * @returns an array of Light
  36199. */
  36200. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36201. /**
  36202. * Get a list of materials by tags
  36203. * @param tagsQuery defines the tags query to use
  36204. * @param forEach defines a predicate used to filter results
  36205. * @returns an array of Material
  36206. */
  36207. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36208. /**
  36209. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36210. * This allowed control for front to back rendering or reversly depending of the special needs.
  36211. *
  36212. * @param renderingGroupId The rendering group id corresponding to its index
  36213. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36214. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36215. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36216. */
  36217. 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;
  36218. /**
  36219. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36220. *
  36221. * @param renderingGroupId The rendering group id corresponding to its index
  36222. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36223. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36224. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36225. */
  36226. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36227. /**
  36228. * Gets the current auto clear configuration for one rendering group of the rendering
  36229. * manager.
  36230. * @param index the rendering group index to get the information for
  36231. * @returns The auto clear setup for the requested rendering group
  36232. */
  36233. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36234. private _blockMaterialDirtyMechanism;
  36235. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36236. blockMaterialDirtyMechanism: boolean;
  36237. /**
  36238. * Will flag all materials as dirty to trigger new shader compilation
  36239. * @param flag defines the flag used to specify which material part must be marked as dirty
  36240. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36241. */
  36242. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36243. /** @hidden */
  36244. _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;
  36245. /** @hidden */
  36246. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36247. /** @hidden */
  36248. _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;
  36249. /** @hidden */
  36250. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36251. /** @hidden */
  36252. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36253. /** @hidden */
  36254. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36255. }
  36256. }
  36257. declare module BABYLON {
  36258. /**
  36259. * Set of assets to keep when moving a scene into an asset container.
  36260. */
  36261. export class KeepAssets extends AbstractScene {
  36262. }
  36263. /**
  36264. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36265. */
  36266. export class InstantiatedEntries {
  36267. /**
  36268. * List of new root nodes (eg. nodes with no parent)
  36269. */
  36270. rootNodes: TransformNode[];
  36271. /**
  36272. * List of new skeletons
  36273. */
  36274. skeletons: Skeleton[];
  36275. /**
  36276. * List of new animation groups
  36277. */
  36278. animationGroups: AnimationGroup[];
  36279. }
  36280. /**
  36281. * Container with a set of assets that can be added or removed from a scene.
  36282. */
  36283. export class AssetContainer extends AbstractScene {
  36284. /**
  36285. * The scene the AssetContainer belongs to.
  36286. */
  36287. scene: Scene;
  36288. /**
  36289. * Instantiates an AssetContainer.
  36290. * @param scene The scene the AssetContainer belongs to.
  36291. */
  36292. constructor(scene: Scene);
  36293. /**
  36294. * Instantiate or clone all meshes and add the new ones to the scene.
  36295. * Skeletons and animation groups will all be cloned
  36296. * @param nameFunction defines an optional function used to get new names for clones
  36297. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36298. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36299. */
  36300. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36301. /**
  36302. * Adds all the assets from the container to the scene.
  36303. */
  36304. addAllToScene(): void;
  36305. /**
  36306. * Removes all the assets in the container from the scene
  36307. */
  36308. removeAllFromScene(): void;
  36309. /**
  36310. * Disposes all the assets in the container
  36311. */
  36312. dispose(): void;
  36313. private _moveAssets;
  36314. /**
  36315. * Removes all the assets contained in the scene and adds them to the container.
  36316. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36317. */
  36318. moveAllFromScene(keepAssets?: KeepAssets): void;
  36319. /**
  36320. * 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.
  36321. * @returns the root mesh
  36322. */
  36323. createRootMesh(): Mesh;
  36324. }
  36325. }
  36326. declare module BABYLON {
  36327. /**
  36328. * Defines how the parser contract is defined.
  36329. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36330. */
  36331. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36332. /**
  36333. * Defines how the individual parser contract is defined.
  36334. * These parser can parse an individual asset
  36335. */
  36336. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36337. /**
  36338. * Base class of the scene acting as a container for the different elements composing a scene.
  36339. * This class is dynamically extended by the different components of the scene increasing
  36340. * flexibility and reducing coupling
  36341. */
  36342. export abstract class AbstractScene {
  36343. /**
  36344. * Stores the list of available parsers in the application.
  36345. */
  36346. private static _BabylonFileParsers;
  36347. /**
  36348. * Stores the list of available individual parsers in the application.
  36349. */
  36350. private static _IndividualBabylonFileParsers;
  36351. /**
  36352. * Adds a parser in the list of available ones
  36353. * @param name Defines the name of the parser
  36354. * @param parser Defines the parser to add
  36355. */
  36356. static AddParser(name: string, parser: BabylonFileParser): void;
  36357. /**
  36358. * Gets a general parser from the list of avaialble ones
  36359. * @param name Defines the name of the parser
  36360. * @returns the requested parser or null
  36361. */
  36362. static GetParser(name: string): Nullable<BabylonFileParser>;
  36363. /**
  36364. * Adds n individual parser in the list of available ones
  36365. * @param name Defines the name of the parser
  36366. * @param parser Defines the parser to add
  36367. */
  36368. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36369. /**
  36370. * Gets an individual parser from the list of avaialble ones
  36371. * @param name Defines the name of the parser
  36372. * @returns the requested parser or null
  36373. */
  36374. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36375. /**
  36376. * Parser json data and populate both a scene and its associated container object
  36377. * @param jsonData Defines the data to parse
  36378. * @param scene Defines the scene to parse the data for
  36379. * @param container Defines the container attached to the parsing sequence
  36380. * @param rootUrl Defines the root url of the data
  36381. */
  36382. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36383. /**
  36384. * Gets the list of root nodes (ie. nodes with no parent)
  36385. */
  36386. rootNodes: Node[];
  36387. /** All of the cameras added to this scene
  36388. * @see http://doc.babylonjs.com/babylon101/cameras
  36389. */
  36390. cameras: Camera[];
  36391. /**
  36392. * All of the lights added to this scene
  36393. * @see http://doc.babylonjs.com/babylon101/lights
  36394. */
  36395. lights: Light[];
  36396. /**
  36397. * All of the (abstract) meshes added to this scene
  36398. */
  36399. meshes: AbstractMesh[];
  36400. /**
  36401. * The list of skeletons added to the scene
  36402. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36403. */
  36404. skeletons: Skeleton[];
  36405. /**
  36406. * All of the particle systems added to this scene
  36407. * @see http://doc.babylonjs.com/babylon101/particles
  36408. */
  36409. particleSystems: IParticleSystem[];
  36410. /**
  36411. * Gets a list of Animations associated with the scene
  36412. */
  36413. animations: Animation[];
  36414. /**
  36415. * All of the animation groups added to this scene
  36416. * @see http://doc.babylonjs.com/how_to/group
  36417. */
  36418. animationGroups: AnimationGroup[];
  36419. /**
  36420. * All of the multi-materials added to this scene
  36421. * @see http://doc.babylonjs.com/how_to/multi_materials
  36422. */
  36423. multiMaterials: MultiMaterial[];
  36424. /**
  36425. * All of the materials added to this scene
  36426. * In the context of a Scene, it is not supposed to be modified manually.
  36427. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36428. * Note also that the order of the Material within the array is not significant and might change.
  36429. * @see http://doc.babylonjs.com/babylon101/materials
  36430. */
  36431. materials: Material[];
  36432. /**
  36433. * The list of morph target managers added to the scene
  36434. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36435. */
  36436. morphTargetManagers: MorphTargetManager[];
  36437. /**
  36438. * The list of geometries used in the scene.
  36439. */
  36440. geometries: Geometry[];
  36441. /**
  36442. * All of the tranform nodes added to this scene
  36443. * In the context of a Scene, it is not supposed to be modified manually.
  36444. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36445. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36446. * @see http://doc.babylonjs.com/how_to/transformnode
  36447. */
  36448. transformNodes: TransformNode[];
  36449. /**
  36450. * ActionManagers available on the scene.
  36451. */
  36452. actionManagers: AbstractActionManager[];
  36453. /**
  36454. * Textures to keep.
  36455. */
  36456. textures: BaseTexture[];
  36457. /**
  36458. * Environment texture for the scene
  36459. */
  36460. environmentTexture: Nullable<BaseTexture>;
  36461. }
  36462. }
  36463. declare module BABYLON {
  36464. /**
  36465. * Interface used to define options for Sound class
  36466. */
  36467. export interface ISoundOptions {
  36468. /**
  36469. * Does the sound autoplay once loaded.
  36470. */
  36471. autoplay?: boolean;
  36472. /**
  36473. * Does the sound loop after it finishes playing once.
  36474. */
  36475. loop?: boolean;
  36476. /**
  36477. * Sound's volume
  36478. */
  36479. volume?: number;
  36480. /**
  36481. * Is it a spatial sound?
  36482. */
  36483. spatialSound?: boolean;
  36484. /**
  36485. * Maximum distance to hear that sound
  36486. */
  36487. maxDistance?: number;
  36488. /**
  36489. * Uses user defined attenuation function
  36490. */
  36491. useCustomAttenuation?: boolean;
  36492. /**
  36493. * Define the roll off factor of spatial sounds.
  36494. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36495. */
  36496. rolloffFactor?: number;
  36497. /**
  36498. * Define the reference distance the sound should be heard perfectly.
  36499. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36500. */
  36501. refDistance?: number;
  36502. /**
  36503. * Define the distance attenuation model the sound will follow.
  36504. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36505. */
  36506. distanceModel?: string;
  36507. /**
  36508. * Defines the playback speed (1 by default)
  36509. */
  36510. playbackRate?: number;
  36511. /**
  36512. * Defines if the sound is from a streaming source
  36513. */
  36514. streaming?: boolean;
  36515. /**
  36516. * Defines an optional length (in seconds) inside the sound file
  36517. */
  36518. length?: number;
  36519. /**
  36520. * Defines an optional offset (in seconds) inside the sound file
  36521. */
  36522. offset?: number;
  36523. /**
  36524. * If true, URLs will not be required to state the audio file codec to use.
  36525. */
  36526. skipCodecCheck?: boolean;
  36527. }
  36528. /**
  36529. * Defines a sound that can be played in the application.
  36530. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36531. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36532. */
  36533. export class Sound {
  36534. /**
  36535. * The name of the sound in the scene.
  36536. */
  36537. name: string;
  36538. /**
  36539. * Does the sound autoplay once loaded.
  36540. */
  36541. autoplay: boolean;
  36542. /**
  36543. * Does the sound loop after it finishes playing once.
  36544. */
  36545. loop: boolean;
  36546. /**
  36547. * Does the sound use a custom attenuation curve to simulate the falloff
  36548. * happening when the source gets further away from the camera.
  36549. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36550. */
  36551. useCustomAttenuation: boolean;
  36552. /**
  36553. * The sound track id this sound belongs to.
  36554. */
  36555. soundTrackId: number;
  36556. /**
  36557. * Is this sound currently played.
  36558. */
  36559. isPlaying: boolean;
  36560. /**
  36561. * Is this sound currently paused.
  36562. */
  36563. isPaused: boolean;
  36564. /**
  36565. * Does this sound enables spatial sound.
  36566. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36567. */
  36568. spatialSound: boolean;
  36569. /**
  36570. * Define the reference distance the sound should be heard perfectly.
  36571. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36572. */
  36573. refDistance: number;
  36574. /**
  36575. * Define the roll off factor of spatial sounds.
  36576. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36577. */
  36578. rolloffFactor: number;
  36579. /**
  36580. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36581. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36582. */
  36583. maxDistance: number;
  36584. /**
  36585. * Define the distance attenuation model the sound will follow.
  36586. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36587. */
  36588. distanceModel: string;
  36589. /**
  36590. * @hidden
  36591. * Back Compat
  36592. **/
  36593. onended: () => any;
  36594. /**
  36595. * Observable event when the current playing sound finishes.
  36596. */
  36597. onEndedObservable: Observable<Sound>;
  36598. private _panningModel;
  36599. private _playbackRate;
  36600. private _streaming;
  36601. private _startTime;
  36602. private _startOffset;
  36603. private _position;
  36604. /** @hidden */
  36605. _positionInEmitterSpace: boolean;
  36606. private _localDirection;
  36607. private _volume;
  36608. private _isReadyToPlay;
  36609. private _isDirectional;
  36610. private _readyToPlayCallback;
  36611. private _audioBuffer;
  36612. private _soundSource;
  36613. private _streamingSource;
  36614. private _soundPanner;
  36615. private _soundGain;
  36616. private _inputAudioNode;
  36617. private _outputAudioNode;
  36618. private _coneInnerAngle;
  36619. private _coneOuterAngle;
  36620. private _coneOuterGain;
  36621. private _scene;
  36622. private _connectedTransformNode;
  36623. private _customAttenuationFunction;
  36624. private _registerFunc;
  36625. private _isOutputConnected;
  36626. private _htmlAudioElement;
  36627. private _urlType;
  36628. private _length?;
  36629. private _offset?;
  36630. /** @hidden */
  36631. static _SceneComponentInitialization: (scene: Scene) => void;
  36632. /**
  36633. * Create a sound and attach it to a scene
  36634. * @param name Name of your sound
  36635. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36636. * @param scene defines the scene the sound belongs to
  36637. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36638. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36639. */
  36640. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36641. /**
  36642. * Release the sound and its associated resources
  36643. */
  36644. dispose(): void;
  36645. /**
  36646. * Gets if the sounds is ready to be played or not.
  36647. * @returns true if ready, otherwise false
  36648. */
  36649. isReady(): boolean;
  36650. private _soundLoaded;
  36651. /**
  36652. * Sets the data of the sound from an audiobuffer
  36653. * @param audioBuffer The audioBuffer containing the data
  36654. */
  36655. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36656. /**
  36657. * Updates the current sounds options such as maxdistance, loop...
  36658. * @param options A JSON object containing values named as the object properties
  36659. */
  36660. updateOptions(options: ISoundOptions): void;
  36661. private _createSpatialParameters;
  36662. private _updateSpatialParameters;
  36663. /**
  36664. * Switch the panning model to HRTF:
  36665. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36666. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36667. */
  36668. switchPanningModelToHRTF(): void;
  36669. /**
  36670. * Switch the panning model to Equal Power:
  36671. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36672. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36673. */
  36674. switchPanningModelToEqualPower(): void;
  36675. private _switchPanningModel;
  36676. /**
  36677. * Connect this sound to a sound track audio node like gain...
  36678. * @param soundTrackAudioNode the sound track audio node to connect to
  36679. */
  36680. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36681. /**
  36682. * Transform this sound into a directional source
  36683. * @param coneInnerAngle Size of the inner cone in degree
  36684. * @param coneOuterAngle Size of the outer cone in degree
  36685. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36686. */
  36687. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36688. /**
  36689. * Gets or sets the inner angle for the directional cone.
  36690. */
  36691. /**
  36692. * Gets or sets the inner angle for the directional cone.
  36693. */
  36694. directionalConeInnerAngle: number;
  36695. /**
  36696. * Gets or sets the outer angle for the directional cone.
  36697. */
  36698. /**
  36699. * Gets or sets the outer angle for the directional cone.
  36700. */
  36701. directionalConeOuterAngle: number;
  36702. /**
  36703. * Sets the position of the emitter if spatial sound is enabled
  36704. * @param newPosition Defines the new posisiton
  36705. */
  36706. setPosition(newPosition: Vector3): void;
  36707. /**
  36708. * Sets the local direction of the emitter if spatial sound is enabled
  36709. * @param newLocalDirection Defines the new local direction
  36710. */
  36711. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36712. private _updateDirection;
  36713. /** @hidden */
  36714. updateDistanceFromListener(): void;
  36715. /**
  36716. * Sets a new custom attenuation function for the sound.
  36717. * @param callback Defines the function used for the attenuation
  36718. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36719. */
  36720. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36721. /**
  36722. * Play the sound
  36723. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36724. * @param offset (optional) Start the sound at a specific time in seconds
  36725. * @param length (optional) Sound duration (in seconds)
  36726. */
  36727. play(time?: number, offset?: number, length?: number): void;
  36728. private _onended;
  36729. /**
  36730. * Stop the sound
  36731. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36732. */
  36733. stop(time?: number): void;
  36734. /**
  36735. * Put the sound in pause
  36736. */
  36737. pause(): void;
  36738. /**
  36739. * Sets a dedicated volume for this sounds
  36740. * @param newVolume Define the new volume of the sound
  36741. * @param time Define time for gradual change to new volume
  36742. */
  36743. setVolume(newVolume: number, time?: number): void;
  36744. /**
  36745. * Set the sound play back rate
  36746. * @param newPlaybackRate Define the playback rate the sound should be played at
  36747. */
  36748. setPlaybackRate(newPlaybackRate: number): void;
  36749. /**
  36750. * Gets the volume of the sound.
  36751. * @returns the volume of the sound
  36752. */
  36753. getVolume(): number;
  36754. /**
  36755. * Attach the sound to a dedicated mesh
  36756. * @param transformNode The transform node to connect the sound with
  36757. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36758. */
  36759. attachToMesh(transformNode: TransformNode): void;
  36760. /**
  36761. * Detach the sound from the previously attached mesh
  36762. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36763. */
  36764. detachFromMesh(): void;
  36765. private _onRegisterAfterWorldMatrixUpdate;
  36766. /**
  36767. * Clone the current sound in the scene.
  36768. * @returns the new sound clone
  36769. */
  36770. clone(): Nullable<Sound>;
  36771. /**
  36772. * Gets the current underlying audio buffer containing the data
  36773. * @returns the audio buffer
  36774. */
  36775. getAudioBuffer(): Nullable<AudioBuffer>;
  36776. /**
  36777. * Serializes the Sound in a JSON representation
  36778. * @returns the JSON representation of the sound
  36779. */
  36780. serialize(): any;
  36781. /**
  36782. * Parse a JSON representation of a sound to innstantiate in a given scene
  36783. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36784. * @param scene Define the scene the new parsed sound should be created in
  36785. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36786. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36787. * @returns the newly parsed sound
  36788. */
  36789. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36790. }
  36791. }
  36792. declare module BABYLON {
  36793. /**
  36794. * This defines an action helpful to play a defined sound on a triggered action.
  36795. */
  36796. export class PlaySoundAction extends Action {
  36797. private _sound;
  36798. /**
  36799. * Instantiate the action
  36800. * @param triggerOptions defines the trigger options
  36801. * @param sound defines the sound to play
  36802. * @param condition defines the trigger related conditions
  36803. */
  36804. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36805. /** @hidden */
  36806. _prepare(): void;
  36807. /**
  36808. * Execute the action and play the sound.
  36809. */
  36810. execute(): void;
  36811. /**
  36812. * Serializes the actions and its related information.
  36813. * @param parent defines the object to serialize in
  36814. * @returns the serialized object
  36815. */
  36816. serialize(parent: any): any;
  36817. }
  36818. /**
  36819. * This defines an action helpful to stop a defined sound on a triggered action.
  36820. */
  36821. export class StopSoundAction extends Action {
  36822. private _sound;
  36823. /**
  36824. * Instantiate the action
  36825. * @param triggerOptions defines the trigger options
  36826. * @param sound defines the sound to stop
  36827. * @param condition defines the trigger related conditions
  36828. */
  36829. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36830. /** @hidden */
  36831. _prepare(): void;
  36832. /**
  36833. * Execute the action and stop the sound.
  36834. */
  36835. execute(): void;
  36836. /**
  36837. * Serializes the actions and its related information.
  36838. * @param parent defines the object to serialize in
  36839. * @returns the serialized object
  36840. */
  36841. serialize(parent: any): any;
  36842. }
  36843. }
  36844. declare module BABYLON {
  36845. /**
  36846. * This defines an action responsible to change the value of a property
  36847. * by interpolating between its current value and the newly set one once triggered.
  36848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36849. */
  36850. export class InterpolateValueAction extends Action {
  36851. /**
  36852. * Defines the path of the property where the value should be interpolated
  36853. */
  36854. propertyPath: string;
  36855. /**
  36856. * Defines the target value at the end of the interpolation.
  36857. */
  36858. value: any;
  36859. /**
  36860. * Defines the time it will take for the property to interpolate to the value.
  36861. */
  36862. duration: number;
  36863. /**
  36864. * Defines if the other scene animations should be stopped when the action has been triggered
  36865. */
  36866. stopOtherAnimations?: boolean;
  36867. /**
  36868. * Defines a callback raised once the interpolation animation has been done.
  36869. */
  36870. onInterpolationDone?: () => void;
  36871. /**
  36872. * Observable triggered once the interpolation animation has been done.
  36873. */
  36874. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36875. private _target;
  36876. private _effectiveTarget;
  36877. private _property;
  36878. /**
  36879. * Instantiate the action
  36880. * @param triggerOptions defines the trigger options
  36881. * @param target defines the object containing the value to interpolate
  36882. * @param propertyPath defines the path to the property in the target object
  36883. * @param value defines the target value at the end of the interpolation
  36884. * @param duration deines the time it will take for the property to interpolate to the value.
  36885. * @param condition defines the trigger related conditions
  36886. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36887. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36888. */
  36889. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36890. /** @hidden */
  36891. _prepare(): void;
  36892. /**
  36893. * Execute the action starts the value interpolation.
  36894. */
  36895. execute(): void;
  36896. /**
  36897. * Serializes the actions and its related information.
  36898. * @param parent defines the object to serialize in
  36899. * @returns the serialized object
  36900. */
  36901. serialize(parent: any): any;
  36902. }
  36903. }
  36904. declare module BABYLON {
  36905. /**
  36906. * Options allowed during the creation of a sound track.
  36907. */
  36908. export interface ISoundTrackOptions {
  36909. /**
  36910. * The volume the sound track should take during creation
  36911. */
  36912. volume?: number;
  36913. /**
  36914. * Define if the sound track is the main sound track of the scene
  36915. */
  36916. mainTrack?: boolean;
  36917. }
  36918. /**
  36919. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36920. * It will be also used in a future release to apply effects on a specific track.
  36921. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36922. */
  36923. export class SoundTrack {
  36924. /**
  36925. * The unique identifier of the sound track in the scene.
  36926. */
  36927. id: number;
  36928. /**
  36929. * The list of sounds included in the sound track.
  36930. */
  36931. soundCollection: Array<Sound>;
  36932. private _outputAudioNode;
  36933. private _scene;
  36934. private _connectedAnalyser;
  36935. private _options;
  36936. private _isInitialized;
  36937. /**
  36938. * Creates a new sound track.
  36939. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36940. * @param scene Define the scene the sound track belongs to
  36941. * @param options
  36942. */
  36943. constructor(scene: Scene, options?: ISoundTrackOptions);
  36944. private _initializeSoundTrackAudioGraph;
  36945. /**
  36946. * Release the sound track and its associated resources
  36947. */
  36948. dispose(): void;
  36949. /**
  36950. * Adds a sound to this sound track
  36951. * @param sound define the cound to add
  36952. * @ignoreNaming
  36953. */
  36954. AddSound(sound: Sound): void;
  36955. /**
  36956. * Removes a sound to this sound track
  36957. * @param sound define the cound to remove
  36958. * @ignoreNaming
  36959. */
  36960. RemoveSound(sound: Sound): void;
  36961. /**
  36962. * Set a global volume for the full sound track.
  36963. * @param newVolume Define the new volume of the sound track
  36964. */
  36965. setVolume(newVolume: number): void;
  36966. /**
  36967. * Switch the panning model to HRTF:
  36968. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36970. */
  36971. switchPanningModelToHRTF(): void;
  36972. /**
  36973. * Switch the panning model to Equal Power:
  36974. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36975. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36976. */
  36977. switchPanningModelToEqualPower(): void;
  36978. /**
  36979. * Connect the sound track to an audio analyser allowing some amazing
  36980. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36981. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36982. * @param analyser The analyser to connect to the engine
  36983. */
  36984. connectToAnalyser(analyser: Analyser): void;
  36985. }
  36986. }
  36987. declare module BABYLON {
  36988. interface AbstractScene {
  36989. /**
  36990. * The list of sounds used in the scene.
  36991. */
  36992. sounds: Nullable<Array<Sound>>;
  36993. }
  36994. interface Scene {
  36995. /**
  36996. * @hidden
  36997. * Backing field
  36998. */
  36999. _mainSoundTrack: SoundTrack;
  37000. /**
  37001. * The main sound track played by the scene.
  37002. * It cotains your primary collection of sounds.
  37003. */
  37004. mainSoundTrack: SoundTrack;
  37005. /**
  37006. * The list of sound tracks added to the scene
  37007. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37008. */
  37009. soundTracks: Nullable<Array<SoundTrack>>;
  37010. /**
  37011. * Gets a sound using a given name
  37012. * @param name defines the name to search for
  37013. * @return the found sound or null if not found at all.
  37014. */
  37015. getSoundByName(name: string): Nullable<Sound>;
  37016. /**
  37017. * Gets or sets if audio support is enabled
  37018. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37019. */
  37020. audioEnabled: boolean;
  37021. /**
  37022. * Gets or sets if audio will be output to headphones
  37023. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37024. */
  37025. headphone: boolean;
  37026. /**
  37027. * Gets or sets custom audio listener position provider
  37028. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37029. */
  37030. audioListenerPositionProvider: Nullable<() => Vector3>;
  37031. /**
  37032. * Gets or sets a refresh rate when using 3D audio positioning
  37033. */
  37034. audioPositioningRefreshRate: number;
  37035. }
  37036. /**
  37037. * Defines the sound scene component responsible to manage any sounds
  37038. * in a given scene.
  37039. */
  37040. export class AudioSceneComponent implements ISceneSerializableComponent {
  37041. /**
  37042. * The component name helpfull to identify the component in the list of scene components.
  37043. */
  37044. readonly name: string;
  37045. /**
  37046. * The scene the component belongs to.
  37047. */
  37048. scene: Scene;
  37049. private _audioEnabled;
  37050. /**
  37051. * Gets whether audio is enabled or not.
  37052. * Please use related enable/disable method to switch state.
  37053. */
  37054. readonly audioEnabled: boolean;
  37055. private _headphone;
  37056. /**
  37057. * Gets whether audio is outputing to headphone or not.
  37058. * Please use the according Switch methods to change output.
  37059. */
  37060. readonly headphone: boolean;
  37061. /**
  37062. * Gets or sets a refresh rate when using 3D audio positioning
  37063. */
  37064. audioPositioningRefreshRate: number;
  37065. private _audioListenerPositionProvider;
  37066. /**
  37067. * Gets the current audio listener position provider
  37068. */
  37069. /**
  37070. * Sets a custom listener position for all sounds in the scene
  37071. * By default, this is the position of the first active camera
  37072. */
  37073. audioListenerPositionProvider: Nullable<() => Vector3>;
  37074. /**
  37075. * Creates a new instance of the component for the given scene
  37076. * @param scene Defines the scene to register the component in
  37077. */
  37078. constructor(scene: Scene);
  37079. /**
  37080. * Registers the component in a given scene
  37081. */
  37082. register(): void;
  37083. /**
  37084. * Rebuilds the elements related to this component in case of
  37085. * context lost for instance.
  37086. */
  37087. rebuild(): void;
  37088. /**
  37089. * Serializes the component data to the specified json object
  37090. * @param serializationObject The object to serialize to
  37091. */
  37092. serialize(serializationObject: any): void;
  37093. /**
  37094. * Adds all the elements from the container to the scene
  37095. * @param container the container holding the elements
  37096. */
  37097. addFromContainer(container: AbstractScene): void;
  37098. /**
  37099. * Removes all the elements in the container from the scene
  37100. * @param container contains the elements to remove
  37101. * @param dispose if the removed element should be disposed (default: false)
  37102. */
  37103. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37104. /**
  37105. * Disposes the component and the associated ressources.
  37106. */
  37107. dispose(): void;
  37108. /**
  37109. * Disables audio in the associated scene.
  37110. */
  37111. disableAudio(): void;
  37112. /**
  37113. * Enables audio in the associated scene.
  37114. */
  37115. enableAudio(): void;
  37116. /**
  37117. * Switch audio to headphone output.
  37118. */
  37119. switchAudioModeForHeadphones(): void;
  37120. /**
  37121. * Switch audio to normal speakers.
  37122. */
  37123. switchAudioModeForNormalSpeakers(): void;
  37124. private _cachedCameraDirection;
  37125. private _cachedCameraPosition;
  37126. private _lastCheck;
  37127. private _afterRender;
  37128. }
  37129. }
  37130. declare module BABYLON {
  37131. /**
  37132. * Wraps one or more Sound objects and selects one with random weight for playback.
  37133. */
  37134. export class WeightedSound {
  37135. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37136. loop: boolean;
  37137. private _coneInnerAngle;
  37138. private _coneOuterAngle;
  37139. private _volume;
  37140. /** A Sound is currently playing. */
  37141. isPlaying: boolean;
  37142. /** A Sound is currently paused. */
  37143. isPaused: boolean;
  37144. private _sounds;
  37145. private _weights;
  37146. private _currentIndex?;
  37147. /**
  37148. * Creates a new WeightedSound from the list of sounds given.
  37149. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37150. * @param sounds Array of Sounds that will be selected from.
  37151. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37152. */
  37153. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37154. /**
  37155. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37156. */
  37157. /**
  37158. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37159. */
  37160. directionalConeInnerAngle: number;
  37161. /**
  37162. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37163. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37164. */
  37165. /**
  37166. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37167. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37168. */
  37169. directionalConeOuterAngle: number;
  37170. /**
  37171. * Playback volume.
  37172. */
  37173. /**
  37174. * Playback volume.
  37175. */
  37176. volume: number;
  37177. private _onended;
  37178. /**
  37179. * Suspend playback
  37180. */
  37181. pause(): void;
  37182. /**
  37183. * Stop playback
  37184. */
  37185. stop(): void;
  37186. /**
  37187. * Start playback.
  37188. * @param startOffset Position the clip head at a specific time in seconds.
  37189. */
  37190. play(startOffset?: number): void;
  37191. }
  37192. }
  37193. declare module BABYLON {
  37194. /**
  37195. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37196. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37197. */
  37198. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37199. /**
  37200. * Gets the name of the behavior.
  37201. */
  37202. readonly name: string;
  37203. /**
  37204. * The easing function used by animations
  37205. */
  37206. static EasingFunction: BackEase;
  37207. /**
  37208. * The easing mode used by animations
  37209. */
  37210. static EasingMode: number;
  37211. /**
  37212. * The duration of the animation, in milliseconds
  37213. */
  37214. transitionDuration: number;
  37215. /**
  37216. * Length of the distance animated by the transition when lower radius is reached
  37217. */
  37218. lowerRadiusTransitionRange: number;
  37219. /**
  37220. * Length of the distance animated by the transition when upper radius is reached
  37221. */
  37222. upperRadiusTransitionRange: number;
  37223. private _autoTransitionRange;
  37224. /**
  37225. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37226. */
  37227. /**
  37228. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37229. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37230. */
  37231. autoTransitionRange: boolean;
  37232. private _attachedCamera;
  37233. private _onAfterCheckInputsObserver;
  37234. private _onMeshTargetChangedObserver;
  37235. /**
  37236. * Initializes the behavior.
  37237. */
  37238. init(): void;
  37239. /**
  37240. * Attaches the behavior to its arc rotate camera.
  37241. * @param camera Defines the camera to attach the behavior to
  37242. */
  37243. attach(camera: ArcRotateCamera): void;
  37244. /**
  37245. * Detaches the behavior from its current arc rotate camera.
  37246. */
  37247. detach(): void;
  37248. private _radiusIsAnimating;
  37249. private _radiusBounceTransition;
  37250. private _animatables;
  37251. private _cachedWheelPrecision;
  37252. /**
  37253. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37254. * @param radiusLimit The limit to check against.
  37255. * @return Bool to indicate if at limit.
  37256. */
  37257. private _isRadiusAtLimit;
  37258. /**
  37259. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37260. * @param radiusDelta The delta by which to animate to. Can be negative.
  37261. */
  37262. private _applyBoundRadiusAnimation;
  37263. /**
  37264. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37265. */
  37266. protected _clearAnimationLocks(): void;
  37267. /**
  37268. * Stops and removes all animations that have been applied to the camera
  37269. */
  37270. stopAllAnimations(): void;
  37271. }
  37272. }
  37273. declare module BABYLON {
  37274. /**
  37275. * 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.
  37276. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37277. */
  37278. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37279. /**
  37280. * Gets the name of the behavior.
  37281. */
  37282. readonly name: string;
  37283. private _mode;
  37284. private _radiusScale;
  37285. private _positionScale;
  37286. private _defaultElevation;
  37287. private _elevationReturnTime;
  37288. private _elevationReturnWaitTime;
  37289. private _zoomStopsAnimation;
  37290. private _framingTime;
  37291. /**
  37292. * The easing function used by animations
  37293. */
  37294. static EasingFunction: ExponentialEase;
  37295. /**
  37296. * The easing mode used by animations
  37297. */
  37298. static EasingMode: number;
  37299. /**
  37300. * Sets the current mode used by the behavior
  37301. */
  37302. /**
  37303. * Gets current mode used by the behavior.
  37304. */
  37305. mode: number;
  37306. /**
  37307. * Sets the scale applied to the radius (1 by default)
  37308. */
  37309. /**
  37310. * Gets the scale applied to the radius
  37311. */
  37312. radiusScale: number;
  37313. /**
  37314. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37315. */
  37316. /**
  37317. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37318. */
  37319. positionScale: number;
  37320. /**
  37321. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37322. * behaviour is triggered, in radians.
  37323. */
  37324. /**
  37325. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37326. * behaviour is triggered, in radians.
  37327. */
  37328. defaultElevation: number;
  37329. /**
  37330. * Sets the time (in milliseconds) taken to return to the default beta position.
  37331. * Negative value indicates camera should not return to default.
  37332. */
  37333. /**
  37334. * Gets the time (in milliseconds) taken to return to the default beta position.
  37335. * Negative value indicates camera should not return to default.
  37336. */
  37337. elevationReturnTime: number;
  37338. /**
  37339. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37340. */
  37341. /**
  37342. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37343. */
  37344. elevationReturnWaitTime: number;
  37345. /**
  37346. * Sets the flag that indicates if user zooming should stop animation.
  37347. */
  37348. /**
  37349. * Gets the flag that indicates if user zooming should stop animation.
  37350. */
  37351. zoomStopsAnimation: boolean;
  37352. /**
  37353. * Sets the transition time when framing the mesh, in milliseconds
  37354. */
  37355. /**
  37356. * Gets the transition time when framing the mesh, in milliseconds
  37357. */
  37358. framingTime: number;
  37359. /**
  37360. * Define if the behavior should automatically change the configured
  37361. * camera limits and sensibilities.
  37362. */
  37363. autoCorrectCameraLimitsAndSensibility: boolean;
  37364. private _onPrePointerObservableObserver;
  37365. private _onAfterCheckInputsObserver;
  37366. private _onMeshTargetChangedObserver;
  37367. private _attachedCamera;
  37368. private _isPointerDown;
  37369. private _lastInteractionTime;
  37370. /**
  37371. * Initializes the behavior.
  37372. */
  37373. init(): void;
  37374. /**
  37375. * Attaches the behavior to its arc rotate camera.
  37376. * @param camera Defines the camera to attach the behavior to
  37377. */
  37378. attach(camera: ArcRotateCamera): void;
  37379. /**
  37380. * Detaches the behavior from its current arc rotate camera.
  37381. */
  37382. detach(): void;
  37383. private _animatables;
  37384. private _betaIsAnimating;
  37385. private _betaTransition;
  37386. private _radiusTransition;
  37387. private _vectorTransition;
  37388. /**
  37389. * Targets the given mesh and updates zoom level accordingly.
  37390. * @param mesh The mesh to target.
  37391. * @param radius Optional. If a cached radius position already exists, overrides default.
  37392. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37393. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37394. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37395. */
  37396. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37397. /**
  37398. * Targets the given mesh with its children and updates zoom level accordingly.
  37399. * @param mesh The mesh to target.
  37400. * @param radius Optional. If a cached radius position already exists, overrides default.
  37401. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37402. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37403. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37404. */
  37405. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37406. /**
  37407. * Targets the given meshes with their children and updates zoom level accordingly.
  37408. * @param meshes The mesh to target.
  37409. * @param radius Optional. If a cached radius position already exists, overrides default.
  37410. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37411. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37412. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37413. */
  37414. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37415. /**
  37416. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37417. * @param minimumWorld Determines the smaller position of the bounding box extend
  37418. * @param maximumWorld Determines the bigger position of the bounding box extend
  37419. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37420. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37421. */
  37422. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37423. /**
  37424. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37425. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37426. * frustum width.
  37427. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37428. * to fully enclose the mesh in the viewing frustum.
  37429. */
  37430. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37431. /**
  37432. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37433. * is automatically returned to its default position (expected to be above ground plane).
  37434. */
  37435. private _maintainCameraAboveGround;
  37436. /**
  37437. * Returns the frustum slope based on the canvas ratio and camera FOV
  37438. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37439. */
  37440. private _getFrustumSlope;
  37441. /**
  37442. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37443. */
  37444. private _clearAnimationLocks;
  37445. /**
  37446. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37447. */
  37448. private _applyUserInteraction;
  37449. /**
  37450. * Stops and removes all animations that have been applied to the camera
  37451. */
  37452. stopAllAnimations(): void;
  37453. /**
  37454. * Gets a value indicating if the user is moving the camera
  37455. */
  37456. readonly isUserIsMoving: boolean;
  37457. /**
  37458. * The camera can move all the way towards the mesh.
  37459. */
  37460. static IgnoreBoundsSizeMode: number;
  37461. /**
  37462. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37463. */
  37464. static FitFrustumSidesMode: number;
  37465. }
  37466. }
  37467. declare module BABYLON {
  37468. /**
  37469. * Base class for Camera Pointer Inputs.
  37470. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37471. * for example usage.
  37472. */
  37473. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37474. /**
  37475. * Defines the camera the input is attached to.
  37476. */
  37477. abstract camera: Camera;
  37478. /**
  37479. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37480. */
  37481. protected _altKey: boolean;
  37482. protected _ctrlKey: boolean;
  37483. protected _metaKey: boolean;
  37484. protected _shiftKey: boolean;
  37485. /**
  37486. * Which mouse buttons were pressed at time of last mouse event.
  37487. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37488. */
  37489. protected _buttonsPressed: number;
  37490. /**
  37491. * Defines the buttons associated with the input to handle camera move.
  37492. */
  37493. buttons: number[];
  37494. /**
  37495. * Attach the input controls to a specific dom element to get the input from.
  37496. * @param element Defines the element the controls should be listened from
  37497. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37498. */
  37499. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37500. /**
  37501. * Detach the current controls from the specified dom element.
  37502. * @param element Defines the element to stop listening the inputs from
  37503. */
  37504. detachControl(element: Nullable<HTMLElement>): void;
  37505. /**
  37506. * Gets the class name of the current input.
  37507. * @returns the class name
  37508. */
  37509. getClassName(): string;
  37510. /**
  37511. * Get the friendly name associated with the input class.
  37512. * @returns the input friendly name
  37513. */
  37514. getSimpleName(): string;
  37515. /**
  37516. * Called on pointer POINTERDOUBLETAP event.
  37517. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37518. */
  37519. protected onDoubleTap(type: string): void;
  37520. /**
  37521. * Called on pointer POINTERMOVE event if only a single touch is active.
  37522. * Override this method to provide functionality.
  37523. */
  37524. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37525. /**
  37526. * Called on pointer POINTERMOVE event if multiple touches are active.
  37527. * Override this method to provide functionality.
  37528. */
  37529. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37530. /**
  37531. * Called on JS contextmenu event.
  37532. * Override this method to provide functionality.
  37533. */
  37534. protected onContextMenu(evt: PointerEvent): void;
  37535. /**
  37536. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37537. * press.
  37538. * Override this method to provide functionality.
  37539. */
  37540. protected onButtonDown(evt: PointerEvent): void;
  37541. /**
  37542. * Called each time a new POINTERUP event occurs. Ie, for each button
  37543. * release.
  37544. * Override this method to provide functionality.
  37545. */
  37546. protected onButtonUp(evt: PointerEvent): void;
  37547. /**
  37548. * Called when window becomes inactive.
  37549. * Override this method to provide functionality.
  37550. */
  37551. protected onLostFocus(): void;
  37552. private _pointerInput;
  37553. private _observer;
  37554. private _onLostFocus;
  37555. private pointA;
  37556. private pointB;
  37557. }
  37558. }
  37559. declare module BABYLON {
  37560. /**
  37561. * Manage the pointers inputs to control an arc rotate camera.
  37562. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37563. */
  37564. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37565. /**
  37566. * Defines the camera the input is attached to.
  37567. */
  37568. camera: ArcRotateCamera;
  37569. /**
  37570. * Gets the class name of the current input.
  37571. * @returns the class name
  37572. */
  37573. getClassName(): string;
  37574. /**
  37575. * Defines the buttons associated with the input to handle camera move.
  37576. */
  37577. buttons: number[];
  37578. /**
  37579. * Defines the pointer angular sensibility along the X axis or how fast is
  37580. * the camera rotating.
  37581. */
  37582. angularSensibilityX: number;
  37583. /**
  37584. * Defines the pointer angular sensibility along the Y axis or how fast is
  37585. * the camera rotating.
  37586. */
  37587. angularSensibilityY: number;
  37588. /**
  37589. * Defines the pointer pinch precision or how fast is the camera zooming.
  37590. */
  37591. pinchPrecision: number;
  37592. /**
  37593. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37594. * from 0.
  37595. * It defines the percentage of current camera.radius to use as delta when
  37596. * pinch zoom is used.
  37597. */
  37598. pinchDeltaPercentage: number;
  37599. /**
  37600. * Defines the pointer panning sensibility or how fast is the camera moving.
  37601. */
  37602. panningSensibility: number;
  37603. /**
  37604. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37605. */
  37606. multiTouchPanning: boolean;
  37607. /**
  37608. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37609. * zoom (pinch) through multitouch.
  37610. */
  37611. multiTouchPanAndZoom: boolean;
  37612. /**
  37613. * Revers pinch action direction.
  37614. */
  37615. pinchInwards: boolean;
  37616. private _isPanClick;
  37617. private _twoFingerActivityCount;
  37618. private _isPinching;
  37619. /**
  37620. * Called on pointer POINTERMOVE event if only a single touch is active.
  37621. */
  37622. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37623. /**
  37624. * Called on pointer POINTERDOUBLETAP event.
  37625. */
  37626. protected onDoubleTap(type: string): void;
  37627. /**
  37628. * Called on pointer POINTERMOVE event if multiple touches are active.
  37629. */
  37630. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37631. /**
  37632. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37633. * press.
  37634. */
  37635. protected onButtonDown(evt: PointerEvent): void;
  37636. /**
  37637. * Called each time a new POINTERUP event occurs. Ie, for each button
  37638. * release.
  37639. */
  37640. protected onButtonUp(evt: PointerEvent): void;
  37641. /**
  37642. * Called when window becomes inactive.
  37643. */
  37644. protected onLostFocus(): void;
  37645. }
  37646. }
  37647. declare module BABYLON {
  37648. /**
  37649. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37650. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37651. */
  37652. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37653. /**
  37654. * Defines the camera the input is attached to.
  37655. */
  37656. camera: ArcRotateCamera;
  37657. /**
  37658. * Defines the list of key codes associated with the up action (increase alpha)
  37659. */
  37660. keysUp: number[];
  37661. /**
  37662. * Defines the list of key codes associated with the down action (decrease alpha)
  37663. */
  37664. keysDown: number[];
  37665. /**
  37666. * Defines the list of key codes associated with the left action (increase beta)
  37667. */
  37668. keysLeft: number[];
  37669. /**
  37670. * Defines the list of key codes associated with the right action (decrease beta)
  37671. */
  37672. keysRight: number[];
  37673. /**
  37674. * Defines the list of key codes associated with the reset action.
  37675. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37676. */
  37677. keysReset: number[];
  37678. /**
  37679. * Defines the panning sensibility of the inputs.
  37680. * (How fast is the camera paning)
  37681. */
  37682. panningSensibility: number;
  37683. /**
  37684. * Defines the zooming sensibility of the inputs.
  37685. * (How fast is the camera zooming)
  37686. */
  37687. zoomingSensibility: number;
  37688. /**
  37689. * Defines wether maintaining the alt key down switch the movement mode from
  37690. * orientation to zoom.
  37691. */
  37692. useAltToZoom: boolean;
  37693. /**
  37694. * Rotation speed of the camera
  37695. */
  37696. angularSpeed: number;
  37697. private _keys;
  37698. private _ctrlPressed;
  37699. private _altPressed;
  37700. private _onCanvasBlurObserver;
  37701. private _onKeyboardObserver;
  37702. private _engine;
  37703. private _scene;
  37704. /**
  37705. * Attach the input controls to a specific dom element to get the input from.
  37706. * @param element Defines the element the controls should be listened from
  37707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37708. */
  37709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37710. /**
  37711. * Detach the current controls from the specified dom element.
  37712. * @param element Defines the element to stop listening the inputs from
  37713. */
  37714. detachControl(element: Nullable<HTMLElement>): void;
  37715. /**
  37716. * Update the current camera state depending on the inputs that have been used this frame.
  37717. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37718. */
  37719. checkInputs(): void;
  37720. /**
  37721. * Gets the class name of the current intput.
  37722. * @returns the class name
  37723. */
  37724. getClassName(): string;
  37725. /**
  37726. * Get the friendly name associated with the input class.
  37727. * @returns the input friendly name
  37728. */
  37729. getSimpleName(): string;
  37730. }
  37731. }
  37732. declare module BABYLON {
  37733. /**
  37734. * Manage the mouse wheel inputs to control an arc rotate camera.
  37735. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37736. */
  37737. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37738. /**
  37739. * Defines the camera the input is attached to.
  37740. */
  37741. camera: ArcRotateCamera;
  37742. /**
  37743. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37744. */
  37745. wheelPrecision: number;
  37746. /**
  37747. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37748. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37749. */
  37750. wheelDeltaPercentage: number;
  37751. private _wheel;
  37752. private _observer;
  37753. private computeDeltaFromMouseWheelLegacyEvent;
  37754. /**
  37755. * Attach the input controls to a specific dom element to get the input from.
  37756. * @param element Defines the element the controls should be listened from
  37757. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37758. */
  37759. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37760. /**
  37761. * Detach the current controls from the specified dom element.
  37762. * @param element Defines the element to stop listening the inputs from
  37763. */
  37764. detachControl(element: Nullable<HTMLElement>): void;
  37765. /**
  37766. * Gets the class name of the current intput.
  37767. * @returns the class name
  37768. */
  37769. getClassName(): string;
  37770. /**
  37771. * Get the friendly name associated with the input class.
  37772. * @returns the input friendly name
  37773. */
  37774. getSimpleName(): string;
  37775. }
  37776. }
  37777. declare module BABYLON {
  37778. /**
  37779. * Default Inputs manager for the ArcRotateCamera.
  37780. * It groups all the default supported inputs for ease of use.
  37781. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37782. */
  37783. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37784. /**
  37785. * Instantiates a new ArcRotateCameraInputsManager.
  37786. * @param camera Defines the camera the inputs belong to
  37787. */
  37788. constructor(camera: ArcRotateCamera);
  37789. /**
  37790. * Add mouse wheel input support to the input manager.
  37791. * @returns the current input manager
  37792. */
  37793. addMouseWheel(): ArcRotateCameraInputsManager;
  37794. /**
  37795. * Add pointers input support to the input manager.
  37796. * @returns the current input manager
  37797. */
  37798. addPointers(): ArcRotateCameraInputsManager;
  37799. /**
  37800. * Add keyboard input support to the input manager.
  37801. * @returns the current input manager
  37802. */
  37803. addKeyboard(): ArcRotateCameraInputsManager;
  37804. }
  37805. }
  37806. declare module BABYLON {
  37807. /**
  37808. * This represents an orbital type of camera.
  37809. *
  37810. * 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.
  37811. * 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.
  37812. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37813. */
  37814. export class ArcRotateCamera extends TargetCamera {
  37815. /**
  37816. * Defines the rotation angle of the camera along the longitudinal axis.
  37817. */
  37818. alpha: number;
  37819. /**
  37820. * Defines the rotation angle of the camera along the latitudinal axis.
  37821. */
  37822. beta: number;
  37823. /**
  37824. * Defines the radius of the camera from it s target point.
  37825. */
  37826. radius: number;
  37827. protected _target: Vector3;
  37828. protected _targetHost: Nullable<AbstractMesh>;
  37829. /**
  37830. * Defines the target point of the camera.
  37831. * The camera looks towards it form the radius distance.
  37832. */
  37833. target: Vector3;
  37834. /**
  37835. * Define the current local position of the camera in the scene
  37836. */
  37837. position: Vector3;
  37838. protected _upVector: Vector3;
  37839. protected _upToYMatrix: Matrix;
  37840. protected _YToUpMatrix: Matrix;
  37841. /**
  37842. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37843. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37844. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37845. */
  37846. upVector: Vector3;
  37847. /**
  37848. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37849. */
  37850. setMatUp(): void;
  37851. /**
  37852. * Current inertia value on the longitudinal axis.
  37853. * The bigger this number the longer it will take for the camera to stop.
  37854. */
  37855. inertialAlphaOffset: number;
  37856. /**
  37857. * Current inertia value on the latitudinal axis.
  37858. * The bigger this number the longer it will take for the camera to stop.
  37859. */
  37860. inertialBetaOffset: number;
  37861. /**
  37862. * Current inertia value on the radius axis.
  37863. * The bigger this number the longer it will take for the camera to stop.
  37864. */
  37865. inertialRadiusOffset: number;
  37866. /**
  37867. * Minimum allowed angle on the longitudinal axis.
  37868. * This can help limiting how the Camera is able to move in the scene.
  37869. */
  37870. lowerAlphaLimit: Nullable<number>;
  37871. /**
  37872. * Maximum allowed angle on the longitudinal axis.
  37873. * This can help limiting how the Camera is able to move in the scene.
  37874. */
  37875. upperAlphaLimit: Nullable<number>;
  37876. /**
  37877. * Minimum allowed angle on the latitudinal axis.
  37878. * This can help limiting how the Camera is able to move in the scene.
  37879. */
  37880. lowerBetaLimit: number;
  37881. /**
  37882. * Maximum allowed angle on the latitudinal axis.
  37883. * This can help limiting how the Camera is able to move in the scene.
  37884. */
  37885. upperBetaLimit: number;
  37886. /**
  37887. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37888. * This can help limiting how the Camera is able to move in the scene.
  37889. */
  37890. lowerRadiusLimit: Nullable<number>;
  37891. /**
  37892. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37893. * This can help limiting how the Camera is able to move in the scene.
  37894. */
  37895. upperRadiusLimit: Nullable<number>;
  37896. /**
  37897. * Defines the current inertia value used during panning of the camera along the X axis.
  37898. */
  37899. inertialPanningX: number;
  37900. /**
  37901. * Defines the current inertia value used during panning of the camera along the Y axis.
  37902. */
  37903. inertialPanningY: number;
  37904. /**
  37905. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37906. * Basically if your fingers moves away from more than this distance you will be considered
  37907. * in pinch mode.
  37908. */
  37909. pinchToPanMaxDistance: number;
  37910. /**
  37911. * Defines the maximum distance the camera can pan.
  37912. * This could help keeping the cammera always in your scene.
  37913. */
  37914. panningDistanceLimit: Nullable<number>;
  37915. /**
  37916. * Defines the target of the camera before paning.
  37917. */
  37918. panningOriginTarget: Vector3;
  37919. /**
  37920. * Defines the value of the inertia used during panning.
  37921. * 0 would mean stop inertia and one would mean no decelleration at all.
  37922. */
  37923. panningInertia: number;
  37924. /**
  37925. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37926. */
  37927. angularSensibilityX: number;
  37928. /**
  37929. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37930. */
  37931. angularSensibilityY: number;
  37932. /**
  37933. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37934. */
  37935. pinchPrecision: number;
  37936. /**
  37937. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37938. * It will be used instead of pinchDeltaPrecision if different from 0.
  37939. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37940. */
  37941. pinchDeltaPercentage: number;
  37942. /**
  37943. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37944. */
  37945. panningSensibility: number;
  37946. /**
  37947. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37948. */
  37949. keysUp: number[];
  37950. /**
  37951. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37952. */
  37953. keysDown: number[];
  37954. /**
  37955. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37956. */
  37957. keysLeft: number[];
  37958. /**
  37959. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37960. */
  37961. keysRight: number[];
  37962. /**
  37963. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37964. */
  37965. wheelPrecision: number;
  37966. /**
  37967. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37968. * It will be used instead of pinchDeltaPrecision if different from 0.
  37969. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37970. */
  37971. wheelDeltaPercentage: number;
  37972. /**
  37973. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37974. */
  37975. zoomOnFactor: number;
  37976. /**
  37977. * Defines a screen offset for the camera position.
  37978. */
  37979. targetScreenOffset: Vector2;
  37980. /**
  37981. * Allows the camera to be completely reversed.
  37982. * If false the camera can not arrive upside down.
  37983. */
  37984. allowUpsideDown: boolean;
  37985. /**
  37986. * Define if double tap/click is used to restore the previously saved state of the camera.
  37987. */
  37988. useInputToRestoreState: boolean;
  37989. /** @hidden */
  37990. _viewMatrix: Matrix;
  37991. /** @hidden */
  37992. _useCtrlForPanning: boolean;
  37993. /** @hidden */
  37994. _panningMouseButton: number;
  37995. /**
  37996. * Defines the input associated to the camera.
  37997. */
  37998. inputs: ArcRotateCameraInputsManager;
  37999. /** @hidden */
  38000. _reset: () => void;
  38001. /**
  38002. * Defines the allowed panning axis.
  38003. */
  38004. panningAxis: Vector3;
  38005. protected _localDirection: Vector3;
  38006. protected _transformedDirection: Vector3;
  38007. private _bouncingBehavior;
  38008. /**
  38009. * Gets the bouncing behavior of the camera if it has been enabled.
  38010. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38011. */
  38012. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  38013. /**
  38014. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38015. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38016. */
  38017. useBouncingBehavior: boolean;
  38018. private _framingBehavior;
  38019. /**
  38020. * Gets the framing behavior of the camera if it has been enabled.
  38021. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38022. */
  38023. readonly framingBehavior: Nullable<FramingBehavior>;
  38024. /**
  38025. * Defines if the framing behavior of the camera is enabled on the camera.
  38026. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38027. */
  38028. useFramingBehavior: boolean;
  38029. private _autoRotationBehavior;
  38030. /**
  38031. * Gets the auto rotation behavior of the camera if it has been enabled.
  38032. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38033. */
  38034. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  38035. /**
  38036. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38037. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38038. */
  38039. useAutoRotationBehavior: boolean;
  38040. /**
  38041. * Observable triggered when the mesh target has been changed on the camera.
  38042. */
  38043. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38044. /**
  38045. * Event raised when the camera is colliding with a mesh.
  38046. */
  38047. onCollide: (collidedMesh: AbstractMesh) => void;
  38048. /**
  38049. * Defines whether the camera should check collision with the objects oh the scene.
  38050. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38051. */
  38052. checkCollisions: boolean;
  38053. /**
  38054. * Defines the collision radius of the camera.
  38055. * This simulates a sphere around the camera.
  38056. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38057. */
  38058. collisionRadius: Vector3;
  38059. protected _collider: Collider;
  38060. protected _previousPosition: Vector3;
  38061. protected _collisionVelocity: Vector3;
  38062. protected _newPosition: Vector3;
  38063. protected _previousAlpha: number;
  38064. protected _previousBeta: number;
  38065. protected _previousRadius: number;
  38066. protected _collisionTriggered: boolean;
  38067. protected _targetBoundingCenter: Nullable<Vector3>;
  38068. private _computationVector;
  38069. /**
  38070. * Instantiates a new ArcRotateCamera in a given scene
  38071. * @param name Defines the name of the camera
  38072. * @param alpha Defines the camera rotation along the logitudinal axis
  38073. * @param beta Defines the camera rotation along the latitudinal axis
  38074. * @param radius Defines the camera distance from its target
  38075. * @param target Defines the camera target
  38076. * @param scene Defines the scene the camera belongs to
  38077. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38078. */
  38079. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38080. /** @hidden */
  38081. _initCache(): void;
  38082. /** @hidden */
  38083. _updateCache(ignoreParentClass?: boolean): void;
  38084. protected _getTargetPosition(): Vector3;
  38085. private _storedAlpha;
  38086. private _storedBeta;
  38087. private _storedRadius;
  38088. private _storedTarget;
  38089. private _storedTargetScreenOffset;
  38090. /**
  38091. * Stores the current state of the camera (alpha, beta, radius and target)
  38092. * @returns the camera itself
  38093. */
  38094. storeState(): Camera;
  38095. /**
  38096. * @hidden
  38097. * Restored camera state. You must call storeState() first
  38098. */
  38099. _restoreStateValues(): boolean;
  38100. /** @hidden */
  38101. _isSynchronizedViewMatrix(): boolean;
  38102. /**
  38103. * Attached controls to the current camera.
  38104. * @param element Defines the element the controls should be listened from
  38105. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38106. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38107. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38108. */
  38109. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38110. /**
  38111. * Detach the current controls from the camera.
  38112. * The camera will stop reacting to inputs.
  38113. * @param element Defines the element to stop listening the inputs from
  38114. */
  38115. detachControl(element: HTMLElement): void;
  38116. /** @hidden */
  38117. _checkInputs(): void;
  38118. protected _checkLimits(): void;
  38119. /**
  38120. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38121. */
  38122. rebuildAnglesAndRadius(): void;
  38123. /**
  38124. * Use a position to define the current camera related information like alpha, beta and radius
  38125. * @param position Defines the position to set the camera at
  38126. */
  38127. setPosition(position: Vector3): void;
  38128. /**
  38129. * Defines the target the camera should look at.
  38130. * This will automatically adapt alpha beta and radius to fit within the new target.
  38131. * @param target Defines the new target as a Vector or a mesh
  38132. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38133. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38134. */
  38135. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38136. /** @hidden */
  38137. _getViewMatrix(): Matrix;
  38138. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38139. /**
  38140. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38141. * @param meshes Defines the mesh to zoom on
  38142. * @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)
  38143. */
  38144. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38145. /**
  38146. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38147. * The target will be changed but the radius
  38148. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38149. * @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)
  38150. */
  38151. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38152. min: Vector3;
  38153. max: Vector3;
  38154. distance: number;
  38155. }, doNotUpdateMaxZ?: boolean): void;
  38156. /**
  38157. * @override
  38158. * Override Camera.createRigCamera
  38159. */
  38160. createRigCamera(name: string, cameraIndex: number): Camera;
  38161. /**
  38162. * @hidden
  38163. * @override
  38164. * Override Camera._updateRigCameras
  38165. */
  38166. _updateRigCameras(): void;
  38167. /**
  38168. * Destroy the camera and release the current resources hold by it.
  38169. */
  38170. dispose(): void;
  38171. /**
  38172. * Gets the current object class name.
  38173. * @return the class name
  38174. */
  38175. getClassName(): string;
  38176. }
  38177. }
  38178. declare module BABYLON {
  38179. /**
  38180. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38181. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38182. */
  38183. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38184. /**
  38185. * Gets the name of the behavior.
  38186. */
  38187. readonly name: string;
  38188. private _zoomStopsAnimation;
  38189. private _idleRotationSpeed;
  38190. private _idleRotationWaitTime;
  38191. private _idleRotationSpinupTime;
  38192. /**
  38193. * Sets the flag that indicates if user zooming should stop animation.
  38194. */
  38195. /**
  38196. * Gets the flag that indicates if user zooming should stop animation.
  38197. */
  38198. zoomStopsAnimation: boolean;
  38199. /**
  38200. * Sets the default speed at which the camera rotates around the model.
  38201. */
  38202. /**
  38203. * Gets the default speed at which the camera rotates around the model.
  38204. */
  38205. idleRotationSpeed: number;
  38206. /**
  38207. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38208. */
  38209. /**
  38210. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38211. */
  38212. idleRotationWaitTime: number;
  38213. /**
  38214. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38215. */
  38216. /**
  38217. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38218. */
  38219. idleRotationSpinupTime: number;
  38220. /**
  38221. * Gets a value indicating if the camera is currently rotating because of this behavior
  38222. */
  38223. readonly rotationInProgress: boolean;
  38224. private _onPrePointerObservableObserver;
  38225. private _onAfterCheckInputsObserver;
  38226. private _attachedCamera;
  38227. private _isPointerDown;
  38228. private _lastFrameTime;
  38229. private _lastInteractionTime;
  38230. private _cameraRotationSpeed;
  38231. /**
  38232. * Initializes the behavior.
  38233. */
  38234. init(): void;
  38235. /**
  38236. * Attaches the behavior to its arc rotate camera.
  38237. * @param camera Defines the camera to attach the behavior to
  38238. */
  38239. attach(camera: ArcRotateCamera): void;
  38240. /**
  38241. * Detaches the behavior from its current arc rotate camera.
  38242. */
  38243. detach(): void;
  38244. /**
  38245. * Returns true if user is scrolling.
  38246. * @return true if user is scrolling.
  38247. */
  38248. private _userIsZooming;
  38249. private _lastFrameRadius;
  38250. private _shouldAnimationStopForInteraction;
  38251. /**
  38252. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38253. */
  38254. private _applyUserInteraction;
  38255. private _userIsMoving;
  38256. }
  38257. }
  38258. declare module BABYLON {
  38259. /**
  38260. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38261. */
  38262. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38263. private ui;
  38264. /**
  38265. * The name of the behavior
  38266. */
  38267. name: string;
  38268. /**
  38269. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38270. */
  38271. distanceAwayFromFace: number;
  38272. /**
  38273. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38274. */
  38275. distanceAwayFromBottomOfFace: number;
  38276. private _faceVectors;
  38277. private _target;
  38278. private _scene;
  38279. private _onRenderObserver;
  38280. private _tmpMatrix;
  38281. private _tmpVector;
  38282. /**
  38283. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38284. * @param ui The transform node that should be attched to the mesh
  38285. */
  38286. constructor(ui: TransformNode);
  38287. /**
  38288. * Initializes the behavior
  38289. */
  38290. init(): void;
  38291. private _closestFace;
  38292. private _zeroVector;
  38293. private _lookAtTmpMatrix;
  38294. private _lookAtToRef;
  38295. /**
  38296. * Attaches the AttachToBoxBehavior to the passed in mesh
  38297. * @param target The mesh that the specified node will be attached to
  38298. */
  38299. attach(target: Mesh): void;
  38300. /**
  38301. * Detaches the behavior from the mesh
  38302. */
  38303. detach(): void;
  38304. }
  38305. }
  38306. declare module BABYLON {
  38307. /**
  38308. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38309. */
  38310. export class FadeInOutBehavior implements Behavior<Mesh> {
  38311. /**
  38312. * Time in milliseconds to delay before fading in (Default: 0)
  38313. */
  38314. delay: number;
  38315. /**
  38316. * Time in milliseconds for the mesh to fade in (Default: 300)
  38317. */
  38318. fadeInTime: number;
  38319. private _millisecondsPerFrame;
  38320. private _hovered;
  38321. private _hoverValue;
  38322. private _ownerNode;
  38323. /**
  38324. * Instatiates the FadeInOutBehavior
  38325. */
  38326. constructor();
  38327. /**
  38328. * The name of the behavior
  38329. */
  38330. readonly name: string;
  38331. /**
  38332. * Initializes the behavior
  38333. */
  38334. init(): void;
  38335. /**
  38336. * Attaches the fade behavior on the passed in mesh
  38337. * @param ownerNode The mesh that will be faded in/out once attached
  38338. */
  38339. attach(ownerNode: Mesh): void;
  38340. /**
  38341. * Detaches the behavior from the mesh
  38342. */
  38343. detach(): void;
  38344. /**
  38345. * Triggers the mesh to begin fading in or out
  38346. * @param value if the object should fade in or out (true to fade in)
  38347. */
  38348. fadeIn(value: boolean): void;
  38349. private _update;
  38350. private _setAllVisibility;
  38351. }
  38352. }
  38353. declare module BABYLON {
  38354. /**
  38355. * Class containing a set of static utilities functions for managing Pivots
  38356. * @hidden
  38357. */
  38358. export class PivotTools {
  38359. private static _PivotCached;
  38360. private static _OldPivotPoint;
  38361. private static _PivotTranslation;
  38362. private static _PivotTmpVector;
  38363. /** @hidden */
  38364. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38365. /** @hidden */
  38366. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38367. }
  38368. }
  38369. declare module BABYLON {
  38370. /**
  38371. * Class containing static functions to help procedurally build meshes
  38372. */
  38373. export class PlaneBuilder {
  38374. /**
  38375. * Creates a plane mesh
  38376. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38377. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38378. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38379. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38380. * * 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
  38381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38382. * @param name defines the name of the mesh
  38383. * @param options defines the options used to create the mesh
  38384. * @param scene defines the hosting scene
  38385. * @returns the plane mesh
  38386. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38387. */
  38388. static CreatePlane(name: string, options: {
  38389. size?: number;
  38390. width?: number;
  38391. height?: number;
  38392. sideOrientation?: number;
  38393. frontUVs?: Vector4;
  38394. backUVs?: Vector4;
  38395. updatable?: boolean;
  38396. sourcePlane?: Plane;
  38397. }, scene?: Nullable<Scene>): Mesh;
  38398. }
  38399. }
  38400. declare module BABYLON {
  38401. /**
  38402. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38403. */
  38404. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38405. private static _AnyMouseID;
  38406. /**
  38407. * Abstract mesh the behavior is set on
  38408. */
  38409. attachedNode: AbstractMesh;
  38410. private _dragPlane;
  38411. private _scene;
  38412. private _pointerObserver;
  38413. private _beforeRenderObserver;
  38414. private static _planeScene;
  38415. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38416. /**
  38417. * 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)
  38418. */
  38419. maxDragAngle: number;
  38420. /**
  38421. * @hidden
  38422. */
  38423. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38424. /**
  38425. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38426. */
  38427. currentDraggingPointerID: number;
  38428. /**
  38429. * The last position where the pointer hit the drag plane in world space
  38430. */
  38431. lastDragPosition: Vector3;
  38432. /**
  38433. * If the behavior is currently in a dragging state
  38434. */
  38435. dragging: boolean;
  38436. /**
  38437. * 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)
  38438. */
  38439. dragDeltaRatio: number;
  38440. /**
  38441. * If the drag plane orientation should be updated during the dragging (Default: true)
  38442. */
  38443. updateDragPlane: boolean;
  38444. private _debugMode;
  38445. private _moving;
  38446. /**
  38447. * Fires each time the attached mesh is dragged with the pointer
  38448. * * delta between last drag position and current drag position in world space
  38449. * * dragDistance along the drag axis
  38450. * * dragPlaneNormal normal of the current drag plane used during the drag
  38451. * * dragPlanePoint in world space where the drag intersects the drag plane
  38452. */
  38453. onDragObservable: Observable<{
  38454. delta: Vector3;
  38455. dragPlanePoint: Vector3;
  38456. dragPlaneNormal: Vector3;
  38457. dragDistance: number;
  38458. pointerId: number;
  38459. }>;
  38460. /**
  38461. * Fires each time a drag begins (eg. mouse down on mesh)
  38462. */
  38463. onDragStartObservable: Observable<{
  38464. dragPlanePoint: Vector3;
  38465. pointerId: number;
  38466. }>;
  38467. /**
  38468. * Fires each time a drag ends (eg. mouse release after drag)
  38469. */
  38470. onDragEndObservable: Observable<{
  38471. dragPlanePoint: Vector3;
  38472. pointerId: number;
  38473. }>;
  38474. /**
  38475. * If the attached mesh should be moved when dragged
  38476. */
  38477. moveAttached: boolean;
  38478. /**
  38479. * If the drag behavior will react to drag events (Default: true)
  38480. */
  38481. enabled: boolean;
  38482. /**
  38483. * If pointer events should start and release the drag (Default: true)
  38484. */
  38485. startAndReleaseDragOnPointerEvents: boolean;
  38486. /**
  38487. * If camera controls should be detached during the drag
  38488. */
  38489. detachCameraControls: boolean;
  38490. /**
  38491. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38492. */
  38493. useObjectOrienationForDragging: boolean;
  38494. private _options;
  38495. /**
  38496. * Gets the options used by the behavior
  38497. */
  38498. /**
  38499. * Sets the options used by the behavior
  38500. */
  38501. options: {
  38502. dragAxis?: Vector3;
  38503. dragPlaneNormal?: Vector3;
  38504. };
  38505. /**
  38506. * Creates a pointer drag behavior that can be attached to a mesh
  38507. * @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)
  38508. */
  38509. constructor(options?: {
  38510. dragAxis?: Vector3;
  38511. dragPlaneNormal?: Vector3;
  38512. });
  38513. /**
  38514. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38515. */
  38516. validateDrag: (targetPosition: Vector3) => boolean;
  38517. /**
  38518. * The name of the behavior
  38519. */
  38520. readonly name: string;
  38521. /**
  38522. * Initializes the behavior
  38523. */
  38524. init(): void;
  38525. private _tmpVector;
  38526. private _alternatePickedPoint;
  38527. private _worldDragAxis;
  38528. private _targetPosition;
  38529. private _attachedElement;
  38530. /**
  38531. * Attaches the drag behavior the passed in mesh
  38532. * @param ownerNode The mesh that will be dragged around once attached
  38533. * @param predicate Predicate to use for pick filtering
  38534. */
  38535. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38536. /**
  38537. * Force relase the drag action by code.
  38538. */
  38539. releaseDrag(): void;
  38540. private _startDragRay;
  38541. private _lastPointerRay;
  38542. /**
  38543. * Simulates the start of a pointer drag event on the behavior
  38544. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38545. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38546. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38547. */
  38548. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38549. private _startDrag;
  38550. private _dragDelta;
  38551. private _moveDrag;
  38552. private _pickWithRayOnDragPlane;
  38553. private _pointA;
  38554. private _pointB;
  38555. private _pointC;
  38556. private _lineA;
  38557. private _lineB;
  38558. private _localAxis;
  38559. private _lookAt;
  38560. private _updateDragPlanePosition;
  38561. /**
  38562. * Detaches the behavior from the mesh
  38563. */
  38564. detach(): void;
  38565. }
  38566. }
  38567. declare module BABYLON {
  38568. /**
  38569. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38570. */
  38571. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38572. private _dragBehaviorA;
  38573. private _dragBehaviorB;
  38574. private _startDistance;
  38575. private _initialScale;
  38576. private _targetScale;
  38577. private _ownerNode;
  38578. private _sceneRenderObserver;
  38579. /**
  38580. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38581. */
  38582. constructor();
  38583. /**
  38584. * The name of the behavior
  38585. */
  38586. readonly name: string;
  38587. /**
  38588. * Initializes the behavior
  38589. */
  38590. init(): void;
  38591. private _getCurrentDistance;
  38592. /**
  38593. * Attaches the scale behavior the passed in mesh
  38594. * @param ownerNode The mesh that will be scaled around once attached
  38595. */
  38596. attach(ownerNode: Mesh): void;
  38597. /**
  38598. * Detaches the behavior from the mesh
  38599. */
  38600. detach(): void;
  38601. }
  38602. }
  38603. declare module BABYLON {
  38604. /**
  38605. * 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
  38606. */
  38607. export class SixDofDragBehavior implements Behavior<Mesh> {
  38608. private static _virtualScene;
  38609. private _ownerNode;
  38610. private _sceneRenderObserver;
  38611. private _scene;
  38612. private _targetPosition;
  38613. private _virtualOriginMesh;
  38614. private _virtualDragMesh;
  38615. private _pointerObserver;
  38616. private _moving;
  38617. private _startingOrientation;
  38618. /**
  38619. * 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)
  38620. */
  38621. private zDragFactor;
  38622. /**
  38623. * If the object should rotate to face the drag origin
  38624. */
  38625. rotateDraggedObject: boolean;
  38626. /**
  38627. * If the behavior is currently in a dragging state
  38628. */
  38629. dragging: boolean;
  38630. /**
  38631. * 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)
  38632. */
  38633. dragDeltaRatio: number;
  38634. /**
  38635. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38636. */
  38637. currentDraggingPointerID: number;
  38638. /**
  38639. * If camera controls should be detached during the drag
  38640. */
  38641. detachCameraControls: boolean;
  38642. /**
  38643. * Fires each time a drag starts
  38644. */
  38645. onDragStartObservable: Observable<{}>;
  38646. /**
  38647. * Fires each time a drag ends (eg. mouse release after drag)
  38648. */
  38649. onDragEndObservable: Observable<{}>;
  38650. /**
  38651. * 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
  38652. */
  38653. constructor();
  38654. /**
  38655. * The name of the behavior
  38656. */
  38657. readonly name: string;
  38658. /**
  38659. * Initializes the behavior
  38660. */
  38661. init(): void;
  38662. /**
  38663. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38664. */
  38665. private readonly _pointerCamera;
  38666. /**
  38667. * Attaches the scale behavior the passed in mesh
  38668. * @param ownerNode The mesh that will be scaled around once attached
  38669. */
  38670. attach(ownerNode: Mesh): void;
  38671. /**
  38672. * Detaches the behavior from the mesh
  38673. */
  38674. detach(): void;
  38675. }
  38676. }
  38677. declare module BABYLON {
  38678. /**
  38679. * Class used to apply inverse kinematics to bones
  38680. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38681. */
  38682. export class BoneIKController {
  38683. private static _tmpVecs;
  38684. private static _tmpQuat;
  38685. private static _tmpMats;
  38686. /**
  38687. * Gets or sets the target mesh
  38688. */
  38689. targetMesh: AbstractMesh;
  38690. /** Gets or sets the mesh used as pole */
  38691. poleTargetMesh: AbstractMesh;
  38692. /**
  38693. * Gets or sets the bone used as pole
  38694. */
  38695. poleTargetBone: Nullable<Bone>;
  38696. /**
  38697. * Gets or sets the target position
  38698. */
  38699. targetPosition: Vector3;
  38700. /**
  38701. * Gets or sets the pole target position
  38702. */
  38703. poleTargetPosition: Vector3;
  38704. /**
  38705. * Gets or sets the pole target local offset
  38706. */
  38707. poleTargetLocalOffset: Vector3;
  38708. /**
  38709. * Gets or sets the pole angle
  38710. */
  38711. poleAngle: number;
  38712. /**
  38713. * Gets or sets the mesh associated with the controller
  38714. */
  38715. mesh: AbstractMesh;
  38716. /**
  38717. * 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)
  38718. */
  38719. slerpAmount: number;
  38720. private _bone1Quat;
  38721. private _bone1Mat;
  38722. private _bone2Ang;
  38723. private _bone1;
  38724. private _bone2;
  38725. private _bone1Length;
  38726. private _bone2Length;
  38727. private _maxAngle;
  38728. private _maxReach;
  38729. private _rightHandedSystem;
  38730. private _bendAxis;
  38731. private _slerping;
  38732. private _adjustRoll;
  38733. /**
  38734. * Gets or sets maximum allowed angle
  38735. */
  38736. maxAngle: number;
  38737. /**
  38738. * Creates a new BoneIKController
  38739. * @param mesh defines the mesh to control
  38740. * @param bone defines the bone to control
  38741. * @param options defines options to set up the controller
  38742. */
  38743. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38744. targetMesh?: AbstractMesh;
  38745. poleTargetMesh?: AbstractMesh;
  38746. poleTargetBone?: Bone;
  38747. poleTargetLocalOffset?: Vector3;
  38748. poleAngle?: number;
  38749. bendAxis?: Vector3;
  38750. maxAngle?: number;
  38751. slerpAmount?: number;
  38752. });
  38753. private _setMaxAngle;
  38754. /**
  38755. * Force the controller to update the bones
  38756. */
  38757. update(): void;
  38758. }
  38759. }
  38760. declare module BABYLON {
  38761. /**
  38762. * Class used to make a bone look toward a point in space
  38763. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38764. */
  38765. export class BoneLookController {
  38766. private static _tmpVecs;
  38767. private static _tmpQuat;
  38768. private static _tmpMats;
  38769. /**
  38770. * The target Vector3 that the bone will look at
  38771. */
  38772. target: Vector3;
  38773. /**
  38774. * The mesh that the bone is attached to
  38775. */
  38776. mesh: AbstractMesh;
  38777. /**
  38778. * The bone that will be looking to the target
  38779. */
  38780. bone: Bone;
  38781. /**
  38782. * The up axis of the coordinate system that is used when the bone is rotated
  38783. */
  38784. upAxis: Vector3;
  38785. /**
  38786. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38787. */
  38788. upAxisSpace: Space;
  38789. /**
  38790. * Used to make an adjustment to the yaw of the bone
  38791. */
  38792. adjustYaw: number;
  38793. /**
  38794. * Used to make an adjustment to the pitch of the bone
  38795. */
  38796. adjustPitch: number;
  38797. /**
  38798. * Used to make an adjustment to the roll of the bone
  38799. */
  38800. adjustRoll: number;
  38801. /**
  38802. * 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)
  38803. */
  38804. slerpAmount: number;
  38805. private _minYaw;
  38806. private _maxYaw;
  38807. private _minPitch;
  38808. private _maxPitch;
  38809. private _minYawSin;
  38810. private _minYawCos;
  38811. private _maxYawSin;
  38812. private _maxYawCos;
  38813. private _midYawConstraint;
  38814. private _minPitchTan;
  38815. private _maxPitchTan;
  38816. private _boneQuat;
  38817. private _slerping;
  38818. private _transformYawPitch;
  38819. private _transformYawPitchInv;
  38820. private _firstFrameSkipped;
  38821. private _yawRange;
  38822. private _fowardAxis;
  38823. /**
  38824. * Gets or sets the minimum yaw angle that the bone can look to
  38825. */
  38826. minYaw: number;
  38827. /**
  38828. * Gets or sets the maximum yaw angle that the bone can look to
  38829. */
  38830. maxYaw: number;
  38831. /**
  38832. * Gets or sets the minimum pitch angle that the bone can look to
  38833. */
  38834. minPitch: number;
  38835. /**
  38836. * Gets or sets the maximum pitch angle that the bone can look to
  38837. */
  38838. maxPitch: number;
  38839. /**
  38840. * Create a BoneLookController
  38841. * @param mesh the mesh that the bone belongs to
  38842. * @param bone the bone that will be looking to the target
  38843. * @param target the target Vector3 to look at
  38844. * @param options optional settings:
  38845. * * maxYaw: the maximum angle the bone will yaw to
  38846. * * minYaw: the minimum angle the bone will yaw to
  38847. * * maxPitch: the maximum angle the bone will pitch to
  38848. * * minPitch: the minimum angle the bone will yaw to
  38849. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38850. * * upAxis: the up axis of the coordinate system
  38851. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38852. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38853. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38854. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38855. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38856. * * adjustRoll: used to make an adjustment to the roll of the bone
  38857. **/
  38858. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38859. maxYaw?: number;
  38860. minYaw?: number;
  38861. maxPitch?: number;
  38862. minPitch?: number;
  38863. slerpAmount?: number;
  38864. upAxis?: Vector3;
  38865. upAxisSpace?: Space;
  38866. yawAxis?: Vector3;
  38867. pitchAxis?: Vector3;
  38868. adjustYaw?: number;
  38869. adjustPitch?: number;
  38870. adjustRoll?: number;
  38871. });
  38872. /**
  38873. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38874. */
  38875. update(): void;
  38876. private _getAngleDiff;
  38877. private _getAngleBetween;
  38878. private _isAngleBetween;
  38879. }
  38880. }
  38881. declare module BABYLON {
  38882. /**
  38883. * Manage the gamepad inputs to control an arc rotate camera.
  38884. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38885. */
  38886. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38887. /**
  38888. * Defines the camera the input is attached to.
  38889. */
  38890. camera: ArcRotateCamera;
  38891. /**
  38892. * Defines the gamepad the input is gathering event from.
  38893. */
  38894. gamepad: Nullable<Gamepad>;
  38895. /**
  38896. * Defines the gamepad rotation sensiblity.
  38897. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38898. */
  38899. gamepadRotationSensibility: number;
  38900. /**
  38901. * Defines the gamepad move sensiblity.
  38902. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38903. */
  38904. gamepadMoveSensibility: number;
  38905. private _yAxisScale;
  38906. /**
  38907. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38908. */
  38909. invertYAxis: boolean;
  38910. private _onGamepadConnectedObserver;
  38911. private _onGamepadDisconnectedObserver;
  38912. /**
  38913. * Attach the input controls to a specific dom element to get the input from.
  38914. * @param element Defines the element the controls should be listened from
  38915. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38916. */
  38917. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38918. /**
  38919. * Detach the current controls from the specified dom element.
  38920. * @param element Defines the element to stop listening the inputs from
  38921. */
  38922. detachControl(element: Nullable<HTMLElement>): void;
  38923. /**
  38924. * Update the current camera state depending on the inputs that have been used this frame.
  38925. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38926. */
  38927. checkInputs(): void;
  38928. /**
  38929. * Gets the class name of the current intput.
  38930. * @returns the class name
  38931. */
  38932. getClassName(): string;
  38933. /**
  38934. * Get the friendly name associated with the input class.
  38935. * @returns the input friendly name
  38936. */
  38937. getSimpleName(): string;
  38938. }
  38939. }
  38940. declare module BABYLON {
  38941. interface ArcRotateCameraInputsManager {
  38942. /**
  38943. * Add orientation input support to the input manager.
  38944. * @returns the current input manager
  38945. */
  38946. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38947. }
  38948. /**
  38949. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38950. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38951. */
  38952. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38953. /**
  38954. * Defines the camera the input is attached to.
  38955. */
  38956. camera: ArcRotateCamera;
  38957. /**
  38958. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38959. */
  38960. alphaCorrection: number;
  38961. /**
  38962. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38963. */
  38964. gammaCorrection: number;
  38965. private _alpha;
  38966. private _gamma;
  38967. private _dirty;
  38968. private _deviceOrientationHandler;
  38969. /**
  38970. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38971. */
  38972. constructor();
  38973. /**
  38974. * Attach the input controls to a specific dom element to get the input from.
  38975. * @param element Defines the element the controls should be listened from
  38976. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38977. */
  38978. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38979. /** @hidden */
  38980. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38981. /**
  38982. * Update the current camera state depending on the inputs that have been used this frame.
  38983. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38984. */
  38985. checkInputs(): void;
  38986. /**
  38987. * Detach the current controls from the specified dom element.
  38988. * @param element Defines the element to stop listening the inputs from
  38989. */
  38990. detachControl(element: Nullable<HTMLElement>): void;
  38991. /**
  38992. * Gets the class name of the current intput.
  38993. * @returns the class name
  38994. */
  38995. getClassName(): string;
  38996. /**
  38997. * Get the friendly name associated with the input class.
  38998. * @returns the input friendly name
  38999. */
  39000. getSimpleName(): string;
  39001. }
  39002. }
  39003. declare module BABYLON {
  39004. /**
  39005. * Listen to mouse events to control the camera.
  39006. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39007. */
  39008. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39009. /**
  39010. * Defines the camera the input is attached to.
  39011. */
  39012. camera: FlyCamera;
  39013. /**
  39014. * Defines if touch is enabled. (Default is true.)
  39015. */
  39016. touchEnabled: boolean;
  39017. /**
  39018. * Defines the buttons associated with the input to handle camera rotation.
  39019. */
  39020. buttons: number[];
  39021. /**
  39022. * Assign buttons for Yaw control.
  39023. */
  39024. buttonsYaw: number[];
  39025. /**
  39026. * Assign buttons for Pitch control.
  39027. */
  39028. buttonsPitch: number[];
  39029. /**
  39030. * Assign buttons for Roll control.
  39031. */
  39032. buttonsRoll: number[];
  39033. /**
  39034. * Detect if any button is being pressed while mouse is moved.
  39035. * -1 = Mouse locked.
  39036. * 0 = Left button.
  39037. * 1 = Middle Button.
  39038. * 2 = Right Button.
  39039. */
  39040. activeButton: number;
  39041. /**
  39042. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39043. * Higher values reduce its sensitivity.
  39044. */
  39045. angularSensibility: number;
  39046. private _mousemoveCallback;
  39047. private _observer;
  39048. private _rollObserver;
  39049. private previousPosition;
  39050. private noPreventDefault;
  39051. private element;
  39052. /**
  39053. * Listen to mouse events to control the camera.
  39054. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39055. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39056. */
  39057. constructor(touchEnabled?: boolean);
  39058. /**
  39059. * Attach the mouse control to the HTML DOM element.
  39060. * @param element Defines the element that listens to the input events.
  39061. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39062. */
  39063. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39064. /**
  39065. * Detach the current controls from the specified dom element.
  39066. * @param element Defines the element to stop listening the inputs from
  39067. */
  39068. detachControl(element: Nullable<HTMLElement>): void;
  39069. /**
  39070. * Gets the class name of the current input.
  39071. * @returns the class name.
  39072. */
  39073. getClassName(): string;
  39074. /**
  39075. * Get the friendly name associated with the input class.
  39076. * @returns the input's friendly name.
  39077. */
  39078. getSimpleName(): string;
  39079. private _pointerInput;
  39080. private _onMouseMove;
  39081. /**
  39082. * Rotate camera by mouse offset.
  39083. */
  39084. private rotateCamera;
  39085. }
  39086. }
  39087. declare module BABYLON {
  39088. /**
  39089. * Default Inputs manager for the FlyCamera.
  39090. * It groups all the default supported inputs for ease of use.
  39091. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39092. */
  39093. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39094. /**
  39095. * Instantiates a new FlyCameraInputsManager.
  39096. * @param camera Defines the camera the inputs belong to.
  39097. */
  39098. constructor(camera: FlyCamera);
  39099. /**
  39100. * Add keyboard input support to the input manager.
  39101. * @returns the new FlyCameraKeyboardMoveInput().
  39102. */
  39103. addKeyboard(): FlyCameraInputsManager;
  39104. /**
  39105. * Add mouse input support to the input manager.
  39106. * @param touchEnabled Enable touch screen support.
  39107. * @returns the new FlyCameraMouseInput().
  39108. */
  39109. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39110. }
  39111. }
  39112. declare module BABYLON {
  39113. /**
  39114. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39115. * such as in a 3D Space Shooter or a Flight Simulator.
  39116. */
  39117. export class FlyCamera extends TargetCamera {
  39118. /**
  39119. * Define the collision ellipsoid of the camera.
  39120. * This is helpful for simulating a camera body, like a player's body.
  39121. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39122. */
  39123. ellipsoid: Vector3;
  39124. /**
  39125. * Define an offset for the position of the ellipsoid around the camera.
  39126. * This can be helpful if the camera is attached away from the player's body center,
  39127. * such as at its head.
  39128. */
  39129. ellipsoidOffset: Vector3;
  39130. /**
  39131. * Enable or disable collisions of the camera with the rest of the scene objects.
  39132. */
  39133. checkCollisions: boolean;
  39134. /**
  39135. * Enable or disable gravity on the camera.
  39136. */
  39137. applyGravity: boolean;
  39138. /**
  39139. * Define the current direction the camera is moving to.
  39140. */
  39141. cameraDirection: Vector3;
  39142. /**
  39143. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39144. * This overrides and empties cameraRotation.
  39145. */
  39146. rotationQuaternion: Quaternion;
  39147. /**
  39148. * Track Roll to maintain the wanted Rolling when looking around.
  39149. */
  39150. _trackRoll: number;
  39151. /**
  39152. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39153. */
  39154. rollCorrect: number;
  39155. /**
  39156. * Mimic a banked turn, Rolling the camera when Yawing.
  39157. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39158. */
  39159. bankedTurn: boolean;
  39160. /**
  39161. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39162. */
  39163. bankedTurnLimit: number;
  39164. /**
  39165. * Value of 0 disables the banked Roll.
  39166. * Value of 1 is equal to the Yaw angle in radians.
  39167. */
  39168. bankedTurnMultiplier: number;
  39169. /**
  39170. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39171. */
  39172. inputs: FlyCameraInputsManager;
  39173. /**
  39174. * Gets the input sensibility for mouse input.
  39175. * Higher values reduce sensitivity.
  39176. */
  39177. /**
  39178. * Sets the input sensibility for a mouse input.
  39179. * Higher values reduce sensitivity.
  39180. */
  39181. angularSensibility: number;
  39182. /**
  39183. * Get the keys for camera movement forward.
  39184. */
  39185. /**
  39186. * Set the keys for camera movement forward.
  39187. */
  39188. keysForward: number[];
  39189. /**
  39190. * Get the keys for camera movement backward.
  39191. */
  39192. keysBackward: number[];
  39193. /**
  39194. * Get the keys for camera movement up.
  39195. */
  39196. /**
  39197. * Set the keys for camera movement up.
  39198. */
  39199. keysUp: number[];
  39200. /**
  39201. * Get the keys for camera movement down.
  39202. */
  39203. /**
  39204. * Set the keys for camera movement down.
  39205. */
  39206. keysDown: number[];
  39207. /**
  39208. * Get the keys for camera movement left.
  39209. */
  39210. /**
  39211. * Set the keys for camera movement left.
  39212. */
  39213. keysLeft: number[];
  39214. /**
  39215. * Set the keys for camera movement right.
  39216. */
  39217. /**
  39218. * Set the keys for camera movement right.
  39219. */
  39220. keysRight: number[];
  39221. /**
  39222. * Event raised when the camera collides with a mesh in the scene.
  39223. */
  39224. onCollide: (collidedMesh: AbstractMesh) => void;
  39225. private _collider;
  39226. private _needMoveForGravity;
  39227. private _oldPosition;
  39228. private _diffPosition;
  39229. private _newPosition;
  39230. /** @hidden */
  39231. _localDirection: Vector3;
  39232. /** @hidden */
  39233. _transformedDirection: Vector3;
  39234. /**
  39235. * Instantiates a FlyCamera.
  39236. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39237. * such as in a 3D Space Shooter or a Flight Simulator.
  39238. * @param name Define the name of the camera in the scene.
  39239. * @param position Define the starting position of the camera in the scene.
  39240. * @param scene Define the scene the camera belongs to.
  39241. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39242. */
  39243. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39244. /**
  39245. * Attach a control to the HTML DOM element.
  39246. * @param element Defines the element that listens to the input events.
  39247. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39248. */
  39249. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39250. /**
  39251. * Detach a control from the HTML DOM element.
  39252. * The camera will stop reacting to that input.
  39253. * @param element Defines the element that listens to the input events.
  39254. */
  39255. detachControl(element: HTMLElement): void;
  39256. private _collisionMask;
  39257. /**
  39258. * Get the mask that the camera ignores in collision events.
  39259. */
  39260. /**
  39261. * Set the mask that the camera ignores in collision events.
  39262. */
  39263. collisionMask: number;
  39264. /** @hidden */
  39265. _collideWithWorld(displacement: Vector3): void;
  39266. /** @hidden */
  39267. private _onCollisionPositionChange;
  39268. /** @hidden */
  39269. _checkInputs(): void;
  39270. /** @hidden */
  39271. _decideIfNeedsToMove(): boolean;
  39272. /** @hidden */
  39273. _updatePosition(): void;
  39274. /**
  39275. * Restore the Roll to its target value at the rate specified.
  39276. * @param rate - Higher means slower restoring.
  39277. * @hidden
  39278. */
  39279. restoreRoll(rate: number): void;
  39280. /**
  39281. * Destroy the camera and release the current resources held by it.
  39282. */
  39283. dispose(): void;
  39284. /**
  39285. * Get the current object class name.
  39286. * @returns the class name.
  39287. */
  39288. getClassName(): string;
  39289. }
  39290. }
  39291. declare module BABYLON {
  39292. /**
  39293. * Listen to keyboard events to control the camera.
  39294. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39295. */
  39296. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39297. /**
  39298. * Defines the camera the input is attached to.
  39299. */
  39300. camera: FlyCamera;
  39301. /**
  39302. * The list of keyboard keys used to control the forward move of the camera.
  39303. */
  39304. keysForward: number[];
  39305. /**
  39306. * The list of keyboard keys used to control the backward move of the camera.
  39307. */
  39308. keysBackward: number[];
  39309. /**
  39310. * The list of keyboard keys used to control the forward move of the camera.
  39311. */
  39312. keysUp: number[];
  39313. /**
  39314. * The list of keyboard keys used to control the backward move of the camera.
  39315. */
  39316. keysDown: number[];
  39317. /**
  39318. * The list of keyboard keys used to control the right strafe move of the camera.
  39319. */
  39320. keysRight: number[];
  39321. /**
  39322. * The list of keyboard keys used to control the left strafe move of the camera.
  39323. */
  39324. keysLeft: number[];
  39325. private _keys;
  39326. private _onCanvasBlurObserver;
  39327. private _onKeyboardObserver;
  39328. private _engine;
  39329. private _scene;
  39330. /**
  39331. * Attach the input controls to a specific dom element to get the input from.
  39332. * @param element Defines the element the controls should be listened from
  39333. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39334. */
  39335. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39336. /**
  39337. * Detach the current controls from the specified dom element.
  39338. * @param element Defines the element to stop listening the inputs from
  39339. */
  39340. detachControl(element: Nullable<HTMLElement>): void;
  39341. /**
  39342. * Gets the class name of the current intput.
  39343. * @returns the class name
  39344. */
  39345. getClassName(): string;
  39346. /** @hidden */
  39347. _onLostFocus(e: FocusEvent): void;
  39348. /**
  39349. * Get the friendly name associated with the input class.
  39350. * @returns the input friendly name
  39351. */
  39352. getSimpleName(): string;
  39353. /**
  39354. * Update the current camera state depending on the inputs that have been used this frame.
  39355. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39356. */
  39357. checkInputs(): void;
  39358. }
  39359. }
  39360. declare module BABYLON {
  39361. /**
  39362. * Manage the mouse wheel inputs to control a follow camera.
  39363. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39364. */
  39365. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39366. /**
  39367. * Defines the camera the input is attached to.
  39368. */
  39369. camera: FollowCamera;
  39370. /**
  39371. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39372. */
  39373. axisControlRadius: boolean;
  39374. /**
  39375. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39376. */
  39377. axisControlHeight: boolean;
  39378. /**
  39379. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39380. */
  39381. axisControlRotation: boolean;
  39382. /**
  39383. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39384. * relation to mouseWheel events.
  39385. */
  39386. wheelPrecision: number;
  39387. /**
  39388. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39389. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39390. */
  39391. wheelDeltaPercentage: number;
  39392. private _wheel;
  39393. private _observer;
  39394. /**
  39395. * Attach the input controls to a specific dom element to get the input from.
  39396. * @param element Defines the element the controls should be listened from
  39397. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39398. */
  39399. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39400. /**
  39401. * Detach the current controls from the specified dom element.
  39402. * @param element Defines the element to stop listening the inputs from
  39403. */
  39404. detachControl(element: Nullable<HTMLElement>): void;
  39405. /**
  39406. * Gets the class name of the current intput.
  39407. * @returns the class name
  39408. */
  39409. getClassName(): string;
  39410. /**
  39411. * Get the friendly name associated with the input class.
  39412. * @returns the input friendly name
  39413. */
  39414. getSimpleName(): string;
  39415. }
  39416. }
  39417. declare module BABYLON {
  39418. /**
  39419. * Manage the pointers inputs to control an follow camera.
  39420. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39421. */
  39422. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39423. /**
  39424. * Defines the camera the input is attached to.
  39425. */
  39426. camera: FollowCamera;
  39427. /**
  39428. * Gets the class name of the current input.
  39429. * @returns the class name
  39430. */
  39431. getClassName(): string;
  39432. /**
  39433. * Defines the pointer angular sensibility along the X axis or how fast is
  39434. * the camera rotating.
  39435. * A negative number will reverse the axis direction.
  39436. */
  39437. angularSensibilityX: number;
  39438. /**
  39439. * Defines the pointer angular sensibility along the Y axis or how fast is
  39440. * the camera rotating.
  39441. * A negative number will reverse the axis direction.
  39442. */
  39443. angularSensibilityY: number;
  39444. /**
  39445. * Defines the pointer pinch precision or how fast is the camera zooming.
  39446. * A negative number will reverse the axis direction.
  39447. */
  39448. pinchPrecision: number;
  39449. /**
  39450. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39451. * from 0.
  39452. * It defines the percentage of current camera.radius to use as delta when
  39453. * pinch zoom is used.
  39454. */
  39455. pinchDeltaPercentage: number;
  39456. /**
  39457. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39458. */
  39459. axisXControlRadius: boolean;
  39460. /**
  39461. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39462. */
  39463. axisXControlHeight: boolean;
  39464. /**
  39465. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39466. */
  39467. axisXControlRotation: boolean;
  39468. /**
  39469. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39470. */
  39471. axisYControlRadius: boolean;
  39472. /**
  39473. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39474. */
  39475. axisYControlHeight: boolean;
  39476. /**
  39477. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39478. */
  39479. axisYControlRotation: boolean;
  39480. /**
  39481. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39482. */
  39483. axisPinchControlRadius: boolean;
  39484. /**
  39485. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39486. */
  39487. axisPinchControlHeight: boolean;
  39488. /**
  39489. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39490. */
  39491. axisPinchControlRotation: boolean;
  39492. /**
  39493. * Log error messages if basic misconfiguration has occurred.
  39494. */
  39495. warningEnable: boolean;
  39496. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39497. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39498. private _warningCounter;
  39499. private _warning;
  39500. }
  39501. }
  39502. declare module BABYLON {
  39503. /**
  39504. * Default Inputs manager for the FollowCamera.
  39505. * It groups all the default supported inputs for ease of use.
  39506. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39507. */
  39508. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39509. /**
  39510. * Instantiates a new FollowCameraInputsManager.
  39511. * @param camera Defines the camera the inputs belong to
  39512. */
  39513. constructor(camera: FollowCamera);
  39514. /**
  39515. * Add keyboard input support to the input manager.
  39516. * @returns the current input manager
  39517. */
  39518. addKeyboard(): FollowCameraInputsManager;
  39519. /**
  39520. * Add mouse wheel input support to the input manager.
  39521. * @returns the current input manager
  39522. */
  39523. addMouseWheel(): FollowCameraInputsManager;
  39524. /**
  39525. * Add pointers input support to the input manager.
  39526. * @returns the current input manager
  39527. */
  39528. addPointers(): FollowCameraInputsManager;
  39529. /**
  39530. * Add orientation input support to the input manager.
  39531. * @returns the current input manager
  39532. */
  39533. addVRDeviceOrientation(): FollowCameraInputsManager;
  39534. }
  39535. }
  39536. declare module BABYLON {
  39537. /**
  39538. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39539. * an arc rotate version arcFollowCamera are available.
  39540. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39541. */
  39542. export class FollowCamera extends TargetCamera {
  39543. /**
  39544. * Distance the follow camera should follow an object at
  39545. */
  39546. radius: number;
  39547. /**
  39548. * Minimum allowed distance of the camera to the axis of rotation
  39549. * (The camera can not get closer).
  39550. * This can help limiting how the Camera is able to move in the scene.
  39551. */
  39552. lowerRadiusLimit: Nullable<number>;
  39553. /**
  39554. * Maximum allowed distance of the camera to the axis of rotation
  39555. * (The camera can not get further).
  39556. * This can help limiting how the Camera is able to move in the scene.
  39557. */
  39558. upperRadiusLimit: Nullable<number>;
  39559. /**
  39560. * Define a rotation offset between the camera and the object it follows
  39561. */
  39562. rotationOffset: number;
  39563. /**
  39564. * Minimum allowed angle to camera position relative to target object.
  39565. * This can help limiting how the Camera is able to move in the scene.
  39566. */
  39567. lowerRotationOffsetLimit: Nullable<number>;
  39568. /**
  39569. * Maximum allowed angle to camera position relative to target object.
  39570. * This can help limiting how the Camera is able to move in the scene.
  39571. */
  39572. upperRotationOffsetLimit: Nullable<number>;
  39573. /**
  39574. * Define a height offset between the camera and the object it follows.
  39575. * It can help following an object from the top (like a car chaing a plane)
  39576. */
  39577. heightOffset: number;
  39578. /**
  39579. * Minimum allowed height of camera position relative to target object.
  39580. * This can help limiting how the Camera is able to move in the scene.
  39581. */
  39582. lowerHeightOffsetLimit: Nullable<number>;
  39583. /**
  39584. * Maximum allowed height of camera position relative to target object.
  39585. * This can help limiting how the Camera is able to move in the scene.
  39586. */
  39587. upperHeightOffsetLimit: Nullable<number>;
  39588. /**
  39589. * Define how fast the camera can accelerate to follow it s target.
  39590. */
  39591. cameraAcceleration: number;
  39592. /**
  39593. * Define the speed limit of the camera following an object.
  39594. */
  39595. maxCameraSpeed: number;
  39596. /**
  39597. * Define the target of the camera.
  39598. */
  39599. lockedTarget: Nullable<AbstractMesh>;
  39600. /**
  39601. * Defines the input associated with the camera.
  39602. */
  39603. inputs: FollowCameraInputsManager;
  39604. /**
  39605. * Instantiates the follow camera.
  39606. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39607. * @param name Define the name of the camera in the scene
  39608. * @param position Define the position of the camera
  39609. * @param scene Define the scene the camera belong to
  39610. * @param lockedTarget Define the target of the camera
  39611. */
  39612. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39613. private _follow;
  39614. /**
  39615. * Attached controls to the current camera.
  39616. * @param element Defines the element the controls should be listened from
  39617. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39618. */
  39619. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39620. /**
  39621. * Detach the current controls from the camera.
  39622. * The camera will stop reacting to inputs.
  39623. * @param element Defines the element to stop listening the inputs from
  39624. */
  39625. detachControl(element: HTMLElement): void;
  39626. /** @hidden */
  39627. _checkInputs(): void;
  39628. private _checkLimits;
  39629. /**
  39630. * Gets the camera class name.
  39631. * @returns the class name
  39632. */
  39633. getClassName(): string;
  39634. }
  39635. /**
  39636. * Arc Rotate version of the follow camera.
  39637. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39638. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39639. */
  39640. export class ArcFollowCamera extends TargetCamera {
  39641. /** The longitudinal angle of the camera */
  39642. alpha: number;
  39643. /** The latitudinal angle of the camera */
  39644. beta: number;
  39645. /** The radius of the camera from its target */
  39646. radius: number;
  39647. /** Define the camera target (the messh it should follow) */
  39648. target: Nullable<AbstractMesh>;
  39649. private _cartesianCoordinates;
  39650. /**
  39651. * Instantiates a new ArcFollowCamera
  39652. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39653. * @param name Define the name of the camera
  39654. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39655. * @param beta Define the rotation angle of the camera around the elevation axis
  39656. * @param radius Define the radius of the camera from its target point
  39657. * @param target Define the target of the camera
  39658. * @param scene Define the scene the camera belongs to
  39659. */
  39660. constructor(name: string,
  39661. /** The longitudinal angle of the camera */
  39662. alpha: number,
  39663. /** The latitudinal angle of the camera */
  39664. beta: number,
  39665. /** The radius of the camera from its target */
  39666. radius: number,
  39667. /** Define the camera target (the messh it should follow) */
  39668. target: Nullable<AbstractMesh>, scene: Scene);
  39669. private _follow;
  39670. /** @hidden */
  39671. _checkInputs(): void;
  39672. /**
  39673. * Returns the class name of the object.
  39674. * It is mostly used internally for serialization purposes.
  39675. */
  39676. getClassName(): string;
  39677. }
  39678. }
  39679. declare module BABYLON {
  39680. /**
  39681. * Manage the keyboard inputs to control the movement of a follow camera.
  39682. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39683. */
  39684. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39685. /**
  39686. * Defines the camera the input is attached to.
  39687. */
  39688. camera: FollowCamera;
  39689. /**
  39690. * Defines the list of key codes associated with the up action (increase heightOffset)
  39691. */
  39692. keysHeightOffsetIncr: number[];
  39693. /**
  39694. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39695. */
  39696. keysHeightOffsetDecr: number[];
  39697. /**
  39698. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39699. */
  39700. keysHeightOffsetModifierAlt: boolean;
  39701. /**
  39702. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39703. */
  39704. keysHeightOffsetModifierCtrl: boolean;
  39705. /**
  39706. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39707. */
  39708. keysHeightOffsetModifierShift: boolean;
  39709. /**
  39710. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39711. */
  39712. keysRotationOffsetIncr: number[];
  39713. /**
  39714. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39715. */
  39716. keysRotationOffsetDecr: number[];
  39717. /**
  39718. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39719. */
  39720. keysRotationOffsetModifierAlt: boolean;
  39721. /**
  39722. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39723. */
  39724. keysRotationOffsetModifierCtrl: boolean;
  39725. /**
  39726. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39727. */
  39728. keysRotationOffsetModifierShift: boolean;
  39729. /**
  39730. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39731. */
  39732. keysRadiusIncr: number[];
  39733. /**
  39734. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39735. */
  39736. keysRadiusDecr: number[];
  39737. /**
  39738. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39739. */
  39740. keysRadiusModifierAlt: boolean;
  39741. /**
  39742. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39743. */
  39744. keysRadiusModifierCtrl: boolean;
  39745. /**
  39746. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39747. */
  39748. keysRadiusModifierShift: boolean;
  39749. /**
  39750. * Defines the rate of change of heightOffset.
  39751. */
  39752. heightSensibility: number;
  39753. /**
  39754. * Defines the rate of change of rotationOffset.
  39755. */
  39756. rotationSensibility: number;
  39757. /**
  39758. * Defines the rate of change of radius.
  39759. */
  39760. radiusSensibility: number;
  39761. private _keys;
  39762. private _ctrlPressed;
  39763. private _altPressed;
  39764. private _shiftPressed;
  39765. private _onCanvasBlurObserver;
  39766. private _onKeyboardObserver;
  39767. private _engine;
  39768. private _scene;
  39769. /**
  39770. * Attach the input controls to a specific dom element to get the input from.
  39771. * @param element Defines the element the controls should be listened from
  39772. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39773. */
  39774. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39775. /**
  39776. * Detach the current controls from the specified dom element.
  39777. * @param element Defines the element to stop listening the inputs from
  39778. */
  39779. detachControl(element: Nullable<HTMLElement>): void;
  39780. /**
  39781. * Update the current camera state depending on the inputs that have been used this frame.
  39782. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39783. */
  39784. checkInputs(): void;
  39785. /**
  39786. * Gets the class name of the current input.
  39787. * @returns the class name
  39788. */
  39789. getClassName(): string;
  39790. /**
  39791. * Get the friendly name associated with the input class.
  39792. * @returns the input friendly name
  39793. */
  39794. getSimpleName(): string;
  39795. /**
  39796. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39797. * allow modification of the heightOffset value.
  39798. */
  39799. private _modifierHeightOffset;
  39800. /**
  39801. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39802. * allow modification of the rotationOffset value.
  39803. */
  39804. private _modifierRotationOffset;
  39805. /**
  39806. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39807. * allow modification of the radius value.
  39808. */
  39809. private _modifierRadius;
  39810. }
  39811. }
  39812. declare module BABYLON {
  39813. interface FreeCameraInputsManager {
  39814. /**
  39815. * @hidden
  39816. */
  39817. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39818. /**
  39819. * Add orientation input support to the input manager.
  39820. * @returns the current input manager
  39821. */
  39822. addDeviceOrientation(): FreeCameraInputsManager;
  39823. }
  39824. /**
  39825. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39826. * Screen rotation is taken into account.
  39827. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39828. */
  39829. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39830. private _camera;
  39831. private _screenOrientationAngle;
  39832. private _constantTranform;
  39833. private _screenQuaternion;
  39834. private _alpha;
  39835. private _beta;
  39836. private _gamma;
  39837. /**
  39838. * Can be used to detect if a device orientation sensor is availible on a device
  39839. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39840. * @returns a promise that will resolve on orientation change
  39841. */
  39842. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39843. /**
  39844. * @hidden
  39845. */
  39846. _onDeviceOrientationChangedObservable: Observable<void>;
  39847. /**
  39848. * Instantiates a new input
  39849. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39850. */
  39851. constructor();
  39852. /**
  39853. * Define the camera controlled by the input.
  39854. */
  39855. camera: FreeCamera;
  39856. /**
  39857. * Attach the input controls to a specific dom element to get the input from.
  39858. * @param element Defines the element the controls should be listened from
  39859. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39860. */
  39861. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39862. private _orientationChanged;
  39863. private _deviceOrientation;
  39864. /**
  39865. * Detach the current controls from the specified dom element.
  39866. * @param element Defines the element to stop listening the inputs from
  39867. */
  39868. detachControl(element: Nullable<HTMLElement>): void;
  39869. /**
  39870. * Update the current camera state depending on the inputs that have been used this frame.
  39871. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39872. */
  39873. checkInputs(): void;
  39874. /**
  39875. * Gets the class name of the current intput.
  39876. * @returns the class name
  39877. */
  39878. getClassName(): string;
  39879. /**
  39880. * Get the friendly name associated with the input class.
  39881. * @returns the input friendly name
  39882. */
  39883. getSimpleName(): string;
  39884. }
  39885. }
  39886. declare module BABYLON {
  39887. /**
  39888. * Manage the gamepad inputs to control a free camera.
  39889. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39890. */
  39891. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39892. /**
  39893. * Define the camera the input is attached to.
  39894. */
  39895. camera: FreeCamera;
  39896. /**
  39897. * Define the Gamepad controlling the input
  39898. */
  39899. gamepad: Nullable<Gamepad>;
  39900. /**
  39901. * Defines the gamepad rotation sensiblity.
  39902. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39903. */
  39904. gamepadAngularSensibility: number;
  39905. /**
  39906. * Defines the gamepad move sensiblity.
  39907. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39908. */
  39909. gamepadMoveSensibility: number;
  39910. private _yAxisScale;
  39911. /**
  39912. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39913. */
  39914. invertYAxis: boolean;
  39915. private _onGamepadConnectedObserver;
  39916. private _onGamepadDisconnectedObserver;
  39917. private _cameraTransform;
  39918. private _deltaTransform;
  39919. private _vector3;
  39920. private _vector2;
  39921. /**
  39922. * Attach the input controls to a specific dom element to get the input from.
  39923. * @param element Defines the element the controls should be listened from
  39924. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39925. */
  39926. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39927. /**
  39928. * Detach the current controls from the specified dom element.
  39929. * @param element Defines the element to stop listening the inputs from
  39930. */
  39931. detachControl(element: Nullable<HTMLElement>): void;
  39932. /**
  39933. * Update the current camera state depending on the inputs that have been used this frame.
  39934. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39935. */
  39936. checkInputs(): void;
  39937. /**
  39938. * Gets the class name of the current intput.
  39939. * @returns the class name
  39940. */
  39941. getClassName(): string;
  39942. /**
  39943. * Get the friendly name associated with the input class.
  39944. * @returns the input friendly name
  39945. */
  39946. getSimpleName(): string;
  39947. }
  39948. }
  39949. declare module BABYLON {
  39950. /**
  39951. * Defines the potential axis of a Joystick
  39952. */
  39953. export enum JoystickAxis {
  39954. /** X axis */
  39955. X = 0,
  39956. /** Y axis */
  39957. Y = 1,
  39958. /** Z axis */
  39959. Z = 2
  39960. }
  39961. /**
  39962. * Class used to define virtual joystick (used in touch mode)
  39963. */
  39964. export class VirtualJoystick {
  39965. /**
  39966. * Gets or sets a boolean indicating that left and right values must be inverted
  39967. */
  39968. reverseLeftRight: boolean;
  39969. /**
  39970. * Gets or sets a boolean indicating that up and down values must be inverted
  39971. */
  39972. reverseUpDown: boolean;
  39973. /**
  39974. * Gets the offset value for the position (ie. the change of the position value)
  39975. */
  39976. deltaPosition: Vector3;
  39977. /**
  39978. * Gets a boolean indicating if the virtual joystick was pressed
  39979. */
  39980. pressed: boolean;
  39981. /**
  39982. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39983. */
  39984. static Canvas: Nullable<HTMLCanvasElement>;
  39985. private static _globalJoystickIndex;
  39986. private static vjCanvasContext;
  39987. private static vjCanvasWidth;
  39988. private static vjCanvasHeight;
  39989. private static halfWidth;
  39990. private _action;
  39991. private _axisTargetedByLeftAndRight;
  39992. private _axisTargetedByUpAndDown;
  39993. private _joystickSensibility;
  39994. private _inversedSensibility;
  39995. private _joystickPointerID;
  39996. private _joystickColor;
  39997. private _joystickPointerPos;
  39998. private _joystickPreviousPointerPos;
  39999. private _joystickPointerStartPos;
  40000. private _deltaJoystickVector;
  40001. private _leftJoystick;
  40002. private _touches;
  40003. private _onPointerDownHandlerRef;
  40004. private _onPointerMoveHandlerRef;
  40005. private _onPointerUpHandlerRef;
  40006. private _onResize;
  40007. /**
  40008. * Creates a new virtual joystick
  40009. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40010. */
  40011. constructor(leftJoystick?: boolean);
  40012. /**
  40013. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40014. * @param newJoystickSensibility defines the new sensibility
  40015. */
  40016. setJoystickSensibility(newJoystickSensibility: number): void;
  40017. private _onPointerDown;
  40018. private _onPointerMove;
  40019. private _onPointerUp;
  40020. /**
  40021. * Change the color of the virtual joystick
  40022. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40023. */
  40024. setJoystickColor(newColor: string): void;
  40025. /**
  40026. * Defines a callback to call when the joystick is touched
  40027. * @param action defines the callback
  40028. */
  40029. setActionOnTouch(action: () => any): void;
  40030. /**
  40031. * Defines which axis you'd like to control for left & right
  40032. * @param axis defines the axis to use
  40033. */
  40034. setAxisForLeftRight(axis: JoystickAxis): void;
  40035. /**
  40036. * Defines which axis you'd like to control for up & down
  40037. * @param axis defines the axis to use
  40038. */
  40039. setAxisForUpDown(axis: JoystickAxis): void;
  40040. private _drawVirtualJoystick;
  40041. /**
  40042. * Release internal HTML canvas
  40043. */
  40044. releaseCanvas(): void;
  40045. }
  40046. }
  40047. declare module BABYLON {
  40048. interface FreeCameraInputsManager {
  40049. /**
  40050. * Add virtual joystick input support to the input manager.
  40051. * @returns the current input manager
  40052. */
  40053. addVirtualJoystick(): FreeCameraInputsManager;
  40054. }
  40055. /**
  40056. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40057. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40058. */
  40059. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40060. /**
  40061. * Defines the camera the input is attached to.
  40062. */
  40063. camera: FreeCamera;
  40064. private _leftjoystick;
  40065. private _rightjoystick;
  40066. /**
  40067. * Gets the left stick of the virtual joystick.
  40068. * @returns The virtual Joystick
  40069. */
  40070. getLeftJoystick(): VirtualJoystick;
  40071. /**
  40072. * Gets the right stick of the virtual joystick.
  40073. * @returns The virtual Joystick
  40074. */
  40075. getRightJoystick(): VirtualJoystick;
  40076. /**
  40077. * Update the current camera state depending on the inputs that have been used this frame.
  40078. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40079. */
  40080. checkInputs(): void;
  40081. /**
  40082. * Attach the input controls to a specific dom element to get the input from.
  40083. * @param element Defines the element the controls should be listened from
  40084. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40085. */
  40086. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40087. /**
  40088. * Detach the current controls from the specified dom element.
  40089. * @param element Defines the element to stop listening the inputs from
  40090. */
  40091. detachControl(element: Nullable<HTMLElement>): void;
  40092. /**
  40093. * Gets the class name of the current intput.
  40094. * @returns the class name
  40095. */
  40096. getClassName(): string;
  40097. /**
  40098. * Get the friendly name associated with the input class.
  40099. * @returns the input friendly name
  40100. */
  40101. getSimpleName(): string;
  40102. }
  40103. }
  40104. declare module BABYLON {
  40105. /**
  40106. * This represents a FPS type of camera controlled by touch.
  40107. * This is like a universal camera minus the Gamepad controls.
  40108. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40109. */
  40110. export class TouchCamera extends FreeCamera {
  40111. /**
  40112. * Defines the touch sensibility for rotation.
  40113. * The higher the faster.
  40114. */
  40115. touchAngularSensibility: number;
  40116. /**
  40117. * Defines the touch sensibility for move.
  40118. * The higher the faster.
  40119. */
  40120. touchMoveSensibility: number;
  40121. /**
  40122. * Instantiates a new touch camera.
  40123. * This represents a FPS type of camera controlled by touch.
  40124. * This is like a universal camera minus the Gamepad controls.
  40125. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40126. * @param name Define the name of the camera in the scene
  40127. * @param position Define the start position of the camera in the scene
  40128. * @param scene Define the scene the camera belongs to
  40129. */
  40130. constructor(name: string, position: Vector3, scene: Scene);
  40131. /**
  40132. * Gets the current object class name.
  40133. * @return the class name
  40134. */
  40135. getClassName(): string;
  40136. /** @hidden */
  40137. _setupInputs(): void;
  40138. }
  40139. }
  40140. declare module BABYLON {
  40141. /**
  40142. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40143. * being tilted forward or back and left or right.
  40144. */
  40145. export class DeviceOrientationCamera extends FreeCamera {
  40146. private _initialQuaternion;
  40147. private _quaternionCache;
  40148. private _tmpDragQuaternion;
  40149. private _disablePointerInputWhenUsingDeviceOrientation;
  40150. /**
  40151. * Creates a new device orientation camera
  40152. * @param name The name of the camera
  40153. * @param position The start position camera
  40154. * @param scene The scene the camera belongs to
  40155. */
  40156. constructor(name: string, position: Vector3, scene: Scene);
  40157. /**
  40158. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40159. */
  40160. disablePointerInputWhenUsingDeviceOrientation: boolean;
  40161. private _dragFactor;
  40162. /**
  40163. * Enabled turning on the y axis when the orientation sensor is active
  40164. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40165. */
  40166. enableHorizontalDragging(dragFactor?: number): void;
  40167. /**
  40168. * Gets the current instance class name ("DeviceOrientationCamera").
  40169. * This helps avoiding instanceof at run time.
  40170. * @returns the class name
  40171. */
  40172. getClassName(): string;
  40173. /**
  40174. * @hidden
  40175. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40176. */
  40177. _checkInputs(): void;
  40178. /**
  40179. * Reset the camera to its default orientation on the specified axis only.
  40180. * @param axis The axis to reset
  40181. */
  40182. resetToCurrentRotation(axis?: Axis): void;
  40183. }
  40184. }
  40185. declare module BABYLON {
  40186. /**
  40187. * Defines supported buttons for XBox360 compatible gamepads
  40188. */
  40189. export enum Xbox360Button {
  40190. /** A */
  40191. A = 0,
  40192. /** B */
  40193. B = 1,
  40194. /** X */
  40195. X = 2,
  40196. /** Y */
  40197. Y = 3,
  40198. /** Start */
  40199. Start = 4,
  40200. /** Back */
  40201. Back = 5,
  40202. /** Left button */
  40203. LB = 6,
  40204. /** Right button */
  40205. RB = 7,
  40206. /** Left stick */
  40207. LeftStick = 8,
  40208. /** Right stick */
  40209. RightStick = 9
  40210. }
  40211. /** Defines values for XBox360 DPad */
  40212. export enum Xbox360Dpad {
  40213. /** Up */
  40214. Up = 0,
  40215. /** Down */
  40216. Down = 1,
  40217. /** Left */
  40218. Left = 2,
  40219. /** Right */
  40220. Right = 3
  40221. }
  40222. /**
  40223. * Defines a XBox360 gamepad
  40224. */
  40225. export class Xbox360Pad extends Gamepad {
  40226. private _leftTrigger;
  40227. private _rightTrigger;
  40228. private _onlefttriggerchanged;
  40229. private _onrighttriggerchanged;
  40230. private _onbuttondown;
  40231. private _onbuttonup;
  40232. private _ondpaddown;
  40233. private _ondpadup;
  40234. /** Observable raised when a button is pressed */
  40235. onButtonDownObservable: Observable<Xbox360Button>;
  40236. /** Observable raised when a button is released */
  40237. onButtonUpObservable: Observable<Xbox360Button>;
  40238. /** Observable raised when a pad is pressed */
  40239. onPadDownObservable: Observable<Xbox360Dpad>;
  40240. /** Observable raised when a pad is released */
  40241. onPadUpObservable: Observable<Xbox360Dpad>;
  40242. private _buttonA;
  40243. private _buttonB;
  40244. private _buttonX;
  40245. private _buttonY;
  40246. private _buttonBack;
  40247. private _buttonStart;
  40248. private _buttonLB;
  40249. private _buttonRB;
  40250. private _buttonLeftStick;
  40251. private _buttonRightStick;
  40252. private _dPadUp;
  40253. private _dPadDown;
  40254. private _dPadLeft;
  40255. private _dPadRight;
  40256. private _isXboxOnePad;
  40257. /**
  40258. * Creates a new XBox360 gamepad object
  40259. * @param id defines the id of this gamepad
  40260. * @param index defines its index
  40261. * @param gamepad defines the internal HTML gamepad object
  40262. * @param xboxOne defines if it is a XBox One gamepad
  40263. */
  40264. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40265. /**
  40266. * Defines the callback to call when left trigger is pressed
  40267. * @param callback defines the callback to use
  40268. */
  40269. onlefttriggerchanged(callback: (value: number) => void): void;
  40270. /**
  40271. * Defines the callback to call when right trigger is pressed
  40272. * @param callback defines the callback to use
  40273. */
  40274. onrighttriggerchanged(callback: (value: number) => void): void;
  40275. /**
  40276. * Gets the left trigger value
  40277. */
  40278. /**
  40279. * Sets the left trigger value
  40280. */
  40281. leftTrigger: number;
  40282. /**
  40283. * Gets the right trigger value
  40284. */
  40285. /**
  40286. * Sets the right trigger value
  40287. */
  40288. rightTrigger: number;
  40289. /**
  40290. * Defines the callback to call when a button is pressed
  40291. * @param callback defines the callback to use
  40292. */
  40293. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40294. /**
  40295. * Defines the callback to call when a button is released
  40296. * @param callback defines the callback to use
  40297. */
  40298. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40299. /**
  40300. * Defines the callback to call when a pad is pressed
  40301. * @param callback defines the callback to use
  40302. */
  40303. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40304. /**
  40305. * Defines the callback to call when a pad is released
  40306. * @param callback defines the callback to use
  40307. */
  40308. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40309. private _setButtonValue;
  40310. private _setDPadValue;
  40311. /**
  40312. * Gets the value of the `A` button
  40313. */
  40314. /**
  40315. * Sets the value of the `A` button
  40316. */
  40317. buttonA: number;
  40318. /**
  40319. * Gets the value of the `B` button
  40320. */
  40321. /**
  40322. * Sets the value of the `B` button
  40323. */
  40324. buttonB: number;
  40325. /**
  40326. * Gets the value of the `X` button
  40327. */
  40328. /**
  40329. * Sets the value of the `X` button
  40330. */
  40331. buttonX: number;
  40332. /**
  40333. * Gets the value of the `Y` button
  40334. */
  40335. /**
  40336. * Sets the value of the `Y` button
  40337. */
  40338. buttonY: number;
  40339. /**
  40340. * Gets the value of the `Start` button
  40341. */
  40342. /**
  40343. * Sets the value of the `Start` button
  40344. */
  40345. buttonStart: number;
  40346. /**
  40347. * Gets the value of the `Back` button
  40348. */
  40349. /**
  40350. * Sets the value of the `Back` button
  40351. */
  40352. buttonBack: number;
  40353. /**
  40354. * Gets the value of the `Left` button
  40355. */
  40356. /**
  40357. * Sets the value of the `Left` button
  40358. */
  40359. buttonLB: number;
  40360. /**
  40361. * Gets the value of the `Right` button
  40362. */
  40363. /**
  40364. * Sets the value of the `Right` button
  40365. */
  40366. buttonRB: number;
  40367. /**
  40368. * Gets the value of the Left joystick
  40369. */
  40370. /**
  40371. * Sets the value of the Left joystick
  40372. */
  40373. buttonLeftStick: number;
  40374. /**
  40375. * Gets the value of the Right joystick
  40376. */
  40377. /**
  40378. * Sets the value of the Right joystick
  40379. */
  40380. buttonRightStick: number;
  40381. /**
  40382. * Gets the value of D-pad up
  40383. */
  40384. /**
  40385. * Sets the value of D-pad up
  40386. */
  40387. dPadUp: number;
  40388. /**
  40389. * Gets the value of D-pad down
  40390. */
  40391. /**
  40392. * Sets the value of D-pad down
  40393. */
  40394. dPadDown: number;
  40395. /**
  40396. * Gets the value of D-pad left
  40397. */
  40398. /**
  40399. * Sets the value of D-pad left
  40400. */
  40401. dPadLeft: number;
  40402. /**
  40403. * Gets the value of D-pad right
  40404. */
  40405. /**
  40406. * Sets the value of D-pad right
  40407. */
  40408. dPadRight: number;
  40409. /**
  40410. * Force the gamepad to synchronize with device values
  40411. */
  40412. update(): void;
  40413. /**
  40414. * Disposes the gamepad
  40415. */
  40416. dispose(): void;
  40417. }
  40418. }
  40419. declare module BABYLON {
  40420. /**
  40421. * Defines supported buttons for DualShock compatible gamepads
  40422. */
  40423. export enum DualShockButton {
  40424. /** Cross */
  40425. Cross = 0,
  40426. /** Circle */
  40427. Circle = 1,
  40428. /** Square */
  40429. Square = 2,
  40430. /** Triangle */
  40431. Triangle = 3,
  40432. /** Options */
  40433. Options = 4,
  40434. /** Share */
  40435. Share = 5,
  40436. /** L1 */
  40437. L1 = 6,
  40438. /** R1 */
  40439. R1 = 7,
  40440. /** Left stick */
  40441. LeftStick = 8,
  40442. /** Right stick */
  40443. RightStick = 9
  40444. }
  40445. /** Defines values for DualShock DPad */
  40446. export enum DualShockDpad {
  40447. /** Up */
  40448. Up = 0,
  40449. /** Down */
  40450. Down = 1,
  40451. /** Left */
  40452. Left = 2,
  40453. /** Right */
  40454. Right = 3
  40455. }
  40456. /**
  40457. * Defines a DualShock gamepad
  40458. */
  40459. export class DualShockPad extends Gamepad {
  40460. private _leftTrigger;
  40461. private _rightTrigger;
  40462. private _onlefttriggerchanged;
  40463. private _onrighttriggerchanged;
  40464. private _onbuttondown;
  40465. private _onbuttonup;
  40466. private _ondpaddown;
  40467. private _ondpadup;
  40468. /** Observable raised when a button is pressed */
  40469. onButtonDownObservable: Observable<DualShockButton>;
  40470. /** Observable raised when a button is released */
  40471. onButtonUpObservable: Observable<DualShockButton>;
  40472. /** Observable raised when a pad is pressed */
  40473. onPadDownObservable: Observable<DualShockDpad>;
  40474. /** Observable raised when a pad is released */
  40475. onPadUpObservable: Observable<DualShockDpad>;
  40476. private _buttonCross;
  40477. private _buttonCircle;
  40478. private _buttonSquare;
  40479. private _buttonTriangle;
  40480. private _buttonShare;
  40481. private _buttonOptions;
  40482. private _buttonL1;
  40483. private _buttonR1;
  40484. private _buttonLeftStick;
  40485. private _buttonRightStick;
  40486. private _dPadUp;
  40487. private _dPadDown;
  40488. private _dPadLeft;
  40489. private _dPadRight;
  40490. /**
  40491. * Creates a new DualShock gamepad object
  40492. * @param id defines the id of this gamepad
  40493. * @param index defines its index
  40494. * @param gamepad defines the internal HTML gamepad object
  40495. */
  40496. constructor(id: string, index: number, gamepad: any);
  40497. /**
  40498. * Defines the callback to call when left trigger is pressed
  40499. * @param callback defines the callback to use
  40500. */
  40501. onlefttriggerchanged(callback: (value: number) => void): void;
  40502. /**
  40503. * Defines the callback to call when right trigger is pressed
  40504. * @param callback defines the callback to use
  40505. */
  40506. onrighttriggerchanged(callback: (value: number) => void): void;
  40507. /**
  40508. * Gets the left trigger value
  40509. */
  40510. /**
  40511. * Sets the left trigger value
  40512. */
  40513. leftTrigger: number;
  40514. /**
  40515. * Gets the right trigger value
  40516. */
  40517. /**
  40518. * Sets the right trigger value
  40519. */
  40520. rightTrigger: number;
  40521. /**
  40522. * Defines the callback to call when a button is pressed
  40523. * @param callback defines the callback to use
  40524. */
  40525. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40526. /**
  40527. * Defines the callback to call when a button is released
  40528. * @param callback defines the callback to use
  40529. */
  40530. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40531. /**
  40532. * Defines the callback to call when a pad is pressed
  40533. * @param callback defines the callback to use
  40534. */
  40535. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40536. /**
  40537. * Defines the callback to call when a pad is released
  40538. * @param callback defines the callback to use
  40539. */
  40540. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40541. private _setButtonValue;
  40542. private _setDPadValue;
  40543. /**
  40544. * Gets the value of the `Cross` button
  40545. */
  40546. /**
  40547. * Sets the value of the `Cross` button
  40548. */
  40549. buttonCross: number;
  40550. /**
  40551. * Gets the value of the `Circle` button
  40552. */
  40553. /**
  40554. * Sets the value of the `Circle` button
  40555. */
  40556. buttonCircle: number;
  40557. /**
  40558. * Gets the value of the `Square` button
  40559. */
  40560. /**
  40561. * Sets the value of the `Square` button
  40562. */
  40563. buttonSquare: number;
  40564. /**
  40565. * Gets the value of the `Triangle` button
  40566. */
  40567. /**
  40568. * Sets the value of the `Triangle` button
  40569. */
  40570. buttonTriangle: number;
  40571. /**
  40572. * Gets the value of the `Options` button
  40573. */
  40574. /**
  40575. * Sets the value of the `Options` button
  40576. */
  40577. buttonOptions: number;
  40578. /**
  40579. * Gets the value of the `Share` button
  40580. */
  40581. /**
  40582. * Sets the value of the `Share` button
  40583. */
  40584. buttonShare: number;
  40585. /**
  40586. * Gets the value of the `L1` button
  40587. */
  40588. /**
  40589. * Sets the value of the `L1` button
  40590. */
  40591. buttonL1: number;
  40592. /**
  40593. * Gets the value of the `R1` button
  40594. */
  40595. /**
  40596. * Sets the value of the `R1` button
  40597. */
  40598. buttonR1: number;
  40599. /**
  40600. * Gets the value of the Left joystick
  40601. */
  40602. /**
  40603. * Sets the value of the Left joystick
  40604. */
  40605. buttonLeftStick: number;
  40606. /**
  40607. * Gets the value of the Right joystick
  40608. */
  40609. /**
  40610. * Sets the value of the Right joystick
  40611. */
  40612. buttonRightStick: number;
  40613. /**
  40614. * Gets the value of D-pad up
  40615. */
  40616. /**
  40617. * Sets the value of D-pad up
  40618. */
  40619. dPadUp: number;
  40620. /**
  40621. * Gets the value of D-pad down
  40622. */
  40623. /**
  40624. * Sets the value of D-pad down
  40625. */
  40626. dPadDown: number;
  40627. /**
  40628. * Gets the value of D-pad left
  40629. */
  40630. /**
  40631. * Sets the value of D-pad left
  40632. */
  40633. dPadLeft: number;
  40634. /**
  40635. * Gets the value of D-pad right
  40636. */
  40637. /**
  40638. * Sets the value of D-pad right
  40639. */
  40640. dPadRight: number;
  40641. /**
  40642. * Force the gamepad to synchronize with device values
  40643. */
  40644. update(): void;
  40645. /**
  40646. * Disposes the gamepad
  40647. */
  40648. dispose(): void;
  40649. }
  40650. }
  40651. declare module BABYLON {
  40652. /**
  40653. * Manager for handling gamepads
  40654. */
  40655. export class GamepadManager {
  40656. private _scene?;
  40657. private _babylonGamepads;
  40658. private _oneGamepadConnected;
  40659. /** @hidden */
  40660. _isMonitoring: boolean;
  40661. private _gamepadEventSupported;
  40662. private _gamepadSupport;
  40663. /**
  40664. * observable to be triggered when the gamepad controller has been connected
  40665. */
  40666. onGamepadConnectedObservable: Observable<Gamepad>;
  40667. /**
  40668. * observable to be triggered when the gamepad controller has been disconnected
  40669. */
  40670. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40671. private _onGamepadConnectedEvent;
  40672. private _onGamepadDisconnectedEvent;
  40673. /**
  40674. * Initializes the gamepad manager
  40675. * @param _scene BabylonJS scene
  40676. */
  40677. constructor(_scene?: Scene | undefined);
  40678. /**
  40679. * The gamepads in the game pad manager
  40680. */
  40681. readonly gamepads: Gamepad[];
  40682. /**
  40683. * Get the gamepad controllers based on type
  40684. * @param type The type of gamepad controller
  40685. * @returns Nullable gamepad
  40686. */
  40687. getGamepadByType(type?: number): Nullable<Gamepad>;
  40688. /**
  40689. * Disposes the gamepad manager
  40690. */
  40691. dispose(): void;
  40692. private _addNewGamepad;
  40693. private _startMonitoringGamepads;
  40694. private _stopMonitoringGamepads;
  40695. /** @hidden */
  40696. _checkGamepadsStatus(): void;
  40697. private _updateGamepadObjects;
  40698. }
  40699. }
  40700. declare module BABYLON {
  40701. interface Scene {
  40702. /** @hidden */
  40703. _gamepadManager: Nullable<GamepadManager>;
  40704. /**
  40705. * Gets the gamepad manager associated with the scene
  40706. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40707. */
  40708. gamepadManager: GamepadManager;
  40709. }
  40710. /**
  40711. * Interface representing a free camera inputs manager
  40712. */
  40713. interface FreeCameraInputsManager {
  40714. /**
  40715. * Adds gamepad input support to the FreeCameraInputsManager.
  40716. * @returns the FreeCameraInputsManager
  40717. */
  40718. addGamepad(): FreeCameraInputsManager;
  40719. }
  40720. /**
  40721. * Interface representing an arc rotate camera inputs manager
  40722. */
  40723. interface ArcRotateCameraInputsManager {
  40724. /**
  40725. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40726. * @returns the camera inputs manager
  40727. */
  40728. addGamepad(): ArcRotateCameraInputsManager;
  40729. }
  40730. /**
  40731. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40732. */
  40733. export class GamepadSystemSceneComponent implements ISceneComponent {
  40734. /**
  40735. * The component name helpfull to identify the component in the list of scene components.
  40736. */
  40737. readonly name: string;
  40738. /**
  40739. * The scene the component belongs to.
  40740. */
  40741. scene: Scene;
  40742. /**
  40743. * Creates a new instance of the component for the given scene
  40744. * @param scene Defines the scene to register the component in
  40745. */
  40746. constructor(scene: Scene);
  40747. /**
  40748. * Registers the component in a given scene
  40749. */
  40750. register(): void;
  40751. /**
  40752. * Rebuilds the elements related to this component in case of
  40753. * context lost for instance.
  40754. */
  40755. rebuild(): void;
  40756. /**
  40757. * Disposes the component and the associated ressources
  40758. */
  40759. dispose(): void;
  40760. private _beforeCameraUpdate;
  40761. }
  40762. }
  40763. declare module BABYLON {
  40764. /**
  40765. * 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,
  40766. * which still works and will still be found in many Playgrounds.
  40767. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40768. */
  40769. export class UniversalCamera extends TouchCamera {
  40770. /**
  40771. * Defines the gamepad rotation sensiblity.
  40772. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40773. */
  40774. gamepadAngularSensibility: number;
  40775. /**
  40776. * Defines the gamepad move sensiblity.
  40777. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40778. */
  40779. gamepadMoveSensibility: number;
  40780. /**
  40781. * 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,
  40782. * which still works and will still be found in many Playgrounds.
  40783. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40784. * @param name Define the name of the camera in the scene
  40785. * @param position Define the start position of the camera in the scene
  40786. * @param scene Define the scene the camera belongs to
  40787. */
  40788. constructor(name: string, position: Vector3, scene: Scene);
  40789. /**
  40790. * Gets the current object class name.
  40791. * @return the class name
  40792. */
  40793. getClassName(): string;
  40794. }
  40795. }
  40796. declare module BABYLON {
  40797. /**
  40798. * This represents a FPS type of camera. This is only here for back compat purpose.
  40799. * Please use the UniversalCamera instead as both are identical.
  40800. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40801. */
  40802. export class GamepadCamera extends UniversalCamera {
  40803. /**
  40804. * Instantiates a new Gamepad Camera
  40805. * This represents a FPS type of camera. This is only here for back compat purpose.
  40806. * Please use the UniversalCamera instead as both are identical.
  40807. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40808. * @param name Define the name of the camera in the scene
  40809. * @param position Define the start position of the camera in the scene
  40810. * @param scene Define the scene the camera belongs to
  40811. */
  40812. constructor(name: string, position: Vector3, scene: Scene);
  40813. /**
  40814. * Gets the current object class name.
  40815. * @return the class name
  40816. */
  40817. getClassName(): string;
  40818. }
  40819. }
  40820. declare module BABYLON {
  40821. /** @hidden */
  40822. export var passPixelShader: {
  40823. name: string;
  40824. shader: string;
  40825. };
  40826. }
  40827. declare module BABYLON {
  40828. /** @hidden */
  40829. export var passCubePixelShader: {
  40830. name: string;
  40831. shader: string;
  40832. };
  40833. }
  40834. declare module BABYLON {
  40835. /**
  40836. * PassPostProcess which produces an output the same as it's input
  40837. */
  40838. export class PassPostProcess extends PostProcess {
  40839. /**
  40840. * Creates the PassPostProcess
  40841. * @param name The name of the effect.
  40842. * @param options The required width/height ratio to downsize to before computing the render pass.
  40843. * @param camera The camera to apply the render pass to.
  40844. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40845. * @param engine The engine which the post process will be applied. (default: current engine)
  40846. * @param reusable If the post process can be reused on the same frame. (default: false)
  40847. * @param textureType The type of texture to be used when performing the post processing.
  40848. * @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)
  40849. */
  40850. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40851. }
  40852. /**
  40853. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40854. */
  40855. export class PassCubePostProcess extends PostProcess {
  40856. private _face;
  40857. /**
  40858. * Gets or sets the cube face to display.
  40859. * * 0 is +X
  40860. * * 1 is -X
  40861. * * 2 is +Y
  40862. * * 3 is -Y
  40863. * * 4 is +Z
  40864. * * 5 is -Z
  40865. */
  40866. face: number;
  40867. /**
  40868. * Creates the PassCubePostProcess
  40869. * @param name The name of the effect.
  40870. * @param options The required width/height ratio to downsize to before computing the render pass.
  40871. * @param camera The camera to apply the render pass to.
  40872. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40873. * @param engine The engine which the post process will be applied. (default: current engine)
  40874. * @param reusable If the post process can be reused on the same frame. (default: false)
  40875. * @param textureType The type of texture to be used when performing the post processing.
  40876. * @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)
  40877. */
  40878. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40879. }
  40880. }
  40881. declare module BABYLON {
  40882. /** @hidden */
  40883. export var anaglyphPixelShader: {
  40884. name: string;
  40885. shader: string;
  40886. };
  40887. }
  40888. declare module BABYLON {
  40889. /**
  40890. * Postprocess used to generate anaglyphic rendering
  40891. */
  40892. export class AnaglyphPostProcess extends PostProcess {
  40893. private _passedProcess;
  40894. /**
  40895. * Creates a new AnaglyphPostProcess
  40896. * @param name defines postprocess name
  40897. * @param options defines creation options or target ratio scale
  40898. * @param rigCameras defines cameras using this postprocess
  40899. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40900. * @param engine defines hosting engine
  40901. * @param reusable defines if the postprocess will be reused multiple times per frame
  40902. */
  40903. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40904. }
  40905. }
  40906. declare module BABYLON {
  40907. /**
  40908. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40909. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40910. */
  40911. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40912. /**
  40913. * Creates a new AnaglyphArcRotateCamera
  40914. * @param name defines camera name
  40915. * @param alpha defines alpha angle (in radians)
  40916. * @param beta defines beta angle (in radians)
  40917. * @param radius defines radius
  40918. * @param target defines camera target
  40919. * @param interaxialDistance defines distance between each color axis
  40920. * @param scene defines the hosting scene
  40921. */
  40922. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40923. /**
  40924. * Gets camera class name
  40925. * @returns AnaglyphArcRotateCamera
  40926. */
  40927. getClassName(): string;
  40928. }
  40929. }
  40930. declare module BABYLON {
  40931. /**
  40932. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40933. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40934. */
  40935. export class AnaglyphFreeCamera extends FreeCamera {
  40936. /**
  40937. * Creates a new AnaglyphFreeCamera
  40938. * @param name defines camera name
  40939. * @param position defines initial position
  40940. * @param interaxialDistance defines distance between each color axis
  40941. * @param scene defines the hosting scene
  40942. */
  40943. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40944. /**
  40945. * Gets camera class name
  40946. * @returns AnaglyphFreeCamera
  40947. */
  40948. getClassName(): string;
  40949. }
  40950. }
  40951. declare module BABYLON {
  40952. /**
  40953. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40954. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40955. */
  40956. export class AnaglyphGamepadCamera extends GamepadCamera {
  40957. /**
  40958. * Creates a new AnaglyphGamepadCamera
  40959. * @param name defines camera name
  40960. * @param position defines initial position
  40961. * @param interaxialDistance defines distance between each color axis
  40962. * @param scene defines the hosting scene
  40963. */
  40964. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40965. /**
  40966. * Gets camera class name
  40967. * @returns AnaglyphGamepadCamera
  40968. */
  40969. getClassName(): string;
  40970. }
  40971. }
  40972. declare module BABYLON {
  40973. /**
  40974. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40975. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40976. */
  40977. export class AnaglyphUniversalCamera extends UniversalCamera {
  40978. /**
  40979. * Creates a new AnaglyphUniversalCamera
  40980. * @param name defines camera name
  40981. * @param position defines initial position
  40982. * @param interaxialDistance defines distance between each color axis
  40983. * @param scene defines the hosting scene
  40984. */
  40985. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40986. /**
  40987. * Gets camera class name
  40988. * @returns AnaglyphUniversalCamera
  40989. */
  40990. getClassName(): string;
  40991. }
  40992. }
  40993. declare module BABYLON {
  40994. /** @hidden */
  40995. export var stereoscopicInterlacePixelShader: {
  40996. name: string;
  40997. shader: string;
  40998. };
  40999. }
  41000. declare module BABYLON {
  41001. /**
  41002. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41003. */
  41004. export class StereoscopicInterlacePostProcess extends PostProcess {
  41005. private _stepSize;
  41006. private _passedProcess;
  41007. /**
  41008. * Initializes a StereoscopicInterlacePostProcess
  41009. * @param name The name of the effect.
  41010. * @param rigCameras The rig cameras to be appled to the post process
  41011. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41012. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41013. * @param engine The engine which the post process will be applied. (default: current engine)
  41014. * @param reusable If the post process can be reused on the same frame. (default: false)
  41015. */
  41016. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41017. }
  41018. }
  41019. declare module BABYLON {
  41020. /**
  41021. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41022. * @see http://doc.babylonjs.com/features/cameras
  41023. */
  41024. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41025. /**
  41026. * Creates a new StereoscopicArcRotateCamera
  41027. * @param name defines camera name
  41028. * @param alpha defines alpha angle (in radians)
  41029. * @param beta defines beta angle (in radians)
  41030. * @param radius defines radius
  41031. * @param target defines camera target
  41032. * @param interaxialDistance defines distance between each color axis
  41033. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41034. * @param scene defines the hosting scene
  41035. */
  41036. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41037. /**
  41038. * Gets camera class name
  41039. * @returns StereoscopicArcRotateCamera
  41040. */
  41041. getClassName(): string;
  41042. }
  41043. }
  41044. declare module BABYLON {
  41045. /**
  41046. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41047. * @see http://doc.babylonjs.com/features/cameras
  41048. */
  41049. export class StereoscopicFreeCamera extends FreeCamera {
  41050. /**
  41051. * Creates a new StereoscopicFreeCamera
  41052. * @param name defines camera name
  41053. * @param position defines initial position
  41054. * @param interaxialDistance defines distance between each color axis
  41055. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41056. * @param scene defines the hosting scene
  41057. */
  41058. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41059. /**
  41060. * Gets camera class name
  41061. * @returns StereoscopicFreeCamera
  41062. */
  41063. getClassName(): string;
  41064. }
  41065. }
  41066. declare module BABYLON {
  41067. /**
  41068. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41069. * @see http://doc.babylonjs.com/features/cameras
  41070. */
  41071. export class StereoscopicGamepadCamera extends GamepadCamera {
  41072. /**
  41073. * Creates a new StereoscopicGamepadCamera
  41074. * @param name defines camera name
  41075. * @param position defines initial position
  41076. * @param interaxialDistance defines distance between each color axis
  41077. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41078. * @param scene defines the hosting scene
  41079. */
  41080. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41081. /**
  41082. * Gets camera class name
  41083. * @returns StereoscopicGamepadCamera
  41084. */
  41085. getClassName(): string;
  41086. }
  41087. }
  41088. declare module BABYLON {
  41089. /**
  41090. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41091. * @see http://doc.babylonjs.com/features/cameras
  41092. */
  41093. export class StereoscopicUniversalCamera extends UniversalCamera {
  41094. /**
  41095. * Creates a new StereoscopicUniversalCamera
  41096. * @param name defines camera name
  41097. * @param position defines initial position
  41098. * @param interaxialDistance defines distance between each color axis
  41099. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41100. * @param scene defines the hosting scene
  41101. */
  41102. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41103. /**
  41104. * Gets camera class name
  41105. * @returns StereoscopicUniversalCamera
  41106. */
  41107. getClassName(): string;
  41108. }
  41109. }
  41110. declare module BABYLON {
  41111. /**
  41112. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41113. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41114. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41115. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41116. */
  41117. export class VirtualJoysticksCamera extends FreeCamera {
  41118. /**
  41119. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41120. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41121. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41122. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41123. * @param name Define the name of the camera in the scene
  41124. * @param position Define the start position of the camera in the scene
  41125. * @param scene Define the scene the camera belongs to
  41126. */
  41127. constructor(name: string, position: Vector3, scene: Scene);
  41128. /**
  41129. * Gets the current object class name.
  41130. * @return the class name
  41131. */
  41132. getClassName(): string;
  41133. }
  41134. }
  41135. declare module BABYLON {
  41136. /**
  41137. * This represents all the required metrics to create a VR camera.
  41138. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41139. */
  41140. export class VRCameraMetrics {
  41141. /**
  41142. * Define the horizontal resolution off the screen.
  41143. */
  41144. hResolution: number;
  41145. /**
  41146. * Define the vertical resolution off the screen.
  41147. */
  41148. vResolution: number;
  41149. /**
  41150. * Define the horizontal screen size.
  41151. */
  41152. hScreenSize: number;
  41153. /**
  41154. * Define the vertical screen size.
  41155. */
  41156. vScreenSize: number;
  41157. /**
  41158. * Define the vertical screen center position.
  41159. */
  41160. vScreenCenter: number;
  41161. /**
  41162. * Define the distance of the eyes to the screen.
  41163. */
  41164. eyeToScreenDistance: number;
  41165. /**
  41166. * Define the distance between both lenses
  41167. */
  41168. lensSeparationDistance: number;
  41169. /**
  41170. * Define the distance between both viewer's eyes.
  41171. */
  41172. interpupillaryDistance: number;
  41173. /**
  41174. * Define the distortion factor of the VR postprocess.
  41175. * Please, touch with care.
  41176. */
  41177. distortionK: number[];
  41178. /**
  41179. * Define the chromatic aberration correction factors for the VR post process.
  41180. */
  41181. chromaAbCorrection: number[];
  41182. /**
  41183. * Define the scale factor of the post process.
  41184. * The smaller the better but the slower.
  41185. */
  41186. postProcessScaleFactor: number;
  41187. /**
  41188. * Define an offset for the lens center.
  41189. */
  41190. lensCenterOffset: number;
  41191. /**
  41192. * Define if the current vr camera should compensate the distortion of the lense or not.
  41193. */
  41194. compensateDistortion: boolean;
  41195. /**
  41196. * Defines if multiview should be enabled when rendering (Default: false)
  41197. */
  41198. multiviewEnabled: boolean;
  41199. /**
  41200. * Gets the rendering aspect ratio based on the provided resolutions.
  41201. */
  41202. readonly aspectRatio: number;
  41203. /**
  41204. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41205. */
  41206. readonly aspectRatioFov: number;
  41207. /**
  41208. * @hidden
  41209. */
  41210. readonly leftHMatrix: Matrix;
  41211. /**
  41212. * @hidden
  41213. */
  41214. readonly rightHMatrix: Matrix;
  41215. /**
  41216. * @hidden
  41217. */
  41218. readonly leftPreViewMatrix: Matrix;
  41219. /**
  41220. * @hidden
  41221. */
  41222. readonly rightPreViewMatrix: Matrix;
  41223. /**
  41224. * Get the default VRMetrics based on the most generic setup.
  41225. * @returns the default vr metrics
  41226. */
  41227. static GetDefault(): VRCameraMetrics;
  41228. }
  41229. }
  41230. declare module BABYLON {
  41231. /** @hidden */
  41232. export var vrDistortionCorrectionPixelShader: {
  41233. name: string;
  41234. shader: string;
  41235. };
  41236. }
  41237. declare module BABYLON {
  41238. /**
  41239. * VRDistortionCorrectionPostProcess used for mobile VR
  41240. */
  41241. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41242. private _isRightEye;
  41243. private _distortionFactors;
  41244. private _postProcessScaleFactor;
  41245. private _lensCenterOffset;
  41246. private _scaleIn;
  41247. private _scaleFactor;
  41248. private _lensCenter;
  41249. /**
  41250. * Initializes the VRDistortionCorrectionPostProcess
  41251. * @param name The name of the effect.
  41252. * @param camera The camera to apply the render pass to.
  41253. * @param isRightEye If this is for the right eye distortion
  41254. * @param vrMetrics All the required metrics for the VR camera
  41255. */
  41256. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41257. }
  41258. }
  41259. declare module BABYLON {
  41260. /**
  41261. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41262. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41263. */
  41264. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41265. /**
  41266. * Creates a new VRDeviceOrientationArcRotateCamera
  41267. * @param name defines camera name
  41268. * @param alpha defines the camera rotation along the logitudinal axis
  41269. * @param beta defines the camera rotation along the latitudinal axis
  41270. * @param radius defines the camera distance from its target
  41271. * @param target defines the camera target
  41272. * @param scene defines the scene the camera belongs to
  41273. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41274. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41275. */
  41276. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41277. /**
  41278. * Gets camera class name
  41279. * @returns VRDeviceOrientationArcRotateCamera
  41280. */
  41281. getClassName(): string;
  41282. }
  41283. }
  41284. declare module BABYLON {
  41285. /**
  41286. * Camera used to simulate VR rendering (based on FreeCamera)
  41287. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41288. */
  41289. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41290. /**
  41291. * Creates a new VRDeviceOrientationFreeCamera
  41292. * @param name defines camera name
  41293. * @param position defines the start position of the camera
  41294. * @param scene defines the scene the camera belongs to
  41295. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41296. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41297. */
  41298. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41299. /**
  41300. * Gets camera class name
  41301. * @returns VRDeviceOrientationFreeCamera
  41302. */
  41303. getClassName(): string;
  41304. }
  41305. }
  41306. declare module BABYLON {
  41307. /**
  41308. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41309. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41310. */
  41311. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41312. /**
  41313. * Creates a new VRDeviceOrientationGamepadCamera
  41314. * @param name defines camera name
  41315. * @param position defines the start position of the camera
  41316. * @param scene defines the scene the camera belongs to
  41317. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41318. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41319. */
  41320. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41321. /**
  41322. * Gets camera class name
  41323. * @returns VRDeviceOrientationGamepadCamera
  41324. */
  41325. getClassName(): string;
  41326. }
  41327. }
  41328. declare module BABYLON {
  41329. /** @hidden */
  41330. export var imageProcessingPixelShader: {
  41331. name: string;
  41332. shader: string;
  41333. };
  41334. }
  41335. declare module BABYLON {
  41336. /**
  41337. * ImageProcessingPostProcess
  41338. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41339. */
  41340. export class ImageProcessingPostProcess extends PostProcess {
  41341. /**
  41342. * Default configuration related to image processing available in the PBR Material.
  41343. */
  41344. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41345. /**
  41346. * Gets the image processing configuration used either in this material.
  41347. */
  41348. /**
  41349. * Sets the Default image processing configuration used either in the this material.
  41350. *
  41351. * If sets to null, the scene one is in use.
  41352. */
  41353. imageProcessingConfiguration: ImageProcessingConfiguration;
  41354. /**
  41355. * Keep track of the image processing observer to allow dispose and replace.
  41356. */
  41357. private _imageProcessingObserver;
  41358. /**
  41359. * Attaches a new image processing configuration to the PBR Material.
  41360. * @param configuration
  41361. */
  41362. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41363. /**
  41364. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41365. */
  41366. /**
  41367. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41368. */
  41369. colorCurves: Nullable<ColorCurves>;
  41370. /**
  41371. * Gets wether the color curves effect is enabled.
  41372. */
  41373. /**
  41374. * Sets wether the color curves effect is enabled.
  41375. */
  41376. colorCurvesEnabled: boolean;
  41377. /**
  41378. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41379. */
  41380. /**
  41381. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41382. */
  41383. colorGradingTexture: Nullable<BaseTexture>;
  41384. /**
  41385. * Gets wether the color grading effect is enabled.
  41386. */
  41387. /**
  41388. * Gets wether the color grading effect is enabled.
  41389. */
  41390. colorGradingEnabled: boolean;
  41391. /**
  41392. * Gets exposure used in the effect.
  41393. */
  41394. /**
  41395. * Sets exposure used in the effect.
  41396. */
  41397. exposure: number;
  41398. /**
  41399. * Gets wether tonemapping is enabled or not.
  41400. */
  41401. /**
  41402. * Sets wether tonemapping is enabled or not
  41403. */
  41404. toneMappingEnabled: boolean;
  41405. /**
  41406. * Gets the type of tone mapping effect.
  41407. */
  41408. /**
  41409. * Sets the type of tone mapping effect.
  41410. */
  41411. toneMappingType: number;
  41412. /**
  41413. * Gets contrast used in the effect.
  41414. */
  41415. /**
  41416. * Sets contrast used in the effect.
  41417. */
  41418. contrast: number;
  41419. /**
  41420. * Gets Vignette stretch size.
  41421. */
  41422. /**
  41423. * Sets Vignette stretch size.
  41424. */
  41425. vignetteStretch: number;
  41426. /**
  41427. * Gets Vignette centre X Offset.
  41428. */
  41429. /**
  41430. * Sets Vignette centre X Offset.
  41431. */
  41432. vignetteCentreX: number;
  41433. /**
  41434. * Gets Vignette centre Y Offset.
  41435. */
  41436. /**
  41437. * Sets Vignette centre Y Offset.
  41438. */
  41439. vignetteCentreY: number;
  41440. /**
  41441. * Gets Vignette weight or intensity of the vignette effect.
  41442. */
  41443. /**
  41444. * Sets Vignette weight or intensity of the vignette effect.
  41445. */
  41446. vignetteWeight: number;
  41447. /**
  41448. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41449. * if vignetteEnabled is set to true.
  41450. */
  41451. /**
  41452. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41453. * if vignetteEnabled is set to true.
  41454. */
  41455. vignetteColor: Color4;
  41456. /**
  41457. * Gets Camera field of view used by the Vignette effect.
  41458. */
  41459. /**
  41460. * Sets Camera field of view used by the Vignette effect.
  41461. */
  41462. vignetteCameraFov: number;
  41463. /**
  41464. * Gets the vignette blend mode allowing different kind of effect.
  41465. */
  41466. /**
  41467. * Sets the vignette blend mode allowing different kind of effect.
  41468. */
  41469. vignetteBlendMode: number;
  41470. /**
  41471. * Gets wether the vignette effect is enabled.
  41472. */
  41473. /**
  41474. * Sets wether the vignette effect is enabled.
  41475. */
  41476. vignetteEnabled: boolean;
  41477. private _fromLinearSpace;
  41478. /**
  41479. * Gets wether the input of the processing is in Gamma or Linear Space.
  41480. */
  41481. /**
  41482. * Sets wether the input of the processing is in Gamma or Linear Space.
  41483. */
  41484. fromLinearSpace: boolean;
  41485. /**
  41486. * Defines cache preventing GC.
  41487. */
  41488. private _defines;
  41489. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41490. /**
  41491. * "ImageProcessingPostProcess"
  41492. * @returns "ImageProcessingPostProcess"
  41493. */
  41494. getClassName(): string;
  41495. protected _updateParameters(): void;
  41496. dispose(camera?: Camera): void;
  41497. }
  41498. }
  41499. declare module BABYLON {
  41500. /**
  41501. * Class containing static functions to help procedurally build meshes
  41502. */
  41503. export class GroundBuilder {
  41504. /**
  41505. * Creates a ground mesh
  41506. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41507. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41509. * @param name defines the name of the mesh
  41510. * @param options defines the options used to create the mesh
  41511. * @param scene defines the hosting scene
  41512. * @returns the ground mesh
  41513. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41514. */
  41515. static CreateGround(name: string, options: {
  41516. width?: number;
  41517. height?: number;
  41518. subdivisions?: number;
  41519. subdivisionsX?: number;
  41520. subdivisionsY?: number;
  41521. updatable?: boolean;
  41522. }, scene: any): Mesh;
  41523. /**
  41524. * Creates a tiled ground mesh
  41525. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41526. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41527. * * 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
  41528. * * 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
  41529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41530. * @param name defines the name of the mesh
  41531. * @param options defines the options used to create the mesh
  41532. * @param scene defines the hosting scene
  41533. * @returns the tiled ground mesh
  41534. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41535. */
  41536. static CreateTiledGround(name: string, options: {
  41537. xmin: number;
  41538. zmin: number;
  41539. xmax: number;
  41540. zmax: number;
  41541. subdivisions?: {
  41542. w: number;
  41543. h: number;
  41544. };
  41545. precision?: {
  41546. w: number;
  41547. h: number;
  41548. };
  41549. updatable?: boolean;
  41550. }, scene?: Nullable<Scene>): Mesh;
  41551. /**
  41552. * Creates a ground mesh from a height map
  41553. * * The parameter `url` sets the URL of the height map image resource.
  41554. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41555. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41556. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41557. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41558. * * 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.
  41559. * * 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).
  41560. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41562. * @param name defines the name of the mesh
  41563. * @param url defines the url to the height map
  41564. * @param options defines the options used to create the mesh
  41565. * @param scene defines the hosting scene
  41566. * @returns the ground mesh
  41567. * @see https://doc.babylonjs.com/babylon101/height_map
  41568. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41569. */
  41570. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41571. width?: number;
  41572. height?: number;
  41573. subdivisions?: number;
  41574. minHeight?: number;
  41575. maxHeight?: number;
  41576. colorFilter?: Color3;
  41577. alphaFilter?: number;
  41578. updatable?: boolean;
  41579. onReady?: (mesh: GroundMesh) => void;
  41580. }, scene?: Nullable<Scene>): GroundMesh;
  41581. }
  41582. }
  41583. declare module BABYLON {
  41584. /**
  41585. * Class containing static functions to help procedurally build meshes
  41586. */
  41587. export class TorusBuilder {
  41588. /**
  41589. * Creates a torus mesh
  41590. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41591. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41592. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41593. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41594. * * 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
  41595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41596. * @param name defines the name of the mesh
  41597. * @param options defines the options used to create the mesh
  41598. * @param scene defines the hosting scene
  41599. * @returns the torus mesh
  41600. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41601. */
  41602. static CreateTorus(name: string, options: {
  41603. diameter?: number;
  41604. thickness?: number;
  41605. tessellation?: number;
  41606. updatable?: boolean;
  41607. sideOrientation?: number;
  41608. frontUVs?: Vector4;
  41609. backUVs?: Vector4;
  41610. }, scene: any): Mesh;
  41611. }
  41612. }
  41613. declare module BABYLON {
  41614. /**
  41615. * Class containing static functions to help procedurally build meshes
  41616. */
  41617. export class CylinderBuilder {
  41618. /**
  41619. * Creates a cylinder or a cone mesh
  41620. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41621. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41622. * * 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.
  41623. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41624. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41625. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41626. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41627. * * 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).
  41628. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41629. * * 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).
  41630. * * 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
  41631. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41632. * * 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
  41633. * * 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.
  41634. * * If `enclose` is false, a ring surface is one element.
  41635. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41636. * * 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
  41637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41638. * * 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
  41639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41640. * @param name defines the name of the mesh
  41641. * @param options defines the options used to create the mesh
  41642. * @param scene defines the hosting scene
  41643. * @returns the cylinder mesh
  41644. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41645. */
  41646. static CreateCylinder(name: string, options: {
  41647. height?: number;
  41648. diameterTop?: number;
  41649. diameterBottom?: number;
  41650. diameter?: number;
  41651. tessellation?: number;
  41652. subdivisions?: number;
  41653. arc?: number;
  41654. faceColors?: Color4[];
  41655. faceUV?: Vector4[];
  41656. updatable?: boolean;
  41657. hasRings?: boolean;
  41658. enclose?: boolean;
  41659. cap?: number;
  41660. sideOrientation?: number;
  41661. frontUVs?: Vector4;
  41662. backUVs?: Vector4;
  41663. }, scene: any): Mesh;
  41664. }
  41665. }
  41666. declare module BABYLON {
  41667. /**
  41668. * States of the webXR experience
  41669. */
  41670. export enum WebXRState {
  41671. /**
  41672. * Transitioning to being in XR mode
  41673. */
  41674. ENTERING_XR = 0,
  41675. /**
  41676. * Transitioning to non XR mode
  41677. */
  41678. EXITING_XR = 1,
  41679. /**
  41680. * In XR mode and presenting
  41681. */
  41682. IN_XR = 2,
  41683. /**
  41684. * Not entered XR mode
  41685. */
  41686. NOT_IN_XR = 3
  41687. }
  41688. /**
  41689. * Abstraction of the XR render target
  41690. */
  41691. export interface WebXRRenderTarget extends IDisposable {
  41692. /**
  41693. * xrpresent context of the canvas which can be used to display/mirror xr content
  41694. */
  41695. canvasContext: WebGLRenderingContext;
  41696. /**
  41697. * xr layer for the canvas
  41698. */
  41699. xrLayer: Nullable<XRWebGLLayer>;
  41700. /**
  41701. * Initializes the xr layer for the session
  41702. * @param xrSession xr session
  41703. * @returns a promise that will resolve once the XR Layer has been created
  41704. */
  41705. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  41706. }
  41707. }
  41708. declare module BABYLON {
  41709. /**
  41710. * COnfiguration object for WebXR output canvas
  41711. */
  41712. export class WebXRManagedOutputCanvasOptions {
  41713. /**
  41714. * Options for this XR Layer output
  41715. */
  41716. canvasOptions: XRWebGLLayerOptions;
  41717. /**
  41718. * CSS styling for a newly created canvas (if not provided)
  41719. */
  41720. newCanvasCssStyle?: string;
  41721. /**
  41722. * Get the default values of the configuration object
  41723. * @returns default values of this configuration object
  41724. */
  41725. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  41726. }
  41727. /**
  41728. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41729. */
  41730. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  41731. private configuration;
  41732. private _engine;
  41733. private _canvas;
  41734. /**
  41735. * xrpresent context of the canvas which can be used to display/mirror xr content
  41736. */
  41737. canvasContext: WebGLRenderingContext;
  41738. /**
  41739. * xr layer for the canvas
  41740. */
  41741. xrLayer: Nullable<XRWebGLLayer>;
  41742. /**
  41743. * Initializes the xr layer for the session
  41744. * @param xrSession xr session
  41745. * @returns a promise that will resolve once the XR Layer has been created
  41746. */
  41747. initializeXRLayerAsync(xrSession: any): any;
  41748. /**
  41749. * Initializes the canvas to be added/removed upon entering/exiting xr
  41750. * @param engine the Babylon engine
  41751. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41752. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  41753. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  41754. */
  41755. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  41756. /**
  41757. * Disposes of the object
  41758. */
  41759. dispose(): void;
  41760. private _setManagedOutputCanvas;
  41761. private _addCanvas;
  41762. private _removeCanvas;
  41763. }
  41764. }
  41765. declare module BABYLON {
  41766. /**
  41767. * Manages an XRSession to work with Babylon's engine
  41768. * @see https://doc.babylonjs.com/how_to/webxr
  41769. */
  41770. export class WebXRSessionManager implements IDisposable {
  41771. private scene;
  41772. /**
  41773. * Fires every time a new xrFrame arrives which can be used to update the camera
  41774. */
  41775. onXRFrameObservable: Observable<any>;
  41776. /**
  41777. * Fires when the xr session is ended either by the device or manually done
  41778. */
  41779. onXRSessionEnded: Observable<any>;
  41780. /**
  41781. * Underlying xr session
  41782. */
  41783. session: XRSession;
  41784. /**
  41785. * Type of reference space used when creating the session
  41786. */
  41787. referenceSpace: XRReferenceSpace;
  41788. /**
  41789. * Current XR frame
  41790. */
  41791. currentFrame: Nullable<XRFrame>;
  41792. private _xrNavigator;
  41793. private baseLayer;
  41794. private _rttProvider;
  41795. private _sessionEnded;
  41796. /**
  41797. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41798. * @param scene The scene which the session should be created for
  41799. */
  41800. constructor(scene: Scene);
  41801. /**
  41802. * Initializes the manager
  41803. * After initialization enterXR can be called to start an XR session
  41804. * @returns Promise which resolves after it is initialized
  41805. */
  41806. initializeAsync(): Promise<void>;
  41807. /**
  41808. * Initializes an xr session
  41809. * @param xrSessionMode mode to initialize
  41810. * @param optionalFeatures defines optional values to pass to the session builder
  41811. * @returns a promise which will resolve once the session has been initialized
  41812. */
  41813. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  41814. /**
  41815. * Sets the reference space on the xr session
  41816. * @param referenceSpace space to set
  41817. * @returns a promise that will resolve once the reference space has been set
  41818. */
  41819. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41820. /**
  41821. * Updates the render state of the session
  41822. * @param state state to set
  41823. * @returns a promise that resolves once the render state has been updated
  41824. */
  41825. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41826. /**
  41827. * Starts rendering to the xr layer
  41828. * @returns a promise that will resolve once rendering has started
  41829. */
  41830. startRenderingToXRAsync(): Promise<void>;
  41831. /**
  41832. * Gets the correct render target texture to be rendered this frame for this eye
  41833. * @param eye the eye for which to get the render target
  41834. * @returns the render target for the specified eye
  41835. */
  41836. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  41837. /**
  41838. * Stops the xrSession and restores the renderloop
  41839. * @returns Promise which resolves after it exits XR
  41840. */
  41841. exitXRAsync(): Promise<void>;
  41842. /**
  41843. * Checks if a session would be supported for the creation options specified
  41844. * @param sessionMode session mode to check if supported eg. immersive-vr
  41845. * @returns true if supported
  41846. */
  41847. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  41848. /**
  41849. * Creates a WebXRRenderTarget object for the XR session
  41850. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  41851. * @param options optional options to provide when creating a new render target
  41852. * @returns a WebXR render target to which the session can render
  41853. */
  41854. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  41855. /**
  41856. * @hidden
  41857. * Converts the render layer of xrSession to a render target
  41858. * @param session session to create render target for
  41859. * @param scene scene the new render target should be created for
  41860. */
  41861. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41862. /**
  41863. * Disposes of the session manager
  41864. */
  41865. dispose(): void;
  41866. /**
  41867. * Gets a promise returning true when fullfiled if the given session mode is supported
  41868. * @param sessionMode defines the session to test
  41869. * @returns a promise
  41870. */
  41871. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  41872. }
  41873. }
  41874. declare module BABYLON {
  41875. /**
  41876. * WebXR Camera which holds the views for the xrSession
  41877. * @see https://doc.babylonjs.com/how_to/webxr
  41878. */
  41879. export class WebXRCamera extends FreeCamera {
  41880. /**
  41881. * Is the camera in debug mode. Used when using an emulator
  41882. */
  41883. debugMode: boolean;
  41884. /**
  41885. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41886. * @param name the name of the camera
  41887. * @param scene the scene to add the camera to
  41888. */
  41889. constructor(name: string, scene: Scene);
  41890. private _updateNumberOfRigCameras;
  41891. /** @hidden */
  41892. _updateForDualEyeDebugging(): void;
  41893. /**
  41894. * Updates the cameras position from the current pose information of the XR session
  41895. * @param xrSessionManager the session containing pose information
  41896. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41897. */
  41898. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41899. }
  41900. }
  41901. declare module BABYLON {
  41902. /**
  41903. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41904. * @see https://doc.babylonjs.com/how_to/webxr
  41905. */
  41906. export class WebXRExperienceHelper implements IDisposable {
  41907. private scene;
  41908. /**
  41909. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  41910. */
  41911. container: AbstractMesh;
  41912. /**
  41913. * Camera used to render xr content
  41914. */
  41915. camera: WebXRCamera;
  41916. /**
  41917. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41918. */
  41919. state: WebXRState;
  41920. private _setState;
  41921. private static _TmpVector;
  41922. /**
  41923. * Fires when the state of the experience helper has changed
  41924. */
  41925. onStateChangedObservable: Observable<WebXRState>;
  41926. /** Session manager used to keep track of xr session */
  41927. sessionManager: WebXRSessionManager;
  41928. private _nonVRCamera;
  41929. private _originalSceneAutoClear;
  41930. private _supported;
  41931. /**
  41932. * Creates the experience helper
  41933. * @param scene the scene to attach the experience helper to
  41934. * @returns a promise for the experience helper
  41935. */
  41936. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41937. /**
  41938. * Creates a WebXRExperienceHelper
  41939. * @param scene The scene the helper should be created in
  41940. */
  41941. private constructor();
  41942. /**
  41943. * Exits XR mode and returns the scene to its original state
  41944. * @returns promise that resolves after xr mode has exited
  41945. */
  41946. exitXRAsync(): Promise<void>;
  41947. /**
  41948. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41949. * @param sessionMode options for the XR session
  41950. * @param referenceSpaceType frame of reference of the XR session
  41951. * @param renderTarget the output canvas that will be used to enter XR mode
  41952. * @returns promise that resolves after xr mode has entered
  41953. */
  41954. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  41955. /**
  41956. * Updates the global position of the camera by moving the camera's container
  41957. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41958. * @param position The desired global position of the camera
  41959. */
  41960. setPositionOfCameraUsingContainer(position: Vector3): void;
  41961. /**
  41962. * Rotates the xr camera by rotating the camera's container around the camera's position
  41963. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41964. * @param rotation the desired quaternion rotation to apply to the camera
  41965. */
  41966. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41967. /**
  41968. * Disposes of the experience helper
  41969. */
  41970. dispose(): void;
  41971. }
  41972. }
  41973. declare module BABYLON {
  41974. /**
  41975. * Represents an XR input
  41976. */
  41977. export class WebXRController {
  41978. private scene;
  41979. /** The underlying input source for the controller */
  41980. inputSource: XRInputSource;
  41981. private parentContainer;
  41982. /**
  41983. * 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
  41984. */
  41985. grip?: AbstractMesh;
  41986. /**
  41987. * Pointer which can be used to select objects or attach a visible laser to
  41988. */
  41989. pointer: AbstractMesh;
  41990. private _gamepadMode;
  41991. /**
  41992. * If available, this is the gamepad object related to this controller.
  41993. * Using this object it is possible to get click events and trackpad changes of the
  41994. * webxr controller that is currently being used.
  41995. */
  41996. gamepadController?: WebVRController;
  41997. /**
  41998. * Event that fires when the controller is removed/disposed
  41999. */
  42000. onDisposeObservable: Observable<{}>;
  42001. private _tmpQuaternion;
  42002. private _tmpVector;
  42003. /**
  42004. * Creates the controller
  42005. * @see https://doc.babylonjs.com/how_to/webxr
  42006. * @param scene the scene which the controller should be associated to
  42007. * @param inputSource the underlying input source for the controller
  42008. * @param parentContainer parent that the controller meshes should be children of
  42009. */
  42010. constructor(scene: Scene,
  42011. /** The underlying input source for the controller */
  42012. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42013. /**
  42014. * Updates the controller pose based on the given XRFrame
  42015. * @param xrFrame xr frame to update the pose with
  42016. * @param referenceSpace reference space to use
  42017. */
  42018. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42019. /**
  42020. * Gets a world space ray coming from the controller
  42021. * @param result the resulting ray
  42022. */
  42023. getWorldPointerRayToRef(result: Ray): void;
  42024. /**
  42025. * Get the scene associated with this controller
  42026. * @returns the scene object
  42027. */
  42028. getScene(): Scene;
  42029. /**
  42030. * Disposes of the object
  42031. */
  42032. dispose(): void;
  42033. }
  42034. }
  42035. declare module BABYLON {
  42036. /**
  42037. * XR input used to track XR inputs such as controllers/rays
  42038. */
  42039. export class WebXRInput implements IDisposable {
  42040. /**
  42041. * Base experience the input listens to
  42042. */
  42043. baseExperience: WebXRExperienceHelper;
  42044. /**
  42045. * XR controllers being tracked
  42046. */
  42047. controllers: Array<WebXRController>;
  42048. private _frameObserver;
  42049. private _stateObserver;
  42050. /**
  42051. * Event when a controller has been connected/added
  42052. */
  42053. onControllerAddedObservable: Observable<WebXRController>;
  42054. /**
  42055. * Event when a controller has been removed/disconnected
  42056. */
  42057. onControllerRemovedObservable: Observable<WebXRController>;
  42058. /**
  42059. * Initializes the WebXRInput
  42060. * @param baseExperience experience helper which the input should be created for
  42061. */
  42062. constructor(
  42063. /**
  42064. * Base experience the input listens to
  42065. */
  42066. baseExperience: WebXRExperienceHelper);
  42067. private _onInputSourcesChange;
  42068. private _addAndRemoveControllers;
  42069. /**
  42070. * Disposes of the object
  42071. */
  42072. dispose(): void;
  42073. }
  42074. }
  42075. declare module BABYLON {
  42076. /**
  42077. * Class used to represent data loading progression
  42078. */
  42079. export class SceneLoaderProgressEvent {
  42080. /** defines if data length to load can be evaluated */
  42081. readonly lengthComputable: boolean;
  42082. /** defines the loaded data length */
  42083. readonly loaded: number;
  42084. /** defines the data length to load */
  42085. readonly total: number;
  42086. /**
  42087. * Create a new progress event
  42088. * @param lengthComputable defines if data length to load can be evaluated
  42089. * @param loaded defines the loaded data length
  42090. * @param total defines the data length to load
  42091. */
  42092. constructor(
  42093. /** defines if data length to load can be evaluated */
  42094. lengthComputable: boolean,
  42095. /** defines the loaded data length */
  42096. loaded: number,
  42097. /** defines the data length to load */
  42098. total: number);
  42099. /**
  42100. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42101. * @param event defines the source event
  42102. * @returns a new SceneLoaderProgressEvent
  42103. */
  42104. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42105. }
  42106. /**
  42107. * Interface used by SceneLoader plugins to define supported file extensions
  42108. */
  42109. export interface ISceneLoaderPluginExtensions {
  42110. /**
  42111. * Defines the list of supported extensions
  42112. */
  42113. [extension: string]: {
  42114. isBinary: boolean;
  42115. };
  42116. }
  42117. /**
  42118. * Interface used by SceneLoader plugin factory
  42119. */
  42120. export interface ISceneLoaderPluginFactory {
  42121. /**
  42122. * Defines the name of the factory
  42123. */
  42124. name: string;
  42125. /**
  42126. * Function called to create a new plugin
  42127. * @return the new plugin
  42128. */
  42129. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42130. /**
  42131. * The callback that returns true if the data can be directly loaded.
  42132. * @param data string containing the file data
  42133. * @returns if the data can be loaded directly
  42134. */
  42135. canDirectLoad?(data: string): boolean;
  42136. }
  42137. /**
  42138. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  42139. */
  42140. export interface ISceneLoaderPluginBase {
  42141. /**
  42142. * The friendly name of this plugin.
  42143. */
  42144. name: string;
  42145. /**
  42146. * The file extensions supported by this plugin.
  42147. */
  42148. extensions: string | ISceneLoaderPluginExtensions;
  42149. /**
  42150. * The callback called when loading from a url.
  42151. * @param scene scene loading this url
  42152. * @param url url to load
  42153. * @param onSuccess callback called when the file successfully loads
  42154. * @param onProgress callback called while file is loading (if the server supports this mode)
  42155. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42156. * @param onError callback called when the file fails to load
  42157. * @returns a file request object
  42158. */
  42159. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42160. /**
  42161. * The callback called when loading from a file object.
  42162. * @param scene scene loading this file
  42163. * @param file defines the file to load
  42164. * @param onSuccess defines the callback to call when data is loaded
  42165. * @param onProgress defines the callback to call during loading process
  42166. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42167. * @param onError defines the callback to call when an error occurs
  42168. * @returns a file request object
  42169. */
  42170. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42171. /**
  42172. * The callback that returns true if the data can be directly loaded.
  42173. * @param data string containing the file data
  42174. * @returns if the data can be loaded directly
  42175. */
  42176. canDirectLoad?(data: string): boolean;
  42177. /**
  42178. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  42179. * @param scene scene loading this data
  42180. * @param data string containing the data
  42181. * @returns data to pass to the plugin
  42182. */
  42183. directLoad?(scene: Scene, data: string): any;
  42184. /**
  42185. * The callback that allows custom handling of the root url based on the response url.
  42186. * @param rootUrl the original root url
  42187. * @param responseURL the response url if available
  42188. * @returns the new root url
  42189. */
  42190. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  42191. }
  42192. /**
  42193. * Interface used to define a SceneLoader plugin
  42194. */
  42195. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  42196. /**
  42197. * Import meshes into a scene.
  42198. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42199. * @param scene The scene to import into
  42200. * @param data The data to import
  42201. * @param rootUrl The root url for scene and resources
  42202. * @param meshes The meshes array to import into
  42203. * @param particleSystems The particle systems array to import into
  42204. * @param skeletons The skeletons array to import into
  42205. * @param onError The callback when import fails
  42206. * @returns True if successful or false otherwise
  42207. */
  42208. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42209. /**
  42210. * Load into a scene.
  42211. * @param scene The scene to load into
  42212. * @param data The data to import
  42213. * @param rootUrl The root url for scene and resources
  42214. * @param onError The callback when import fails
  42215. * @returns True if successful or false otherwise
  42216. */
  42217. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42218. /**
  42219. * Load into an asset container.
  42220. * @param scene The scene to load into
  42221. * @param data The data to import
  42222. * @param rootUrl The root url for scene and resources
  42223. * @param onError The callback when import fails
  42224. * @returns The loaded asset container
  42225. */
  42226. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42227. }
  42228. /**
  42229. * Interface used to define an async SceneLoader plugin
  42230. */
  42231. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  42232. /**
  42233. * Import meshes into a scene.
  42234. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42235. * @param scene The scene to import into
  42236. * @param data The data to import
  42237. * @param rootUrl The root url for scene and resources
  42238. * @param onProgress The callback when the load progresses
  42239. * @param fileName Defines the name of the file to load
  42240. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42241. */
  42242. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42243. meshes: AbstractMesh[];
  42244. particleSystems: IParticleSystem[];
  42245. skeletons: Skeleton[];
  42246. animationGroups: AnimationGroup[];
  42247. }>;
  42248. /**
  42249. * Load into a scene.
  42250. * @param scene The scene to load into
  42251. * @param data The data to import
  42252. * @param rootUrl The root url for scene and resources
  42253. * @param onProgress The callback when the load progresses
  42254. * @param fileName Defines the name of the file to load
  42255. * @returns Nothing
  42256. */
  42257. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42258. /**
  42259. * Load into an asset container.
  42260. * @param scene The scene to load into
  42261. * @param data The data to import
  42262. * @param rootUrl The root url for scene and resources
  42263. * @param onProgress The callback when the load progresses
  42264. * @param fileName Defines the name of the file to load
  42265. * @returns The loaded asset container
  42266. */
  42267. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42268. }
  42269. /**
  42270. * Class used to load scene from various file formats using registered plugins
  42271. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42272. */
  42273. export class SceneLoader {
  42274. /**
  42275. * No logging while loading
  42276. */
  42277. static readonly NO_LOGGING: number;
  42278. /**
  42279. * Minimal logging while loading
  42280. */
  42281. static readonly MINIMAL_LOGGING: number;
  42282. /**
  42283. * Summary logging while loading
  42284. */
  42285. static readonly SUMMARY_LOGGING: number;
  42286. /**
  42287. * Detailled logging while loading
  42288. */
  42289. static readonly DETAILED_LOGGING: number;
  42290. /**
  42291. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42292. */
  42293. static ForceFullSceneLoadingForIncremental: boolean;
  42294. /**
  42295. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42296. */
  42297. static ShowLoadingScreen: boolean;
  42298. /**
  42299. * Defines the current logging level (while loading the scene)
  42300. * @ignorenaming
  42301. */
  42302. static loggingLevel: number;
  42303. /**
  42304. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42305. */
  42306. static CleanBoneMatrixWeights: boolean;
  42307. /**
  42308. * Event raised when a plugin is used to load a scene
  42309. */
  42310. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42311. private static _registeredPlugins;
  42312. private static _getDefaultPlugin;
  42313. private static _getPluginForExtension;
  42314. private static _getPluginForDirectLoad;
  42315. private static _getPluginForFilename;
  42316. private static _getDirectLoad;
  42317. private static _loadData;
  42318. private static _getFileInfo;
  42319. /**
  42320. * Gets a plugin that can load the given extension
  42321. * @param extension defines the extension to load
  42322. * @returns a plugin or null if none works
  42323. */
  42324. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42325. /**
  42326. * Gets a boolean indicating that the given extension can be loaded
  42327. * @param extension defines the extension to load
  42328. * @returns true if the extension is supported
  42329. */
  42330. static IsPluginForExtensionAvailable(extension: string): boolean;
  42331. /**
  42332. * Adds a new plugin to the list of registered plugins
  42333. * @param plugin defines the plugin to add
  42334. */
  42335. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42336. /**
  42337. * Import meshes into a scene
  42338. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42339. * @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)
  42340. * @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)
  42341. * @param scene the instance of BABYLON.Scene to append to
  42342. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42343. * @param onProgress a callback with a progress event for each file being loaded
  42344. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42345. * @param pluginExtension the extension used to determine the plugin
  42346. * @returns The loaded plugin
  42347. */
  42348. 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>;
  42349. /**
  42350. * Import meshes into a scene
  42351. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42352. * @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)
  42353. * @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)
  42354. * @param scene the instance of BABYLON.Scene to append to
  42355. * @param onProgress a callback with a progress event for each file being loaded
  42356. * @param pluginExtension the extension used to determine the plugin
  42357. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42358. */
  42359. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42360. meshes: AbstractMesh[];
  42361. particleSystems: IParticleSystem[];
  42362. skeletons: Skeleton[];
  42363. animationGroups: AnimationGroup[];
  42364. }>;
  42365. /**
  42366. * Load a scene
  42367. * @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)
  42368. * @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)
  42369. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42370. * @param onSuccess a callback with the scene when import succeeds
  42371. * @param onProgress a callback with a progress event for each file being loaded
  42372. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42373. * @param pluginExtension the extension used to determine the plugin
  42374. * @returns The loaded plugin
  42375. */
  42376. 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>;
  42377. /**
  42378. * Load a scene
  42379. * @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)
  42380. * @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)
  42381. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42382. * @param onProgress a callback with a progress event for each file being loaded
  42383. * @param pluginExtension the extension used to determine the plugin
  42384. * @returns The loaded scene
  42385. */
  42386. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42387. /**
  42388. * Append a scene
  42389. * @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)
  42390. * @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)
  42391. * @param scene is the instance of BABYLON.Scene to append to
  42392. * @param onSuccess a callback with the scene when import succeeds
  42393. * @param onProgress a callback with a progress event for each file being loaded
  42394. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42395. * @param pluginExtension the extension used to determine the plugin
  42396. * @returns The loaded plugin
  42397. */
  42398. 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>;
  42399. /**
  42400. * Append a scene
  42401. * @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)
  42402. * @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)
  42403. * @param scene is the instance of BABYLON.Scene to append to
  42404. * @param onProgress a callback with a progress event for each file being loaded
  42405. * @param pluginExtension the extension used to determine the plugin
  42406. * @returns The given scene
  42407. */
  42408. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42409. /**
  42410. * Load a scene into an asset container
  42411. * @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)
  42412. * @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)
  42413. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42414. * @param onSuccess a callback with the scene when import succeeds
  42415. * @param onProgress a callback with a progress event for each file being loaded
  42416. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42417. * @param pluginExtension the extension used to determine the plugin
  42418. * @returns The loaded plugin
  42419. */
  42420. 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>;
  42421. /**
  42422. * Load a scene into an asset container
  42423. * @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)
  42424. * @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)
  42425. * @param scene is the instance of Scene to append to
  42426. * @param onProgress a callback with a progress event for each file being loaded
  42427. * @param pluginExtension the extension used to determine the plugin
  42428. * @returns The loaded asset container
  42429. */
  42430. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42431. }
  42432. }
  42433. declare module BABYLON {
  42434. /**
  42435. * Generic Controller
  42436. */
  42437. export class GenericController extends WebVRController {
  42438. /**
  42439. * Base Url for the controller model.
  42440. */
  42441. static readonly MODEL_BASE_URL: string;
  42442. /**
  42443. * File name for the controller model.
  42444. */
  42445. static readonly MODEL_FILENAME: string;
  42446. /**
  42447. * Creates a new GenericController from a gamepad
  42448. * @param vrGamepad the gamepad that the controller should be created from
  42449. */
  42450. constructor(vrGamepad: any);
  42451. /**
  42452. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42453. * @param scene scene in which to add meshes
  42454. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42455. */
  42456. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42457. /**
  42458. * Called once for each button that changed state since the last frame
  42459. * @param buttonIdx Which button index changed
  42460. * @param state New state of the button
  42461. * @param changes Which properties on the state changed since last frame
  42462. */
  42463. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42464. }
  42465. }
  42466. declare module BABYLON {
  42467. /**
  42468. * Defines the WindowsMotionController object that the state of the windows motion controller
  42469. */
  42470. export class WindowsMotionController extends WebVRController {
  42471. /**
  42472. * The base url used to load the left and right controller models
  42473. */
  42474. static MODEL_BASE_URL: string;
  42475. /**
  42476. * The name of the left controller model file
  42477. */
  42478. static MODEL_LEFT_FILENAME: string;
  42479. /**
  42480. * The name of the right controller model file
  42481. */
  42482. static MODEL_RIGHT_FILENAME: string;
  42483. /**
  42484. * The controller name prefix for this controller type
  42485. */
  42486. static readonly GAMEPAD_ID_PREFIX: string;
  42487. /**
  42488. * The controller id pattern for this controller type
  42489. */
  42490. private static readonly GAMEPAD_ID_PATTERN;
  42491. private _loadedMeshInfo;
  42492. protected readonly _mapping: {
  42493. buttons: string[];
  42494. buttonMeshNames: {
  42495. 'trigger': string;
  42496. 'menu': string;
  42497. 'grip': string;
  42498. 'thumbstick': string;
  42499. 'trackpad': string;
  42500. };
  42501. buttonObservableNames: {
  42502. 'trigger': string;
  42503. 'menu': string;
  42504. 'grip': string;
  42505. 'thumbstick': string;
  42506. 'trackpad': string;
  42507. };
  42508. axisMeshNames: string[];
  42509. pointingPoseMeshName: string;
  42510. };
  42511. /**
  42512. * Fired when the trackpad on this controller is clicked
  42513. */
  42514. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42515. /**
  42516. * Fired when the trackpad on this controller is modified
  42517. */
  42518. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42519. /**
  42520. * The current x and y values of this controller's trackpad
  42521. */
  42522. trackpad: StickValues;
  42523. /**
  42524. * Creates a new WindowsMotionController from a gamepad
  42525. * @param vrGamepad the gamepad that the controller should be created from
  42526. */
  42527. constructor(vrGamepad: any);
  42528. /**
  42529. * Fired when the trigger on this controller is modified
  42530. */
  42531. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42532. /**
  42533. * Fired when the menu button on this controller is modified
  42534. */
  42535. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42536. /**
  42537. * Fired when the grip button on this controller is modified
  42538. */
  42539. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42540. /**
  42541. * Fired when the thumbstick button on this controller is modified
  42542. */
  42543. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42544. /**
  42545. * Fired when the touchpad button on this controller is modified
  42546. */
  42547. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42548. /**
  42549. * Fired when the touchpad values on this controller are modified
  42550. */
  42551. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42552. protected _updateTrackpad(): void;
  42553. /**
  42554. * Called once per frame by the engine.
  42555. */
  42556. update(): void;
  42557. /**
  42558. * Called once for each button that changed state since the last frame
  42559. * @param buttonIdx Which button index changed
  42560. * @param state New state of the button
  42561. * @param changes Which properties on the state changed since last frame
  42562. */
  42563. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42564. /**
  42565. * Moves the buttons on the controller mesh based on their current state
  42566. * @param buttonName the name of the button to move
  42567. * @param buttonValue the value of the button which determines the buttons new position
  42568. */
  42569. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42570. /**
  42571. * Moves the axis on the controller mesh based on its current state
  42572. * @param axis the index of the axis
  42573. * @param axisValue the value of the axis which determines the meshes new position
  42574. * @hidden
  42575. */
  42576. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42577. /**
  42578. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42579. * @param scene scene in which to add meshes
  42580. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42581. */
  42582. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42583. /**
  42584. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42585. * can be transformed by button presses and axes values, based on this._mapping.
  42586. *
  42587. * @param scene scene in which the meshes exist
  42588. * @param meshes list of meshes that make up the controller model to process
  42589. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42590. */
  42591. private processModel;
  42592. private createMeshInfo;
  42593. /**
  42594. * Gets the ray of the controller in the direction the controller is pointing
  42595. * @param length the length the resulting ray should be
  42596. * @returns a ray in the direction the controller is pointing
  42597. */
  42598. getForwardRay(length?: number): Ray;
  42599. /**
  42600. * Disposes of the controller
  42601. */
  42602. dispose(): void;
  42603. }
  42604. /**
  42605. * This class represents a new windows motion controller in XR.
  42606. */
  42607. export class XRWindowsMotionController extends WindowsMotionController {
  42608. /**
  42609. * Changing the original WIndowsMotionController mapping to fir the new mapping
  42610. */
  42611. protected readonly _mapping: {
  42612. buttons: string[];
  42613. buttonMeshNames: {
  42614. 'trigger': string;
  42615. 'menu': string;
  42616. 'grip': string;
  42617. 'thumbstick': string;
  42618. 'trackpad': string;
  42619. };
  42620. buttonObservableNames: {
  42621. 'trigger': string;
  42622. 'menu': string;
  42623. 'grip': string;
  42624. 'thumbstick': string;
  42625. 'trackpad': string;
  42626. };
  42627. axisMeshNames: string[];
  42628. pointingPoseMeshName: string;
  42629. };
  42630. /**
  42631. * Construct a new XR-Based windows motion controller
  42632. *
  42633. * @param gamepadInfo the gamepad object from the browser
  42634. */
  42635. constructor(gamepadInfo: any);
  42636. /**
  42637. * holds the thumbstick values (X,Y)
  42638. */
  42639. readonly thumbstickValues: StickValues;
  42640. /**
  42641. * Fired when the thumbstick on this controller is clicked
  42642. */
  42643. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  42644. /**
  42645. * Fired when the thumbstick on this controller is modified
  42646. */
  42647. onThumbstickValuesChangedObservable: Observable<StickValues>;
  42648. /**
  42649. * Fired when the touchpad button on this controller is modified
  42650. */
  42651. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42652. /**
  42653. * Fired when the touchpad values on this controller are modified
  42654. */
  42655. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42656. /**
  42657. * Fired when the thumbstick button on this controller is modified
  42658. * here to prevent breaking changes
  42659. */
  42660. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42661. /**
  42662. * updating the thumbstick(!) and not the trackpad.
  42663. * This is named this way due to the difference between WebVR and XR and to avoid
  42664. * changing the parent class.
  42665. */
  42666. protected _updateTrackpad(): void;
  42667. /**
  42668. * Disposes the class with joy
  42669. */
  42670. dispose(): void;
  42671. }
  42672. }
  42673. declare module BABYLON {
  42674. /**
  42675. * Oculus Touch Controller
  42676. */
  42677. export class OculusTouchController extends WebVRController {
  42678. /**
  42679. * Base Url for the controller model.
  42680. */
  42681. static MODEL_BASE_URL: string;
  42682. /**
  42683. * File name for the left controller model.
  42684. */
  42685. static MODEL_LEFT_FILENAME: string;
  42686. /**
  42687. * File name for the right controller model.
  42688. */
  42689. static MODEL_RIGHT_FILENAME: string;
  42690. /**
  42691. * Base Url for the Quest controller model.
  42692. */
  42693. static QUEST_MODEL_BASE_URL: string;
  42694. /**
  42695. * @hidden
  42696. * If the controllers are running on a device that needs the updated Quest controller models
  42697. */
  42698. static _IsQuest: boolean;
  42699. /**
  42700. * Fired when the secondary trigger on this controller is modified
  42701. */
  42702. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42703. /**
  42704. * Fired when the thumb rest on this controller is modified
  42705. */
  42706. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42707. /**
  42708. * Creates a new OculusTouchController from a gamepad
  42709. * @param vrGamepad the gamepad that the controller should be created from
  42710. */
  42711. constructor(vrGamepad: any);
  42712. /**
  42713. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42714. * @param scene scene in which to add meshes
  42715. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42716. */
  42717. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42718. /**
  42719. * Fired when the A button on this controller is modified
  42720. */
  42721. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42722. /**
  42723. * Fired when the B button on this controller is modified
  42724. */
  42725. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42726. /**
  42727. * Fired when the X button on this controller is modified
  42728. */
  42729. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42730. /**
  42731. * Fired when the Y button on this controller is modified
  42732. */
  42733. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42734. /**
  42735. * Called once for each button that changed state since the last frame
  42736. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42737. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42738. * 2) secondary trigger (same)
  42739. * 3) A (right) X (left), touch, pressed = value
  42740. * 4) B / Y
  42741. * 5) thumb rest
  42742. * @param buttonIdx Which button index changed
  42743. * @param state New state of the button
  42744. * @param changes Which properties on the state changed since last frame
  42745. */
  42746. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42747. }
  42748. }
  42749. declare module BABYLON {
  42750. /**
  42751. * Vive Controller
  42752. */
  42753. export class ViveController extends WebVRController {
  42754. /**
  42755. * Base Url for the controller model.
  42756. */
  42757. static MODEL_BASE_URL: string;
  42758. /**
  42759. * File name for the controller model.
  42760. */
  42761. static MODEL_FILENAME: string;
  42762. /**
  42763. * Creates a new ViveController from a gamepad
  42764. * @param vrGamepad the gamepad that the controller should be created from
  42765. */
  42766. constructor(vrGamepad: any);
  42767. /**
  42768. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42769. * @param scene scene in which to add meshes
  42770. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42771. */
  42772. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42773. /**
  42774. * Fired when the left button on this controller is modified
  42775. */
  42776. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42777. /**
  42778. * Fired when the right button on this controller is modified
  42779. */
  42780. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42781. /**
  42782. * Fired when the menu button on this controller is modified
  42783. */
  42784. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42785. /**
  42786. * Called once for each button that changed state since the last frame
  42787. * Vive mapping:
  42788. * 0: touchpad
  42789. * 1: trigger
  42790. * 2: left AND right buttons
  42791. * 3: menu button
  42792. * @param buttonIdx Which button index changed
  42793. * @param state New state of the button
  42794. * @param changes Which properties on the state changed since last frame
  42795. */
  42796. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42797. }
  42798. }
  42799. declare module BABYLON {
  42800. /**
  42801. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42802. */
  42803. export class WebXRControllerModelLoader {
  42804. /**
  42805. * an observable that triggers when a new model (the mesh itself) was initialized.
  42806. * To know when the mesh was loaded use the controller's own modelLoaded() method
  42807. */
  42808. onControllerModelLoaded: Observable<WebXRController>;
  42809. /**
  42810. * Creates the WebXRControllerModelLoader
  42811. * @param input xr input that creates the controllers
  42812. */
  42813. constructor(input: WebXRInput);
  42814. }
  42815. }
  42816. declare module BABYLON {
  42817. /**
  42818. * Handles pointer input automatically for the pointer of XR controllers
  42819. */
  42820. export class WebXRControllerPointerSelection {
  42821. private static _idCounter;
  42822. private _tmpRay;
  42823. /**
  42824. * Creates a WebXRControllerPointerSelection
  42825. * @param input input manager to setup pointer selection
  42826. */
  42827. constructor(input: WebXRInput);
  42828. private _convertNormalToDirectionOfRay;
  42829. private _updatePointerDistance;
  42830. }
  42831. }
  42832. declare module BABYLON {
  42833. /**
  42834. * Enables teleportation
  42835. */
  42836. export class WebXRControllerTeleportation {
  42837. private _teleportationFillColor;
  42838. private _teleportationBorderColor;
  42839. private _tmpRay;
  42840. private _tmpVector;
  42841. /**
  42842. * Creates a WebXRControllerTeleportation
  42843. * @param input input manager to add teleportation to
  42844. * @param floorMeshes floormeshes which can be teleported to
  42845. */
  42846. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  42847. }
  42848. }
  42849. declare module BABYLON {
  42850. /**
  42851. * Button which can be used to enter a different mode of XR
  42852. */
  42853. export class WebXREnterExitUIButton {
  42854. /** button element */
  42855. element: HTMLElement;
  42856. /** XR initialization options for the button */
  42857. sessionMode: XRSessionMode;
  42858. /** Reference space type */
  42859. referenceSpaceType: XRReferenceSpaceType;
  42860. /**
  42861. * Creates a WebXREnterExitUIButton
  42862. * @param element button element
  42863. * @param sessionMode XR initialization session mode
  42864. * @param referenceSpaceType the type of reference space to be used
  42865. */
  42866. constructor(
  42867. /** button element */
  42868. element: HTMLElement,
  42869. /** XR initialization options for the button */
  42870. sessionMode: XRSessionMode,
  42871. /** Reference space type */
  42872. referenceSpaceType: XRReferenceSpaceType);
  42873. /**
  42874. * Overwritable function which can be used to update the button's visuals when the state changes
  42875. * @param activeButton the current active button in the UI
  42876. */
  42877. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42878. }
  42879. /**
  42880. * Options to create the webXR UI
  42881. */
  42882. export class WebXREnterExitUIOptions {
  42883. /**
  42884. * Context to enter xr with
  42885. */
  42886. renderTarget?: Nullable<WebXRRenderTarget>;
  42887. /**
  42888. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42889. */
  42890. customButtons?: Array<WebXREnterExitUIButton>;
  42891. /**
  42892. * A session mode to use when creating the default button.
  42893. * Default is immersive-vr
  42894. */
  42895. sessionMode?: XRSessionMode;
  42896. /**
  42897. * A reference space type to use when creating the default button.
  42898. * Default is local-floor
  42899. */
  42900. referenceSpaceType?: XRReferenceSpaceType;
  42901. }
  42902. /**
  42903. * UI to allow the user to enter/exit XR mode
  42904. */
  42905. export class WebXREnterExitUI implements IDisposable {
  42906. private scene;
  42907. private _overlay;
  42908. private _buttons;
  42909. private _activeButton;
  42910. /**
  42911. * Fired every time the active button is changed.
  42912. *
  42913. * When xr is entered via a button that launches xr that button will be the callback parameter
  42914. *
  42915. * When exiting xr the callback parameter will be null)
  42916. */
  42917. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42918. /**
  42919. * Creates UI to allow the user to enter/exit XR mode
  42920. * @param scene the scene to add the ui to
  42921. * @param helper the xr experience helper to enter/exit xr with
  42922. * @param options options to configure the UI
  42923. * @returns the created ui
  42924. */
  42925. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42926. private constructor();
  42927. private _updateButtons;
  42928. /**
  42929. * Disposes of the object
  42930. */
  42931. dispose(): void;
  42932. }
  42933. }
  42934. declare module BABYLON {
  42935. /**
  42936. * Options for the default xr helper
  42937. */
  42938. export class WebXRDefaultExperienceOptions {
  42939. /**
  42940. * Floor meshes that should be used for teleporting
  42941. */
  42942. floorMeshes: Array<AbstractMesh>;
  42943. /**
  42944. * Enable or disable default UI to enter XR
  42945. */
  42946. disableDefaultUI?: boolean;
  42947. /**
  42948. * optional configuration for the output canvas
  42949. */
  42950. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  42951. }
  42952. /**
  42953. * Default experience which provides a similar setup to the previous webVRExperience
  42954. */
  42955. export class WebXRDefaultExperience {
  42956. /**
  42957. * Base experience
  42958. */
  42959. baseExperience: WebXRExperienceHelper;
  42960. /**
  42961. * Input experience extension
  42962. */
  42963. input: WebXRInput;
  42964. /**
  42965. * Loads the controller models
  42966. */
  42967. controllerModelLoader: WebXRControllerModelLoader;
  42968. /**
  42969. * Enables laser pointer and selection
  42970. */
  42971. pointerSelection: WebXRControllerPointerSelection;
  42972. /**
  42973. * Enables teleportation
  42974. */
  42975. teleportation: WebXRControllerTeleportation;
  42976. /**
  42977. * Enables ui for enetering/exiting xr
  42978. */
  42979. enterExitUI: WebXREnterExitUI;
  42980. /**
  42981. * Default target xr should render to
  42982. */
  42983. renderTarget: WebXRRenderTarget;
  42984. /**
  42985. * Creates the default xr experience
  42986. * @param scene scene
  42987. * @param options options for basic configuration
  42988. * @returns resulting WebXRDefaultExperience
  42989. */
  42990. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  42991. private constructor();
  42992. /**
  42993. * DIsposes of the experience helper
  42994. */
  42995. dispose(): void;
  42996. }
  42997. }
  42998. declare module BABYLON {
  42999. /**
  43000. * Options to modify the vr teleportation behavior.
  43001. */
  43002. export interface VRTeleportationOptions {
  43003. /**
  43004. * The name of the mesh which should be used as the teleportation floor. (default: null)
  43005. */
  43006. floorMeshName?: string;
  43007. /**
  43008. * A list of meshes to be used as the teleportation floor. (default: empty)
  43009. */
  43010. floorMeshes?: Mesh[];
  43011. /**
  43012. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  43013. */
  43014. teleportationMode?: number;
  43015. /**
  43016. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  43017. */
  43018. teleportationTime?: number;
  43019. /**
  43020. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  43021. */
  43022. teleportationSpeed?: number;
  43023. /**
  43024. * The easing function used in the animation or null for Linear. (default CircleEase)
  43025. */
  43026. easingFunction?: EasingFunction;
  43027. }
  43028. /**
  43029. * Options to modify the vr experience helper's behavior.
  43030. */
  43031. export interface VRExperienceHelperOptions extends WebVROptions {
  43032. /**
  43033. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  43034. */
  43035. createDeviceOrientationCamera?: boolean;
  43036. /**
  43037. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  43038. */
  43039. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  43040. /**
  43041. * Uses the main button on the controller to toggle the laser casted. (default: true)
  43042. */
  43043. laserToggle?: boolean;
  43044. /**
  43045. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  43046. */
  43047. floorMeshes?: Mesh[];
  43048. /**
  43049. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  43050. */
  43051. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  43052. /**
  43053. * Defines if WebXR should be used instead of WebVR (if available)
  43054. */
  43055. useXR?: boolean;
  43056. }
  43057. /**
  43058. * Event containing information after VR has been entered
  43059. */
  43060. export class OnAfterEnteringVRObservableEvent {
  43061. /**
  43062. * If entering vr was successful
  43063. */
  43064. success: boolean;
  43065. }
  43066. /**
  43067. * Helps to quickly add VR support to an existing scene.
  43068. * See http://doc.babylonjs.com/how_to/webvr_helper
  43069. */
  43070. export class VRExperienceHelper {
  43071. /** Options to modify the vr experience helper's behavior. */
  43072. webVROptions: VRExperienceHelperOptions;
  43073. private _scene;
  43074. private _position;
  43075. private _btnVR;
  43076. private _btnVRDisplayed;
  43077. private _webVRsupported;
  43078. private _webVRready;
  43079. private _webVRrequesting;
  43080. private _webVRpresenting;
  43081. private _hasEnteredVR;
  43082. private _fullscreenVRpresenting;
  43083. private _inputElement;
  43084. private _webVRCamera;
  43085. private _vrDeviceOrientationCamera;
  43086. private _deviceOrientationCamera;
  43087. private _existingCamera;
  43088. private _onKeyDown;
  43089. private _onVrDisplayPresentChange;
  43090. private _onVRDisplayChanged;
  43091. private _onVRRequestPresentStart;
  43092. private _onVRRequestPresentComplete;
  43093. /**
  43094. * 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)
  43095. */
  43096. enableGazeEvenWhenNoPointerLock: boolean;
  43097. /**
  43098. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  43099. */
  43100. exitVROnDoubleTap: boolean;
  43101. /**
  43102. * Observable raised right before entering VR.
  43103. */
  43104. onEnteringVRObservable: Observable<VRExperienceHelper>;
  43105. /**
  43106. * Observable raised when entering VR has completed.
  43107. */
  43108. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  43109. /**
  43110. * Observable raised when exiting VR.
  43111. */
  43112. onExitingVRObservable: Observable<VRExperienceHelper>;
  43113. /**
  43114. * Observable raised when controller mesh is loaded.
  43115. */
  43116. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43117. /** Return this.onEnteringVRObservable
  43118. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  43119. */
  43120. readonly onEnteringVR: Observable<VRExperienceHelper>;
  43121. /** Return this.onExitingVRObservable
  43122. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  43123. */
  43124. readonly onExitingVR: Observable<VRExperienceHelper>;
  43125. /** Return this.onControllerMeshLoadedObservable
  43126. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  43127. */
  43128. readonly onControllerMeshLoaded: Observable<WebVRController>;
  43129. private _rayLength;
  43130. private _useCustomVRButton;
  43131. private _teleportationRequested;
  43132. private _teleportActive;
  43133. private _floorMeshName;
  43134. private _floorMeshesCollection;
  43135. private _teleportationMode;
  43136. private _teleportationTime;
  43137. private _teleportationSpeed;
  43138. private _teleportationEasing;
  43139. private _rotationAllowed;
  43140. private _teleportBackwardsVector;
  43141. private _teleportationTarget;
  43142. private _isDefaultTeleportationTarget;
  43143. private _postProcessMove;
  43144. private _teleportationFillColor;
  43145. private _teleportationBorderColor;
  43146. private _rotationAngle;
  43147. private _haloCenter;
  43148. private _cameraGazer;
  43149. private _padSensibilityUp;
  43150. private _padSensibilityDown;
  43151. private _leftController;
  43152. private _rightController;
  43153. /**
  43154. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  43155. */
  43156. onNewMeshSelected: Observable<AbstractMesh>;
  43157. /**
  43158. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  43159. * This observable will provide the mesh and the controller used to select the mesh
  43160. */
  43161. onMeshSelectedWithController: Observable<{
  43162. mesh: AbstractMesh;
  43163. controller: WebVRController;
  43164. }>;
  43165. /**
  43166. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  43167. */
  43168. onNewMeshPicked: Observable<PickingInfo>;
  43169. private _circleEase;
  43170. /**
  43171. * Observable raised before camera teleportation
  43172. */
  43173. onBeforeCameraTeleport: Observable<Vector3>;
  43174. /**
  43175. * Observable raised after camera teleportation
  43176. */
  43177. onAfterCameraTeleport: Observable<Vector3>;
  43178. /**
  43179. * Observable raised when current selected mesh gets unselected
  43180. */
  43181. onSelectedMeshUnselected: Observable<AbstractMesh>;
  43182. private _raySelectionPredicate;
  43183. /**
  43184. * To be optionaly changed by user to define custom ray selection
  43185. */
  43186. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  43187. /**
  43188. * To be optionaly changed by user to define custom selection logic (after ray selection)
  43189. */
  43190. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43191. /**
  43192. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  43193. */
  43194. teleportationEnabled: boolean;
  43195. private _defaultHeight;
  43196. private _teleportationInitialized;
  43197. private _interactionsEnabled;
  43198. private _interactionsRequested;
  43199. private _displayGaze;
  43200. private _displayLaserPointer;
  43201. /**
  43202. * The mesh used to display where the user is going to teleport.
  43203. */
  43204. /**
  43205. * Sets the mesh to be used to display where the user is going to teleport.
  43206. */
  43207. teleportationTarget: Mesh;
  43208. /**
  43209. * 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
  43210. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  43211. * See http://doc.babylonjs.com/resources/baking_transformations
  43212. */
  43213. gazeTrackerMesh: Mesh;
  43214. /**
  43215. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  43216. */
  43217. updateGazeTrackerScale: boolean;
  43218. /**
  43219. * If the gaze trackers color should be updated when selecting meshes
  43220. */
  43221. updateGazeTrackerColor: boolean;
  43222. /**
  43223. * If the controller laser color should be updated when selecting meshes
  43224. */
  43225. updateControllerLaserColor: boolean;
  43226. /**
  43227. * The gaze tracking mesh corresponding to the left controller
  43228. */
  43229. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  43230. /**
  43231. * The gaze tracking mesh corresponding to the right controller
  43232. */
  43233. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  43234. /**
  43235. * If the ray of the gaze should be displayed.
  43236. */
  43237. /**
  43238. * Sets if the ray of the gaze should be displayed.
  43239. */
  43240. displayGaze: boolean;
  43241. /**
  43242. * If the ray of the LaserPointer should be displayed.
  43243. */
  43244. /**
  43245. * Sets if the ray of the LaserPointer should be displayed.
  43246. */
  43247. displayLaserPointer: boolean;
  43248. /**
  43249. * The deviceOrientationCamera used as the camera when not in VR.
  43250. */
  43251. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  43252. /**
  43253. * Based on the current WebVR support, returns the current VR camera used.
  43254. */
  43255. readonly currentVRCamera: Nullable<Camera>;
  43256. /**
  43257. * The webVRCamera which is used when in VR.
  43258. */
  43259. readonly webVRCamera: WebVRFreeCamera;
  43260. /**
  43261. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  43262. */
  43263. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  43264. /**
  43265. * The html button that is used to trigger entering into VR.
  43266. */
  43267. readonly vrButton: Nullable<HTMLButtonElement>;
  43268. private readonly _teleportationRequestInitiated;
  43269. /**
  43270. * Defines wether or not Pointer lock should be requested when switching to
  43271. * full screen.
  43272. */
  43273. requestPointerLockOnFullScreen: boolean;
  43274. /**
  43275. * If asking to force XR, this will be populated with the default xr experience
  43276. */
  43277. xr: WebXRDefaultExperience;
  43278. /**
  43279. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  43280. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  43281. */
  43282. xrTestDone: boolean;
  43283. /**
  43284. * Instantiates a VRExperienceHelper.
  43285. * Helps to quickly add VR support to an existing scene.
  43286. * @param scene The scene the VRExperienceHelper belongs to.
  43287. * @param webVROptions Options to modify the vr experience helper's behavior.
  43288. */
  43289. constructor(scene: Scene,
  43290. /** Options to modify the vr experience helper's behavior. */
  43291. webVROptions?: VRExperienceHelperOptions);
  43292. private completeVRInit;
  43293. private _onDefaultMeshLoaded;
  43294. private _onResize;
  43295. private _onFullscreenChange;
  43296. /**
  43297. * Gets a value indicating if we are currently in VR mode.
  43298. */
  43299. readonly isInVRMode: boolean;
  43300. private onVrDisplayPresentChange;
  43301. private onVRDisplayChanged;
  43302. private moveButtonToBottomRight;
  43303. private displayVRButton;
  43304. private updateButtonVisibility;
  43305. private _cachedAngularSensibility;
  43306. /**
  43307. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  43308. * Otherwise, will use the fullscreen API.
  43309. */
  43310. enterVR(): void;
  43311. /**
  43312. * Attempt to exit VR, or fullscreen.
  43313. */
  43314. exitVR(): void;
  43315. /**
  43316. * The position of the vr experience helper.
  43317. */
  43318. /**
  43319. * Sets the position of the vr experience helper.
  43320. */
  43321. position: Vector3;
  43322. /**
  43323. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  43324. */
  43325. enableInteractions(): void;
  43326. private readonly _noControllerIsActive;
  43327. private beforeRender;
  43328. private _isTeleportationFloor;
  43329. /**
  43330. * Adds a floor mesh to be used for teleportation.
  43331. * @param floorMesh the mesh to be used for teleportation.
  43332. */
  43333. addFloorMesh(floorMesh: Mesh): void;
  43334. /**
  43335. * Removes a floor mesh from being used for teleportation.
  43336. * @param floorMesh the mesh to be removed.
  43337. */
  43338. removeFloorMesh(floorMesh: Mesh): void;
  43339. /**
  43340. * Enables interactions and teleportation using the VR controllers and gaze.
  43341. * @param vrTeleportationOptions options to modify teleportation behavior.
  43342. */
  43343. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  43344. private _onNewGamepadConnected;
  43345. private _tryEnableInteractionOnController;
  43346. private _onNewGamepadDisconnected;
  43347. private _enableInteractionOnController;
  43348. private _checkTeleportWithRay;
  43349. private _checkRotate;
  43350. private _checkTeleportBackwards;
  43351. private _enableTeleportationOnController;
  43352. private _createTeleportationCircles;
  43353. private _displayTeleportationTarget;
  43354. private _hideTeleportationTarget;
  43355. private _rotateCamera;
  43356. private _moveTeleportationSelectorTo;
  43357. private _workingVector;
  43358. private _workingQuaternion;
  43359. private _workingMatrix;
  43360. /**
  43361. * Time Constant Teleportation Mode
  43362. */
  43363. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  43364. /**
  43365. * Speed Constant Teleportation Mode
  43366. */
  43367. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  43368. /**
  43369. * Teleports the users feet to the desired location
  43370. * @param location The location where the user's feet should be placed
  43371. */
  43372. teleportCamera(location: Vector3): void;
  43373. private _convertNormalToDirectionOfRay;
  43374. private _castRayAndSelectObject;
  43375. private _notifySelectedMeshUnselected;
  43376. /**
  43377. * Sets the color of the laser ray from the vr controllers.
  43378. * @param color new color for the ray.
  43379. */
  43380. changeLaserColor(color: Color3): void;
  43381. /**
  43382. * Sets the color of the ray from the vr headsets gaze.
  43383. * @param color new color for the ray.
  43384. */
  43385. changeGazeColor(color: Color3): void;
  43386. /**
  43387. * Exits VR and disposes of the vr experience helper
  43388. */
  43389. dispose(): void;
  43390. /**
  43391. * Gets the name of the VRExperienceHelper class
  43392. * @returns "VRExperienceHelper"
  43393. */
  43394. getClassName(): string;
  43395. }
  43396. }
  43397. declare module BABYLON {
  43398. /**
  43399. * Contains an array of blocks representing the octree
  43400. */
  43401. export interface IOctreeContainer<T> {
  43402. /**
  43403. * Blocks within the octree
  43404. */
  43405. blocks: Array<OctreeBlock<T>>;
  43406. }
  43407. /**
  43408. * Class used to store a cell in an octree
  43409. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43410. */
  43411. export class OctreeBlock<T> {
  43412. /**
  43413. * Gets the content of the current block
  43414. */
  43415. entries: T[];
  43416. /**
  43417. * Gets the list of block children
  43418. */
  43419. blocks: Array<OctreeBlock<T>>;
  43420. private _depth;
  43421. private _maxDepth;
  43422. private _capacity;
  43423. private _minPoint;
  43424. private _maxPoint;
  43425. private _boundingVectors;
  43426. private _creationFunc;
  43427. /**
  43428. * Creates a new block
  43429. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43430. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43431. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43432. * @param depth defines the current depth of this block in the octree
  43433. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43434. * @param creationFunc defines a callback to call when an element is added to the block
  43435. */
  43436. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43437. /**
  43438. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43439. */
  43440. readonly capacity: number;
  43441. /**
  43442. * Gets the minimum vector (in world space) of the block's bounding box
  43443. */
  43444. readonly minPoint: Vector3;
  43445. /**
  43446. * Gets the maximum vector (in world space) of the block's bounding box
  43447. */
  43448. readonly maxPoint: Vector3;
  43449. /**
  43450. * Add a new element to this block
  43451. * @param entry defines the element to add
  43452. */
  43453. addEntry(entry: T): void;
  43454. /**
  43455. * Remove an element from this block
  43456. * @param entry defines the element to remove
  43457. */
  43458. removeEntry(entry: T): void;
  43459. /**
  43460. * Add an array of elements to this block
  43461. * @param entries defines the array of elements to add
  43462. */
  43463. addEntries(entries: T[]): void;
  43464. /**
  43465. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43466. * @param frustumPlanes defines the frustum planes to test
  43467. * @param selection defines the array to store current content if selection is positive
  43468. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43469. */
  43470. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43471. /**
  43472. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43473. * @param sphereCenter defines the bounding sphere center
  43474. * @param sphereRadius defines the bounding sphere radius
  43475. * @param selection defines the array to store current content if selection is positive
  43476. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43477. */
  43478. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43479. /**
  43480. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43481. * @param ray defines the ray to test with
  43482. * @param selection defines the array to store current content if selection is positive
  43483. */
  43484. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43485. /**
  43486. * Subdivide the content into child blocks (this block will then be empty)
  43487. */
  43488. createInnerBlocks(): void;
  43489. /**
  43490. * @hidden
  43491. */
  43492. 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;
  43493. }
  43494. }
  43495. declare module BABYLON {
  43496. /**
  43497. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43498. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43499. */
  43500. export class Octree<T> {
  43501. /** 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.) */
  43502. maxDepth: number;
  43503. /**
  43504. * Blocks within the octree containing objects
  43505. */
  43506. blocks: Array<OctreeBlock<T>>;
  43507. /**
  43508. * Content stored in the octree
  43509. */
  43510. dynamicContent: T[];
  43511. private _maxBlockCapacity;
  43512. private _selectionContent;
  43513. private _creationFunc;
  43514. /**
  43515. * Creates a octree
  43516. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43517. * @param creationFunc function to be used to instatiate the octree
  43518. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43519. * @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.)
  43520. */
  43521. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43522. /** 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.) */
  43523. maxDepth?: number);
  43524. /**
  43525. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43526. * @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);
  43527. * @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);
  43528. * @param entries meshes to be added to the octree blocks
  43529. */
  43530. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43531. /**
  43532. * Adds a mesh to the octree
  43533. * @param entry Mesh to add to the octree
  43534. */
  43535. addMesh(entry: T): void;
  43536. /**
  43537. * Remove an element from the octree
  43538. * @param entry defines the element to remove
  43539. */
  43540. removeMesh(entry: T): void;
  43541. /**
  43542. * Selects an array of meshes within the frustum
  43543. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43544. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43545. * @returns array of meshes within the frustum
  43546. */
  43547. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43548. /**
  43549. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43550. * @param sphereCenter defines the bounding sphere center
  43551. * @param sphereRadius defines the bounding sphere radius
  43552. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43553. * @returns an array of objects that intersect the sphere
  43554. */
  43555. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43556. /**
  43557. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43558. * @param ray defines the ray to test with
  43559. * @returns array of intersected objects
  43560. */
  43561. intersectsRay(ray: Ray): SmartArray<T>;
  43562. /**
  43563. * Adds a mesh into the octree block if it intersects the block
  43564. */
  43565. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43566. /**
  43567. * Adds a submesh into the octree block if it intersects the block
  43568. */
  43569. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43570. }
  43571. }
  43572. declare module BABYLON {
  43573. interface Scene {
  43574. /**
  43575. * @hidden
  43576. * Backing Filed
  43577. */
  43578. _selectionOctree: Octree<AbstractMesh>;
  43579. /**
  43580. * Gets the octree used to boost mesh selection (picking)
  43581. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43582. */
  43583. selectionOctree: Octree<AbstractMesh>;
  43584. /**
  43585. * Creates or updates the octree used to boost selection (picking)
  43586. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43587. * @param maxCapacity defines the maximum capacity per leaf
  43588. * @param maxDepth defines the maximum depth of the octree
  43589. * @returns an octree of AbstractMesh
  43590. */
  43591. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43592. }
  43593. interface AbstractMesh {
  43594. /**
  43595. * @hidden
  43596. * Backing Field
  43597. */
  43598. _submeshesOctree: Octree<SubMesh>;
  43599. /**
  43600. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43601. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43602. * @param maxCapacity defines the maximum size of each block (64 by default)
  43603. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43604. * @returns the new octree
  43605. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43606. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43607. */
  43608. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43609. }
  43610. /**
  43611. * Defines the octree scene component responsible to manage any octrees
  43612. * in a given scene.
  43613. */
  43614. export class OctreeSceneComponent {
  43615. /**
  43616. * The component name help to identify the component in the list of scene components.
  43617. */
  43618. readonly name: string;
  43619. /**
  43620. * The scene the component belongs to.
  43621. */
  43622. scene: Scene;
  43623. /**
  43624. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43625. */
  43626. readonly checksIsEnabled: boolean;
  43627. /**
  43628. * Creates a new instance of the component for the given scene
  43629. * @param scene Defines the scene to register the component in
  43630. */
  43631. constructor(scene: Scene);
  43632. /**
  43633. * Registers the component in a given scene
  43634. */
  43635. register(): void;
  43636. /**
  43637. * Return the list of active meshes
  43638. * @returns the list of active meshes
  43639. */
  43640. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43641. /**
  43642. * Return the list of active sub meshes
  43643. * @param mesh The mesh to get the candidates sub meshes from
  43644. * @returns the list of active sub meshes
  43645. */
  43646. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43647. private _tempRay;
  43648. /**
  43649. * Return the list of sub meshes intersecting with a given local ray
  43650. * @param mesh defines the mesh to find the submesh for
  43651. * @param localRay defines the ray in local space
  43652. * @returns the list of intersecting sub meshes
  43653. */
  43654. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43655. /**
  43656. * Return the list of sub meshes colliding with a collider
  43657. * @param mesh defines the mesh to find the submesh for
  43658. * @param collider defines the collider to evaluate the collision against
  43659. * @returns the list of colliding sub meshes
  43660. */
  43661. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43662. /**
  43663. * Rebuilds the elements related to this component in case of
  43664. * context lost for instance.
  43665. */
  43666. rebuild(): void;
  43667. /**
  43668. * Disposes the component and the associated ressources.
  43669. */
  43670. dispose(): void;
  43671. }
  43672. }
  43673. declare module BABYLON {
  43674. /**
  43675. * Renders a layer on top of an existing scene
  43676. */
  43677. export class UtilityLayerRenderer implements IDisposable {
  43678. /** the original scene that will be rendered on top of */
  43679. originalScene: Scene;
  43680. private _pointerCaptures;
  43681. private _lastPointerEvents;
  43682. private static _DefaultUtilityLayer;
  43683. private static _DefaultKeepDepthUtilityLayer;
  43684. private _sharedGizmoLight;
  43685. private _renderCamera;
  43686. /**
  43687. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  43688. * @returns the camera that is used when rendering the utility layer
  43689. */
  43690. getRenderCamera(): Nullable<Camera>;
  43691. /**
  43692. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  43693. * @param cam the camera that should be used when rendering the utility layer
  43694. */
  43695. setRenderCamera(cam: Nullable<Camera>): void;
  43696. /**
  43697. * @hidden
  43698. * Light which used by gizmos to get light shading
  43699. */
  43700. _getSharedGizmoLight(): HemisphericLight;
  43701. /**
  43702. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  43703. */
  43704. pickUtilitySceneFirst: boolean;
  43705. /**
  43706. * 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)
  43707. */
  43708. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  43709. /**
  43710. * 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)
  43711. */
  43712. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  43713. /**
  43714. * The scene that is rendered on top of the original scene
  43715. */
  43716. utilityLayerScene: Scene;
  43717. /**
  43718. * If the utility layer should automatically be rendered on top of existing scene
  43719. */
  43720. shouldRender: boolean;
  43721. /**
  43722. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  43723. */
  43724. onlyCheckPointerDownEvents: boolean;
  43725. /**
  43726. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  43727. */
  43728. processAllEvents: boolean;
  43729. /**
  43730. * Observable raised when the pointer move from the utility layer scene to the main scene
  43731. */
  43732. onPointerOutObservable: Observable<number>;
  43733. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  43734. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  43735. private _afterRenderObserver;
  43736. private _sceneDisposeObserver;
  43737. private _originalPointerObserver;
  43738. /**
  43739. * Instantiates a UtilityLayerRenderer
  43740. * @param originalScene the original scene that will be rendered on top of
  43741. * @param handleEvents boolean indicating if the utility layer should handle events
  43742. */
  43743. constructor(
  43744. /** the original scene that will be rendered on top of */
  43745. originalScene: Scene, handleEvents?: boolean);
  43746. private _notifyObservers;
  43747. /**
  43748. * Renders the utility layers scene on top of the original scene
  43749. */
  43750. render(): void;
  43751. /**
  43752. * Disposes of the renderer
  43753. */
  43754. dispose(): void;
  43755. private _updateCamera;
  43756. }
  43757. }
  43758. declare module BABYLON {
  43759. /**
  43760. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  43761. */
  43762. export class Gizmo implements IDisposable {
  43763. /** The utility layer the gizmo will be added to */
  43764. gizmoLayer: UtilityLayerRenderer;
  43765. /**
  43766. * The root mesh of the gizmo
  43767. */
  43768. _rootMesh: Mesh;
  43769. private _attachedMesh;
  43770. /**
  43771. * Ratio for the scale of the gizmo (Default: 1)
  43772. */
  43773. scaleRatio: number;
  43774. /**
  43775. * If a custom mesh has been set (Default: false)
  43776. */
  43777. protected _customMeshSet: boolean;
  43778. /**
  43779. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  43780. * * When set, interactions will be enabled
  43781. */
  43782. attachedMesh: Nullable<AbstractMesh>;
  43783. /**
  43784. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43785. * @param mesh The mesh to replace the default mesh of the gizmo
  43786. */
  43787. setCustomMesh(mesh: Mesh): void;
  43788. /**
  43789. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  43790. */
  43791. updateGizmoRotationToMatchAttachedMesh: boolean;
  43792. /**
  43793. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  43794. */
  43795. updateGizmoPositionToMatchAttachedMesh: boolean;
  43796. /**
  43797. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  43798. */
  43799. updateScale: boolean;
  43800. protected _interactionsEnabled: boolean;
  43801. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43802. private _beforeRenderObserver;
  43803. private _tempVector;
  43804. /**
  43805. * Creates a gizmo
  43806. * @param gizmoLayer The utility layer the gizmo will be added to
  43807. */
  43808. constructor(
  43809. /** The utility layer the gizmo will be added to */
  43810. gizmoLayer?: UtilityLayerRenderer);
  43811. /**
  43812. * Updates the gizmo to match the attached mesh's position/rotation
  43813. */
  43814. protected _update(): void;
  43815. /**
  43816. * Disposes of the gizmo
  43817. */
  43818. dispose(): void;
  43819. }
  43820. }
  43821. declare module BABYLON {
  43822. /**
  43823. * Single plane drag gizmo
  43824. */
  43825. export class PlaneDragGizmo extends Gizmo {
  43826. /**
  43827. * Drag behavior responsible for the gizmos dragging interactions
  43828. */
  43829. dragBehavior: PointerDragBehavior;
  43830. private _pointerObserver;
  43831. /**
  43832. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43833. */
  43834. snapDistance: number;
  43835. /**
  43836. * Event that fires each time the gizmo snaps to a new location.
  43837. * * snapDistance is the the change in distance
  43838. */
  43839. onSnapObservable: Observable<{
  43840. snapDistance: number;
  43841. }>;
  43842. private _plane;
  43843. private _coloredMaterial;
  43844. private _hoverMaterial;
  43845. private _isEnabled;
  43846. private _parent;
  43847. /** @hidden */
  43848. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  43849. /** @hidden */
  43850. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43851. /**
  43852. * Creates a PlaneDragGizmo
  43853. * @param gizmoLayer The utility layer the gizmo will be added to
  43854. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  43855. * @param color The color of the gizmo
  43856. */
  43857. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43858. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43859. /**
  43860. * If the gizmo is enabled
  43861. */
  43862. isEnabled: boolean;
  43863. /**
  43864. * Disposes of the gizmo
  43865. */
  43866. dispose(): void;
  43867. }
  43868. }
  43869. declare module BABYLON {
  43870. /**
  43871. * Gizmo that enables dragging a mesh along 3 axis
  43872. */
  43873. export class PositionGizmo extends Gizmo {
  43874. /**
  43875. * Internal gizmo used for interactions on the x axis
  43876. */
  43877. xGizmo: AxisDragGizmo;
  43878. /**
  43879. * Internal gizmo used for interactions on the y axis
  43880. */
  43881. yGizmo: AxisDragGizmo;
  43882. /**
  43883. * Internal gizmo used for interactions on the z axis
  43884. */
  43885. zGizmo: AxisDragGizmo;
  43886. /**
  43887. * Internal gizmo used for interactions on the yz plane
  43888. */
  43889. xPlaneGizmo: PlaneDragGizmo;
  43890. /**
  43891. * Internal gizmo used for interactions on the xz plane
  43892. */
  43893. yPlaneGizmo: PlaneDragGizmo;
  43894. /**
  43895. * Internal gizmo used for interactions on the xy plane
  43896. */
  43897. zPlaneGizmo: PlaneDragGizmo;
  43898. /**
  43899. * private variables
  43900. */
  43901. private _meshAttached;
  43902. private _updateGizmoRotationToMatchAttachedMesh;
  43903. private _snapDistance;
  43904. private _scaleRatio;
  43905. /** Fires an event when any of it's sub gizmos are dragged */
  43906. onDragStartObservable: Observable<unknown>;
  43907. /** Fires an event when any of it's sub gizmos are released from dragging */
  43908. onDragEndObservable: Observable<unknown>;
  43909. /**
  43910. * If set to true, planar drag is enabled
  43911. */
  43912. private _planarGizmoEnabled;
  43913. attachedMesh: Nullable<AbstractMesh>;
  43914. /**
  43915. * Creates a PositionGizmo
  43916. * @param gizmoLayer The utility layer the gizmo will be added to
  43917. */
  43918. constructor(gizmoLayer?: UtilityLayerRenderer);
  43919. /**
  43920. * If the planar drag gizmo is enabled
  43921. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  43922. */
  43923. planarGizmoEnabled: boolean;
  43924. updateGizmoRotationToMatchAttachedMesh: boolean;
  43925. /**
  43926. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43927. */
  43928. snapDistance: number;
  43929. /**
  43930. * Ratio for the scale of the gizmo (Default: 1)
  43931. */
  43932. scaleRatio: number;
  43933. /**
  43934. * Disposes of the gizmo
  43935. */
  43936. dispose(): void;
  43937. /**
  43938. * CustomMeshes are not supported by this gizmo
  43939. * @param mesh The mesh to replace the default mesh of the gizmo
  43940. */
  43941. setCustomMesh(mesh: Mesh): void;
  43942. }
  43943. }
  43944. declare module BABYLON {
  43945. /**
  43946. * Single axis drag gizmo
  43947. */
  43948. export class AxisDragGizmo extends Gizmo {
  43949. /**
  43950. * Drag behavior responsible for the gizmos dragging interactions
  43951. */
  43952. dragBehavior: PointerDragBehavior;
  43953. private _pointerObserver;
  43954. /**
  43955. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43956. */
  43957. snapDistance: number;
  43958. /**
  43959. * Event that fires each time the gizmo snaps to a new location.
  43960. * * snapDistance is the the change in distance
  43961. */
  43962. onSnapObservable: Observable<{
  43963. snapDistance: number;
  43964. }>;
  43965. private _isEnabled;
  43966. private _parent;
  43967. private _arrow;
  43968. private _coloredMaterial;
  43969. private _hoverMaterial;
  43970. /** @hidden */
  43971. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  43972. /** @hidden */
  43973. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43974. /**
  43975. * Creates an AxisDragGizmo
  43976. * @param gizmoLayer The utility layer the gizmo will be added to
  43977. * @param dragAxis The axis which the gizmo will be able to drag on
  43978. * @param color The color of the gizmo
  43979. */
  43980. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43981. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43982. /**
  43983. * If the gizmo is enabled
  43984. */
  43985. isEnabled: boolean;
  43986. /**
  43987. * Disposes of the gizmo
  43988. */
  43989. dispose(): void;
  43990. }
  43991. }
  43992. declare module BABYLON.Debug {
  43993. /**
  43994. * The Axes viewer will show 3 axes in a specific point in space
  43995. */
  43996. export class AxesViewer {
  43997. private _xAxis;
  43998. private _yAxis;
  43999. private _zAxis;
  44000. private _scaleLinesFactor;
  44001. private _instanced;
  44002. /**
  44003. * Gets the hosting scene
  44004. */
  44005. scene: Scene;
  44006. /**
  44007. * Gets or sets a number used to scale line length
  44008. */
  44009. scaleLines: number;
  44010. /** Gets the node hierarchy used to render x-axis */
  44011. readonly xAxis: TransformNode;
  44012. /** Gets the node hierarchy used to render y-axis */
  44013. readonly yAxis: TransformNode;
  44014. /** Gets the node hierarchy used to render z-axis */
  44015. readonly zAxis: TransformNode;
  44016. /**
  44017. * Creates a new AxesViewer
  44018. * @param scene defines the hosting scene
  44019. * @param scaleLines defines a number used to scale line length (1 by default)
  44020. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44021. * @param xAxis defines the node hierarchy used to render the x-axis
  44022. * @param yAxis defines the node hierarchy used to render the y-axis
  44023. * @param zAxis defines the node hierarchy used to render the z-axis
  44024. */
  44025. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44026. /**
  44027. * Force the viewer to update
  44028. * @param position defines the position of the viewer
  44029. * @param xaxis defines the x axis of the viewer
  44030. * @param yaxis defines the y axis of the viewer
  44031. * @param zaxis defines the z axis of the viewer
  44032. */
  44033. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44034. /**
  44035. * Creates an instance of this axes viewer.
  44036. * @returns a new axes viewer with instanced meshes
  44037. */
  44038. createInstance(): AxesViewer;
  44039. /** Releases resources */
  44040. dispose(): void;
  44041. private static _SetRenderingGroupId;
  44042. }
  44043. }
  44044. declare module BABYLON.Debug {
  44045. /**
  44046. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44047. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44048. */
  44049. export class BoneAxesViewer extends AxesViewer {
  44050. /**
  44051. * Gets or sets the target mesh where to display the axes viewer
  44052. */
  44053. mesh: Nullable<Mesh>;
  44054. /**
  44055. * Gets or sets the target bone where to display the axes viewer
  44056. */
  44057. bone: Nullable<Bone>;
  44058. /** Gets current position */
  44059. pos: Vector3;
  44060. /** Gets direction of X axis */
  44061. xaxis: Vector3;
  44062. /** Gets direction of Y axis */
  44063. yaxis: Vector3;
  44064. /** Gets direction of Z axis */
  44065. zaxis: Vector3;
  44066. /**
  44067. * Creates a new BoneAxesViewer
  44068. * @param scene defines the hosting scene
  44069. * @param bone defines the target bone
  44070. * @param mesh defines the target mesh
  44071. * @param scaleLines defines a scaling factor for line length (1 by default)
  44072. */
  44073. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44074. /**
  44075. * Force the viewer to update
  44076. */
  44077. update(): void;
  44078. /** Releases resources */
  44079. dispose(): void;
  44080. }
  44081. }
  44082. declare module BABYLON {
  44083. /**
  44084. * Interface used to define scene explorer extensibility option
  44085. */
  44086. export interface IExplorerExtensibilityOption {
  44087. /**
  44088. * Define the option label
  44089. */
  44090. label: string;
  44091. /**
  44092. * Defines the action to execute on click
  44093. */
  44094. action: (entity: any) => void;
  44095. }
  44096. /**
  44097. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44098. */
  44099. export interface IExplorerExtensibilityGroup {
  44100. /**
  44101. * Defines a predicate to test if a given type mut be extended
  44102. */
  44103. predicate: (entity: any) => boolean;
  44104. /**
  44105. * Gets the list of options added to a type
  44106. */
  44107. entries: IExplorerExtensibilityOption[];
  44108. }
  44109. /**
  44110. * Interface used to define the options to use to create the Inspector
  44111. */
  44112. export interface IInspectorOptions {
  44113. /**
  44114. * Display in overlay mode (default: false)
  44115. */
  44116. overlay?: boolean;
  44117. /**
  44118. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44119. */
  44120. globalRoot?: HTMLElement;
  44121. /**
  44122. * Display the Scene explorer
  44123. */
  44124. showExplorer?: boolean;
  44125. /**
  44126. * Display the property inspector
  44127. */
  44128. showInspector?: boolean;
  44129. /**
  44130. * Display in embed mode (both panes on the right)
  44131. */
  44132. embedMode?: boolean;
  44133. /**
  44134. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44135. */
  44136. handleResize?: boolean;
  44137. /**
  44138. * Allow the panes to popup (default: true)
  44139. */
  44140. enablePopup?: boolean;
  44141. /**
  44142. * Allow the panes to be closed by users (default: true)
  44143. */
  44144. enableClose?: boolean;
  44145. /**
  44146. * Optional list of extensibility entries
  44147. */
  44148. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44149. /**
  44150. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44151. */
  44152. inspectorURL?: string;
  44153. }
  44154. interface Scene {
  44155. /**
  44156. * @hidden
  44157. * Backing field
  44158. */
  44159. _debugLayer: DebugLayer;
  44160. /**
  44161. * Gets the debug layer (aka Inspector) associated with the scene
  44162. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44163. */
  44164. debugLayer: DebugLayer;
  44165. }
  44166. /**
  44167. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44168. * what is happening in your scene
  44169. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44170. */
  44171. export class DebugLayer {
  44172. /**
  44173. * Define the url to get the inspector script from.
  44174. * By default it uses the babylonjs CDN.
  44175. * @ignoreNaming
  44176. */
  44177. static InspectorURL: string;
  44178. private _scene;
  44179. private BJSINSPECTOR;
  44180. private _onPropertyChangedObservable?;
  44181. /**
  44182. * Observable triggered when a property is changed through the inspector.
  44183. */
  44184. readonly onPropertyChangedObservable: any;
  44185. /**
  44186. * Instantiates a new debug layer.
  44187. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44188. * what is happening in your scene
  44189. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44190. * @param scene Defines the scene to inspect
  44191. */
  44192. constructor(scene: Scene);
  44193. /** Creates the inspector window. */
  44194. private _createInspector;
  44195. /**
  44196. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44197. * @param entity defines the entity to select
  44198. * @param lineContainerTitle defines the specific block to highlight
  44199. */
  44200. select(entity: any, lineContainerTitle?: string): void;
  44201. /** Get the inspector from bundle or global */
  44202. private _getGlobalInspector;
  44203. /**
  44204. * Get if the inspector is visible or not.
  44205. * @returns true if visible otherwise, false
  44206. */
  44207. isVisible(): boolean;
  44208. /**
  44209. * Hide the inspector and close its window.
  44210. */
  44211. hide(): void;
  44212. /**
  44213. * Launch the debugLayer.
  44214. * @param config Define the configuration of the inspector
  44215. * @return a promise fulfilled when the debug layer is visible
  44216. */
  44217. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44218. }
  44219. }
  44220. declare module BABYLON {
  44221. /**
  44222. * Class containing static functions to help procedurally build meshes
  44223. */
  44224. export class BoxBuilder {
  44225. /**
  44226. * Creates a box mesh
  44227. * * The parameter `size` sets the size (float) of each box side (default 1)
  44228. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44229. * * 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)
  44230. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44231. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44232. * * 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
  44233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44234. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44235. * @param name defines the name of the mesh
  44236. * @param options defines the options used to create the mesh
  44237. * @param scene defines the hosting scene
  44238. * @returns the box mesh
  44239. */
  44240. static CreateBox(name: string, options: {
  44241. size?: number;
  44242. width?: number;
  44243. height?: number;
  44244. depth?: number;
  44245. faceUV?: Vector4[];
  44246. faceColors?: Color4[];
  44247. sideOrientation?: number;
  44248. frontUVs?: Vector4;
  44249. backUVs?: Vector4;
  44250. wrap?: boolean;
  44251. topBaseAt?: number;
  44252. bottomBaseAt?: number;
  44253. updatable?: boolean;
  44254. }, scene?: Nullable<Scene>): Mesh;
  44255. }
  44256. }
  44257. declare module BABYLON {
  44258. /**
  44259. * Class containing static functions to help procedurally build meshes
  44260. */
  44261. export class SphereBuilder {
  44262. /**
  44263. * Creates a sphere mesh
  44264. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44265. * * 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`)
  44266. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44267. * * 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
  44268. * * 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)
  44269. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44270. * * 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
  44271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44272. * @param name defines the name of the mesh
  44273. * @param options defines the options used to create the mesh
  44274. * @param scene defines the hosting scene
  44275. * @returns the sphere mesh
  44276. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44277. */
  44278. static CreateSphere(name: string, options: {
  44279. segments?: number;
  44280. diameter?: number;
  44281. diameterX?: number;
  44282. diameterY?: number;
  44283. diameterZ?: number;
  44284. arc?: number;
  44285. slice?: number;
  44286. sideOrientation?: number;
  44287. frontUVs?: Vector4;
  44288. backUVs?: Vector4;
  44289. updatable?: boolean;
  44290. }, scene?: Nullable<Scene>): Mesh;
  44291. }
  44292. }
  44293. declare module BABYLON.Debug {
  44294. /**
  44295. * Used to show the physics impostor around the specific mesh
  44296. */
  44297. export class PhysicsViewer {
  44298. /** @hidden */
  44299. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44300. /** @hidden */
  44301. protected _meshes: Array<Nullable<AbstractMesh>>;
  44302. /** @hidden */
  44303. protected _scene: Nullable<Scene>;
  44304. /** @hidden */
  44305. protected _numMeshes: number;
  44306. /** @hidden */
  44307. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44308. private _renderFunction;
  44309. private _utilityLayer;
  44310. private _debugBoxMesh;
  44311. private _debugSphereMesh;
  44312. private _debugCylinderMesh;
  44313. private _debugMaterial;
  44314. private _debugMeshMeshes;
  44315. /**
  44316. * Creates a new PhysicsViewer
  44317. * @param scene defines the hosting scene
  44318. */
  44319. constructor(scene: Scene);
  44320. /** @hidden */
  44321. protected _updateDebugMeshes(): void;
  44322. /**
  44323. * Renders a specified physic impostor
  44324. * @param impostor defines the impostor to render
  44325. * @param targetMesh defines the mesh represented by the impostor
  44326. * @returns the new debug mesh used to render the impostor
  44327. */
  44328. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44329. /**
  44330. * Hides a specified physic impostor
  44331. * @param impostor defines the impostor to hide
  44332. */
  44333. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44334. private _getDebugMaterial;
  44335. private _getDebugBoxMesh;
  44336. private _getDebugSphereMesh;
  44337. private _getDebugCylinderMesh;
  44338. private _getDebugMeshMesh;
  44339. private _getDebugMesh;
  44340. /** Releases all resources */
  44341. dispose(): void;
  44342. }
  44343. }
  44344. declare module BABYLON {
  44345. /**
  44346. * Class containing static functions to help procedurally build meshes
  44347. */
  44348. export class LinesBuilder {
  44349. /**
  44350. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44351. * * 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
  44352. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44353. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44354. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44355. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44356. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44357. * * 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
  44358. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44360. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44361. * @param name defines the name of the new line system
  44362. * @param options defines the options used to create the line system
  44363. * @param scene defines the hosting scene
  44364. * @returns a new line system mesh
  44365. */
  44366. static CreateLineSystem(name: string, options: {
  44367. lines: Vector3[][];
  44368. updatable?: boolean;
  44369. instance?: Nullable<LinesMesh>;
  44370. colors?: Nullable<Color4[][]>;
  44371. useVertexAlpha?: boolean;
  44372. }, scene: Nullable<Scene>): LinesMesh;
  44373. /**
  44374. * Creates a line mesh
  44375. * 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
  44376. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44377. * * The parameter `points` is an array successive Vector3
  44378. * * 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
  44379. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44380. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44381. * * When updating an instance, remember that only point positions can change, not the number of points
  44382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44383. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44384. * @param name defines the name of the new line system
  44385. * @param options defines the options used to create the line system
  44386. * @param scene defines the hosting scene
  44387. * @returns a new line mesh
  44388. */
  44389. static CreateLines(name: string, options: {
  44390. points: Vector3[];
  44391. updatable?: boolean;
  44392. instance?: Nullable<LinesMesh>;
  44393. colors?: Color4[];
  44394. useVertexAlpha?: boolean;
  44395. }, scene?: Nullable<Scene>): LinesMesh;
  44396. /**
  44397. * Creates a dashed line mesh
  44398. * * 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
  44399. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44400. * * The parameter `points` is an array successive Vector3
  44401. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44402. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44403. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44404. * * 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
  44405. * * When updating an instance, remember that only point positions can change, not the number of points
  44406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44407. * @param name defines the name of the mesh
  44408. * @param options defines the options used to create the mesh
  44409. * @param scene defines the hosting scene
  44410. * @returns the dashed line mesh
  44411. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44412. */
  44413. static CreateDashedLines(name: string, options: {
  44414. points: Vector3[];
  44415. dashSize?: number;
  44416. gapSize?: number;
  44417. dashNb?: number;
  44418. updatable?: boolean;
  44419. instance?: LinesMesh;
  44420. }, scene?: Nullable<Scene>): LinesMesh;
  44421. }
  44422. }
  44423. declare module BABYLON {
  44424. /**
  44425. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44426. * in order to better appreciate the issue one might have.
  44427. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44428. */
  44429. export class RayHelper {
  44430. /**
  44431. * Defines the ray we are currently tryin to visualize.
  44432. */
  44433. ray: Nullable<Ray>;
  44434. private _renderPoints;
  44435. private _renderLine;
  44436. private _renderFunction;
  44437. private _scene;
  44438. private _updateToMeshFunction;
  44439. private _attachedToMesh;
  44440. private _meshSpaceDirection;
  44441. private _meshSpaceOrigin;
  44442. /**
  44443. * Helper function to create a colored helper in a scene in one line.
  44444. * @param ray Defines the ray we are currently tryin to visualize
  44445. * @param scene Defines the scene the ray is used in
  44446. * @param color Defines the color we want to see the ray in
  44447. * @returns The newly created ray helper.
  44448. */
  44449. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44450. /**
  44451. * Instantiate a new ray helper.
  44452. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44453. * in order to better appreciate the issue one might have.
  44454. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44455. * @param ray Defines the ray we are currently tryin to visualize
  44456. */
  44457. constructor(ray: Ray);
  44458. /**
  44459. * Shows the ray we are willing to debug.
  44460. * @param scene Defines the scene the ray needs to be rendered in
  44461. * @param color Defines the color the ray needs to be rendered in
  44462. */
  44463. show(scene: Scene, color?: Color3): void;
  44464. /**
  44465. * Hides the ray we are debugging.
  44466. */
  44467. hide(): void;
  44468. private _render;
  44469. /**
  44470. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44471. * @param mesh Defines the mesh we want the helper attached to
  44472. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44473. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44474. * @param length Defines the length of the ray
  44475. */
  44476. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44477. /**
  44478. * Detach the ray helper from the mesh it has previously been attached to.
  44479. */
  44480. detachFromMesh(): void;
  44481. private _updateToMesh;
  44482. /**
  44483. * Dispose the helper and release its associated resources.
  44484. */
  44485. dispose(): void;
  44486. }
  44487. }
  44488. declare module BABYLON.Debug {
  44489. /**
  44490. * Class used to render a debug view of a given skeleton
  44491. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  44492. */
  44493. export class SkeletonViewer {
  44494. /** defines the skeleton to render */
  44495. skeleton: Skeleton;
  44496. /** defines the mesh attached to the skeleton */
  44497. mesh: AbstractMesh;
  44498. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44499. autoUpdateBonesMatrices: boolean;
  44500. /** defines the rendering group id to use with the viewer */
  44501. renderingGroupId: number;
  44502. /** Gets or sets the color used to render the skeleton */
  44503. color: Color3;
  44504. private _scene;
  44505. private _debugLines;
  44506. private _debugMesh;
  44507. private _isEnabled;
  44508. private _renderFunction;
  44509. private _utilityLayer;
  44510. /**
  44511. * Returns the mesh used to render the bones
  44512. */
  44513. readonly debugMesh: Nullable<LinesMesh>;
  44514. /**
  44515. * Creates a new SkeletonViewer
  44516. * @param skeleton defines the skeleton to render
  44517. * @param mesh defines the mesh attached to the skeleton
  44518. * @param scene defines the hosting scene
  44519. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  44520. * @param renderingGroupId defines the rendering group id to use with the viewer
  44521. */
  44522. constructor(
  44523. /** defines the skeleton to render */
  44524. skeleton: Skeleton,
  44525. /** defines the mesh attached to the skeleton */
  44526. mesh: AbstractMesh, scene: Scene,
  44527. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44528. autoUpdateBonesMatrices?: boolean,
  44529. /** defines the rendering group id to use with the viewer */
  44530. renderingGroupId?: number);
  44531. /** Gets or sets a boolean indicating if the viewer is enabled */
  44532. isEnabled: boolean;
  44533. private _getBonePosition;
  44534. private _getLinesForBonesWithLength;
  44535. private _getLinesForBonesNoLength;
  44536. /** Update the viewer to sync with current skeleton state */
  44537. update(): void;
  44538. /** Release associated resources */
  44539. dispose(): void;
  44540. }
  44541. }
  44542. declare module BABYLON {
  44543. /**
  44544. * Options to create the null engine
  44545. */
  44546. export class NullEngineOptions {
  44547. /**
  44548. * Render width (Default: 512)
  44549. */
  44550. renderWidth: number;
  44551. /**
  44552. * Render height (Default: 256)
  44553. */
  44554. renderHeight: number;
  44555. /**
  44556. * Texture size (Default: 512)
  44557. */
  44558. textureSize: number;
  44559. /**
  44560. * If delta time between frames should be constant
  44561. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44562. */
  44563. deterministicLockstep: boolean;
  44564. /**
  44565. * Maximum about of steps between frames (Default: 4)
  44566. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44567. */
  44568. lockstepMaxSteps: number;
  44569. }
  44570. /**
  44571. * The null engine class provides support for headless version of babylon.js.
  44572. * This can be used in server side scenario or for testing purposes
  44573. */
  44574. export class NullEngine extends Engine {
  44575. private _options;
  44576. /**
  44577. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  44578. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44579. * @returns true if engine is in deterministic lock step mode
  44580. */
  44581. isDeterministicLockStep(): boolean;
  44582. /**
  44583. * Gets the max steps when engine is running in deterministic lock step
  44584. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44585. * @returns the max steps
  44586. */
  44587. getLockstepMaxSteps(): number;
  44588. /**
  44589. * Gets the current hardware scaling level.
  44590. * By default the hardware scaling level is computed from the window device ratio.
  44591. * 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.
  44592. * @returns a number indicating the current hardware scaling level
  44593. */
  44594. getHardwareScalingLevel(): number;
  44595. constructor(options?: NullEngineOptions);
  44596. /**
  44597. * Creates a vertex buffer
  44598. * @param vertices the data for the vertex buffer
  44599. * @returns the new WebGL static buffer
  44600. */
  44601. createVertexBuffer(vertices: FloatArray): DataBuffer;
  44602. /**
  44603. * Creates a new index buffer
  44604. * @param indices defines the content of the index buffer
  44605. * @param updatable defines if the index buffer must be updatable
  44606. * @returns a new webGL buffer
  44607. */
  44608. createIndexBuffer(indices: IndicesArray): DataBuffer;
  44609. /**
  44610. * Clear the current render buffer or the current render target (if any is set up)
  44611. * @param color defines the color to use
  44612. * @param backBuffer defines if the back buffer must be cleared
  44613. * @param depth defines if the depth buffer must be cleared
  44614. * @param stencil defines if the stencil buffer must be cleared
  44615. */
  44616. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44617. /**
  44618. * Gets the current render width
  44619. * @param useScreen defines if screen size must be used (or the current render target if any)
  44620. * @returns a number defining the current render width
  44621. */
  44622. getRenderWidth(useScreen?: boolean): number;
  44623. /**
  44624. * Gets the current render height
  44625. * @param useScreen defines if screen size must be used (or the current render target if any)
  44626. * @returns a number defining the current render height
  44627. */
  44628. getRenderHeight(useScreen?: boolean): number;
  44629. /**
  44630. * Set the WebGL's viewport
  44631. * @param viewport defines the viewport element to be used
  44632. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  44633. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  44634. */
  44635. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  44636. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  44637. /**
  44638. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  44639. * @param pipelineContext defines the pipeline context to use
  44640. * @param uniformsNames defines the list of uniform names
  44641. * @returns an array of webGL uniform locations
  44642. */
  44643. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  44644. /**
  44645. * Gets the lsit of active attributes for a given webGL program
  44646. * @param pipelineContext defines the pipeline context to use
  44647. * @param attributesNames defines the list of attribute names to get
  44648. * @returns an array of indices indicating the offset of each attribute
  44649. */
  44650. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44651. /**
  44652. * Binds an effect to the webGL context
  44653. * @param effect defines the effect to bind
  44654. */
  44655. bindSamplers(effect: Effect): void;
  44656. /**
  44657. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  44658. * @param effect defines the effect to activate
  44659. */
  44660. enableEffect(effect: Effect): void;
  44661. /**
  44662. * Set various states to the webGL context
  44663. * @param culling defines backface culling state
  44664. * @param zOffset defines the value to apply to zOffset (0 by default)
  44665. * @param force defines if states must be applied even if cache is up to date
  44666. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  44667. */
  44668. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44669. /**
  44670. * Set the value of an uniform to an array of int32
  44671. * @param uniform defines the webGL uniform location where to store the value
  44672. * @param array defines the array of int32 to store
  44673. */
  44674. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44675. /**
  44676. * Set the value of an uniform to an array of int32 (stored as vec2)
  44677. * @param uniform defines the webGL uniform location where to store the value
  44678. * @param array defines the array of int32 to store
  44679. */
  44680. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44681. /**
  44682. * Set the value of an uniform to an array of int32 (stored as vec3)
  44683. * @param uniform defines the webGL uniform location where to store the value
  44684. * @param array defines the array of int32 to store
  44685. */
  44686. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44687. /**
  44688. * Set the value of an uniform to an array of int32 (stored as vec4)
  44689. * @param uniform defines the webGL uniform location where to store the value
  44690. * @param array defines the array of int32 to store
  44691. */
  44692. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44693. /**
  44694. * Set the value of an uniform to an array of float32
  44695. * @param uniform defines the webGL uniform location where to store the value
  44696. * @param array defines the array of float32 to store
  44697. */
  44698. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44699. /**
  44700. * Set the value of an uniform to an array of float32 (stored as vec2)
  44701. * @param uniform defines the webGL uniform location where to store the value
  44702. * @param array defines the array of float32 to store
  44703. */
  44704. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44705. /**
  44706. * Set the value of an uniform to an array of float32 (stored as vec3)
  44707. * @param uniform defines the webGL uniform location where to store the value
  44708. * @param array defines the array of float32 to store
  44709. */
  44710. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44711. /**
  44712. * Set the value of an uniform to an array of float32 (stored as vec4)
  44713. * @param uniform defines the webGL uniform location where to store the value
  44714. * @param array defines the array of float32 to store
  44715. */
  44716. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44717. /**
  44718. * Set the value of an uniform to an array of number
  44719. * @param uniform defines the webGL uniform location where to store the value
  44720. * @param array defines the array of number to store
  44721. */
  44722. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44723. /**
  44724. * Set the value of an uniform to an array of number (stored as vec2)
  44725. * @param uniform defines the webGL uniform location where to store the value
  44726. * @param array defines the array of number to store
  44727. */
  44728. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44729. /**
  44730. * Set the value of an uniform to an array of number (stored as vec3)
  44731. * @param uniform defines the webGL uniform location where to store the value
  44732. * @param array defines the array of number to store
  44733. */
  44734. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44735. /**
  44736. * Set the value of an uniform to an array of number (stored as vec4)
  44737. * @param uniform defines the webGL uniform location where to store the value
  44738. * @param array defines the array of number to store
  44739. */
  44740. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44741. /**
  44742. * Set the value of an uniform to an array of float32 (stored as matrices)
  44743. * @param uniform defines the webGL uniform location where to store the value
  44744. * @param matrices defines the array of float32 to store
  44745. */
  44746. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44747. /**
  44748. * Set the value of an uniform to a matrix (3x3)
  44749. * @param uniform defines the webGL uniform location where to store the value
  44750. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  44751. */
  44752. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44753. /**
  44754. * Set the value of an uniform to a matrix (2x2)
  44755. * @param uniform defines the webGL uniform location where to store the value
  44756. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  44757. */
  44758. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44759. /**
  44760. * Set the value of an uniform to a number (float)
  44761. * @param uniform defines the webGL uniform location where to store the value
  44762. * @param value defines the float number to store
  44763. */
  44764. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44765. /**
  44766. * Set the value of an uniform to a vec2
  44767. * @param uniform defines the webGL uniform location where to store the value
  44768. * @param x defines the 1st component of the value
  44769. * @param y defines the 2nd component of the value
  44770. */
  44771. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44772. /**
  44773. * Set the value of an uniform to a vec3
  44774. * @param uniform defines the webGL uniform location where to store the value
  44775. * @param x defines the 1st component of the value
  44776. * @param y defines the 2nd component of the value
  44777. * @param z defines the 3rd component of the value
  44778. */
  44779. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44780. /**
  44781. * Set the value of an uniform to a boolean
  44782. * @param uniform defines the webGL uniform location where to store the value
  44783. * @param bool defines the boolean to store
  44784. */
  44785. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44786. /**
  44787. * Set the value of an uniform to a vec4
  44788. * @param uniform defines the webGL uniform location where to store the value
  44789. * @param x defines the 1st component of the value
  44790. * @param y defines the 2nd component of the value
  44791. * @param z defines the 3rd component of the value
  44792. * @param w defines the 4th component of the value
  44793. */
  44794. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44795. /**
  44796. * Sets the current alpha mode
  44797. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  44798. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44799. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44800. */
  44801. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44802. /**
  44803. * Bind webGl buffers directly to the webGL context
  44804. * @param vertexBuffers defines the vertex buffer to bind
  44805. * @param indexBuffer defines the index buffer to bind
  44806. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  44807. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  44808. * @param effect defines the effect associated with the vertex buffer
  44809. */
  44810. bindBuffers(vertexBuffers: {
  44811. [key: string]: VertexBuffer;
  44812. }, indexBuffer: DataBuffer, effect: Effect): void;
  44813. /**
  44814. * Force the entire cache to be cleared
  44815. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  44816. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  44817. */
  44818. wipeCaches(bruteForce?: boolean): void;
  44819. /**
  44820. * Send a draw order
  44821. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  44822. * @param indexStart defines the starting index
  44823. * @param indexCount defines the number of index to draw
  44824. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44825. */
  44826. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  44827. /**
  44828. * Draw a list of indexed primitives
  44829. * @param fillMode defines the primitive to use
  44830. * @param indexStart defines the starting index
  44831. * @param indexCount defines the number of index to draw
  44832. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44833. */
  44834. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44835. /**
  44836. * Draw a list of unindexed primitives
  44837. * @param fillMode defines the primitive to use
  44838. * @param verticesStart defines the index of first vertex to draw
  44839. * @param verticesCount defines the count of vertices to draw
  44840. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44841. */
  44842. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44843. /** @hidden */
  44844. _createTexture(): WebGLTexture;
  44845. /** @hidden */
  44846. _releaseTexture(texture: InternalTexture): void;
  44847. /**
  44848. * Usually called from Texture.ts.
  44849. * Passed information to create a WebGLTexture
  44850. * @param urlArg defines a value which contains one of the following:
  44851. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44852. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44853. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44854. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44855. * @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)
  44856. * @param scene needed for loading to the correct scene
  44857. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  44858. * @param onLoad optional callback to be called upon successful completion
  44859. * @param onError optional callback to be called upon failure
  44860. * @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
  44861. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44862. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44863. * @param forcedExtension defines the extension to use to pick the right loader
  44864. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  44865. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44866. */
  44867. 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;
  44868. /**
  44869. * Creates a new render target texture
  44870. * @param size defines the size of the texture
  44871. * @param options defines the options used to create the texture
  44872. * @returns a new render target texture stored in an InternalTexture
  44873. */
  44874. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44875. /**
  44876. * Update the sampling mode of a given texture
  44877. * @param samplingMode defines the required sampling mode
  44878. * @param texture defines the texture to update
  44879. */
  44880. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44881. /**
  44882. * Binds the frame buffer to the specified texture.
  44883. * @param texture The texture to render to or null for the default canvas
  44884. * @param faceIndex The face of the texture to render to in case of cube texture
  44885. * @param requiredWidth The width of the target to render to
  44886. * @param requiredHeight The height of the target to render to
  44887. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  44888. * @param depthStencilTexture The depth stencil texture to use to render
  44889. * @param lodLevel defines le lod level to bind to the frame buffer
  44890. */
  44891. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44892. /**
  44893. * Unbind the current render target texture from the webGL context
  44894. * @param texture defines the render target texture to unbind
  44895. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44896. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44897. */
  44898. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44899. /**
  44900. * Creates a dynamic vertex buffer
  44901. * @param vertices the data for the dynamic vertex buffer
  44902. * @returns the new WebGL dynamic buffer
  44903. */
  44904. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  44905. /**
  44906. * Update the content of a dynamic texture
  44907. * @param texture defines the texture to update
  44908. * @param canvas defines the canvas containing the source
  44909. * @param invertY defines if data must be stored with Y axis inverted
  44910. * @param premulAlpha defines if alpha is stored as premultiplied
  44911. * @param format defines the format of the data
  44912. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  44913. */
  44914. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  44915. /**
  44916. * Gets a boolean indicating if all created effects are ready
  44917. * @returns true if all effects are ready
  44918. */
  44919. areAllEffectsReady(): boolean;
  44920. /**
  44921. * @hidden
  44922. * Get the current error code of the webGL context
  44923. * @returns the error code
  44924. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  44925. */
  44926. getError(): number;
  44927. /** @hidden */
  44928. _getUnpackAlignement(): number;
  44929. /** @hidden */
  44930. _unpackFlipY(value: boolean): void;
  44931. /**
  44932. * Update a dynamic index buffer
  44933. * @param indexBuffer defines the target index buffer
  44934. * @param indices defines the data to update
  44935. * @param offset defines the offset in the target index buffer where update should start
  44936. */
  44937. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  44938. /**
  44939. * Updates a dynamic vertex buffer.
  44940. * @param vertexBuffer the vertex buffer to update
  44941. * @param vertices the data used to update the vertex buffer
  44942. * @param byteOffset the byte offset of the data (optional)
  44943. * @param byteLength the byte length of the data (optional)
  44944. */
  44945. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  44946. /** @hidden */
  44947. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  44948. /** @hidden */
  44949. _bindTexture(channel: number, texture: InternalTexture): void;
  44950. protected _deleteBuffer(buffer: WebGLBuffer): void;
  44951. /**
  44952. * 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
  44953. */
  44954. releaseEffects(): void;
  44955. displayLoadingUI(): void;
  44956. hideLoadingUI(): void;
  44957. /** @hidden */
  44958. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44959. /** @hidden */
  44960. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44961. /** @hidden */
  44962. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44963. /** @hidden */
  44964. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44965. }
  44966. }
  44967. declare module BABYLON {
  44968. /** @hidden */
  44969. export class _OcclusionDataStorage {
  44970. /** @hidden */
  44971. occlusionInternalRetryCounter: number;
  44972. /** @hidden */
  44973. isOcclusionQueryInProgress: boolean;
  44974. /** @hidden */
  44975. isOccluded: boolean;
  44976. /** @hidden */
  44977. occlusionRetryCount: number;
  44978. /** @hidden */
  44979. occlusionType: number;
  44980. /** @hidden */
  44981. occlusionQueryAlgorithmType: number;
  44982. }
  44983. interface Engine {
  44984. /**
  44985. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  44986. * @return the new query
  44987. */
  44988. createQuery(): WebGLQuery;
  44989. /**
  44990. * Delete and release a webGL query
  44991. * @param query defines the query to delete
  44992. * @return the current engine
  44993. */
  44994. deleteQuery(query: WebGLQuery): Engine;
  44995. /**
  44996. * Check if a given query has resolved and got its value
  44997. * @param query defines the query to check
  44998. * @returns true if the query got its value
  44999. */
  45000. isQueryResultAvailable(query: WebGLQuery): boolean;
  45001. /**
  45002. * Gets the value of a given query
  45003. * @param query defines the query to check
  45004. * @returns the value of the query
  45005. */
  45006. getQueryResult(query: WebGLQuery): number;
  45007. /**
  45008. * Initiates an occlusion query
  45009. * @param algorithmType defines the algorithm to use
  45010. * @param query defines the query to use
  45011. * @returns the current engine
  45012. * @see http://doc.babylonjs.com/features/occlusionquery
  45013. */
  45014. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45015. /**
  45016. * Ends an occlusion query
  45017. * @see http://doc.babylonjs.com/features/occlusionquery
  45018. * @param algorithmType defines the algorithm to use
  45019. * @returns the current engine
  45020. */
  45021. endOcclusionQuery(algorithmType: number): Engine;
  45022. /**
  45023. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45024. * Please note that only one query can be issued at a time
  45025. * @returns a time token used to track the time span
  45026. */
  45027. startTimeQuery(): Nullable<_TimeToken>;
  45028. /**
  45029. * Ends a time query
  45030. * @param token defines the token used to measure the time span
  45031. * @returns the time spent (in ns)
  45032. */
  45033. endTimeQuery(token: _TimeToken): int;
  45034. /** @hidden */
  45035. _currentNonTimestampToken: Nullable<_TimeToken>;
  45036. /** @hidden */
  45037. _createTimeQuery(): WebGLQuery;
  45038. /** @hidden */
  45039. _deleteTimeQuery(query: WebGLQuery): void;
  45040. /** @hidden */
  45041. _getGlAlgorithmType(algorithmType: number): number;
  45042. /** @hidden */
  45043. _getTimeQueryResult(query: WebGLQuery): any;
  45044. /** @hidden */
  45045. _getTimeQueryAvailability(query: WebGLQuery): any;
  45046. }
  45047. interface AbstractMesh {
  45048. /**
  45049. * Backing filed
  45050. * @hidden
  45051. */
  45052. __occlusionDataStorage: _OcclusionDataStorage;
  45053. /**
  45054. * Access property
  45055. * @hidden
  45056. */
  45057. _occlusionDataStorage: _OcclusionDataStorage;
  45058. /**
  45059. * 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.
  45060. * The default value is -1 which means don't break the query and wait till the result
  45061. * @see http://doc.babylonjs.com/features/occlusionquery
  45062. */
  45063. occlusionRetryCount: number;
  45064. /**
  45065. * 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:
  45066. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45067. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45068. * * 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.
  45069. * @see http://doc.babylonjs.com/features/occlusionquery
  45070. */
  45071. occlusionType: number;
  45072. /**
  45073. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45074. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45075. * * 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.
  45076. * @see http://doc.babylonjs.com/features/occlusionquery
  45077. */
  45078. occlusionQueryAlgorithmType: number;
  45079. /**
  45080. * 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
  45081. * @see http://doc.babylonjs.com/features/occlusionquery
  45082. */
  45083. isOccluded: boolean;
  45084. /**
  45085. * Flag to check the progress status of the query
  45086. * @see http://doc.babylonjs.com/features/occlusionquery
  45087. */
  45088. isOcclusionQueryInProgress: boolean;
  45089. }
  45090. }
  45091. declare module BABYLON {
  45092. /** @hidden */
  45093. export var _forceTransformFeedbackToBundle: boolean;
  45094. interface Engine {
  45095. /**
  45096. * Creates a webGL transform feedback object
  45097. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45098. * @returns the webGL transform feedback object
  45099. */
  45100. createTransformFeedback(): WebGLTransformFeedback;
  45101. /**
  45102. * Delete a webGL transform feedback object
  45103. * @param value defines the webGL transform feedback object to delete
  45104. */
  45105. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45106. /**
  45107. * Bind a webGL transform feedback object to the webgl context
  45108. * @param value defines the webGL transform feedback object to bind
  45109. */
  45110. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45111. /**
  45112. * Begins a transform feedback operation
  45113. * @param usePoints defines if points or triangles must be used
  45114. */
  45115. beginTransformFeedback(usePoints: boolean): void;
  45116. /**
  45117. * Ends a transform feedback operation
  45118. */
  45119. endTransformFeedback(): void;
  45120. /**
  45121. * Specify the varyings to use with transform feedback
  45122. * @param program defines the associated webGL program
  45123. * @param value defines the list of strings representing the varying names
  45124. */
  45125. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45126. /**
  45127. * Bind a webGL buffer for a transform feedback operation
  45128. * @param value defines the webGL buffer to bind
  45129. */
  45130. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45131. }
  45132. }
  45133. declare module BABYLON {
  45134. /**
  45135. * Creation options of the multi render target texture.
  45136. */
  45137. export interface IMultiRenderTargetOptions {
  45138. /**
  45139. * Define if the texture needs to create mip maps after render.
  45140. */
  45141. generateMipMaps?: boolean;
  45142. /**
  45143. * Define the types of all the draw buffers we want to create
  45144. */
  45145. types?: number[];
  45146. /**
  45147. * Define the sampling modes of all the draw buffers we want to create
  45148. */
  45149. samplingModes?: number[];
  45150. /**
  45151. * Define if a depth buffer is required
  45152. */
  45153. generateDepthBuffer?: boolean;
  45154. /**
  45155. * Define if a stencil buffer is required
  45156. */
  45157. generateStencilBuffer?: boolean;
  45158. /**
  45159. * Define if a depth texture is required instead of a depth buffer
  45160. */
  45161. generateDepthTexture?: boolean;
  45162. /**
  45163. * Define the number of desired draw buffers
  45164. */
  45165. textureCount?: number;
  45166. /**
  45167. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45168. */
  45169. doNotChangeAspectRatio?: boolean;
  45170. /**
  45171. * Define the default type of the buffers we are creating
  45172. */
  45173. defaultType?: number;
  45174. }
  45175. /**
  45176. * A multi render target, like a render target provides the ability to render to a texture.
  45177. * Unlike the render target, it can render to several draw buffers in one draw.
  45178. * This is specially interesting in deferred rendering or for any effects requiring more than
  45179. * just one color from a single pass.
  45180. */
  45181. export class MultiRenderTarget extends RenderTargetTexture {
  45182. private _internalTextures;
  45183. private _textures;
  45184. private _multiRenderTargetOptions;
  45185. /**
  45186. * Get if draw buffers are currently supported by the used hardware and browser.
  45187. */
  45188. readonly isSupported: boolean;
  45189. /**
  45190. * Get the list of textures generated by the multi render target.
  45191. */
  45192. readonly textures: Texture[];
  45193. /**
  45194. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45195. */
  45196. readonly depthTexture: Texture;
  45197. /**
  45198. * Set the wrapping mode on U of all the textures we are rendering to.
  45199. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45200. */
  45201. wrapU: number;
  45202. /**
  45203. * Set the wrapping mode on V of all the textures we are rendering to.
  45204. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45205. */
  45206. wrapV: number;
  45207. /**
  45208. * Instantiate a new multi render target texture.
  45209. * A multi render target, like a render target provides the ability to render to a texture.
  45210. * Unlike the render target, it can render to several draw buffers in one draw.
  45211. * This is specially interesting in deferred rendering or for any effects requiring more than
  45212. * just one color from a single pass.
  45213. * @param name Define the name of the texture
  45214. * @param size Define the size of the buffers to render to
  45215. * @param count Define the number of target we are rendering into
  45216. * @param scene Define the scene the texture belongs to
  45217. * @param options Define the options used to create the multi render target
  45218. */
  45219. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45220. /** @hidden */
  45221. _rebuild(): void;
  45222. private _createInternalTextures;
  45223. private _createTextures;
  45224. /**
  45225. * Define the number of samples used if MSAA is enabled.
  45226. */
  45227. samples: number;
  45228. /**
  45229. * Resize all the textures in the multi render target.
  45230. * Be carrefull as it will recreate all the data in the new texture.
  45231. * @param size Define the new size
  45232. */
  45233. resize(size: any): void;
  45234. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45235. /**
  45236. * Dispose the render targets and their associated resources
  45237. */
  45238. dispose(): void;
  45239. /**
  45240. * Release all the underlying texture used as draw buffers.
  45241. */
  45242. releaseInternalTextures(): void;
  45243. }
  45244. }
  45245. declare module BABYLON {
  45246. interface ThinEngine {
  45247. /**
  45248. * Unbind a list of render target textures from the webGL context
  45249. * This is used only when drawBuffer extension or webGL2 are active
  45250. * @param textures defines the render target textures to unbind
  45251. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45252. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45253. */
  45254. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45255. /**
  45256. * Create a multi render target texture
  45257. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45258. * @param size defines the size of the texture
  45259. * @param options defines the creation options
  45260. * @returns the cube texture as an InternalTexture
  45261. */
  45262. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45263. /**
  45264. * Update the sample count for a given multiple render target texture
  45265. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45266. * @param textures defines the textures to update
  45267. * @param samples defines the sample count to set
  45268. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45269. */
  45270. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45271. }
  45272. }
  45273. declare module BABYLON {
  45274. /**
  45275. * Class used to define an additional view for the engine
  45276. * @see https://doc.babylonjs.com/how_to/multi_canvases
  45277. */
  45278. export class EngineView {
  45279. /** Defines the canvas where to render the view */
  45280. target: HTMLCanvasElement;
  45281. /** Defines an optional camera used to render the view (will use active camera else) */
  45282. camera?: Camera;
  45283. }
  45284. interface Engine {
  45285. /**
  45286. * Gets or sets the HTML element to use for attaching events
  45287. */
  45288. inputElement: Nullable<HTMLElement>;
  45289. /**
  45290. * Gets the current engine view
  45291. * @see https://doc.babylonjs.com/how_to/multi_canvases
  45292. */
  45293. activeView: Nullable<EngineView>;
  45294. /** Gets or sets the list of views */
  45295. views: EngineView[];
  45296. /**
  45297. * Register a new child canvas
  45298. * @param canvas defines the canvas to register
  45299. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  45300. * @returns the associated view
  45301. */
  45302. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  45303. /**
  45304. * Remove a registered child canvas
  45305. * @param canvas defines the canvas to remove
  45306. * @returns the current engine
  45307. */
  45308. unRegisterView(canvas: HTMLCanvasElement): Engine;
  45309. }
  45310. }
  45311. declare module BABYLON {
  45312. /**
  45313. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  45314. */
  45315. export interface CubeMapInfo {
  45316. /**
  45317. * The pixel array for the front face.
  45318. * This is stored in format, left to right, up to down format.
  45319. */
  45320. front: Nullable<ArrayBufferView>;
  45321. /**
  45322. * The pixel array for the back face.
  45323. * This is stored in format, left to right, up to down format.
  45324. */
  45325. back: Nullable<ArrayBufferView>;
  45326. /**
  45327. * The pixel array for the left face.
  45328. * This is stored in format, left to right, up to down format.
  45329. */
  45330. left: Nullable<ArrayBufferView>;
  45331. /**
  45332. * The pixel array for the right face.
  45333. * This is stored in format, left to right, up to down format.
  45334. */
  45335. right: Nullable<ArrayBufferView>;
  45336. /**
  45337. * The pixel array for the up face.
  45338. * This is stored in format, left to right, up to down format.
  45339. */
  45340. up: Nullable<ArrayBufferView>;
  45341. /**
  45342. * The pixel array for the down face.
  45343. * This is stored in format, left to right, up to down format.
  45344. */
  45345. down: Nullable<ArrayBufferView>;
  45346. /**
  45347. * The size of the cubemap stored.
  45348. *
  45349. * Each faces will be size * size pixels.
  45350. */
  45351. size: number;
  45352. /**
  45353. * The format of the texture.
  45354. *
  45355. * RGBA, RGB.
  45356. */
  45357. format: number;
  45358. /**
  45359. * The type of the texture data.
  45360. *
  45361. * UNSIGNED_INT, FLOAT.
  45362. */
  45363. type: number;
  45364. /**
  45365. * Specifies whether the texture is in gamma space.
  45366. */
  45367. gammaSpace: boolean;
  45368. }
  45369. /**
  45370. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  45371. */
  45372. export class PanoramaToCubeMapTools {
  45373. private static FACE_FRONT;
  45374. private static FACE_BACK;
  45375. private static FACE_RIGHT;
  45376. private static FACE_LEFT;
  45377. private static FACE_DOWN;
  45378. private static FACE_UP;
  45379. /**
  45380. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  45381. *
  45382. * @param float32Array The source data.
  45383. * @param inputWidth The width of the input panorama.
  45384. * @param inputHeight The height of the input panorama.
  45385. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  45386. * @return The cubemap data
  45387. */
  45388. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  45389. private static CreateCubemapTexture;
  45390. private static CalcProjectionSpherical;
  45391. }
  45392. }
  45393. declare module BABYLON {
  45394. /**
  45395. * Helper class dealing with the extraction of spherical polynomial dataArray
  45396. * from a cube map.
  45397. */
  45398. export class CubeMapToSphericalPolynomialTools {
  45399. private static FileFaces;
  45400. /**
  45401. * Converts a texture to the according Spherical Polynomial data.
  45402. * This extracts the first 3 orders only as they are the only one used in the lighting.
  45403. *
  45404. * @param texture The texture to extract the information from.
  45405. * @return The Spherical Polynomial data.
  45406. */
  45407. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  45408. /**
  45409. * Converts a cubemap to the according Spherical Polynomial data.
  45410. * This extracts the first 3 orders only as they are the only one used in the lighting.
  45411. *
  45412. * @param cubeInfo The Cube map to extract the information from.
  45413. * @return The Spherical Polynomial data.
  45414. */
  45415. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  45416. }
  45417. }
  45418. declare module BABYLON {
  45419. interface BaseTexture {
  45420. /**
  45421. * Get the polynomial representation of the texture data.
  45422. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  45423. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  45424. */
  45425. sphericalPolynomial: Nullable<SphericalPolynomial>;
  45426. }
  45427. }
  45428. declare module BABYLON {
  45429. /** @hidden */
  45430. export var rgbdEncodePixelShader: {
  45431. name: string;
  45432. shader: string;
  45433. };
  45434. }
  45435. declare module BABYLON {
  45436. /** @hidden */
  45437. export var rgbdDecodePixelShader: {
  45438. name: string;
  45439. shader: string;
  45440. };
  45441. }
  45442. declare module BABYLON {
  45443. /**
  45444. * Raw texture data and descriptor sufficient for WebGL texture upload
  45445. */
  45446. export interface EnvironmentTextureInfo {
  45447. /**
  45448. * Version of the environment map
  45449. */
  45450. version: number;
  45451. /**
  45452. * Width of image
  45453. */
  45454. width: number;
  45455. /**
  45456. * Irradiance information stored in the file.
  45457. */
  45458. irradiance: any;
  45459. /**
  45460. * Specular information stored in the file.
  45461. */
  45462. specular: any;
  45463. }
  45464. /**
  45465. * Defines One Image in the file. It requires only the position in the file
  45466. * as well as the length.
  45467. */
  45468. interface BufferImageData {
  45469. /**
  45470. * Length of the image data.
  45471. */
  45472. length: number;
  45473. /**
  45474. * Position of the data from the null terminator delimiting the end of the JSON.
  45475. */
  45476. position: number;
  45477. }
  45478. /**
  45479. * Defines the specular data enclosed in the file.
  45480. * This corresponds to the version 1 of the data.
  45481. */
  45482. export interface EnvironmentTextureSpecularInfoV1 {
  45483. /**
  45484. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  45485. */
  45486. specularDataPosition?: number;
  45487. /**
  45488. * This contains all the images data needed to reconstruct the cubemap.
  45489. */
  45490. mipmaps: Array<BufferImageData>;
  45491. /**
  45492. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  45493. */
  45494. lodGenerationScale: number;
  45495. }
  45496. /**
  45497. * Sets of helpers addressing the serialization and deserialization of environment texture
  45498. * stored in a BabylonJS env file.
  45499. * Those files are usually stored as .env files.
  45500. */
  45501. export class EnvironmentTextureTools {
  45502. /**
  45503. * Magic number identifying the env file.
  45504. */
  45505. private static _MagicBytes;
  45506. /**
  45507. * Gets the environment info from an env file.
  45508. * @param data The array buffer containing the .env bytes.
  45509. * @returns the environment file info (the json header) if successfully parsed.
  45510. */
  45511. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45512. /**
  45513. * Creates an environment texture from a loaded cube texture.
  45514. * @param texture defines the cube texture to convert in env file
  45515. * @return a promise containing the environment data if succesfull.
  45516. */
  45517. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45518. /**
  45519. * Creates a JSON representation of the spherical data.
  45520. * @param texture defines the texture containing the polynomials
  45521. * @return the JSON representation of the spherical info
  45522. */
  45523. private static _CreateEnvTextureIrradiance;
  45524. /**
  45525. * Creates the ArrayBufferViews used for initializing environment texture image data.
  45526. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  45527. * @param info parameters that determine what views will be created for accessing the underlying buffer
  45528. * @return the views described by info providing access to the underlying buffer
  45529. */
  45530. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  45531. /**
  45532. * Uploads the texture info contained in the env file to the GPU.
  45533. * @param texture defines the internal texture to upload to
  45534. * @param arrayBuffer defines the buffer cotaining the data to load
  45535. * @param info defines the texture info retrieved through the GetEnvInfo method
  45536. * @returns a promise
  45537. */
  45538. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45539. private static _OnImageReadyAsync;
  45540. /**
  45541. * Uploads the levels of image data to the GPU.
  45542. * @param texture defines the internal texture to upload to
  45543. * @param imageData defines the array buffer views of image data [mipmap][face]
  45544. * @returns a promise
  45545. */
  45546. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45547. /**
  45548. * Uploads spherical polynomials information to the texture.
  45549. * @param texture defines the texture we are trying to upload the information to
  45550. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45551. */
  45552. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45553. /** @hidden */
  45554. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45555. }
  45556. }
  45557. declare module BABYLON {
  45558. /**
  45559. * Contains position and normal vectors for a vertex
  45560. */
  45561. export class PositionNormalVertex {
  45562. /** the position of the vertex (defaut: 0,0,0) */
  45563. position: Vector3;
  45564. /** the normal of the vertex (defaut: 0,1,0) */
  45565. normal: Vector3;
  45566. /**
  45567. * Creates a PositionNormalVertex
  45568. * @param position the position of the vertex (defaut: 0,0,0)
  45569. * @param normal the normal of the vertex (defaut: 0,1,0)
  45570. */
  45571. constructor(
  45572. /** the position of the vertex (defaut: 0,0,0) */
  45573. position?: Vector3,
  45574. /** the normal of the vertex (defaut: 0,1,0) */
  45575. normal?: Vector3);
  45576. /**
  45577. * Clones the PositionNormalVertex
  45578. * @returns the cloned PositionNormalVertex
  45579. */
  45580. clone(): PositionNormalVertex;
  45581. }
  45582. /**
  45583. * Contains position, normal and uv vectors for a vertex
  45584. */
  45585. export class PositionNormalTextureVertex {
  45586. /** the position of the vertex (defaut: 0,0,0) */
  45587. position: Vector3;
  45588. /** the normal of the vertex (defaut: 0,1,0) */
  45589. normal: Vector3;
  45590. /** the uv of the vertex (default: 0,0) */
  45591. uv: Vector2;
  45592. /**
  45593. * Creates a PositionNormalTextureVertex
  45594. * @param position the position of the vertex (defaut: 0,0,0)
  45595. * @param normal the normal of the vertex (defaut: 0,1,0)
  45596. * @param uv the uv of the vertex (default: 0,0)
  45597. */
  45598. constructor(
  45599. /** the position of the vertex (defaut: 0,0,0) */
  45600. position?: Vector3,
  45601. /** the normal of the vertex (defaut: 0,1,0) */
  45602. normal?: Vector3,
  45603. /** the uv of the vertex (default: 0,0) */
  45604. uv?: Vector2);
  45605. /**
  45606. * Clones the PositionNormalTextureVertex
  45607. * @returns the cloned PositionNormalTextureVertex
  45608. */
  45609. clone(): PositionNormalTextureVertex;
  45610. }
  45611. }
  45612. declare module BABYLON {
  45613. /** @hidden */
  45614. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  45615. private _genericAttributeLocation;
  45616. private _varyingLocationCount;
  45617. private _varyingLocationMap;
  45618. private _replacements;
  45619. private _textureCount;
  45620. private _uniforms;
  45621. lineProcessor(line: string): string;
  45622. attributeProcessor(attribute: string): string;
  45623. varyingProcessor(varying: string, isFragment: boolean): string;
  45624. uniformProcessor(uniform: string): string;
  45625. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  45626. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  45627. }
  45628. }
  45629. declare module BABYLON {
  45630. /**
  45631. * Container for accessors for natively-stored mesh data buffers.
  45632. */
  45633. class NativeDataBuffer extends DataBuffer {
  45634. /**
  45635. * Accessor value used to identify/retrieve a natively-stored index buffer.
  45636. */
  45637. nativeIndexBuffer?: any;
  45638. /**
  45639. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  45640. */
  45641. nativeVertexBuffer?: any;
  45642. }
  45643. /** @hidden */
  45644. class NativeTexture extends InternalTexture {
  45645. getInternalTexture(): InternalTexture;
  45646. getViewCount(): number;
  45647. }
  45648. /** @hidden */
  45649. export class NativeEngine extends Engine {
  45650. private readonly _native;
  45651. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  45652. private readonly INVALID_HANDLE;
  45653. getHardwareScalingLevel(): number;
  45654. constructor();
  45655. /**
  45656. * Can be used to override the current requestAnimationFrame requester.
  45657. * @hidden
  45658. */
  45659. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  45660. /**
  45661. * Override default engine behavior.
  45662. * @param color
  45663. * @param backBuffer
  45664. * @param depth
  45665. * @param stencil
  45666. */
  45667. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  45668. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45669. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  45670. createVertexBuffer(data: DataArray): NativeDataBuffer;
  45671. recordVertexArrayObject(vertexBuffers: {
  45672. [key: string]: VertexBuffer;
  45673. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  45674. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45675. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45676. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45677. /**
  45678. * Draw a list of indexed primitives
  45679. * @param fillMode defines the primitive to use
  45680. * @param indexStart defines the starting index
  45681. * @param indexCount defines the number of index to draw
  45682. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45683. */
  45684. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45685. /**
  45686. * Draw a list of unindexed primitives
  45687. * @param fillMode defines the primitive to use
  45688. * @param verticesStart defines the index of first vertex to draw
  45689. * @param verticesCount defines the count of vertices to draw
  45690. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45691. */
  45692. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45693. createPipelineContext(): IPipelineContext;
  45694. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  45695. /** @hidden */
  45696. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45697. /** @hidden */
  45698. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45699. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45700. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45701. protected _setProgram(program: WebGLProgram): void;
  45702. _releaseEffect(effect: Effect): void;
  45703. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45704. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  45705. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45706. bindSamplers(effect: Effect): void;
  45707. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  45708. getRenderWidth(useScreen?: boolean): number;
  45709. getRenderHeight(useScreen?: boolean): number;
  45710. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  45711. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45712. /**
  45713. * Set the z offset to apply to current rendering
  45714. * @param value defines the offset to apply
  45715. */
  45716. setZOffset(value: number): void;
  45717. /**
  45718. * Gets the current value of the zOffset
  45719. * @returns the current zOffset state
  45720. */
  45721. getZOffset(): number;
  45722. /**
  45723. * Enable or disable depth buffering
  45724. * @param enable defines the state to set
  45725. */
  45726. setDepthBuffer(enable: boolean): void;
  45727. /**
  45728. * Gets a boolean indicating if depth writing is enabled
  45729. * @returns the current depth writing state
  45730. */
  45731. getDepthWrite(): boolean;
  45732. /**
  45733. * Enable or disable depth writing
  45734. * @param enable defines the state to set
  45735. */
  45736. setDepthWrite(enable: boolean): void;
  45737. /**
  45738. * Enable or disable color writing
  45739. * @param enable defines the state to set
  45740. */
  45741. setColorWrite(enable: boolean): void;
  45742. /**
  45743. * Gets a boolean indicating if color writing is enabled
  45744. * @returns the current color writing state
  45745. */
  45746. getColorWrite(): boolean;
  45747. /**
  45748. * Sets alpha constants used by some alpha blending modes
  45749. * @param r defines the red component
  45750. * @param g defines the green component
  45751. * @param b defines the blue component
  45752. * @param a defines the alpha component
  45753. */
  45754. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  45755. /**
  45756. * Sets the current alpha mode
  45757. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  45758. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45759. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45760. */
  45761. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45762. /**
  45763. * Gets the current alpha mode
  45764. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45765. * @returns the current alpha mode
  45766. */
  45767. getAlphaMode(): number;
  45768. setInt(uniform: WebGLUniformLocation, int: number): void;
  45769. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45770. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45771. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45772. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45773. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45774. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45775. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45776. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45777. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45778. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45779. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45780. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45781. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45782. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45783. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45784. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45785. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45786. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45787. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45788. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  45789. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  45790. wipeCaches(bruteForce?: boolean): void;
  45791. _createTexture(): WebGLTexture;
  45792. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  45793. /**
  45794. * Usually called from BABYLON.Texture.ts.
  45795. * Passed information to create a WebGLTexture
  45796. * @param urlArg defines a value which contains one of the following:
  45797. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45798. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45799. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45800. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45801. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  45802. * @param scene needed for loading to the correct scene
  45803. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  45804. * @param onLoad optional callback to be called upon successful completion
  45805. * @param onError optional callback to be called upon failure
  45806. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  45807. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45808. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45809. * @param forcedExtension defines the extension to use to pick the right loader
  45810. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45811. */
  45812. 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;
  45813. /**
  45814. * Creates a cube texture
  45815. * @param rootUrl defines the url where the files to load is located
  45816. * @param scene defines the current scene
  45817. * @param files defines the list of files to load (1 per face)
  45818. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45819. * @param onLoad defines an optional callback raised when the texture is loaded
  45820. * @param onError defines an optional callback raised if there is an issue to load the texture
  45821. * @param format defines the format of the data
  45822. * @param forcedExtension defines the extension to use to pick the right loader
  45823. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45824. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45825. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45826. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45827. * @returns the cube texture as an InternalTexture
  45828. */
  45829. 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;
  45830. private _getSamplingFilter;
  45831. private static _GetNativeTextureFormat;
  45832. createRenderTargetTexture(size: number | {
  45833. width: number;
  45834. height: number;
  45835. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  45836. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45837. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45838. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45839. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45840. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45841. /**
  45842. * Updates a dynamic vertex buffer.
  45843. * @param vertexBuffer the vertex buffer to update
  45844. * @param data the data used to update the vertex buffer
  45845. * @param byteOffset the byte offset of the data (optional)
  45846. * @param byteLength the byte length of the data (optional)
  45847. */
  45848. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  45849. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  45850. private _updateAnisotropicLevel;
  45851. private _getAddressMode;
  45852. /** @hidden */
  45853. _bindTexture(channel: number, texture: InternalTexture): void;
  45854. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  45855. releaseEffects(): void;
  45856. /** @hidden */
  45857. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45858. /** @hidden */
  45859. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45860. /** @hidden */
  45861. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45862. /** @hidden */
  45863. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45864. }
  45865. }
  45866. declare module BABYLON {
  45867. /**
  45868. * Gather the list of clipboard event types as constants.
  45869. */
  45870. export class ClipboardEventTypes {
  45871. /**
  45872. * The clipboard event is fired when a copy command is active (pressed).
  45873. */
  45874. static readonly COPY: number;
  45875. /**
  45876. * The clipboard event is fired when a cut command is active (pressed).
  45877. */
  45878. static readonly CUT: number;
  45879. /**
  45880. * The clipboard event is fired when a paste command is active (pressed).
  45881. */
  45882. static readonly PASTE: number;
  45883. }
  45884. /**
  45885. * This class is used to store clipboard related info for the onClipboardObservable event.
  45886. */
  45887. export class ClipboardInfo {
  45888. /**
  45889. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45890. */
  45891. type: number;
  45892. /**
  45893. * Defines the related dom event
  45894. */
  45895. event: ClipboardEvent;
  45896. /**
  45897. *Creates an instance of ClipboardInfo.
  45898. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45899. * @param event Defines the related dom event
  45900. */
  45901. constructor(
  45902. /**
  45903. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45904. */
  45905. type: number,
  45906. /**
  45907. * Defines the related dom event
  45908. */
  45909. event: ClipboardEvent);
  45910. /**
  45911. * Get the clipboard event's type from the keycode.
  45912. * @param keyCode Defines the keyCode for the current keyboard event.
  45913. * @return {number}
  45914. */
  45915. static GetTypeFromCharacter(keyCode: number): number;
  45916. }
  45917. }
  45918. declare module BABYLON {
  45919. /**
  45920. * Google Daydream controller
  45921. */
  45922. export class DaydreamController extends WebVRController {
  45923. /**
  45924. * Base Url for the controller model.
  45925. */
  45926. static MODEL_BASE_URL: string;
  45927. /**
  45928. * File name for the controller model.
  45929. */
  45930. static MODEL_FILENAME: string;
  45931. /**
  45932. * Gamepad Id prefix used to identify Daydream Controller.
  45933. */
  45934. static readonly GAMEPAD_ID_PREFIX: string;
  45935. /**
  45936. * Creates a new DaydreamController from a gamepad
  45937. * @param vrGamepad the gamepad that the controller should be created from
  45938. */
  45939. constructor(vrGamepad: any);
  45940. /**
  45941. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45942. * @param scene scene in which to add meshes
  45943. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45944. */
  45945. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45946. /**
  45947. * Called once for each button that changed state since the last frame
  45948. * @param buttonIdx Which button index changed
  45949. * @param state New state of the button
  45950. * @param changes Which properties on the state changed since last frame
  45951. */
  45952. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45953. }
  45954. }
  45955. declare module BABYLON {
  45956. /**
  45957. * Gear VR Controller
  45958. */
  45959. export class GearVRController extends WebVRController {
  45960. /**
  45961. * Base Url for the controller model.
  45962. */
  45963. static MODEL_BASE_URL: string;
  45964. /**
  45965. * File name for the controller model.
  45966. */
  45967. static MODEL_FILENAME: string;
  45968. /**
  45969. * Gamepad Id prefix used to identify this controller.
  45970. */
  45971. static readonly GAMEPAD_ID_PREFIX: string;
  45972. private readonly _buttonIndexToObservableNameMap;
  45973. /**
  45974. * Creates a new GearVRController from a gamepad
  45975. * @param vrGamepad the gamepad that the controller should be created from
  45976. */
  45977. constructor(vrGamepad: any);
  45978. /**
  45979. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45980. * @param scene scene in which to add meshes
  45981. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45982. */
  45983. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45984. /**
  45985. * Called once for each button that changed state since the last frame
  45986. * @param buttonIdx Which button index changed
  45987. * @param state New state of the button
  45988. * @param changes Which properties on the state changed since last frame
  45989. */
  45990. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45991. }
  45992. }
  45993. declare module BABYLON {
  45994. /**
  45995. * Class containing static functions to help procedurally build meshes
  45996. */
  45997. export class PolyhedronBuilder {
  45998. /**
  45999. * Creates a polyhedron mesh
  46000. * * 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
  46001. * * The parameter `size` (positive float, default 1) sets the polygon size
  46002. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46003. * * 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`
  46004. * * 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
  46005. * * 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)`)
  46006. * * 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
  46007. * * 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
  46008. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46009. * * 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
  46010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46011. * @param name defines the name of the mesh
  46012. * @param options defines the options used to create the mesh
  46013. * @param scene defines the hosting scene
  46014. * @returns the polyhedron mesh
  46015. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46016. */
  46017. static CreatePolyhedron(name: string, options: {
  46018. type?: number;
  46019. size?: number;
  46020. sizeX?: number;
  46021. sizeY?: number;
  46022. sizeZ?: number;
  46023. custom?: any;
  46024. faceUV?: Vector4[];
  46025. faceColors?: Color4[];
  46026. flat?: boolean;
  46027. updatable?: boolean;
  46028. sideOrientation?: number;
  46029. frontUVs?: Vector4;
  46030. backUVs?: Vector4;
  46031. }, scene?: Nullable<Scene>): Mesh;
  46032. }
  46033. }
  46034. declare module BABYLON {
  46035. /**
  46036. * Gizmo that enables scaling a mesh along 3 axis
  46037. */
  46038. export class ScaleGizmo extends Gizmo {
  46039. /**
  46040. * Internal gizmo used for interactions on the x axis
  46041. */
  46042. xGizmo: AxisScaleGizmo;
  46043. /**
  46044. * Internal gizmo used for interactions on the y axis
  46045. */
  46046. yGizmo: AxisScaleGizmo;
  46047. /**
  46048. * Internal gizmo used for interactions on the z axis
  46049. */
  46050. zGizmo: AxisScaleGizmo;
  46051. /**
  46052. * Internal gizmo used to scale all axis equally
  46053. */
  46054. uniformScaleGizmo: AxisScaleGizmo;
  46055. private _meshAttached;
  46056. private _updateGizmoRotationToMatchAttachedMesh;
  46057. private _snapDistance;
  46058. private _scaleRatio;
  46059. private _uniformScalingMesh;
  46060. private _octahedron;
  46061. private _sensitivity;
  46062. /** Fires an event when any of it's sub gizmos are dragged */
  46063. onDragStartObservable: Observable<unknown>;
  46064. /** Fires an event when any of it's sub gizmos are released from dragging */
  46065. onDragEndObservable: Observable<unknown>;
  46066. attachedMesh: Nullable<AbstractMesh>;
  46067. /**
  46068. * Creates a ScaleGizmo
  46069. * @param gizmoLayer The utility layer the gizmo will be added to
  46070. */
  46071. constructor(gizmoLayer?: UtilityLayerRenderer);
  46072. updateGizmoRotationToMatchAttachedMesh: boolean;
  46073. /**
  46074. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46075. */
  46076. snapDistance: number;
  46077. /**
  46078. * Ratio for the scale of the gizmo (Default: 1)
  46079. */
  46080. scaleRatio: number;
  46081. /**
  46082. * Sensitivity factor for dragging (Default: 1)
  46083. */
  46084. sensitivity: number;
  46085. /**
  46086. * Disposes of the gizmo
  46087. */
  46088. dispose(): void;
  46089. }
  46090. }
  46091. declare module BABYLON {
  46092. /**
  46093. * Single axis scale gizmo
  46094. */
  46095. export class AxisScaleGizmo extends Gizmo {
  46096. /**
  46097. * Drag behavior responsible for the gizmos dragging interactions
  46098. */
  46099. dragBehavior: PointerDragBehavior;
  46100. private _pointerObserver;
  46101. /**
  46102. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46103. */
  46104. snapDistance: number;
  46105. /**
  46106. * Event that fires each time the gizmo snaps to a new location.
  46107. * * snapDistance is the the change in distance
  46108. */
  46109. onSnapObservable: Observable<{
  46110. snapDistance: number;
  46111. }>;
  46112. /**
  46113. * If the scaling operation should be done on all axis (default: false)
  46114. */
  46115. uniformScaling: boolean;
  46116. /**
  46117. * Custom sensitivity value for the drag strength
  46118. */
  46119. sensitivity: number;
  46120. private _isEnabled;
  46121. private _parent;
  46122. private _arrow;
  46123. private _coloredMaterial;
  46124. private _hoverMaterial;
  46125. /**
  46126. * Creates an AxisScaleGizmo
  46127. * @param gizmoLayer The utility layer the gizmo will be added to
  46128. * @param dragAxis The axis which the gizmo will be able to scale on
  46129. * @param color The color of the gizmo
  46130. */
  46131. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46132. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46133. /**
  46134. * If the gizmo is enabled
  46135. */
  46136. isEnabled: boolean;
  46137. /**
  46138. * Disposes of the gizmo
  46139. */
  46140. dispose(): void;
  46141. /**
  46142. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46143. * @param mesh The mesh to replace the default mesh of the gizmo
  46144. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46145. */
  46146. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46147. }
  46148. }
  46149. declare module BABYLON {
  46150. /**
  46151. * Bounding box gizmo
  46152. */
  46153. export class BoundingBoxGizmo extends Gizmo {
  46154. private _lineBoundingBox;
  46155. private _rotateSpheresParent;
  46156. private _scaleBoxesParent;
  46157. private _boundingDimensions;
  46158. private _renderObserver;
  46159. private _pointerObserver;
  46160. private _scaleDragSpeed;
  46161. private _tmpQuaternion;
  46162. private _tmpVector;
  46163. private _tmpRotationMatrix;
  46164. /**
  46165. * 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)
  46166. */
  46167. ignoreChildren: boolean;
  46168. /**
  46169. * 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)
  46170. */
  46171. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46172. /**
  46173. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46174. */
  46175. rotationSphereSize: number;
  46176. /**
  46177. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46178. */
  46179. scaleBoxSize: number;
  46180. /**
  46181. * 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)
  46182. */
  46183. fixedDragMeshScreenSize: boolean;
  46184. /**
  46185. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46186. */
  46187. fixedDragMeshScreenSizeDistanceFactor: number;
  46188. /**
  46189. * Fired when a rotation sphere or scale box is dragged
  46190. */
  46191. onDragStartObservable: Observable<{}>;
  46192. /**
  46193. * Fired when a scale box is dragged
  46194. */
  46195. onScaleBoxDragObservable: Observable<{}>;
  46196. /**
  46197. * Fired when a scale box drag is ended
  46198. */
  46199. onScaleBoxDragEndObservable: Observable<{}>;
  46200. /**
  46201. * Fired when a rotation sphere is dragged
  46202. */
  46203. onRotationSphereDragObservable: Observable<{}>;
  46204. /**
  46205. * Fired when a rotation sphere drag is ended
  46206. */
  46207. onRotationSphereDragEndObservable: Observable<{}>;
  46208. /**
  46209. * 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)
  46210. */
  46211. scalePivot: Nullable<Vector3>;
  46212. /**
  46213. * Mesh used as a pivot to rotate the attached mesh
  46214. */
  46215. private _anchorMesh;
  46216. private _existingMeshScale;
  46217. private _dragMesh;
  46218. private pointerDragBehavior;
  46219. private coloredMaterial;
  46220. private hoverColoredMaterial;
  46221. /**
  46222. * Sets the color of the bounding box gizmo
  46223. * @param color the color to set
  46224. */
  46225. setColor(color: Color3): void;
  46226. /**
  46227. * Creates an BoundingBoxGizmo
  46228. * @param gizmoLayer The utility layer the gizmo will be added to
  46229. * @param color The color of the gizmo
  46230. */
  46231. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46232. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46233. private _selectNode;
  46234. /**
  46235. * Updates the bounding box information for the Gizmo
  46236. */
  46237. updateBoundingBox(): void;
  46238. private _updateRotationSpheres;
  46239. private _updateScaleBoxes;
  46240. /**
  46241. * Enables rotation on the specified axis and disables rotation on the others
  46242. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46243. */
  46244. setEnabledRotationAxis(axis: string): void;
  46245. /**
  46246. * Enables/disables scaling
  46247. * @param enable if scaling should be enabled
  46248. */
  46249. setEnabledScaling(enable: boolean): void;
  46250. private _updateDummy;
  46251. /**
  46252. * Enables a pointer drag behavior on the bounding box of the gizmo
  46253. */
  46254. enableDragBehavior(): void;
  46255. /**
  46256. * Disposes of the gizmo
  46257. */
  46258. dispose(): void;
  46259. /**
  46260. * 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)
  46261. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  46262. * @returns the bounding box mesh with the passed in mesh as a child
  46263. */
  46264. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  46265. /**
  46266. * CustomMeshes are not supported by this gizmo
  46267. * @param mesh The mesh to replace the default mesh of the gizmo
  46268. */
  46269. setCustomMesh(mesh: Mesh): void;
  46270. }
  46271. }
  46272. declare module BABYLON {
  46273. /**
  46274. * Single plane rotation gizmo
  46275. */
  46276. export class PlaneRotationGizmo extends Gizmo {
  46277. /**
  46278. * Drag behavior responsible for the gizmos dragging interactions
  46279. */
  46280. dragBehavior: PointerDragBehavior;
  46281. private _pointerObserver;
  46282. /**
  46283. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  46284. */
  46285. snapDistance: number;
  46286. /**
  46287. * Event that fires each time the gizmo snaps to a new location.
  46288. * * snapDistance is the the change in distance
  46289. */
  46290. onSnapObservable: Observable<{
  46291. snapDistance: number;
  46292. }>;
  46293. private _isEnabled;
  46294. private _parent;
  46295. /**
  46296. * Creates a PlaneRotationGizmo
  46297. * @param gizmoLayer The utility layer the gizmo will be added to
  46298. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  46299. * @param color The color of the gizmo
  46300. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46301. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46302. */
  46303. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  46304. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46305. /**
  46306. * If the gizmo is enabled
  46307. */
  46308. isEnabled: boolean;
  46309. /**
  46310. * Disposes of the gizmo
  46311. */
  46312. dispose(): void;
  46313. }
  46314. }
  46315. declare module BABYLON {
  46316. /**
  46317. * Gizmo that enables rotating a mesh along 3 axis
  46318. */
  46319. export class RotationGizmo extends Gizmo {
  46320. /**
  46321. * Internal gizmo used for interactions on the x axis
  46322. */
  46323. xGizmo: PlaneRotationGizmo;
  46324. /**
  46325. * Internal gizmo used for interactions on the y axis
  46326. */
  46327. yGizmo: PlaneRotationGizmo;
  46328. /**
  46329. * Internal gizmo used for interactions on the z axis
  46330. */
  46331. zGizmo: PlaneRotationGizmo;
  46332. /** Fires an event when any of it's sub gizmos are dragged */
  46333. onDragStartObservable: Observable<unknown>;
  46334. /** Fires an event when any of it's sub gizmos are released from dragging */
  46335. onDragEndObservable: Observable<unknown>;
  46336. private _meshAttached;
  46337. attachedMesh: Nullable<AbstractMesh>;
  46338. /**
  46339. * Creates a RotationGizmo
  46340. * @param gizmoLayer The utility layer the gizmo will be added to
  46341. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46342. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46343. */
  46344. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  46345. updateGizmoRotationToMatchAttachedMesh: boolean;
  46346. /**
  46347. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46348. */
  46349. snapDistance: number;
  46350. /**
  46351. * Ratio for the scale of the gizmo (Default: 1)
  46352. */
  46353. scaleRatio: number;
  46354. /**
  46355. * Disposes of the gizmo
  46356. */
  46357. dispose(): void;
  46358. /**
  46359. * CustomMeshes are not supported by this gizmo
  46360. * @param mesh The mesh to replace the default mesh of the gizmo
  46361. */
  46362. setCustomMesh(mesh: Mesh): void;
  46363. }
  46364. }
  46365. declare module BABYLON {
  46366. /**
  46367. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46368. */
  46369. export class GizmoManager implements IDisposable {
  46370. private scene;
  46371. /**
  46372. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46373. */
  46374. gizmos: {
  46375. positionGizmo: Nullable<PositionGizmo>;
  46376. rotationGizmo: Nullable<RotationGizmo>;
  46377. scaleGizmo: Nullable<ScaleGizmo>;
  46378. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46379. };
  46380. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46381. clearGizmoOnEmptyPointerEvent: boolean;
  46382. /** Fires an event when the manager is attached to a mesh */
  46383. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46384. private _gizmosEnabled;
  46385. private _pointerObserver;
  46386. private _attachedMesh;
  46387. private _boundingBoxColor;
  46388. private _defaultUtilityLayer;
  46389. private _defaultKeepDepthUtilityLayer;
  46390. /**
  46391. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46392. */
  46393. boundingBoxDragBehavior: SixDofDragBehavior;
  46394. /**
  46395. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46396. */
  46397. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46398. /**
  46399. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46400. */
  46401. usePointerToAttachGizmos: boolean;
  46402. /**
  46403. * Utility layer that the bounding box gizmo belongs to
  46404. */
  46405. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46406. /**
  46407. * Utility layer that all gizmos besides bounding box belong to
  46408. */
  46409. readonly utilityLayer: UtilityLayerRenderer;
  46410. /**
  46411. * Instatiates a gizmo manager
  46412. * @param scene the scene to overlay the gizmos on top of
  46413. */
  46414. constructor(scene: Scene);
  46415. /**
  46416. * Attaches a set of gizmos to the specified mesh
  46417. * @param mesh The mesh the gizmo's should be attached to
  46418. */
  46419. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46420. /**
  46421. * If the position gizmo is enabled
  46422. */
  46423. positionGizmoEnabled: boolean;
  46424. /**
  46425. * If the rotation gizmo is enabled
  46426. */
  46427. rotationGizmoEnabled: boolean;
  46428. /**
  46429. * If the scale gizmo is enabled
  46430. */
  46431. scaleGizmoEnabled: boolean;
  46432. /**
  46433. * If the boundingBox gizmo is enabled
  46434. */
  46435. boundingBoxGizmoEnabled: boolean;
  46436. /**
  46437. * Disposes of the gizmo manager
  46438. */
  46439. dispose(): void;
  46440. }
  46441. }
  46442. declare module BABYLON {
  46443. /**
  46444. * A directional light is defined by a direction (what a surprise!).
  46445. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46446. * 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.
  46447. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46448. */
  46449. export class DirectionalLight extends ShadowLight {
  46450. private _shadowFrustumSize;
  46451. /**
  46452. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46453. */
  46454. /**
  46455. * Specifies a fix frustum size for the shadow generation.
  46456. */
  46457. shadowFrustumSize: number;
  46458. private _shadowOrthoScale;
  46459. /**
  46460. * Gets the shadow projection scale against the optimal computed one.
  46461. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46462. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46463. */
  46464. /**
  46465. * Sets the shadow projection scale against the optimal computed one.
  46466. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46467. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46468. */
  46469. shadowOrthoScale: number;
  46470. /**
  46471. * Automatically compute the projection matrix to best fit (including all the casters)
  46472. * on each frame.
  46473. */
  46474. autoUpdateExtends: boolean;
  46475. private _orthoLeft;
  46476. private _orthoRight;
  46477. private _orthoTop;
  46478. private _orthoBottom;
  46479. /**
  46480. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46481. * The directional light is emitted from everywhere in the given direction.
  46482. * It can cast shadows.
  46483. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46484. * @param name The friendly name of the light
  46485. * @param direction The direction of the light
  46486. * @param scene The scene the light belongs to
  46487. */
  46488. constructor(name: string, direction: Vector3, scene: Scene);
  46489. /**
  46490. * Returns the string "DirectionalLight".
  46491. * @return The class name
  46492. */
  46493. getClassName(): string;
  46494. /**
  46495. * Returns the integer 1.
  46496. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46497. */
  46498. getTypeID(): number;
  46499. /**
  46500. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46501. * Returns the DirectionalLight Shadow projection matrix.
  46502. */
  46503. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46504. /**
  46505. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46506. * Returns the DirectionalLight Shadow projection matrix.
  46507. */
  46508. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46509. /**
  46510. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46511. * Returns the DirectionalLight Shadow projection matrix.
  46512. */
  46513. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46514. protected _buildUniformLayout(): void;
  46515. /**
  46516. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46517. * @param effect The effect to update
  46518. * @param lightIndex The index of the light in the effect to update
  46519. * @returns The directional light
  46520. */
  46521. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46522. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  46523. /**
  46524. * Gets the minZ used for shadow according to both the scene and the light.
  46525. *
  46526. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46527. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46528. * @param activeCamera The camera we are returning the min for
  46529. * @returns the depth min z
  46530. */
  46531. getDepthMinZ(activeCamera: Camera): number;
  46532. /**
  46533. * Gets the maxZ used for shadow according to both the scene and the light.
  46534. *
  46535. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46536. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46537. * @param activeCamera The camera we are returning the max for
  46538. * @returns the depth max z
  46539. */
  46540. getDepthMaxZ(activeCamera: Camera): number;
  46541. /**
  46542. * Prepares the list of defines specific to the light type.
  46543. * @param defines the list of defines
  46544. * @param lightIndex defines the index of the light for the effect
  46545. */
  46546. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46547. }
  46548. }
  46549. declare module BABYLON {
  46550. /**
  46551. * Class containing static functions to help procedurally build meshes
  46552. */
  46553. export class HemisphereBuilder {
  46554. /**
  46555. * Creates a hemisphere mesh
  46556. * @param name defines the name of the mesh
  46557. * @param options defines the options used to create the mesh
  46558. * @param scene defines the hosting scene
  46559. * @returns the hemisphere mesh
  46560. */
  46561. static CreateHemisphere(name: string, options: {
  46562. segments?: number;
  46563. diameter?: number;
  46564. sideOrientation?: number;
  46565. }, scene: any): Mesh;
  46566. }
  46567. }
  46568. declare module BABYLON {
  46569. /**
  46570. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46571. * These values define a cone of light starting from the position, emitting toward the direction.
  46572. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46573. * and the exponent defines the speed of the decay of the light with distance (reach).
  46574. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46575. */
  46576. export class SpotLight extends ShadowLight {
  46577. private _angle;
  46578. private _innerAngle;
  46579. private _cosHalfAngle;
  46580. private _lightAngleScale;
  46581. private _lightAngleOffset;
  46582. /**
  46583. * Gets the cone angle of the spot light in Radians.
  46584. */
  46585. /**
  46586. * Sets the cone angle of the spot light in Radians.
  46587. */
  46588. angle: number;
  46589. /**
  46590. * Only used in gltf falloff mode, this defines the angle where
  46591. * the directional falloff will start before cutting at angle which could be seen
  46592. * as outer angle.
  46593. */
  46594. /**
  46595. * Only used in gltf falloff mode, this defines the angle where
  46596. * the directional falloff will start before cutting at angle which could be seen
  46597. * as outer angle.
  46598. */
  46599. innerAngle: number;
  46600. private _shadowAngleScale;
  46601. /**
  46602. * Allows scaling the angle of the light for shadow generation only.
  46603. */
  46604. /**
  46605. * Allows scaling the angle of the light for shadow generation only.
  46606. */
  46607. shadowAngleScale: number;
  46608. /**
  46609. * The light decay speed with the distance from the emission spot.
  46610. */
  46611. exponent: number;
  46612. private _projectionTextureMatrix;
  46613. /**
  46614. * Allows reading the projecton texture
  46615. */
  46616. readonly projectionTextureMatrix: Matrix;
  46617. protected _projectionTextureLightNear: number;
  46618. /**
  46619. * Gets the near clip of the Spotlight for texture projection.
  46620. */
  46621. /**
  46622. * Sets the near clip of the Spotlight for texture projection.
  46623. */
  46624. projectionTextureLightNear: number;
  46625. protected _projectionTextureLightFar: number;
  46626. /**
  46627. * Gets the far clip of the Spotlight for texture projection.
  46628. */
  46629. /**
  46630. * Sets the far clip of the Spotlight for texture projection.
  46631. */
  46632. projectionTextureLightFar: number;
  46633. protected _projectionTextureUpDirection: Vector3;
  46634. /**
  46635. * Gets the Up vector of the Spotlight for texture projection.
  46636. */
  46637. /**
  46638. * Sets the Up vector of the Spotlight for texture projection.
  46639. */
  46640. projectionTextureUpDirection: Vector3;
  46641. private _projectionTexture;
  46642. /**
  46643. * Gets the projection texture of the light.
  46644. */
  46645. /**
  46646. * Sets the projection texture of the light.
  46647. */
  46648. projectionTexture: Nullable<BaseTexture>;
  46649. private _projectionTextureViewLightDirty;
  46650. private _projectionTextureProjectionLightDirty;
  46651. private _projectionTextureDirty;
  46652. private _projectionTextureViewTargetVector;
  46653. private _projectionTextureViewLightMatrix;
  46654. private _projectionTextureProjectionLightMatrix;
  46655. private _projectionTextureScalingMatrix;
  46656. /**
  46657. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46658. * It can cast shadows.
  46659. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46660. * @param name The light friendly name
  46661. * @param position The position of the spot light in the scene
  46662. * @param direction The direction of the light in the scene
  46663. * @param angle The cone angle of the light in Radians
  46664. * @param exponent The light decay speed with the distance from the emission spot
  46665. * @param scene The scene the lights belongs to
  46666. */
  46667. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46668. /**
  46669. * Returns the string "SpotLight".
  46670. * @returns the class name
  46671. */
  46672. getClassName(): string;
  46673. /**
  46674. * Returns the integer 2.
  46675. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46676. */
  46677. getTypeID(): number;
  46678. /**
  46679. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46680. */
  46681. protected _setDirection(value: Vector3): void;
  46682. /**
  46683. * Overrides the position setter to recompute the projection texture view light Matrix.
  46684. */
  46685. protected _setPosition(value: Vector3): void;
  46686. /**
  46687. * 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.
  46688. * Returns the SpotLight.
  46689. */
  46690. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46691. protected _computeProjectionTextureViewLightMatrix(): void;
  46692. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46693. /**
  46694. * Main function for light texture projection matrix computing.
  46695. */
  46696. protected _computeProjectionTextureMatrix(): void;
  46697. protected _buildUniformLayout(): void;
  46698. private _computeAngleValues;
  46699. /**
  46700. * Sets the passed Effect "effect" with the Light textures.
  46701. * @param effect The effect to update
  46702. * @param lightIndex The index of the light in the effect to update
  46703. * @returns The light
  46704. */
  46705. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  46706. /**
  46707. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46708. * @param effect The effect to update
  46709. * @param lightIndex The index of the light in the effect to update
  46710. * @returns The spot light
  46711. */
  46712. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46713. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  46714. /**
  46715. * Disposes the light and the associated resources.
  46716. */
  46717. dispose(): void;
  46718. /**
  46719. * Prepares the list of defines specific to the light type.
  46720. * @param defines the list of defines
  46721. * @param lightIndex defines the index of the light for the effect
  46722. */
  46723. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46724. }
  46725. }
  46726. declare module BABYLON {
  46727. /**
  46728. * Gizmo that enables viewing a light
  46729. */
  46730. export class LightGizmo extends Gizmo {
  46731. private _lightMesh;
  46732. private _material;
  46733. private _cachedPosition;
  46734. private _cachedForward;
  46735. private _attachedMeshParent;
  46736. /**
  46737. * Creates a LightGizmo
  46738. * @param gizmoLayer The utility layer the gizmo will be added to
  46739. */
  46740. constructor(gizmoLayer?: UtilityLayerRenderer);
  46741. private _light;
  46742. /**
  46743. * The light that the gizmo is attached to
  46744. */
  46745. light: Nullable<Light>;
  46746. /**
  46747. * Gets the material used to render the light gizmo
  46748. */
  46749. readonly material: StandardMaterial;
  46750. /**
  46751. * @hidden
  46752. * Updates the gizmo to match the attached mesh's position/rotation
  46753. */
  46754. protected _update(): void;
  46755. private static _Scale;
  46756. /**
  46757. * Creates the lines for a light mesh
  46758. */
  46759. private static _CreateLightLines;
  46760. /**
  46761. * Disposes of the light gizmo
  46762. */
  46763. dispose(): void;
  46764. private static _CreateHemisphericLightMesh;
  46765. private static _CreatePointLightMesh;
  46766. private static _CreateSpotLightMesh;
  46767. private static _CreateDirectionalLightMesh;
  46768. }
  46769. }
  46770. declare module BABYLON {
  46771. /** @hidden */
  46772. export var backgroundFragmentDeclaration: {
  46773. name: string;
  46774. shader: string;
  46775. };
  46776. }
  46777. declare module BABYLON {
  46778. /** @hidden */
  46779. export var backgroundUboDeclaration: {
  46780. name: string;
  46781. shader: string;
  46782. };
  46783. }
  46784. declare module BABYLON {
  46785. /** @hidden */
  46786. export var backgroundPixelShader: {
  46787. name: string;
  46788. shader: string;
  46789. };
  46790. }
  46791. declare module BABYLON {
  46792. /** @hidden */
  46793. export var backgroundVertexDeclaration: {
  46794. name: string;
  46795. shader: string;
  46796. };
  46797. }
  46798. declare module BABYLON {
  46799. /** @hidden */
  46800. export var backgroundVertexShader: {
  46801. name: string;
  46802. shader: string;
  46803. };
  46804. }
  46805. declare module BABYLON {
  46806. /**
  46807. * Background material used to create an efficient environement around your scene.
  46808. */
  46809. export class BackgroundMaterial extends PushMaterial {
  46810. /**
  46811. * Standard reflectance value at parallel view angle.
  46812. */
  46813. static StandardReflectance0: number;
  46814. /**
  46815. * Standard reflectance value at grazing angle.
  46816. */
  46817. static StandardReflectance90: number;
  46818. protected _primaryColor: Color3;
  46819. /**
  46820. * Key light Color (multiply against the environement texture)
  46821. */
  46822. primaryColor: Color3;
  46823. protected __perceptualColor: Nullable<Color3>;
  46824. /**
  46825. * Experimental Internal Use Only.
  46826. *
  46827. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  46828. * This acts as a helper to set the primary color to a more "human friendly" value.
  46829. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  46830. * output color as close as possible from the chosen value.
  46831. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  46832. * part of lighting setup.)
  46833. */
  46834. _perceptualColor: Nullable<Color3>;
  46835. protected _primaryColorShadowLevel: float;
  46836. /**
  46837. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  46838. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  46839. */
  46840. primaryColorShadowLevel: float;
  46841. protected _primaryColorHighlightLevel: float;
  46842. /**
  46843. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  46844. * The primary color is used at the level chosen to define what the white area would look.
  46845. */
  46846. primaryColorHighlightLevel: float;
  46847. protected _reflectionTexture: Nullable<BaseTexture>;
  46848. /**
  46849. * Reflection Texture used in the material.
  46850. * Should be author in a specific way for the best result (refer to the documentation).
  46851. */
  46852. reflectionTexture: Nullable<BaseTexture>;
  46853. protected _reflectionBlur: float;
  46854. /**
  46855. * Reflection Texture level of blur.
  46856. *
  46857. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  46858. * texture twice.
  46859. */
  46860. reflectionBlur: float;
  46861. protected _diffuseTexture: Nullable<BaseTexture>;
  46862. /**
  46863. * Diffuse Texture used in the material.
  46864. * Should be author in a specific way for the best result (refer to the documentation).
  46865. */
  46866. diffuseTexture: Nullable<BaseTexture>;
  46867. protected _shadowLights: Nullable<IShadowLight[]>;
  46868. /**
  46869. * Specify the list of lights casting shadow on the material.
  46870. * All scene shadow lights will be included if null.
  46871. */
  46872. shadowLights: Nullable<IShadowLight[]>;
  46873. protected _shadowLevel: float;
  46874. /**
  46875. * Helps adjusting the shadow to a softer level if required.
  46876. * 0 means black shadows and 1 means no shadows.
  46877. */
  46878. shadowLevel: float;
  46879. protected _sceneCenter: Vector3;
  46880. /**
  46881. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  46882. * It is usually zero but might be interesting to modify according to your setup.
  46883. */
  46884. sceneCenter: Vector3;
  46885. protected _opacityFresnel: boolean;
  46886. /**
  46887. * This helps specifying that the material is falling off to the sky box at grazing angle.
  46888. * This helps ensuring a nice transition when the camera goes under the ground.
  46889. */
  46890. opacityFresnel: boolean;
  46891. protected _reflectionFresnel: boolean;
  46892. /**
  46893. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46894. * This helps adding a mirror texture on the ground.
  46895. */
  46896. reflectionFresnel: boolean;
  46897. protected _reflectionFalloffDistance: number;
  46898. /**
  46899. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46900. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46901. */
  46902. reflectionFalloffDistance: number;
  46903. protected _reflectionAmount: number;
  46904. /**
  46905. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46906. */
  46907. reflectionAmount: number;
  46908. protected _reflectionReflectance0: number;
  46909. /**
  46910. * This specifies the weight of the reflection at grazing angle.
  46911. */
  46912. reflectionReflectance0: number;
  46913. protected _reflectionReflectance90: number;
  46914. /**
  46915. * This specifies the weight of the reflection at a perpendicular point of view.
  46916. */
  46917. reflectionReflectance90: number;
  46918. /**
  46919. * Sets the reflection reflectance fresnel values according to the default standard
  46920. * empirically know to work well :-)
  46921. */
  46922. reflectionStandardFresnelWeight: number;
  46923. protected _useRGBColor: boolean;
  46924. /**
  46925. * Helps to directly use the maps channels instead of their level.
  46926. */
  46927. useRGBColor: boolean;
  46928. protected _enableNoise: boolean;
  46929. /**
  46930. * This helps reducing the banding effect that could occur on the background.
  46931. */
  46932. enableNoise: boolean;
  46933. /**
  46934. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46935. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46936. * Recommended to be keep at 1.0 except for special cases.
  46937. */
  46938. fovMultiplier: number;
  46939. private _fovMultiplier;
  46940. /**
  46941. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46942. */
  46943. useEquirectangularFOV: boolean;
  46944. private _maxSimultaneousLights;
  46945. /**
  46946. * Number of Simultaneous lights allowed on the material.
  46947. */
  46948. maxSimultaneousLights: int;
  46949. /**
  46950. * Default configuration related to image processing available in the Background Material.
  46951. */
  46952. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46953. /**
  46954. * Keep track of the image processing observer to allow dispose and replace.
  46955. */
  46956. private _imageProcessingObserver;
  46957. /**
  46958. * Attaches a new image processing configuration to the PBR Material.
  46959. * @param configuration (if null the scene configuration will be use)
  46960. */
  46961. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46962. /**
  46963. * Gets the image processing configuration used either in this material.
  46964. */
  46965. /**
  46966. * Sets the Default image processing configuration used either in the this material.
  46967. *
  46968. * If sets to null, the scene one is in use.
  46969. */
  46970. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46971. /**
  46972. * Gets wether the color curves effect is enabled.
  46973. */
  46974. /**
  46975. * Sets wether the color curves effect is enabled.
  46976. */
  46977. cameraColorCurvesEnabled: boolean;
  46978. /**
  46979. * Gets wether the color grading effect is enabled.
  46980. */
  46981. /**
  46982. * Gets wether the color grading effect is enabled.
  46983. */
  46984. cameraColorGradingEnabled: boolean;
  46985. /**
  46986. * Gets wether tonemapping is enabled or not.
  46987. */
  46988. /**
  46989. * Sets wether tonemapping is enabled or not
  46990. */
  46991. cameraToneMappingEnabled: boolean;
  46992. /**
  46993. * The camera exposure used on this material.
  46994. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46995. * This corresponds to a photographic exposure.
  46996. */
  46997. /**
  46998. * The camera exposure used on this material.
  46999. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47000. * This corresponds to a photographic exposure.
  47001. */
  47002. cameraExposure: float;
  47003. /**
  47004. * Gets The camera contrast used on this material.
  47005. */
  47006. /**
  47007. * Sets The camera contrast used on this material.
  47008. */
  47009. cameraContrast: float;
  47010. /**
  47011. * Gets the Color Grading 2D Lookup Texture.
  47012. */
  47013. /**
  47014. * Sets the Color Grading 2D Lookup Texture.
  47015. */
  47016. cameraColorGradingTexture: Nullable<BaseTexture>;
  47017. /**
  47018. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47019. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47020. * 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;
  47021. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47022. */
  47023. /**
  47024. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47025. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47026. * 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;
  47027. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47028. */
  47029. cameraColorCurves: Nullable<ColorCurves>;
  47030. /**
  47031. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47032. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47033. */
  47034. switchToBGR: boolean;
  47035. private _renderTargets;
  47036. private _reflectionControls;
  47037. private _white;
  47038. private _primaryShadowColor;
  47039. private _primaryHighlightColor;
  47040. /**
  47041. * Instantiates a Background Material in the given scene
  47042. * @param name The friendly name of the material
  47043. * @param scene The scene to add the material to
  47044. */
  47045. constructor(name: string, scene: Scene);
  47046. /**
  47047. * Gets a boolean indicating that current material needs to register RTT
  47048. */
  47049. readonly hasRenderTargetTextures: boolean;
  47050. /**
  47051. * The entire material has been created in order to prevent overdraw.
  47052. * @returns false
  47053. */
  47054. needAlphaTesting(): boolean;
  47055. /**
  47056. * The entire material has been created in order to prevent overdraw.
  47057. * @returns true if blending is enable
  47058. */
  47059. needAlphaBlending(): boolean;
  47060. /**
  47061. * Checks wether the material is ready to be rendered for a given mesh.
  47062. * @param mesh The mesh to render
  47063. * @param subMesh The submesh to check against
  47064. * @param useInstances Specify wether or not the material is used with instances
  47065. * @returns true if all the dependencies are ready (Textures, Effects...)
  47066. */
  47067. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47068. /**
  47069. * Compute the primary color according to the chosen perceptual color.
  47070. */
  47071. private _computePrimaryColorFromPerceptualColor;
  47072. /**
  47073. * Compute the highlights and shadow colors according to their chosen levels.
  47074. */
  47075. private _computePrimaryColors;
  47076. /**
  47077. * Build the uniform buffer used in the material.
  47078. */
  47079. buildUniformLayout(): void;
  47080. /**
  47081. * Unbind the material.
  47082. */
  47083. unbind(): void;
  47084. /**
  47085. * Bind only the world matrix to the material.
  47086. * @param world The world matrix to bind.
  47087. */
  47088. bindOnlyWorldMatrix(world: Matrix): void;
  47089. /**
  47090. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47091. * @param world The world matrix to bind.
  47092. * @param subMesh The submesh to bind for.
  47093. */
  47094. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47095. /**
  47096. * Checks to see if a texture is used in the material.
  47097. * @param texture - Base texture to use.
  47098. * @returns - Boolean specifying if a texture is used in the material.
  47099. */
  47100. hasTexture(texture: BaseTexture): boolean;
  47101. /**
  47102. * Dispose the material.
  47103. * @param forceDisposeEffect Force disposal of the associated effect.
  47104. * @param forceDisposeTextures Force disposal of the associated textures.
  47105. */
  47106. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47107. /**
  47108. * Clones the material.
  47109. * @param name The cloned name.
  47110. * @returns The cloned material.
  47111. */
  47112. clone(name: string): BackgroundMaterial;
  47113. /**
  47114. * Serializes the current material to its JSON representation.
  47115. * @returns The JSON representation.
  47116. */
  47117. serialize(): any;
  47118. /**
  47119. * Gets the class name of the material
  47120. * @returns "BackgroundMaterial"
  47121. */
  47122. getClassName(): string;
  47123. /**
  47124. * Parse a JSON input to create back a background material.
  47125. * @param source The JSON data to parse
  47126. * @param scene The scene to create the parsed material in
  47127. * @param rootUrl The root url of the assets the material depends upon
  47128. * @returns the instantiated BackgroundMaterial.
  47129. */
  47130. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47131. }
  47132. }
  47133. declare module BABYLON {
  47134. /**
  47135. * Represents the different options available during the creation of
  47136. * a Environment helper.
  47137. *
  47138. * This can control the default ground, skybox and image processing setup of your scene.
  47139. */
  47140. export interface IEnvironmentHelperOptions {
  47141. /**
  47142. * Specifies wether or not to create a ground.
  47143. * True by default.
  47144. */
  47145. createGround: boolean;
  47146. /**
  47147. * Specifies the ground size.
  47148. * 15 by default.
  47149. */
  47150. groundSize: number;
  47151. /**
  47152. * The texture used on the ground for the main color.
  47153. * Comes from the BabylonJS CDN by default.
  47154. *
  47155. * Remarks: Can be either a texture or a url.
  47156. */
  47157. groundTexture: string | BaseTexture;
  47158. /**
  47159. * The color mixed in the ground texture by default.
  47160. * BabylonJS clearColor by default.
  47161. */
  47162. groundColor: Color3;
  47163. /**
  47164. * Specifies the ground opacity.
  47165. * 1 by default.
  47166. */
  47167. groundOpacity: number;
  47168. /**
  47169. * Enables the ground to receive shadows.
  47170. * True by default.
  47171. */
  47172. enableGroundShadow: boolean;
  47173. /**
  47174. * Helps preventing the shadow to be fully black on the ground.
  47175. * 0.5 by default.
  47176. */
  47177. groundShadowLevel: number;
  47178. /**
  47179. * Creates a mirror texture attach to the ground.
  47180. * false by default.
  47181. */
  47182. enableGroundMirror: boolean;
  47183. /**
  47184. * Specifies the ground mirror size ratio.
  47185. * 0.3 by default as the default kernel is 64.
  47186. */
  47187. groundMirrorSizeRatio: number;
  47188. /**
  47189. * Specifies the ground mirror blur kernel size.
  47190. * 64 by default.
  47191. */
  47192. groundMirrorBlurKernel: number;
  47193. /**
  47194. * Specifies the ground mirror visibility amount.
  47195. * 1 by default
  47196. */
  47197. groundMirrorAmount: number;
  47198. /**
  47199. * Specifies the ground mirror reflectance weight.
  47200. * This uses the standard weight of the background material to setup the fresnel effect
  47201. * of the mirror.
  47202. * 1 by default.
  47203. */
  47204. groundMirrorFresnelWeight: number;
  47205. /**
  47206. * Specifies the ground mirror Falloff distance.
  47207. * This can helps reducing the size of the reflection.
  47208. * 0 by Default.
  47209. */
  47210. groundMirrorFallOffDistance: number;
  47211. /**
  47212. * Specifies the ground mirror texture type.
  47213. * Unsigned Int by Default.
  47214. */
  47215. groundMirrorTextureType: number;
  47216. /**
  47217. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  47218. * the shown objects.
  47219. */
  47220. groundYBias: number;
  47221. /**
  47222. * Specifies wether or not to create a skybox.
  47223. * True by default.
  47224. */
  47225. createSkybox: boolean;
  47226. /**
  47227. * Specifies the skybox size.
  47228. * 20 by default.
  47229. */
  47230. skyboxSize: number;
  47231. /**
  47232. * The texture used on the skybox for the main color.
  47233. * Comes from the BabylonJS CDN by default.
  47234. *
  47235. * Remarks: Can be either a texture or a url.
  47236. */
  47237. skyboxTexture: string | BaseTexture;
  47238. /**
  47239. * The color mixed in the skybox texture by default.
  47240. * BabylonJS clearColor by default.
  47241. */
  47242. skyboxColor: Color3;
  47243. /**
  47244. * The background rotation around the Y axis of the scene.
  47245. * This helps aligning the key lights of your scene with the background.
  47246. * 0 by default.
  47247. */
  47248. backgroundYRotation: number;
  47249. /**
  47250. * Compute automatically the size of the elements to best fit with the scene.
  47251. */
  47252. sizeAuto: boolean;
  47253. /**
  47254. * Default position of the rootMesh if autoSize is not true.
  47255. */
  47256. rootPosition: Vector3;
  47257. /**
  47258. * Sets up the image processing in the scene.
  47259. * true by default.
  47260. */
  47261. setupImageProcessing: boolean;
  47262. /**
  47263. * The texture used as your environment texture in the scene.
  47264. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  47265. *
  47266. * Remarks: Can be either a texture or a url.
  47267. */
  47268. environmentTexture: string | BaseTexture;
  47269. /**
  47270. * The value of the exposure to apply to the scene.
  47271. * 0.6 by default if setupImageProcessing is true.
  47272. */
  47273. cameraExposure: number;
  47274. /**
  47275. * The value of the contrast to apply to the scene.
  47276. * 1.6 by default if setupImageProcessing is true.
  47277. */
  47278. cameraContrast: number;
  47279. /**
  47280. * Specifies wether or not tonemapping should be enabled in the scene.
  47281. * true by default if setupImageProcessing is true.
  47282. */
  47283. toneMappingEnabled: boolean;
  47284. }
  47285. /**
  47286. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  47287. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  47288. * It also helps with the default setup of your imageProcessing configuration.
  47289. */
  47290. export class EnvironmentHelper {
  47291. /**
  47292. * Default ground texture URL.
  47293. */
  47294. private static _groundTextureCDNUrl;
  47295. /**
  47296. * Default skybox texture URL.
  47297. */
  47298. private static _skyboxTextureCDNUrl;
  47299. /**
  47300. * Default environment texture URL.
  47301. */
  47302. private static _environmentTextureCDNUrl;
  47303. /**
  47304. * Creates the default options for the helper.
  47305. */
  47306. private static _getDefaultOptions;
  47307. private _rootMesh;
  47308. /**
  47309. * Gets the root mesh created by the helper.
  47310. */
  47311. readonly rootMesh: Mesh;
  47312. private _skybox;
  47313. /**
  47314. * Gets the skybox created by the helper.
  47315. */
  47316. readonly skybox: Nullable<Mesh>;
  47317. private _skyboxTexture;
  47318. /**
  47319. * Gets the skybox texture created by the helper.
  47320. */
  47321. readonly skyboxTexture: Nullable<BaseTexture>;
  47322. private _skyboxMaterial;
  47323. /**
  47324. * Gets the skybox material created by the helper.
  47325. */
  47326. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47327. private _ground;
  47328. /**
  47329. * Gets the ground mesh created by the helper.
  47330. */
  47331. readonly ground: Nullable<Mesh>;
  47332. private _groundTexture;
  47333. /**
  47334. * Gets the ground texture created by the helper.
  47335. */
  47336. readonly groundTexture: Nullable<BaseTexture>;
  47337. private _groundMirror;
  47338. /**
  47339. * Gets the ground mirror created by the helper.
  47340. */
  47341. readonly groundMirror: Nullable<MirrorTexture>;
  47342. /**
  47343. * Gets the ground mirror render list to helps pushing the meshes
  47344. * you wish in the ground reflection.
  47345. */
  47346. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47347. private _groundMaterial;
  47348. /**
  47349. * Gets the ground material created by the helper.
  47350. */
  47351. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47352. /**
  47353. * Stores the creation options.
  47354. */
  47355. private readonly _scene;
  47356. private _options;
  47357. /**
  47358. * This observable will be notified with any error during the creation of the environment,
  47359. * mainly texture creation errors.
  47360. */
  47361. onErrorObservable: Observable<{
  47362. message?: string;
  47363. exception?: any;
  47364. }>;
  47365. /**
  47366. * constructor
  47367. * @param options Defines the options we want to customize the helper
  47368. * @param scene The scene to add the material to
  47369. */
  47370. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47371. /**
  47372. * Updates the background according to the new options
  47373. * @param options
  47374. */
  47375. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47376. /**
  47377. * Sets the primary color of all the available elements.
  47378. * @param color the main color to affect to the ground and the background
  47379. */
  47380. setMainColor(color: Color3): void;
  47381. /**
  47382. * Setup the image processing according to the specified options.
  47383. */
  47384. private _setupImageProcessing;
  47385. /**
  47386. * Setup the environment texture according to the specified options.
  47387. */
  47388. private _setupEnvironmentTexture;
  47389. /**
  47390. * Setup the background according to the specified options.
  47391. */
  47392. private _setupBackground;
  47393. /**
  47394. * Get the scene sizes according to the setup.
  47395. */
  47396. private _getSceneSize;
  47397. /**
  47398. * Setup the ground according to the specified options.
  47399. */
  47400. private _setupGround;
  47401. /**
  47402. * Setup the ground material according to the specified options.
  47403. */
  47404. private _setupGroundMaterial;
  47405. /**
  47406. * Setup the ground diffuse texture according to the specified options.
  47407. */
  47408. private _setupGroundDiffuseTexture;
  47409. /**
  47410. * Setup the ground mirror texture according to the specified options.
  47411. */
  47412. private _setupGroundMirrorTexture;
  47413. /**
  47414. * Setup the ground to receive the mirror texture.
  47415. */
  47416. private _setupMirrorInGroundMaterial;
  47417. /**
  47418. * Setup the skybox according to the specified options.
  47419. */
  47420. private _setupSkybox;
  47421. /**
  47422. * Setup the skybox material according to the specified options.
  47423. */
  47424. private _setupSkyboxMaterial;
  47425. /**
  47426. * Setup the skybox reflection texture according to the specified options.
  47427. */
  47428. private _setupSkyboxReflectionTexture;
  47429. private _errorHandler;
  47430. /**
  47431. * Dispose all the elements created by the Helper.
  47432. */
  47433. dispose(): void;
  47434. }
  47435. }
  47436. declare module BABYLON {
  47437. /**
  47438. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47439. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47440. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47441. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47442. */
  47443. export class PhotoDome extends TransformNode {
  47444. /**
  47445. * Define the image as a Monoscopic panoramic 360 image.
  47446. */
  47447. static readonly MODE_MONOSCOPIC: number;
  47448. /**
  47449. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47450. */
  47451. static readonly MODE_TOPBOTTOM: number;
  47452. /**
  47453. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47454. */
  47455. static readonly MODE_SIDEBYSIDE: number;
  47456. private _useDirectMapping;
  47457. /**
  47458. * The texture being displayed on the sphere
  47459. */
  47460. protected _photoTexture: Texture;
  47461. /**
  47462. * Gets or sets the texture being displayed on the sphere
  47463. */
  47464. photoTexture: Texture;
  47465. /**
  47466. * Observable raised when an error occured while loading the 360 image
  47467. */
  47468. onLoadErrorObservable: Observable<string>;
  47469. /**
  47470. * The skybox material
  47471. */
  47472. protected _material: BackgroundMaterial;
  47473. /**
  47474. * The surface used for the skybox
  47475. */
  47476. protected _mesh: Mesh;
  47477. /**
  47478. * Gets the mesh used for the skybox.
  47479. */
  47480. readonly mesh: Mesh;
  47481. /**
  47482. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47483. * Also see the options.resolution property.
  47484. */
  47485. fovMultiplier: number;
  47486. private _imageMode;
  47487. /**
  47488. * Gets or set the current video mode for the video. It can be:
  47489. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47490. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47491. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47492. */
  47493. imageMode: number;
  47494. /**
  47495. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47496. * @param name Element's name, child elements will append suffixes for their own names.
  47497. * @param urlsOfPhoto defines the url of the photo to display
  47498. * @param options defines an object containing optional or exposed sub element properties
  47499. * @param onError defines a callback called when an error occured while loading the texture
  47500. */
  47501. constructor(name: string, urlOfPhoto: string, options: {
  47502. resolution?: number;
  47503. size?: number;
  47504. useDirectMapping?: boolean;
  47505. faceForward?: boolean;
  47506. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47507. private _onBeforeCameraRenderObserver;
  47508. private _changeImageMode;
  47509. /**
  47510. * Releases resources associated with this node.
  47511. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47512. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47513. */
  47514. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47515. }
  47516. }
  47517. declare module BABYLON {
  47518. /**
  47519. * Class used to host RGBD texture specific utilities
  47520. */
  47521. export class RGBDTextureTools {
  47522. /**
  47523. * Expand the RGBD Texture from RGBD to Half Float if possible.
  47524. * @param texture the texture to expand.
  47525. */
  47526. static ExpandRGBDTexture(texture: Texture): void;
  47527. }
  47528. }
  47529. declare module BABYLON {
  47530. /**
  47531. * Class used to host texture specific utilities
  47532. */
  47533. export class BRDFTextureTools {
  47534. /**
  47535. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47536. * @param scene defines the hosting scene
  47537. * @returns the environment BRDF texture
  47538. */
  47539. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47540. private static _environmentBRDFBase64Texture;
  47541. }
  47542. }
  47543. declare module BABYLON {
  47544. /**
  47545. * @hidden
  47546. */
  47547. export interface IMaterialClearCoatDefines {
  47548. CLEARCOAT: boolean;
  47549. CLEARCOAT_DEFAULTIOR: boolean;
  47550. CLEARCOAT_TEXTURE: boolean;
  47551. CLEARCOAT_TEXTUREDIRECTUV: number;
  47552. CLEARCOAT_BUMP: boolean;
  47553. CLEARCOAT_BUMPDIRECTUV: number;
  47554. CLEARCOAT_TINT: boolean;
  47555. CLEARCOAT_TINT_TEXTURE: boolean;
  47556. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47557. /** @hidden */
  47558. _areTexturesDirty: boolean;
  47559. }
  47560. /**
  47561. * Define the code related to the clear coat parameters of the pbr material.
  47562. */
  47563. export class PBRClearCoatConfiguration {
  47564. /**
  47565. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47566. * The default fits with a polyurethane material.
  47567. */
  47568. private static readonly _DefaultIndexOfRefraction;
  47569. private _isEnabled;
  47570. /**
  47571. * Defines if the clear coat is enabled in the material.
  47572. */
  47573. isEnabled: boolean;
  47574. /**
  47575. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47576. */
  47577. intensity: number;
  47578. /**
  47579. * Defines the clear coat layer roughness.
  47580. */
  47581. roughness: number;
  47582. private _indexOfRefraction;
  47583. /**
  47584. * Defines the index of refraction of the clear coat.
  47585. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47586. * The default fits with a polyurethane material.
  47587. * Changing the default value is more performance intensive.
  47588. */
  47589. indexOfRefraction: number;
  47590. private _texture;
  47591. /**
  47592. * Stores the clear coat values in a texture.
  47593. */
  47594. texture: Nullable<BaseTexture>;
  47595. private _bumpTexture;
  47596. /**
  47597. * Define the clear coat specific bump texture.
  47598. */
  47599. bumpTexture: Nullable<BaseTexture>;
  47600. private _isTintEnabled;
  47601. /**
  47602. * Defines if the clear coat tint is enabled in the material.
  47603. */
  47604. isTintEnabled: boolean;
  47605. /**
  47606. * Defines the clear coat tint of the material.
  47607. * This is only use if tint is enabled
  47608. */
  47609. tintColor: Color3;
  47610. /**
  47611. * Defines the distance at which the tint color should be found in the
  47612. * clear coat media.
  47613. * This is only use if tint is enabled
  47614. */
  47615. tintColorAtDistance: number;
  47616. /**
  47617. * Defines the clear coat layer thickness.
  47618. * This is only use if tint is enabled
  47619. */
  47620. tintThickness: number;
  47621. private _tintTexture;
  47622. /**
  47623. * Stores the clear tint values in a texture.
  47624. * rgb is tint
  47625. * a is a thickness factor
  47626. */
  47627. tintTexture: Nullable<BaseTexture>;
  47628. /** @hidden */
  47629. private _internalMarkAllSubMeshesAsTexturesDirty;
  47630. /** @hidden */
  47631. _markAllSubMeshesAsTexturesDirty(): void;
  47632. /**
  47633. * Instantiate a new istance of clear coat configuration.
  47634. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47635. */
  47636. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47637. /**
  47638. * Gets wehter the submesh is ready to be used or not.
  47639. * @param defines the list of "defines" to update.
  47640. * @param scene defines the scene the material belongs to.
  47641. * @param engine defines the engine the material belongs to.
  47642. * @param disableBumpMap defines wether the material disables bump or not.
  47643. * @returns - boolean indicating that the submesh is ready or not.
  47644. */
  47645. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47646. /**
  47647. * Checks to see if a texture is used in the material.
  47648. * @param defines the list of "defines" to update.
  47649. * @param scene defines the scene to the material belongs to.
  47650. */
  47651. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47652. /**
  47653. * Binds the material data.
  47654. * @param uniformBuffer defines the Uniform buffer to fill in.
  47655. * @param scene defines the scene the material belongs to.
  47656. * @param engine defines the engine the material belongs to.
  47657. * @param disableBumpMap defines wether the material disables bump or not.
  47658. * @param isFrozen defines wether the material is frozen or not.
  47659. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47660. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47661. */
  47662. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47663. /**
  47664. * Checks to see if a texture is used in the material.
  47665. * @param texture - Base texture to use.
  47666. * @returns - Boolean specifying if a texture is used in the material.
  47667. */
  47668. hasTexture(texture: BaseTexture): boolean;
  47669. /**
  47670. * Returns an array of the actively used textures.
  47671. * @param activeTextures Array of BaseTextures
  47672. */
  47673. getActiveTextures(activeTextures: BaseTexture[]): void;
  47674. /**
  47675. * Returns the animatable textures.
  47676. * @param animatables Array of animatable textures.
  47677. */
  47678. getAnimatables(animatables: IAnimatable[]): void;
  47679. /**
  47680. * Disposes the resources of the material.
  47681. * @param forceDisposeTextures - Forces the disposal of all textures.
  47682. */
  47683. dispose(forceDisposeTextures?: boolean): void;
  47684. /**
  47685. * Get the current class name of the texture useful for serialization or dynamic coding.
  47686. * @returns "PBRClearCoatConfiguration"
  47687. */
  47688. getClassName(): string;
  47689. /**
  47690. * Add fallbacks to the effect fallbacks list.
  47691. * @param defines defines the Base texture to use.
  47692. * @param fallbacks defines the current fallback list.
  47693. * @param currentRank defines the current fallback rank.
  47694. * @returns the new fallback rank.
  47695. */
  47696. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47697. /**
  47698. * Add the required uniforms to the current list.
  47699. * @param uniforms defines the current uniform list.
  47700. */
  47701. static AddUniforms(uniforms: string[]): void;
  47702. /**
  47703. * Add the required samplers to the current list.
  47704. * @param samplers defines the current sampler list.
  47705. */
  47706. static AddSamplers(samplers: string[]): void;
  47707. /**
  47708. * Add the required uniforms to the current buffer.
  47709. * @param uniformBuffer defines the current uniform buffer.
  47710. */
  47711. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47712. /**
  47713. * Makes a duplicate of the current configuration into another one.
  47714. * @param clearCoatConfiguration define the config where to copy the info
  47715. */
  47716. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  47717. /**
  47718. * Serializes this clear coat configuration.
  47719. * @returns - An object with the serialized config.
  47720. */
  47721. serialize(): any;
  47722. /**
  47723. * Parses a anisotropy Configuration from a serialized object.
  47724. * @param source - Serialized object.
  47725. * @param scene Defines the scene we are parsing for
  47726. * @param rootUrl Defines the rootUrl to load from
  47727. */
  47728. parse(source: any, scene: Scene, rootUrl: string): void;
  47729. }
  47730. }
  47731. declare module BABYLON {
  47732. /**
  47733. * @hidden
  47734. */
  47735. export interface IMaterialAnisotropicDefines {
  47736. ANISOTROPIC: boolean;
  47737. ANISOTROPIC_TEXTURE: boolean;
  47738. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47739. MAINUV1: boolean;
  47740. _areTexturesDirty: boolean;
  47741. _needUVs: boolean;
  47742. }
  47743. /**
  47744. * Define the code related to the anisotropic parameters of the pbr material.
  47745. */
  47746. export class PBRAnisotropicConfiguration {
  47747. private _isEnabled;
  47748. /**
  47749. * Defines if the anisotropy is enabled in the material.
  47750. */
  47751. isEnabled: boolean;
  47752. /**
  47753. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  47754. */
  47755. intensity: number;
  47756. /**
  47757. * Defines if the effect is along the tangents, bitangents or in between.
  47758. * By default, the effect is "strectching" the highlights along the tangents.
  47759. */
  47760. direction: Vector2;
  47761. private _texture;
  47762. /**
  47763. * Stores the anisotropy values in a texture.
  47764. * rg is direction (like normal from -1 to 1)
  47765. * b is a intensity
  47766. */
  47767. texture: Nullable<BaseTexture>;
  47768. /** @hidden */
  47769. private _internalMarkAllSubMeshesAsTexturesDirty;
  47770. /** @hidden */
  47771. _markAllSubMeshesAsTexturesDirty(): void;
  47772. /**
  47773. * Instantiate a new istance of anisotropy configuration.
  47774. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47775. */
  47776. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47777. /**
  47778. * Specifies that the submesh is ready to be used.
  47779. * @param defines the list of "defines" to update.
  47780. * @param scene defines the scene the material belongs to.
  47781. * @returns - boolean indicating that the submesh is ready or not.
  47782. */
  47783. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47784. /**
  47785. * Checks to see if a texture is used in the material.
  47786. * @param defines the list of "defines" to update.
  47787. * @param mesh the mesh we are preparing the defines for.
  47788. * @param scene defines the scene the material belongs to.
  47789. */
  47790. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47791. /**
  47792. * Binds the material data.
  47793. * @param uniformBuffer defines the Uniform buffer to fill in.
  47794. * @param scene defines the scene the material belongs to.
  47795. * @param isFrozen defines wether the material is frozen or not.
  47796. */
  47797. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47798. /**
  47799. * Checks to see if a texture is used in the material.
  47800. * @param texture - Base texture to use.
  47801. * @returns - Boolean specifying if a texture is used in the material.
  47802. */
  47803. hasTexture(texture: BaseTexture): boolean;
  47804. /**
  47805. * Returns an array of the actively used textures.
  47806. * @param activeTextures Array of BaseTextures
  47807. */
  47808. getActiveTextures(activeTextures: BaseTexture[]): void;
  47809. /**
  47810. * Returns the animatable textures.
  47811. * @param animatables Array of animatable textures.
  47812. */
  47813. getAnimatables(animatables: IAnimatable[]): void;
  47814. /**
  47815. * Disposes the resources of the material.
  47816. * @param forceDisposeTextures - Forces the disposal of all textures.
  47817. */
  47818. dispose(forceDisposeTextures?: boolean): void;
  47819. /**
  47820. * Get the current class name of the texture useful for serialization or dynamic coding.
  47821. * @returns "PBRAnisotropicConfiguration"
  47822. */
  47823. getClassName(): string;
  47824. /**
  47825. * Add fallbacks to the effect fallbacks list.
  47826. * @param defines defines the Base texture to use.
  47827. * @param fallbacks defines the current fallback list.
  47828. * @param currentRank defines the current fallback rank.
  47829. * @returns the new fallback rank.
  47830. */
  47831. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47832. /**
  47833. * Add the required uniforms to the current list.
  47834. * @param uniforms defines the current uniform list.
  47835. */
  47836. static AddUniforms(uniforms: string[]): void;
  47837. /**
  47838. * Add the required uniforms to the current buffer.
  47839. * @param uniformBuffer defines the current uniform buffer.
  47840. */
  47841. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47842. /**
  47843. * Add the required samplers to the current list.
  47844. * @param samplers defines the current sampler list.
  47845. */
  47846. static AddSamplers(samplers: string[]): void;
  47847. /**
  47848. * Makes a duplicate of the current configuration into another one.
  47849. * @param anisotropicConfiguration define the config where to copy the info
  47850. */
  47851. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  47852. /**
  47853. * Serializes this anisotropy configuration.
  47854. * @returns - An object with the serialized config.
  47855. */
  47856. serialize(): any;
  47857. /**
  47858. * Parses a anisotropy Configuration from a serialized object.
  47859. * @param source - Serialized object.
  47860. * @param scene Defines the scene we are parsing for
  47861. * @param rootUrl Defines the rootUrl to load from
  47862. */
  47863. parse(source: any, scene: Scene, rootUrl: string): void;
  47864. }
  47865. }
  47866. declare module BABYLON {
  47867. /**
  47868. * @hidden
  47869. */
  47870. export interface IMaterialBRDFDefines {
  47871. BRDF_V_HEIGHT_CORRELATED: boolean;
  47872. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47873. SPHERICAL_HARMONICS: boolean;
  47874. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  47875. /** @hidden */
  47876. _areMiscDirty: boolean;
  47877. }
  47878. /**
  47879. * Define the code related to the BRDF parameters of the pbr material.
  47880. */
  47881. export class PBRBRDFConfiguration {
  47882. /**
  47883. * Default value used for the energy conservation.
  47884. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47885. */
  47886. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  47887. /**
  47888. * Default value used for the Smith Visibility Height Correlated mode.
  47889. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47890. */
  47891. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47892. /**
  47893. * Default value used for the IBL diffuse part.
  47894. * This can help switching back to the polynomials mode globally which is a tiny bit
  47895. * less GPU intensive at the drawback of a lower quality.
  47896. */
  47897. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47898. /**
  47899. * Default value used for activating energy conservation for the specular workflow.
  47900. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  47901. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  47902. */
  47903. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  47904. private _useEnergyConservation;
  47905. /**
  47906. * Defines if the material uses energy conservation.
  47907. */
  47908. useEnergyConservation: boolean;
  47909. private _useSmithVisibilityHeightCorrelated;
  47910. /**
  47911. * LEGACY Mode set to false
  47912. * Defines if the material uses height smith correlated visibility term.
  47913. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47914. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47915. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47916. * Not relying on height correlated will also disable energy conservation.
  47917. */
  47918. useSmithVisibilityHeightCorrelated: boolean;
  47919. private _useSphericalHarmonics;
  47920. /**
  47921. * LEGACY Mode set to false
  47922. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47923. * diffuse part of the IBL.
  47924. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47925. * to the ground truth.
  47926. */
  47927. useSphericalHarmonics: boolean;
  47928. private _useSpecularGlossinessInputEnergyConservation;
  47929. /**
  47930. * Defines if the material uses energy conservation, when the specular workflow is active.
  47931. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  47932. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  47933. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  47934. */
  47935. useSpecularGlossinessInputEnergyConservation: boolean;
  47936. /** @hidden */
  47937. private _internalMarkAllSubMeshesAsMiscDirty;
  47938. /** @hidden */
  47939. _markAllSubMeshesAsMiscDirty(): void;
  47940. /**
  47941. * Instantiate a new istance of clear coat configuration.
  47942. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47943. */
  47944. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47945. /**
  47946. * Checks to see if a texture is used in the material.
  47947. * @param defines the list of "defines" to update.
  47948. */
  47949. prepareDefines(defines: IMaterialBRDFDefines): void;
  47950. /**
  47951. * Get the current class name of the texture useful for serialization or dynamic coding.
  47952. * @returns "PBRClearCoatConfiguration"
  47953. */
  47954. getClassName(): string;
  47955. /**
  47956. * Makes a duplicate of the current configuration into another one.
  47957. * @param brdfConfiguration define the config where to copy the info
  47958. */
  47959. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47960. /**
  47961. * Serializes this BRDF configuration.
  47962. * @returns - An object with the serialized config.
  47963. */
  47964. serialize(): any;
  47965. /**
  47966. * Parses a anisotropy Configuration from a serialized object.
  47967. * @param source - Serialized object.
  47968. * @param scene Defines the scene we are parsing for
  47969. * @param rootUrl Defines the rootUrl to load from
  47970. */
  47971. parse(source: any, scene: Scene, rootUrl: string): void;
  47972. }
  47973. }
  47974. declare module BABYLON {
  47975. /**
  47976. * @hidden
  47977. */
  47978. export interface IMaterialSheenDefines {
  47979. SHEEN: boolean;
  47980. SHEEN_TEXTURE: boolean;
  47981. SHEEN_TEXTUREDIRECTUV: number;
  47982. SHEEN_LINKWITHALBEDO: boolean;
  47983. /** @hidden */
  47984. _areTexturesDirty: boolean;
  47985. }
  47986. /**
  47987. * Define the code related to the Sheen parameters of the pbr material.
  47988. */
  47989. export class PBRSheenConfiguration {
  47990. private _isEnabled;
  47991. /**
  47992. * Defines if the material uses sheen.
  47993. */
  47994. isEnabled: boolean;
  47995. private _linkSheenWithAlbedo;
  47996. /**
  47997. * Defines if the sheen is linked to the sheen color.
  47998. */
  47999. linkSheenWithAlbedo: boolean;
  48000. /**
  48001. * Defines the sheen intensity.
  48002. */
  48003. intensity: number;
  48004. /**
  48005. * Defines the sheen color.
  48006. */
  48007. color: Color3;
  48008. private _texture;
  48009. /**
  48010. * Stores the sheen tint values in a texture.
  48011. * rgb is tint
  48012. * a is a intensity
  48013. */
  48014. texture: Nullable<BaseTexture>;
  48015. /** @hidden */
  48016. private _internalMarkAllSubMeshesAsTexturesDirty;
  48017. /** @hidden */
  48018. _markAllSubMeshesAsTexturesDirty(): void;
  48019. /**
  48020. * Instantiate a new istance of clear coat configuration.
  48021. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48022. */
  48023. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48024. /**
  48025. * Specifies that the submesh is ready to be used.
  48026. * @param defines the list of "defines" to update.
  48027. * @param scene defines the scene the material belongs to.
  48028. * @returns - boolean indicating that the submesh is ready or not.
  48029. */
  48030. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48031. /**
  48032. * Checks to see if a texture is used in the material.
  48033. * @param defines the list of "defines" to update.
  48034. * @param scene defines the scene the material belongs to.
  48035. */
  48036. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48037. /**
  48038. * Binds the material data.
  48039. * @param uniformBuffer defines the Uniform buffer to fill in.
  48040. * @param scene defines the scene the material belongs to.
  48041. * @param isFrozen defines wether the material is frozen or not.
  48042. */
  48043. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48044. /**
  48045. * Checks to see if a texture is used in the material.
  48046. * @param texture - Base texture to use.
  48047. * @returns - Boolean specifying if a texture is used in the material.
  48048. */
  48049. hasTexture(texture: BaseTexture): boolean;
  48050. /**
  48051. * Returns an array of the actively used textures.
  48052. * @param activeTextures Array of BaseTextures
  48053. */
  48054. getActiveTextures(activeTextures: BaseTexture[]): void;
  48055. /**
  48056. * Returns the animatable textures.
  48057. * @param animatables Array of animatable textures.
  48058. */
  48059. getAnimatables(animatables: IAnimatable[]): void;
  48060. /**
  48061. * Disposes the resources of the material.
  48062. * @param forceDisposeTextures - Forces the disposal of all textures.
  48063. */
  48064. dispose(forceDisposeTextures?: boolean): void;
  48065. /**
  48066. * Get the current class name of the texture useful for serialization or dynamic coding.
  48067. * @returns "PBRSheenConfiguration"
  48068. */
  48069. getClassName(): string;
  48070. /**
  48071. * Add fallbacks to the effect fallbacks list.
  48072. * @param defines defines the Base texture to use.
  48073. * @param fallbacks defines the current fallback list.
  48074. * @param currentRank defines the current fallback rank.
  48075. * @returns the new fallback rank.
  48076. */
  48077. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48078. /**
  48079. * Add the required uniforms to the current list.
  48080. * @param uniforms defines the current uniform list.
  48081. */
  48082. static AddUniforms(uniforms: string[]): void;
  48083. /**
  48084. * Add the required uniforms to the current buffer.
  48085. * @param uniformBuffer defines the current uniform buffer.
  48086. */
  48087. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48088. /**
  48089. * Add the required samplers to the current list.
  48090. * @param samplers defines the current sampler list.
  48091. */
  48092. static AddSamplers(samplers: string[]): void;
  48093. /**
  48094. * Makes a duplicate of the current configuration into another one.
  48095. * @param sheenConfiguration define the config where to copy the info
  48096. */
  48097. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48098. /**
  48099. * Serializes this BRDF configuration.
  48100. * @returns - An object with the serialized config.
  48101. */
  48102. serialize(): any;
  48103. /**
  48104. * Parses a anisotropy Configuration from a serialized object.
  48105. * @param source - Serialized object.
  48106. * @param scene Defines the scene we are parsing for
  48107. * @param rootUrl Defines the rootUrl to load from
  48108. */
  48109. parse(source: any, scene: Scene, rootUrl: string): void;
  48110. }
  48111. }
  48112. declare module BABYLON {
  48113. /**
  48114. * @hidden
  48115. */
  48116. export interface IMaterialSubSurfaceDefines {
  48117. SUBSURFACE: boolean;
  48118. SS_REFRACTION: boolean;
  48119. SS_TRANSLUCENCY: boolean;
  48120. SS_SCATERRING: boolean;
  48121. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48122. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48123. SS_REFRACTIONMAP_3D: boolean;
  48124. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48125. SS_LODINREFRACTIONALPHA: boolean;
  48126. SS_GAMMAREFRACTION: boolean;
  48127. SS_RGBDREFRACTION: boolean;
  48128. SS_LINEARSPECULARREFRACTION: boolean;
  48129. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48130. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48131. /** @hidden */
  48132. _areTexturesDirty: boolean;
  48133. }
  48134. /**
  48135. * Define the code related to the sub surface parameters of the pbr material.
  48136. */
  48137. export class PBRSubSurfaceConfiguration {
  48138. private _isRefractionEnabled;
  48139. /**
  48140. * Defines if the refraction is enabled in the material.
  48141. */
  48142. isRefractionEnabled: boolean;
  48143. private _isTranslucencyEnabled;
  48144. /**
  48145. * Defines if the translucency is enabled in the material.
  48146. */
  48147. isTranslucencyEnabled: boolean;
  48148. private _isScatteringEnabled;
  48149. /**
  48150. * Defines the refraction intensity of the material.
  48151. * The refraction when enabled replaces the Diffuse part of the material.
  48152. * The intensity helps transitionning between diffuse and refraction.
  48153. */
  48154. refractionIntensity: number;
  48155. /**
  48156. * Defines the translucency intensity of the material.
  48157. * When translucency has been enabled, this defines how much of the "translucency"
  48158. * is addded to the diffuse part of the material.
  48159. */
  48160. translucencyIntensity: number;
  48161. /**
  48162. * Defines the scattering intensity of the material.
  48163. * When scattering has been enabled, this defines how much of the "scattered light"
  48164. * is addded to the diffuse part of the material.
  48165. */
  48166. scatteringIntensity: number;
  48167. private _thicknessTexture;
  48168. /**
  48169. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  48170. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  48171. * 0 would mean minimumThickness
  48172. * 1 would mean maximumThickness
  48173. * The other channels might be use as a mask to vary the different effects intensity.
  48174. */
  48175. thicknessTexture: Nullable<BaseTexture>;
  48176. private _refractionTexture;
  48177. /**
  48178. * Defines the texture to use for refraction.
  48179. */
  48180. refractionTexture: Nullable<BaseTexture>;
  48181. private _indexOfRefraction;
  48182. /**
  48183. * Defines the index of refraction used in the material.
  48184. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  48185. */
  48186. indexOfRefraction: number;
  48187. private _invertRefractionY;
  48188. /**
  48189. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48190. */
  48191. invertRefractionY: boolean;
  48192. private _linkRefractionWithTransparency;
  48193. /**
  48194. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48195. * Materials half opaque for instance using refraction could benefit from this control.
  48196. */
  48197. linkRefractionWithTransparency: boolean;
  48198. /**
  48199. * Defines the minimum thickness stored in the thickness map.
  48200. * If no thickness map is defined, this value will be used to simulate thickness.
  48201. */
  48202. minimumThickness: number;
  48203. /**
  48204. * Defines the maximum thickness stored in the thickness map.
  48205. */
  48206. maximumThickness: number;
  48207. /**
  48208. * Defines the volume tint of the material.
  48209. * This is used for both translucency and scattering.
  48210. */
  48211. tintColor: Color3;
  48212. /**
  48213. * Defines the distance at which the tint color should be found in the media.
  48214. * This is used for refraction only.
  48215. */
  48216. tintColorAtDistance: number;
  48217. /**
  48218. * Defines how far each channel transmit through the media.
  48219. * It is defined as a color to simplify it selection.
  48220. */
  48221. diffusionDistance: Color3;
  48222. private _useMaskFromThicknessTexture;
  48223. /**
  48224. * Stores the intensity of the different subsurface effects in the thickness texture.
  48225. * * the green channel is the translucency intensity.
  48226. * * the blue channel is the scattering intensity.
  48227. * * the alpha channel is the refraction intensity.
  48228. */
  48229. useMaskFromThicknessTexture: boolean;
  48230. /** @hidden */
  48231. private _internalMarkAllSubMeshesAsTexturesDirty;
  48232. /** @hidden */
  48233. _markAllSubMeshesAsTexturesDirty(): void;
  48234. /**
  48235. * Instantiate a new istance of sub surface configuration.
  48236. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48237. */
  48238. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48239. /**
  48240. * Gets wehter the submesh is ready to be used or not.
  48241. * @param defines the list of "defines" to update.
  48242. * @param scene defines the scene the material belongs to.
  48243. * @returns - boolean indicating that the submesh is ready or not.
  48244. */
  48245. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  48246. /**
  48247. * Checks to see if a texture is used in the material.
  48248. * @param defines the list of "defines" to update.
  48249. * @param scene defines the scene to the material belongs to.
  48250. */
  48251. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  48252. /**
  48253. * Binds the material data.
  48254. * @param uniformBuffer defines the Uniform buffer to fill in.
  48255. * @param scene defines the scene the material belongs to.
  48256. * @param engine defines the engine the material belongs to.
  48257. * @param isFrozen defines wether the material is frozen or not.
  48258. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  48259. */
  48260. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  48261. /**
  48262. * Unbinds the material from the mesh.
  48263. * @param activeEffect defines the effect that should be unbound from.
  48264. * @returns true if unbound, otherwise false
  48265. */
  48266. unbind(activeEffect: Effect): boolean;
  48267. /**
  48268. * Returns the texture used for refraction or null if none is used.
  48269. * @param scene defines the scene the material belongs to.
  48270. * @returns - Refraction texture if present. If no refraction texture and refraction
  48271. * is linked with transparency, returns environment texture. Otherwise, returns null.
  48272. */
  48273. private _getRefractionTexture;
  48274. /**
  48275. * Returns true if alpha blending should be disabled.
  48276. */
  48277. readonly disableAlphaBlending: boolean;
  48278. /**
  48279. * Fills the list of render target textures.
  48280. * @param renderTargets the list of render targets to update
  48281. */
  48282. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48283. /**
  48284. * Checks to see if a texture is used in the material.
  48285. * @param texture - Base texture to use.
  48286. * @returns - Boolean specifying if a texture is used in the material.
  48287. */
  48288. hasTexture(texture: BaseTexture): boolean;
  48289. /**
  48290. * Gets a boolean indicating that current material needs to register RTT
  48291. * @returns true if this uses a render target otherwise false.
  48292. */
  48293. hasRenderTargetTextures(): boolean;
  48294. /**
  48295. * Returns an array of the actively used textures.
  48296. * @param activeTextures Array of BaseTextures
  48297. */
  48298. getActiveTextures(activeTextures: BaseTexture[]): void;
  48299. /**
  48300. * Returns the animatable textures.
  48301. * @param animatables Array of animatable textures.
  48302. */
  48303. getAnimatables(animatables: IAnimatable[]): void;
  48304. /**
  48305. * Disposes the resources of the material.
  48306. * @param forceDisposeTextures - Forces the disposal of all textures.
  48307. */
  48308. dispose(forceDisposeTextures?: boolean): void;
  48309. /**
  48310. * Get the current class name of the texture useful for serialization or dynamic coding.
  48311. * @returns "PBRSubSurfaceConfiguration"
  48312. */
  48313. getClassName(): string;
  48314. /**
  48315. * Add fallbacks to the effect fallbacks list.
  48316. * @param defines defines the Base texture to use.
  48317. * @param fallbacks defines the current fallback list.
  48318. * @param currentRank defines the current fallback rank.
  48319. * @returns the new fallback rank.
  48320. */
  48321. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48322. /**
  48323. * Add the required uniforms to the current list.
  48324. * @param uniforms defines the current uniform list.
  48325. */
  48326. static AddUniforms(uniforms: string[]): void;
  48327. /**
  48328. * Add the required samplers to the current list.
  48329. * @param samplers defines the current sampler list.
  48330. */
  48331. static AddSamplers(samplers: string[]): void;
  48332. /**
  48333. * Add the required uniforms to the current buffer.
  48334. * @param uniformBuffer defines the current uniform buffer.
  48335. */
  48336. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48337. /**
  48338. * Makes a duplicate of the current configuration into another one.
  48339. * @param configuration define the config where to copy the info
  48340. */
  48341. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48342. /**
  48343. * Serializes this Sub Surface configuration.
  48344. * @returns - An object with the serialized config.
  48345. */
  48346. serialize(): any;
  48347. /**
  48348. * Parses a anisotropy Configuration from a serialized object.
  48349. * @param source - Serialized object.
  48350. * @param scene Defines the scene we are parsing for
  48351. * @param rootUrl Defines the rootUrl to load from
  48352. */
  48353. parse(source: any, scene: Scene, rootUrl: string): void;
  48354. }
  48355. }
  48356. declare module BABYLON {
  48357. /** @hidden */
  48358. export var pbrFragmentDeclaration: {
  48359. name: string;
  48360. shader: string;
  48361. };
  48362. }
  48363. declare module BABYLON {
  48364. /** @hidden */
  48365. export var pbrUboDeclaration: {
  48366. name: string;
  48367. shader: string;
  48368. };
  48369. }
  48370. declare module BABYLON {
  48371. /** @hidden */
  48372. export var pbrFragmentExtraDeclaration: {
  48373. name: string;
  48374. shader: string;
  48375. };
  48376. }
  48377. declare module BABYLON {
  48378. /** @hidden */
  48379. export var pbrFragmentSamplersDeclaration: {
  48380. name: string;
  48381. shader: string;
  48382. };
  48383. }
  48384. declare module BABYLON {
  48385. /** @hidden */
  48386. export var pbrHelperFunctions: {
  48387. name: string;
  48388. shader: string;
  48389. };
  48390. }
  48391. declare module BABYLON {
  48392. /** @hidden */
  48393. export var harmonicsFunctions: {
  48394. name: string;
  48395. shader: string;
  48396. };
  48397. }
  48398. declare module BABYLON {
  48399. /** @hidden */
  48400. export var pbrDirectLightingSetupFunctions: {
  48401. name: string;
  48402. shader: string;
  48403. };
  48404. }
  48405. declare module BABYLON {
  48406. /** @hidden */
  48407. export var pbrDirectLightingFalloffFunctions: {
  48408. name: string;
  48409. shader: string;
  48410. };
  48411. }
  48412. declare module BABYLON {
  48413. /** @hidden */
  48414. export var pbrBRDFFunctions: {
  48415. name: string;
  48416. shader: string;
  48417. };
  48418. }
  48419. declare module BABYLON {
  48420. /** @hidden */
  48421. export var pbrDirectLightingFunctions: {
  48422. name: string;
  48423. shader: string;
  48424. };
  48425. }
  48426. declare module BABYLON {
  48427. /** @hidden */
  48428. export var pbrIBLFunctions: {
  48429. name: string;
  48430. shader: string;
  48431. };
  48432. }
  48433. declare module BABYLON {
  48434. /** @hidden */
  48435. export var pbrDebug: {
  48436. name: string;
  48437. shader: string;
  48438. };
  48439. }
  48440. declare module BABYLON {
  48441. /** @hidden */
  48442. export var pbrPixelShader: {
  48443. name: string;
  48444. shader: string;
  48445. };
  48446. }
  48447. declare module BABYLON {
  48448. /** @hidden */
  48449. export var pbrVertexDeclaration: {
  48450. name: string;
  48451. shader: string;
  48452. };
  48453. }
  48454. declare module BABYLON {
  48455. /** @hidden */
  48456. export var pbrVertexShader: {
  48457. name: string;
  48458. shader: string;
  48459. };
  48460. }
  48461. declare module BABYLON {
  48462. /**
  48463. * Manages the defines for the PBR Material.
  48464. * @hidden
  48465. */
  48466. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48467. PBR: boolean;
  48468. MAINUV1: boolean;
  48469. MAINUV2: boolean;
  48470. UV1: boolean;
  48471. UV2: boolean;
  48472. ALBEDO: boolean;
  48473. ALBEDODIRECTUV: number;
  48474. VERTEXCOLOR: boolean;
  48475. AMBIENT: boolean;
  48476. AMBIENTDIRECTUV: number;
  48477. AMBIENTINGRAYSCALE: boolean;
  48478. OPACITY: boolean;
  48479. VERTEXALPHA: boolean;
  48480. OPACITYDIRECTUV: number;
  48481. OPACITYRGB: boolean;
  48482. ALPHATEST: boolean;
  48483. DEPTHPREPASS: boolean;
  48484. ALPHABLEND: boolean;
  48485. ALPHAFROMALBEDO: boolean;
  48486. ALPHATESTVALUE: string;
  48487. SPECULAROVERALPHA: boolean;
  48488. RADIANCEOVERALPHA: boolean;
  48489. ALPHAFRESNEL: boolean;
  48490. LINEARALPHAFRESNEL: boolean;
  48491. PREMULTIPLYALPHA: boolean;
  48492. EMISSIVE: boolean;
  48493. EMISSIVEDIRECTUV: number;
  48494. REFLECTIVITY: boolean;
  48495. REFLECTIVITYDIRECTUV: number;
  48496. SPECULARTERM: boolean;
  48497. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48498. MICROSURFACEAUTOMATIC: boolean;
  48499. LODBASEDMICROSFURACE: boolean;
  48500. MICROSURFACEMAP: boolean;
  48501. MICROSURFACEMAPDIRECTUV: number;
  48502. METALLICWORKFLOW: boolean;
  48503. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48504. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48505. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48506. AOSTOREINMETALMAPRED: boolean;
  48507. METALLICF0FACTORFROMMETALLICMAP: boolean;
  48508. ENVIRONMENTBRDF: boolean;
  48509. ENVIRONMENTBRDF_RGBD: boolean;
  48510. NORMAL: boolean;
  48511. TANGENT: boolean;
  48512. BUMP: boolean;
  48513. BUMPDIRECTUV: number;
  48514. OBJECTSPACE_NORMALMAP: boolean;
  48515. PARALLAX: boolean;
  48516. PARALLAXOCCLUSION: boolean;
  48517. NORMALXYSCALE: boolean;
  48518. LIGHTMAP: boolean;
  48519. LIGHTMAPDIRECTUV: number;
  48520. USELIGHTMAPASSHADOWMAP: boolean;
  48521. GAMMALIGHTMAP: boolean;
  48522. RGBDLIGHTMAP: boolean;
  48523. REFLECTION: boolean;
  48524. REFLECTIONMAP_3D: boolean;
  48525. REFLECTIONMAP_SPHERICAL: boolean;
  48526. REFLECTIONMAP_PLANAR: boolean;
  48527. REFLECTIONMAP_CUBIC: boolean;
  48528. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48529. REFLECTIONMAP_PROJECTION: boolean;
  48530. REFLECTIONMAP_SKYBOX: boolean;
  48531. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48532. REFLECTIONMAP_EXPLICIT: boolean;
  48533. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48534. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48535. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48536. INVERTCUBICMAP: boolean;
  48537. USESPHERICALFROMREFLECTIONMAP: boolean;
  48538. USEIRRADIANCEMAP: boolean;
  48539. SPHERICAL_HARMONICS: boolean;
  48540. USESPHERICALINVERTEX: boolean;
  48541. REFLECTIONMAP_OPPOSITEZ: boolean;
  48542. LODINREFLECTIONALPHA: boolean;
  48543. GAMMAREFLECTION: boolean;
  48544. RGBDREFLECTION: boolean;
  48545. LINEARSPECULARREFLECTION: boolean;
  48546. RADIANCEOCCLUSION: boolean;
  48547. HORIZONOCCLUSION: boolean;
  48548. INSTANCES: boolean;
  48549. NUM_BONE_INFLUENCERS: number;
  48550. BonesPerMesh: number;
  48551. BONETEXTURE: boolean;
  48552. NONUNIFORMSCALING: boolean;
  48553. MORPHTARGETS: boolean;
  48554. MORPHTARGETS_NORMAL: boolean;
  48555. MORPHTARGETS_TANGENT: boolean;
  48556. MORPHTARGETS_UV: boolean;
  48557. NUM_MORPH_INFLUENCERS: number;
  48558. IMAGEPROCESSING: boolean;
  48559. VIGNETTE: boolean;
  48560. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48561. VIGNETTEBLENDMODEOPAQUE: boolean;
  48562. TONEMAPPING: boolean;
  48563. TONEMAPPING_ACES: boolean;
  48564. CONTRAST: boolean;
  48565. COLORCURVES: boolean;
  48566. COLORGRADING: boolean;
  48567. COLORGRADING3D: boolean;
  48568. SAMPLER3DGREENDEPTH: boolean;
  48569. SAMPLER3DBGRMAP: boolean;
  48570. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48571. EXPOSURE: boolean;
  48572. MULTIVIEW: boolean;
  48573. USEPHYSICALLIGHTFALLOFF: boolean;
  48574. USEGLTFLIGHTFALLOFF: boolean;
  48575. TWOSIDEDLIGHTING: boolean;
  48576. SHADOWFLOAT: boolean;
  48577. CLIPPLANE: boolean;
  48578. CLIPPLANE2: boolean;
  48579. CLIPPLANE3: boolean;
  48580. CLIPPLANE4: boolean;
  48581. POINTSIZE: boolean;
  48582. FOG: boolean;
  48583. LOGARITHMICDEPTH: boolean;
  48584. FORCENORMALFORWARD: boolean;
  48585. SPECULARAA: boolean;
  48586. CLEARCOAT: boolean;
  48587. CLEARCOAT_DEFAULTIOR: boolean;
  48588. CLEARCOAT_TEXTURE: boolean;
  48589. CLEARCOAT_TEXTUREDIRECTUV: number;
  48590. CLEARCOAT_BUMP: boolean;
  48591. CLEARCOAT_BUMPDIRECTUV: number;
  48592. CLEARCOAT_TINT: boolean;
  48593. CLEARCOAT_TINT_TEXTURE: boolean;
  48594. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48595. ANISOTROPIC: boolean;
  48596. ANISOTROPIC_TEXTURE: boolean;
  48597. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48598. BRDF_V_HEIGHT_CORRELATED: boolean;
  48599. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48600. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48601. SHEEN: boolean;
  48602. SHEEN_TEXTURE: boolean;
  48603. SHEEN_TEXTUREDIRECTUV: number;
  48604. SHEEN_LINKWITHALBEDO: boolean;
  48605. SUBSURFACE: boolean;
  48606. SS_REFRACTION: boolean;
  48607. SS_TRANSLUCENCY: boolean;
  48608. SS_SCATERRING: boolean;
  48609. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48610. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48611. SS_REFRACTIONMAP_3D: boolean;
  48612. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48613. SS_LODINREFRACTIONALPHA: boolean;
  48614. SS_GAMMAREFRACTION: boolean;
  48615. SS_RGBDREFRACTION: boolean;
  48616. SS_LINEARSPECULARREFRACTION: boolean;
  48617. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48618. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48619. UNLIT: boolean;
  48620. DEBUGMODE: number;
  48621. /**
  48622. * Initializes the PBR Material defines.
  48623. */
  48624. constructor();
  48625. /**
  48626. * Resets the PBR Material defines.
  48627. */
  48628. reset(): void;
  48629. }
  48630. /**
  48631. * The Physically based material base class of BJS.
  48632. *
  48633. * This offers the main features of a standard PBR material.
  48634. * For more information, please refer to the documentation :
  48635. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48636. */
  48637. export abstract class PBRBaseMaterial extends PushMaterial {
  48638. /**
  48639. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48640. */
  48641. static readonly PBRMATERIAL_OPAQUE: number;
  48642. /**
  48643. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48644. */
  48645. static readonly PBRMATERIAL_ALPHATEST: number;
  48646. /**
  48647. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48648. */
  48649. static readonly PBRMATERIAL_ALPHABLEND: number;
  48650. /**
  48651. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48652. * They are also discarded below the alpha cutoff threshold to improve performances.
  48653. */
  48654. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48655. /**
  48656. * Defines the default value of how much AO map is occluding the analytical lights
  48657. * (point spot...).
  48658. */
  48659. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48660. /**
  48661. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  48662. */
  48663. static readonly LIGHTFALLOFF_PHYSICAL: number;
  48664. /**
  48665. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  48666. * to enhance interoperability with other engines.
  48667. */
  48668. static readonly LIGHTFALLOFF_GLTF: number;
  48669. /**
  48670. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  48671. * to enhance interoperability with other materials.
  48672. */
  48673. static readonly LIGHTFALLOFF_STANDARD: number;
  48674. /**
  48675. * Intensity of the direct lights e.g. the four lights available in your scene.
  48676. * This impacts both the direct diffuse and specular highlights.
  48677. */
  48678. protected _directIntensity: number;
  48679. /**
  48680. * Intensity of the emissive part of the material.
  48681. * This helps controlling the emissive effect without modifying the emissive color.
  48682. */
  48683. protected _emissiveIntensity: number;
  48684. /**
  48685. * Intensity of the environment e.g. how much the environment will light the object
  48686. * either through harmonics for rough material or through the refelction for shiny ones.
  48687. */
  48688. protected _environmentIntensity: number;
  48689. /**
  48690. * This is a special control allowing the reduction of the specular highlights coming from the
  48691. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48692. */
  48693. protected _specularIntensity: number;
  48694. /**
  48695. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  48696. */
  48697. private _lightingInfos;
  48698. /**
  48699. * Debug Control allowing disabling the bump map on this material.
  48700. */
  48701. protected _disableBumpMap: boolean;
  48702. /**
  48703. * AKA Diffuse Texture in standard nomenclature.
  48704. */
  48705. protected _albedoTexture: Nullable<BaseTexture>;
  48706. /**
  48707. * AKA Occlusion Texture in other nomenclature.
  48708. */
  48709. protected _ambientTexture: Nullable<BaseTexture>;
  48710. /**
  48711. * AKA Occlusion Texture Intensity in other nomenclature.
  48712. */
  48713. protected _ambientTextureStrength: number;
  48714. /**
  48715. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48716. * 1 means it completely occludes it
  48717. * 0 mean it has no impact
  48718. */
  48719. protected _ambientTextureImpactOnAnalyticalLights: number;
  48720. /**
  48721. * Stores the alpha values in a texture.
  48722. */
  48723. protected _opacityTexture: Nullable<BaseTexture>;
  48724. /**
  48725. * Stores the reflection values in a texture.
  48726. */
  48727. protected _reflectionTexture: Nullable<BaseTexture>;
  48728. /**
  48729. * Stores the emissive values in a texture.
  48730. */
  48731. protected _emissiveTexture: Nullable<BaseTexture>;
  48732. /**
  48733. * AKA Specular texture in other nomenclature.
  48734. */
  48735. protected _reflectivityTexture: Nullable<BaseTexture>;
  48736. /**
  48737. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48738. */
  48739. protected _metallicTexture: Nullable<BaseTexture>;
  48740. /**
  48741. * Specifies the metallic scalar of the metallic/roughness workflow.
  48742. * Can also be used to scale the metalness values of the metallic texture.
  48743. */
  48744. protected _metallic: Nullable<number>;
  48745. /**
  48746. * Specifies the roughness scalar of the metallic/roughness workflow.
  48747. * Can also be used to scale the roughness values of the metallic texture.
  48748. */
  48749. protected _roughness: Nullable<number>;
  48750. /**
  48751. * Specifies the an F0 factor to help configuring the material F0.
  48752. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  48753. * to 0.5 the previously hard coded value stays the same.
  48754. * Can also be used to scale the F0 values of the metallic texture.
  48755. */
  48756. protected _metallicF0Factor: number;
  48757. /**
  48758. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  48759. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  48760. * your expectation as it multiplies with the texture data.
  48761. */
  48762. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  48763. /**
  48764. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48765. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48766. */
  48767. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48768. /**
  48769. * Stores surface normal data used to displace a mesh in a texture.
  48770. */
  48771. protected _bumpTexture: Nullable<BaseTexture>;
  48772. /**
  48773. * Stores the pre-calculated light information of a mesh in a texture.
  48774. */
  48775. protected _lightmapTexture: Nullable<BaseTexture>;
  48776. /**
  48777. * The color of a material in ambient lighting.
  48778. */
  48779. protected _ambientColor: Color3;
  48780. /**
  48781. * AKA Diffuse Color in other nomenclature.
  48782. */
  48783. protected _albedoColor: Color3;
  48784. /**
  48785. * AKA Specular Color in other nomenclature.
  48786. */
  48787. protected _reflectivityColor: Color3;
  48788. /**
  48789. * The color applied when light is reflected from a material.
  48790. */
  48791. protected _reflectionColor: Color3;
  48792. /**
  48793. * The color applied when light is emitted from a material.
  48794. */
  48795. protected _emissiveColor: Color3;
  48796. /**
  48797. * AKA Glossiness in other nomenclature.
  48798. */
  48799. protected _microSurface: number;
  48800. /**
  48801. * Specifies that the material will use the light map as a show map.
  48802. */
  48803. protected _useLightmapAsShadowmap: boolean;
  48804. /**
  48805. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48806. * makes the reflect vector face the model (under horizon).
  48807. */
  48808. protected _useHorizonOcclusion: boolean;
  48809. /**
  48810. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48811. * too much the area relying on ambient texture to define their ambient occlusion.
  48812. */
  48813. protected _useRadianceOcclusion: boolean;
  48814. /**
  48815. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48816. */
  48817. protected _useAlphaFromAlbedoTexture: boolean;
  48818. /**
  48819. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  48820. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48821. */
  48822. protected _useSpecularOverAlpha: boolean;
  48823. /**
  48824. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48825. */
  48826. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48827. /**
  48828. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48829. */
  48830. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  48831. /**
  48832. * Specifies if the metallic texture contains the roughness information in its green channel.
  48833. */
  48834. protected _useRoughnessFromMetallicTextureGreen: boolean;
  48835. /**
  48836. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48837. */
  48838. protected _useMetallnessFromMetallicTextureBlue: boolean;
  48839. /**
  48840. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48841. */
  48842. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  48843. /**
  48844. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48845. */
  48846. protected _useAmbientInGrayScale: boolean;
  48847. /**
  48848. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48849. * The material will try to infer what glossiness each pixel should be.
  48850. */
  48851. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  48852. /**
  48853. * Defines the falloff type used in this material.
  48854. * It by default is Physical.
  48855. */
  48856. protected _lightFalloff: number;
  48857. /**
  48858. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48859. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48860. */
  48861. protected _useRadianceOverAlpha: boolean;
  48862. /**
  48863. * Allows using an object space normal map (instead of tangent space).
  48864. */
  48865. protected _useObjectSpaceNormalMap: boolean;
  48866. /**
  48867. * Allows using the bump map in parallax mode.
  48868. */
  48869. protected _useParallax: boolean;
  48870. /**
  48871. * Allows using the bump map in parallax occlusion mode.
  48872. */
  48873. protected _useParallaxOcclusion: boolean;
  48874. /**
  48875. * Controls the scale bias of the parallax mode.
  48876. */
  48877. protected _parallaxScaleBias: number;
  48878. /**
  48879. * If sets to true, disables all the lights affecting the material.
  48880. */
  48881. protected _disableLighting: boolean;
  48882. /**
  48883. * Number of Simultaneous lights allowed on the material.
  48884. */
  48885. protected _maxSimultaneousLights: number;
  48886. /**
  48887. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48888. */
  48889. protected _invertNormalMapX: boolean;
  48890. /**
  48891. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48892. */
  48893. protected _invertNormalMapY: boolean;
  48894. /**
  48895. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48896. */
  48897. protected _twoSidedLighting: boolean;
  48898. /**
  48899. * Defines the alpha limits in alpha test mode.
  48900. */
  48901. protected _alphaCutOff: number;
  48902. /**
  48903. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48904. */
  48905. protected _forceAlphaTest: boolean;
  48906. /**
  48907. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48908. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48909. */
  48910. protected _useAlphaFresnel: boolean;
  48911. /**
  48912. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48913. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48914. */
  48915. protected _useLinearAlphaFresnel: boolean;
  48916. /**
  48917. * The transparency mode of the material.
  48918. */
  48919. protected _transparencyMode: Nullable<number>;
  48920. /**
  48921. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48922. * from cos thetav and roughness:
  48923. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48924. */
  48925. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48926. /**
  48927. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48928. */
  48929. protected _forceIrradianceInFragment: boolean;
  48930. /**
  48931. * Force normal to face away from face.
  48932. */
  48933. protected _forceNormalForward: boolean;
  48934. /**
  48935. * Enables specular anti aliasing in the PBR shader.
  48936. * It will both interacts on the Geometry for analytical and IBL lighting.
  48937. * It also prefilter the roughness map based on the bump values.
  48938. */
  48939. protected _enableSpecularAntiAliasing: boolean;
  48940. /**
  48941. * Default configuration related to image processing available in the PBR Material.
  48942. */
  48943. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48944. /**
  48945. * Keep track of the image processing observer to allow dispose and replace.
  48946. */
  48947. private _imageProcessingObserver;
  48948. /**
  48949. * Attaches a new image processing configuration to the PBR Material.
  48950. * @param configuration
  48951. */
  48952. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48953. /**
  48954. * Stores the available render targets.
  48955. */
  48956. private _renderTargets;
  48957. /**
  48958. * Sets the global ambient color for the material used in lighting calculations.
  48959. */
  48960. private _globalAmbientColor;
  48961. /**
  48962. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48963. */
  48964. private _useLogarithmicDepth;
  48965. /**
  48966. * If set to true, no lighting calculations will be applied.
  48967. */
  48968. private _unlit;
  48969. private _debugMode;
  48970. /**
  48971. * @hidden
  48972. * This is reserved for the inspector.
  48973. * Defines the material debug mode.
  48974. * It helps seeing only some components of the material while troubleshooting.
  48975. */
  48976. debugMode: number;
  48977. /**
  48978. * @hidden
  48979. * This is reserved for the inspector.
  48980. * Specify from where on screen the debug mode should start.
  48981. * The value goes from -1 (full screen) to 1 (not visible)
  48982. * It helps with side by side comparison against the final render
  48983. * This defaults to -1
  48984. */
  48985. private debugLimit;
  48986. /**
  48987. * @hidden
  48988. * This is reserved for the inspector.
  48989. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48990. * You can use the factor to better multiply the final value.
  48991. */
  48992. private debugFactor;
  48993. /**
  48994. * Defines the clear coat layer parameters for the material.
  48995. */
  48996. readonly clearCoat: PBRClearCoatConfiguration;
  48997. /**
  48998. * Defines the anisotropic parameters for the material.
  48999. */
  49000. readonly anisotropy: PBRAnisotropicConfiguration;
  49001. /**
  49002. * Defines the BRDF parameters for the material.
  49003. */
  49004. readonly brdf: PBRBRDFConfiguration;
  49005. /**
  49006. * Defines the Sheen parameters for the material.
  49007. */
  49008. readonly sheen: PBRSheenConfiguration;
  49009. /**
  49010. * Defines the SubSurface parameters for the material.
  49011. */
  49012. readonly subSurface: PBRSubSurfaceConfiguration;
  49013. /**
  49014. * Custom callback helping to override the default shader used in the material.
  49015. */
  49016. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49017. protected _rebuildInParallel: boolean;
  49018. /**
  49019. * Instantiates a new PBRMaterial instance.
  49020. *
  49021. * @param name The material name
  49022. * @param scene The scene the material will be use in.
  49023. */
  49024. constructor(name: string, scene: Scene);
  49025. /**
  49026. * Gets a boolean indicating that current material needs to register RTT
  49027. */
  49028. readonly hasRenderTargetTextures: boolean;
  49029. /**
  49030. * Gets the name of the material class.
  49031. */
  49032. getClassName(): string;
  49033. /**
  49034. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49035. */
  49036. /**
  49037. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49038. */
  49039. useLogarithmicDepth: boolean;
  49040. /**
  49041. * Gets the current transparency mode.
  49042. */
  49043. /**
  49044. * Sets the transparency mode of the material.
  49045. *
  49046. * | Value | Type | Description |
  49047. * | ----- | ----------------------------------- | ----------- |
  49048. * | 0 | OPAQUE | |
  49049. * | 1 | ALPHATEST | |
  49050. * | 2 | ALPHABLEND | |
  49051. * | 3 | ALPHATESTANDBLEND | |
  49052. *
  49053. */
  49054. transparencyMode: Nullable<number>;
  49055. /**
  49056. * Returns true if alpha blending should be disabled.
  49057. */
  49058. private readonly _disableAlphaBlending;
  49059. /**
  49060. * Specifies whether or not this material should be rendered in alpha blend mode.
  49061. */
  49062. needAlphaBlending(): boolean;
  49063. /**
  49064. * Specifies if the mesh will require alpha blending.
  49065. * @param mesh - BJS mesh.
  49066. */
  49067. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  49068. /**
  49069. * Specifies whether or not this material should be rendered in alpha test mode.
  49070. */
  49071. needAlphaTesting(): boolean;
  49072. /**
  49073. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  49074. */
  49075. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  49076. /**
  49077. * Gets the texture used for the alpha test.
  49078. */
  49079. getAlphaTestTexture(): Nullable<BaseTexture>;
  49080. /**
  49081. * Specifies that the submesh is ready to be used.
  49082. * @param mesh - BJS mesh.
  49083. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  49084. * @param useInstances - Specifies that instances should be used.
  49085. * @returns - boolean indicating that the submesh is ready or not.
  49086. */
  49087. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49088. /**
  49089. * Specifies if the material uses metallic roughness workflow.
  49090. * @returns boolean specifiying if the material uses metallic roughness workflow.
  49091. */
  49092. isMetallicWorkflow(): boolean;
  49093. private _prepareEffect;
  49094. private _prepareDefines;
  49095. /**
  49096. * Force shader compilation
  49097. */
  49098. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  49099. /**
  49100. * Initializes the uniform buffer layout for the shader.
  49101. */
  49102. buildUniformLayout(): void;
  49103. /**
  49104. * Unbinds the material from the mesh
  49105. */
  49106. unbind(): void;
  49107. /**
  49108. * Binds the submesh data.
  49109. * @param world - The world matrix.
  49110. * @param mesh - The BJS mesh.
  49111. * @param subMesh - A submesh of the BJS mesh.
  49112. */
  49113. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49114. /**
  49115. * Returns the animatable textures.
  49116. * @returns - Array of animatable textures.
  49117. */
  49118. getAnimatables(): IAnimatable[];
  49119. /**
  49120. * Returns the texture used for reflections.
  49121. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  49122. */
  49123. private _getReflectionTexture;
  49124. /**
  49125. * Returns an array of the actively used textures.
  49126. * @returns - Array of BaseTextures
  49127. */
  49128. getActiveTextures(): BaseTexture[];
  49129. /**
  49130. * Checks to see if a texture is used in the material.
  49131. * @param texture - Base texture to use.
  49132. * @returns - Boolean specifying if a texture is used in the material.
  49133. */
  49134. hasTexture(texture: BaseTexture): boolean;
  49135. /**
  49136. * Disposes the resources of the material.
  49137. * @param forceDisposeEffect - Forces the disposal of effects.
  49138. * @param forceDisposeTextures - Forces the disposal of all textures.
  49139. */
  49140. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49141. }
  49142. }
  49143. declare module BABYLON {
  49144. /**
  49145. * The Physically based material of BJS.
  49146. *
  49147. * This offers the main features of a standard PBR material.
  49148. * For more information, please refer to the documentation :
  49149. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49150. */
  49151. export class PBRMaterial extends PBRBaseMaterial {
  49152. /**
  49153. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49154. */
  49155. static readonly PBRMATERIAL_OPAQUE: number;
  49156. /**
  49157. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49158. */
  49159. static readonly PBRMATERIAL_ALPHATEST: number;
  49160. /**
  49161. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49162. */
  49163. static readonly PBRMATERIAL_ALPHABLEND: number;
  49164. /**
  49165. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49166. * They are also discarded below the alpha cutoff threshold to improve performances.
  49167. */
  49168. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49169. /**
  49170. * Defines the default value of how much AO map is occluding the analytical lights
  49171. * (point spot...).
  49172. */
  49173. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49174. /**
  49175. * Intensity of the direct lights e.g. the four lights available in your scene.
  49176. * This impacts both the direct diffuse and specular highlights.
  49177. */
  49178. directIntensity: number;
  49179. /**
  49180. * Intensity of the emissive part of the material.
  49181. * This helps controlling the emissive effect without modifying the emissive color.
  49182. */
  49183. emissiveIntensity: number;
  49184. /**
  49185. * Intensity of the environment e.g. how much the environment will light the object
  49186. * either through harmonics for rough material or through the refelction for shiny ones.
  49187. */
  49188. environmentIntensity: number;
  49189. /**
  49190. * This is a special control allowing the reduction of the specular highlights coming from the
  49191. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49192. */
  49193. specularIntensity: number;
  49194. /**
  49195. * Debug Control allowing disabling the bump map on this material.
  49196. */
  49197. disableBumpMap: boolean;
  49198. /**
  49199. * AKA Diffuse Texture in standard nomenclature.
  49200. */
  49201. albedoTexture: BaseTexture;
  49202. /**
  49203. * AKA Occlusion Texture in other nomenclature.
  49204. */
  49205. ambientTexture: BaseTexture;
  49206. /**
  49207. * AKA Occlusion Texture Intensity in other nomenclature.
  49208. */
  49209. ambientTextureStrength: number;
  49210. /**
  49211. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49212. * 1 means it completely occludes it
  49213. * 0 mean it has no impact
  49214. */
  49215. ambientTextureImpactOnAnalyticalLights: number;
  49216. /**
  49217. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  49218. */
  49219. opacityTexture: BaseTexture;
  49220. /**
  49221. * Stores the reflection values in a texture.
  49222. */
  49223. reflectionTexture: Nullable<BaseTexture>;
  49224. /**
  49225. * Stores the emissive values in a texture.
  49226. */
  49227. emissiveTexture: BaseTexture;
  49228. /**
  49229. * AKA Specular texture in other nomenclature.
  49230. */
  49231. reflectivityTexture: BaseTexture;
  49232. /**
  49233. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49234. */
  49235. metallicTexture: BaseTexture;
  49236. /**
  49237. * Specifies the metallic scalar of the metallic/roughness workflow.
  49238. * Can also be used to scale the metalness values of the metallic texture.
  49239. */
  49240. metallic: Nullable<number>;
  49241. /**
  49242. * Specifies the roughness scalar of the metallic/roughness workflow.
  49243. * Can also be used to scale the roughness values of the metallic texture.
  49244. */
  49245. roughness: Nullable<number>;
  49246. /**
  49247. * Specifies the an F0 factor to help configuring the material F0.
  49248. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  49249. * to 0.5 the previously hard coded value stays the same.
  49250. * Can also be used to scale the F0 values of the metallic texture.
  49251. */
  49252. metallicF0Factor: number;
  49253. /**
  49254. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  49255. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  49256. * your expectation as it multiplies with the texture data.
  49257. */
  49258. useMetallicF0FactorFromMetallicTexture: boolean;
  49259. /**
  49260. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49261. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49262. */
  49263. microSurfaceTexture: BaseTexture;
  49264. /**
  49265. * Stores surface normal data used to displace a mesh in a texture.
  49266. */
  49267. bumpTexture: BaseTexture;
  49268. /**
  49269. * Stores the pre-calculated light information of a mesh in a texture.
  49270. */
  49271. lightmapTexture: BaseTexture;
  49272. /**
  49273. * Stores the refracted light information in a texture.
  49274. */
  49275. refractionTexture: Nullable<BaseTexture>;
  49276. /**
  49277. * The color of a material in ambient lighting.
  49278. */
  49279. ambientColor: Color3;
  49280. /**
  49281. * AKA Diffuse Color in other nomenclature.
  49282. */
  49283. albedoColor: Color3;
  49284. /**
  49285. * AKA Specular Color in other nomenclature.
  49286. */
  49287. reflectivityColor: Color3;
  49288. /**
  49289. * The color reflected from the material.
  49290. */
  49291. reflectionColor: Color3;
  49292. /**
  49293. * The color emitted from the material.
  49294. */
  49295. emissiveColor: Color3;
  49296. /**
  49297. * AKA Glossiness in other nomenclature.
  49298. */
  49299. microSurface: number;
  49300. /**
  49301. * source material index of refraction (IOR)' / 'destination material IOR.
  49302. */
  49303. indexOfRefraction: number;
  49304. /**
  49305. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49306. */
  49307. invertRefractionY: boolean;
  49308. /**
  49309. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49310. * Materials half opaque for instance using refraction could benefit from this control.
  49311. */
  49312. linkRefractionWithTransparency: boolean;
  49313. /**
  49314. * If true, the light map contains occlusion information instead of lighting info.
  49315. */
  49316. useLightmapAsShadowmap: boolean;
  49317. /**
  49318. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49319. */
  49320. useAlphaFromAlbedoTexture: boolean;
  49321. /**
  49322. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49323. */
  49324. forceAlphaTest: boolean;
  49325. /**
  49326. * Defines the alpha limits in alpha test mode.
  49327. */
  49328. alphaCutOff: number;
  49329. /**
  49330. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49331. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49332. */
  49333. useSpecularOverAlpha: boolean;
  49334. /**
  49335. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49336. */
  49337. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49338. /**
  49339. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49340. */
  49341. useRoughnessFromMetallicTextureAlpha: boolean;
  49342. /**
  49343. * Specifies if the metallic texture contains the roughness information in its green channel.
  49344. */
  49345. useRoughnessFromMetallicTextureGreen: boolean;
  49346. /**
  49347. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49348. */
  49349. useMetallnessFromMetallicTextureBlue: boolean;
  49350. /**
  49351. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49352. */
  49353. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49354. /**
  49355. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49356. */
  49357. useAmbientInGrayScale: boolean;
  49358. /**
  49359. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49360. * The material will try to infer what glossiness each pixel should be.
  49361. */
  49362. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49363. /**
  49364. * BJS is using an harcoded light falloff based on a manually sets up range.
  49365. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49366. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49367. */
  49368. /**
  49369. * BJS is using an harcoded light falloff based on a manually sets up range.
  49370. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49371. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49372. */
  49373. usePhysicalLightFalloff: boolean;
  49374. /**
  49375. * In order to support the falloff compatibility with gltf, a special mode has been added
  49376. * to reproduce the gltf light falloff.
  49377. */
  49378. /**
  49379. * In order to support the falloff compatibility with gltf, a special mode has been added
  49380. * to reproduce the gltf light falloff.
  49381. */
  49382. useGLTFLightFalloff: boolean;
  49383. /**
  49384. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49385. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49386. */
  49387. useRadianceOverAlpha: boolean;
  49388. /**
  49389. * Allows using an object space normal map (instead of tangent space).
  49390. */
  49391. useObjectSpaceNormalMap: boolean;
  49392. /**
  49393. * Allows using the bump map in parallax mode.
  49394. */
  49395. useParallax: boolean;
  49396. /**
  49397. * Allows using the bump map in parallax occlusion mode.
  49398. */
  49399. useParallaxOcclusion: boolean;
  49400. /**
  49401. * Controls the scale bias of the parallax mode.
  49402. */
  49403. parallaxScaleBias: number;
  49404. /**
  49405. * If sets to true, disables all the lights affecting the material.
  49406. */
  49407. disableLighting: boolean;
  49408. /**
  49409. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49410. */
  49411. forceIrradianceInFragment: boolean;
  49412. /**
  49413. * Number of Simultaneous lights allowed on the material.
  49414. */
  49415. maxSimultaneousLights: number;
  49416. /**
  49417. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49418. */
  49419. invertNormalMapX: boolean;
  49420. /**
  49421. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49422. */
  49423. invertNormalMapY: boolean;
  49424. /**
  49425. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49426. */
  49427. twoSidedLighting: boolean;
  49428. /**
  49429. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49430. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49431. */
  49432. useAlphaFresnel: boolean;
  49433. /**
  49434. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49435. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49436. */
  49437. useLinearAlphaFresnel: boolean;
  49438. /**
  49439. * Let user defines the brdf lookup texture used for IBL.
  49440. * A default 8bit version is embedded but you could point at :
  49441. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49442. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49443. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49444. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49445. */
  49446. environmentBRDFTexture: Nullable<BaseTexture>;
  49447. /**
  49448. * Force normal to face away from face.
  49449. */
  49450. forceNormalForward: boolean;
  49451. /**
  49452. * Enables specular anti aliasing in the PBR shader.
  49453. * It will both interacts on the Geometry for analytical and IBL lighting.
  49454. * It also prefilter the roughness map based on the bump values.
  49455. */
  49456. enableSpecularAntiAliasing: boolean;
  49457. /**
  49458. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49459. * makes the reflect vector face the model (under horizon).
  49460. */
  49461. useHorizonOcclusion: boolean;
  49462. /**
  49463. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49464. * too much the area relying on ambient texture to define their ambient occlusion.
  49465. */
  49466. useRadianceOcclusion: boolean;
  49467. /**
  49468. * If set to true, no lighting calculations will be applied.
  49469. */
  49470. unlit: boolean;
  49471. /**
  49472. * Gets the image processing configuration used either in this material.
  49473. */
  49474. /**
  49475. * Sets the Default image processing configuration used either in the this material.
  49476. *
  49477. * If sets to null, the scene one is in use.
  49478. */
  49479. imageProcessingConfiguration: ImageProcessingConfiguration;
  49480. /**
  49481. * Gets wether the color curves effect is enabled.
  49482. */
  49483. /**
  49484. * Sets wether the color curves effect is enabled.
  49485. */
  49486. cameraColorCurvesEnabled: boolean;
  49487. /**
  49488. * Gets wether the color grading effect is enabled.
  49489. */
  49490. /**
  49491. * Gets wether the color grading effect is enabled.
  49492. */
  49493. cameraColorGradingEnabled: boolean;
  49494. /**
  49495. * Gets wether tonemapping is enabled or not.
  49496. */
  49497. /**
  49498. * Sets wether tonemapping is enabled or not
  49499. */
  49500. cameraToneMappingEnabled: boolean;
  49501. /**
  49502. * The camera exposure used on this material.
  49503. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49504. * This corresponds to a photographic exposure.
  49505. */
  49506. /**
  49507. * The camera exposure used on this material.
  49508. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49509. * This corresponds to a photographic exposure.
  49510. */
  49511. cameraExposure: number;
  49512. /**
  49513. * Gets The camera contrast used on this material.
  49514. */
  49515. /**
  49516. * Sets The camera contrast used on this material.
  49517. */
  49518. cameraContrast: number;
  49519. /**
  49520. * Gets the Color Grading 2D Lookup Texture.
  49521. */
  49522. /**
  49523. * Sets the Color Grading 2D Lookup Texture.
  49524. */
  49525. cameraColorGradingTexture: Nullable<BaseTexture>;
  49526. /**
  49527. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49528. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49529. * 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;
  49530. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49531. */
  49532. /**
  49533. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49534. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49535. * 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;
  49536. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49537. */
  49538. cameraColorCurves: Nullable<ColorCurves>;
  49539. /**
  49540. * Instantiates a new PBRMaterial instance.
  49541. *
  49542. * @param name The material name
  49543. * @param scene The scene the material will be use in.
  49544. */
  49545. constructor(name: string, scene: Scene);
  49546. /**
  49547. * Returns the name of this material class.
  49548. */
  49549. getClassName(): string;
  49550. /**
  49551. * Makes a duplicate of the current material.
  49552. * @param name - name to use for the new material.
  49553. */
  49554. clone(name: string): PBRMaterial;
  49555. /**
  49556. * Serializes this PBR Material.
  49557. * @returns - An object with the serialized material.
  49558. */
  49559. serialize(): any;
  49560. /**
  49561. * Parses a PBR Material from a serialized object.
  49562. * @param source - Serialized object.
  49563. * @param scene - BJS scene instance.
  49564. * @param rootUrl - url for the scene object
  49565. * @returns - PBRMaterial
  49566. */
  49567. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49568. }
  49569. }
  49570. declare module BABYLON {
  49571. /**
  49572. * Direct draw surface info
  49573. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49574. */
  49575. export interface DDSInfo {
  49576. /**
  49577. * Width of the texture
  49578. */
  49579. width: number;
  49580. /**
  49581. * Width of the texture
  49582. */
  49583. height: number;
  49584. /**
  49585. * Number of Mipmaps for the texture
  49586. * @see https://en.wikipedia.org/wiki/Mipmap
  49587. */
  49588. mipmapCount: number;
  49589. /**
  49590. * If the textures format is a known fourCC format
  49591. * @see https://www.fourcc.org/
  49592. */
  49593. isFourCC: boolean;
  49594. /**
  49595. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49596. */
  49597. isRGB: boolean;
  49598. /**
  49599. * If the texture is a lumincance format
  49600. */
  49601. isLuminance: boolean;
  49602. /**
  49603. * If this is a cube texture
  49604. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49605. */
  49606. isCube: boolean;
  49607. /**
  49608. * If the texture is a compressed format eg. FOURCC_DXT1
  49609. */
  49610. isCompressed: boolean;
  49611. /**
  49612. * The dxgiFormat of the texture
  49613. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49614. */
  49615. dxgiFormat: number;
  49616. /**
  49617. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49618. */
  49619. textureType: number;
  49620. /**
  49621. * Sphericle polynomial created for the dds texture
  49622. */
  49623. sphericalPolynomial?: SphericalPolynomial;
  49624. }
  49625. /**
  49626. * Class used to provide DDS decompression tools
  49627. */
  49628. export class DDSTools {
  49629. /**
  49630. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  49631. */
  49632. static StoreLODInAlphaChannel: boolean;
  49633. /**
  49634. * Gets DDS information from an array buffer
  49635. * @param arrayBuffer defines the array buffer to read data from
  49636. * @returns the DDS information
  49637. */
  49638. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  49639. private static _FloatView;
  49640. private static _Int32View;
  49641. private static _ToHalfFloat;
  49642. private static _FromHalfFloat;
  49643. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  49644. private static _GetHalfFloatRGBAArrayBuffer;
  49645. private static _GetFloatRGBAArrayBuffer;
  49646. private static _GetFloatAsUIntRGBAArrayBuffer;
  49647. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  49648. private static _GetRGBAArrayBuffer;
  49649. private static _ExtractLongWordOrder;
  49650. private static _GetRGBArrayBuffer;
  49651. private static _GetLuminanceArrayBuffer;
  49652. /**
  49653. * Uploads DDS Levels to a Babylon Texture
  49654. * @hidden
  49655. */
  49656. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  49657. }
  49658. interface ThinEngine {
  49659. /**
  49660. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  49661. * @param rootUrl defines the url where the file to load is located
  49662. * @param scene defines the current scene
  49663. * @param lodScale defines scale to apply to the mip map selection
  49664. * @param lodOffset defines offset to apply to the mip map selection
  49665. * @param onLoad defines an optional callback raised when the texture is loaded
  49666. * @param onError defines an optional callback raised if there is an issue to load the texture
  49667. * @param format defines the format of the data
  49668. * @param forcedExtension defines the extension to use to pick the right loader
  49669. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  49670. * @returns the cube texture as an InternalTexture
  49671. */
  49672. 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;
  49673. }
  49674. }
  49675. declare module BABYLON {
  49676. /**
  49677. * Implementation of the DDS Texture Loader.
  49678. * @hidden
  49679. */
  49680. export class _DDSTextureLoader implements IInternalTextureLoader {
  49681. /**
  49682. * Defines wether the loader supports cascade loading the different faces.
  49683. */
  49684. readonly supportCascades: boolean;
  49685. /**
  49686. * This returns if the loader support the current file information.
  49687. * @param extension defines the file extension of the file being loaded
  49688. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49689. * @param fallback defines the fallback internal texture if any
  49690. * @param isBase64 defines whether the texture is encoded as a base64
  49691. * @param isBuffer defines whether the texture data are stored as a buffer
  49692. * @returns true if the loader can load the specified file
  49693. */
  49694. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49695. /**
  49696. * Transform the url before loading if required.
  49697. * @param rootUrl the url of the texture
  49698. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49699. * @returns the transformed texture
  49700. */
  49701. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49702. /**
  49703. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49704. * @param rootUrl the url of the texture
  49705. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49706. * @returns the fallback texture
  49707. */
  49708. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49709. /**
  49710. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49711. * @param data contains the texture data
  49712. * @param texture defines the BabylonJS internal texture
  49713. * @param createPolynomials will be true if polynomials have been requested
  49714. * @param onLoad defines the callback to trigger once the texture is ready
  49715. * @param onError defines the callback to trigger in case of error
  49716. */
  49717. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49718. /**
  49719. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49720. * @param data contains the texture data
  49721. * @param texture defines the BabylonJS internal texture
  49722. * @param callback defines the method to call once ready to upload
  49723. */
  49724. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49725. }
  49726. }
  49727. declare module BABYLON {
  49728. /**
  49729. * Implementation of the ENV Texture Loader.
  49730. * @hidden
  49731. */
  49732. export class _ENVTextureLoader implements IInternalTextureLoader {
  49733. /**
  49734. * Defines wether the loader supports cascade loading the different faces.
  49735. */
  49736. readonly supportCascades: boolean;
  49737. /**
  49738. * This returns if the loader support the current file information.
  49739. * @param extension defines the file extension of the file being loaded
  49740. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49741. * @param fallback defines the fallback internal texture if any
  49742. * @param isBase64 defines whether the texture is encoded as a base64
  49743. * @param isBuffer defines whether the texture data are stored as a buffer
  49744. * @returns true if the loader can load the specified file
  49745. */
  49746. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49747. /**
  49748. * Transform the url before loading if required.
  49749. * @param rootUrl the url of the texture
  49750. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49751. * @returns the transformed texture
  49752. */
  49753. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49754. /**
  49755. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49756. * @param rootUrl the url of the texture
  49757. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49758. * @returns the fallback texture
  49759. */
  49760. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49761. /**
  49762. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49763. * @param data contains the texture data
  49764. * @param texture defines the BabylonJS internal texture
  49765. * @param createPolynomials will be true if polynomials have been requested
  49766. * @param onLoad defines the callback to trigger once the texture is ready
  49767. * @param onError defines the callback to trigger in case of error
  49768. */
  49769. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49770. /**
  49771. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49772. * @param data contains the texture data
  49773. * @param texture defines the BabylonJS internal texture
  49774. * @param callback defines the method to call once ready to upload
  49775. */
  49776. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49777. }
  49778. }
  49779. declare module BABYLON {
  49780. /**
  49781. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49782. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49783. */
  49784. export class KhronosTextureContainer {
  49785. /** contents of the KTX container file */
  49786. arrayBuffer: any;
  49787. private static HEADER_LEN;
  49788. private static COMPRESSED_2D;
  49789. private static COMPRESSED_3D;
  49790. private static TEX_2D;
  49791. private static TEX_3D;
  49792. /**
  49793. * Gets the openGL type
  49794. */
  49795. glType: number;
  49796. /**
  49797. * Gets the openGL type size
  49798. */
  49799. glTypeSize: number;
  49800. /**
  49801. * Gets the openGL format
  49802. */
  49803. glFormat: number;
  49804. /**
  49805. * Gets the openGL internal format
  49806. */
  49807. glInternalFormat: number;
  49808. /**
  49809. * Gets the base internal format
  49810. */
  49811. glBaseInternalFormat: number;
  49812. /**
  49813. * Gets image width in pixel
  49814. */
  49815. pixelWidth: number;
  49816. /**
  49817. * Gets image height in pixel
  49818. */
  49819. pixelHeight: number;
  49820. /**
  49821. * Gets image depth in pixels
  49822. */
  49823. pixelDepth: number;
  49824. /**
  49825. * Gets the number of array elements
  49826. */
  49827. numberOfArrayElements: number;
  49828. /**
  49829. * Gets the number of faces
  49830. */
  49831. numberOfFaces: number;
  49832. /**
  49833. * Gets the number of mipmap levels
  49834. */
  49835. numberOfMipmapLevels: number;
  49836. /**
  49837. * Gets the bytes of key value data
  49838. */
  49839. bytesOfKeyValueData: number;
  49840. /**
  49841. * Gets the load type
  49842. */
  49843. loadType: number;
  49844. /**
  49845. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  49846. */
  49847. isInvalid: boolean;
  49848. /**
  49849. * Creates a new KhronosTextureContainer
  49850. * @param arrayBuffer contents of the KTX container file
  49851. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49852. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49853. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49854. */
  49855. constructor(
  49856. /** contents of the KTX container file */
  49857. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49858. /**
  49859. * Uploads KTX content to a Babylon Texture.
  49860. * It is assumed that the texture has already been created & is currently bound
  49861. * @hidden
  49862. */
  49863. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49864. private _upload2DCompressedLevels;
  49865. }
  49866. }
  49867. declare module BABYLON {
  49868. /**
  49869. * Implementation of the KTX Texture Loader.
  49870. * @hidden
  49871. */
  49872. export class _KTXTextureLoader implements IInternalTextureLoader {
  49873. /**
  49874. * Defines wether the loader supports cascade loading the different faces.
  49875. */
  49876. readonly supportCascades: boolean;
  49877. /**
  49878. * This returns if the loader support the current file information.
  49879. * @param extension defines the file extension of the file being loaded
  49880. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49881. * @param fallback defines the fallback internal texture if any
  49882. * @param isBase64 defines whether the texture is encoded as a base64
  49883. * @param isBuffer defines whether the texture data are stored as a buffer
  49884. * @returns true if the loader can load the specified file
  49885. */
  49886. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49887. /**
  49888. * Transform the url before loading if required.
  49889. * @param rootUrl the url of the texture
  49890. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49891. * @returns the transformed texture
  49892. */
  49893. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49894. /**
  49895. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49896. * @param rootUrl the url of the texture
  49897. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49898. * @returns the fallback texture
  49899. */
  49900. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49901. /**
  49902. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49903. * @param data contains the texture data
  49904. * @param texture defines the BabylonJS internal texture
  49905. * @param createPolynomials will be true if polynomials have been requested
  49906. * @param onLoad defines the callback to trigger once the texture is ready
  49907. * @param onError defines the callback to trigger in case of error
  49908. */
  49909. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49910. /**
  49911. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49912. * @param data contains the texture data
  49913. * @param texture defines the BabylonJS internal texture
  49914. * @param callback defines the method to call once ready to upload
  49915. */
  49916. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49917. }
  49918. }
  49919. declare module BABYLON {
  49920. /** @hidden */
  49921. export var _forceSceneHelpersToBundle: boolean;
  49922. interface Scene {
  49923. /**
  49924. * Creates a default light for the scene.
  49925. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49926. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49927. */
  49928. createDefaultLight(replace?: boolean): void;
  49929. /**
  49930. * Creates a default camera for the scene.
  49931. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49932. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49933. * @param replace has default false, when true replaces the active camera in the scene
  49934. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49935. */
  49936. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49937. /**
  49938. * Creates a default camera and a default light.
  49939. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49940. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49941. * @param replace has the default false, when true replaces the active camera/light in the scene
  49942. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49943. */
  49944. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49945. /**
  49946. * Creates a new sky box
  49947. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49948. * @param environmentTexture defines the texture to use as environment texture
  49949. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49950. * @param scale defines the overall scale of the skybox
  49951. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49952. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49953. * @returns a new mesh holding the sky box
  49954. */
  49955. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49956. /**
  49957. * Creates a new environment
  49958. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49959. * @param options defines the options you can use to configure the environment
  49960. * @returns the new EnvironmentHelper
  49961. */
  49962. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49963. /**
  49964. * Creates a new VREXperienceHelper
  49965. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49966. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49967. * @returns a new VREXperienceHelper
  49968. */
  49969. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49970. /**
  49971. * Creates a new WebXRDefaultExperience
  49972. * @see http://doc.babylonjs.com/how_to/webxr
  49973. * @param options experience options
  49974. * @returns a promise for a new WebXRDefaultExperience
  49975. */
  49976. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49977. }
  49978. }
  49979. declare module BABYLON {
  49980. /**
  49981. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49982. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49983. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49984. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49985. */
  49986. export class VideoDome extends TransformNode {
  49987. /**
  49988. * Define the video source as a Monoscopic panoramic 360 video.
  49989. */
  49990. static readonly MODE_MONOSCOPIC: number;
  49991. /**
  49992. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49993. */
  49994. static readonly MODE_TOPBOTTOM: number;
  49995. /**
  49996. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49997. */
  49998. static readonly MODE_SIDEBYSIDE: number;
  49999. private _halfDome;
  50000. private _useDirectMapping;
  50001. /**
  50002. * The video texture being displayed on the sphere
  50003. */
  50004. protected _videoTexture: VideoTexture;
  50005. /**
  50006. * Gets the video texture being displayed on the sphere
  50007. */
  50008. readonly videoTexture: VideoTexture;
  50009. /**
  50010. * The skybox material
  50011. */
  50012. protected _material: BackgroundMaterial;
  50013. /**
  50014. * The surface used for the skybox
  50015. */
  50016. protected _mesh: Mesh;
  50017. /**
  50018. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50019. */
  50020. private _halfDomeMask;
  50021. /**
  50022. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50023. * Also see the options.resolution property.
  50024. */
  50025. fovMultiplier: number;
  50026. private _videoMode;
  50027. /**
  50028. * Gets or set the current video mode for the video. It can be:
  50029. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50030. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50031. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50032. */
  50033. videoMode: number;
  50034. /**
  50035. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50036. *
  50037. */
  50038. /**
  50039. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50040. */
  50041. halfDome: boolean;
  50042. /**
  50043. * Oberserver used in Stereoscopic VR Mode.
  50044. */
  50045. private _onBeforeCameraRenderObserver;
  50046. /**
  50047. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50048. * @param name Element's name, child elements will append suffixes for their own names.
  50049. * @param urlsOrVideo defines the url(s) or the video element to use
  50050. * @param options An object containing optional or exposed sub element properties
  50051. */
  50052. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50053. resolution?: number;
  50054. clickToPlay?: boolean;
  50055. autoPlay?: boolean;
  50056. loop?: boolean;
  50057. size?: number;
  50058. poster?: string;
  50059. faceForward?: boolean;
  50060. useDirectMapping?: boolean;
  50061. halfDomeMode?: boolean;
  50062. }, scene: Scene);
  50063. private _changeVideoMode;
  50064. /**
  50065. * Releases resources associated with this node.
  50066. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50067. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50068. */
  50069. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50070. }
  50071. }
  50072. declare module BABYLON {
  50073. /**
  50074. * This class can be used to get instrumentation data from a Babylon engine
  50075. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50076. */
  50077. export class EngineInstrumentation implements IDisposable {
  50078. /**
  50079. * Define the instrumented engine.
  50080. */
  50081. engine: Engine;
  50082. private _captureGPUFrameTime;
  50083. private _gpuFrameTimeToken;
  50084. private _gpuFrameTime;
  50085. private _captureShaderCompilationTime;
  50086. private _shaderCompilationTime;
  50087. private _onBeginFrameObserver;
  50088. private _onEndFrameObserver;
  50089. private _onBeforeShaderCompilationObserver;
  50090. private _onAfterShaderCompilationObserver;
  50091. /**
  50092. * Gets the perf counter used for GPU frame time
  50093. */
  50094. readonly gpuFrameTimeCounter: PerfCounter;
  50095. /**
  50096. * Gets the GPU frame time capture status
  50097. */
  50098. /**
  50099. * Enable or disable the GPU frame time capture
  50100. */
  50101. captureGPUFrameTime: boolean;
  50102. /**
  50103. * Gets the perf counter used for shader compilation time
  50104. */
  50105. readonly shaderCompilationTimeCounter: PerfCounter;
  50106. /**
  50107. * Gets the shader compilation time capture status
  50108. */
  50109. /**
  50110. * Enable or disable the shader compilation time capture
  50111. */
  50112. captureShaderCompilationTime: boolean;
  50113. /**
  50114. * Instantiates a new engine instrumentation.
  50115. * This class can be used to get instrumentation data from a Babylon engine
  50116. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50117. * @param engine Defines the engine to instrument
  50118. */
  50119. constructor(
  50120. /**
  50121. * Define the instrumented engine.
  50122. */
  50123. engine: Engine);
  50124. /**
  50125. * Dispose and release associated resources.
  50126. */
  50127. dispose(): void;
  50128. }
  50129. }
  50130. declare module BABYLON {
  50131. /**
  50132. * This class can be used to get instrumentation data from a Babylon engine
  50133. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50134. */
  50135. export class SceneInstrumentation implements IDisposable {
  50136. /**
  50137. * Defines the scene to instrument
  50138. */
  50139. scene: Scene;
  50140. private _captureActiveMeshesEvaluationTime;
  50141. private _activeMeshesEvaluationTime;
  50142. private _captureRenderTargetsRenderTime;
  50143. private _renderTargetsRenderTime;
  50144. private _captureFrameTime;
  50145. private _frameTime;
  50146. private _captureRenderTime;
  50147. private _renderTime;
  50148. private _captureInterFrameTime;
  50149. private _interFrameTime;
  50150. private _captureParticlesRenderTime;
  50151. private _particlesRenderTime;
  50152. private _captureSpritesRenderTime;
  50153. private _spritesRenderTime;
  50154. private _capturePhysicsTime;
  50155. private _physicsTime;
  50156. private _captureAnimationsTime;
  50157. private _animationsTime;
  50158. private _captureCameraRenderTime;
  50159. private _cameraRenderTime;
  50160. private _onBeforeActiveMeshesEvaluationObserver;
  50161. private _onAfterActiveMeshesEvaluationObserver;
  50162. private _onBeforeRenderTargetsRenderObserver;
  50163. private _onAfterRenderTargetsRenderObserver;
  50164. private _onAfterRenderObserver;
  50165. private _onBeforeDrawPhaseObserver;
  50166. private _onAfterDrawPhaseObserver;
  50167. private _onBeforeAnimationsObserver;
  50168. private _onBeforeParticlesRenderingObserver;
  50169. private _onAfterParticlesRenderingObserver;
  50170. private _onBeforeSpritesRenderingObserver;
  50171. private _onAfterSpritesRenderingObserver;
  50172. private _onBeforePhysicsObserver;
  50173. private _onAfterPhysicsObserver;
  50174. private _onAfterAnimationsObserver;
  50175. private _onBeforeCameraRenderObserver;
  50176. private _onAfterCameraRenderObserver;
  50177. /**
  50178. * Gets the perf counter used for active meshes evaluation time
  50179. */
  50180. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50181. /**
  50182. * Gets the active meshes evaluation time capture status
  50183. */
  50184. /**
  50185. * Enable or disable the active meshes evaluation time capture
  50186. */
  50187. captureActiveMeshesEvaluationTime: boolean;
  50188. /**
  50189. * Gets the perf counter used for render targets render time
  50190. */
  50191. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50192. /**
  50193. * Gets the render targets render time capture status
  50194. */
  50195. /**
  50196. * Enable or disable the render targets render time capture
  50197. */
  50198. captureRenderTargetsRenderTime: boolean;
  50199. /**
  50200. * Gets the perf counter used for particles render time
  50201. */
  50202. readonly particlesRenderTimeCounter: PerfCounter;
  50203. /**
  50204. * Gets the particles render time capture status
  50205. */
  50206. /**
  50207. * Enable or disable the particles render time capture
  50208. */
  50209. captureParticlesRenderTime: boolean;
  50210. /**
  50211. * Gets the perf counter used for sprites render time
  50212. */
  50213. readonly spritesRenderTimeCounter: PerfCounter;
  50214. /**
  50215. * Gets the sprites render time capture status
  50216. */
  50217. /**
  50218. * Enable or disable the sprites render time capture
  50219. */
  50220. captureSpritesRenderTime: boolean;
  50221. /**
  50222. * Gets the perf counter used for physics time
  50223. */
  50224. readonly physicsTimeCounter: PerfCounter;
  50225. /**
  50226. * Gets the physics time capture status
  50227. */
  50228. /**
  50229. * Enable or disable the physics time capture
  50230. */
  50231. capturePhysicsTime: boolean;
  50232. /**
  50233. * Gets the perf counter used for animations time
  50234. */
  50235. readonly animationsTimeCounter: PerfCounter;
  50236. /**
  50237. * Gets the animations time capture status
  50238. */
  50239. /**
  50240. * Enable or disable the animations time capture
  50241. */
  50242. captureAnimationsTime: boolean;
  50243. /**
  50244. * Gets the perf counter used for frame time capture
  50245. */
  50246. readonly frameTimeCounter: PerfCounter;
  50247. /**
  50248. * Gets the frame time capture status
  50249. */
  50250. /**
  50251. * Enable or disable the frame time capture
  50252. */
  50253. captureFrameTime: boolean;
  50254. /**
  50255. * Gets the perf counter used for inter-frames time capture
  50256. */
  50257. readonly interFrameTimeCounter: PerfCounter;
  50258. /**
  50259. * Gets the inter-frames time capture status
  50260. */
  50261. /**
  50262. * Enable or disable the inter-frames time capture
  50263. */
  50264. captureInterFrameTime: boolean;
  50265. /**
  50266. * Gets the perf counter used for render time capture
  50267. */
  50268. readonly renderTimeCounter: PerfCounter;
  50269. /**
  50270. * Gets the render time capture status
  50271. */
  50272. /**
  50273. * Enable or disable the render time capture
  50274. */
  50275. captureRenderTime: boolean;
  50276. /**
  50277. * Gets the perf counter used for camera render time capture
  50278. */
  50279. readonly cameraRenderTimeCounter: PerfCounter;
  50280. /**
  50281. * Gets the camera render time capture status
  50282. */
  50283. /**
  50284. * Enable or disable the camera render time capture
  50285. */
  50286. captureCameraRenderTime: boolean;
  50287. /**
  50288. * Gets the perf counter used for draw calls
  50289. */
  50290. readonly drawCallsCounter: PerfCounter;
  50291. /**
  50292. * Instantiates a new scene instrumentation.
  50293. * This class can be used to get instrumentation data from a Babylon engine
  50294. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50295. * @param scene Defines the scene to instrument
  50296. */
  50297. constructor(
  50298. /**
  50299. * Defines the scene to instrument
  50300. */
  50301. scene: Scene);
  50302. /**
  50303. * Dispose and release associated resources.
  50304. */
  50305. dispose(): void;
  50306. }
  50307. }
  50308. declare module BABYLON {
  50309. /** @hidden */
  50310. export var glowMapGenerationPixelShader: {
  50311. name: string;
  50312. shader: string;
  50313. };
  50314. }
  50315. declare module BABYLON {
  50316. /** @hidden */
  50317. export var glowMapGenerationVertexShader: {
  50318. name: string;
  50319. shader: string;
  50320. };
  50321. }
  50322. declare module BABYLON {
  50323. /**
  50324. * Effect layer options. This helps customizing the behaviour
  50325. * of the effect layer.
  50326. */
  50327. export interface IEffectLayerOptions {
  50328. /**
  50329. * Multiplication factor apply to the canvas size to compute the render target size
  50330. * used to generated the objects (the smaller the faster).
  50331. */
  50332. mainTextureRatio: number;
  50333. /**
  50334. * Enforces a fixed size texture to ensure effect stability across devices.
  50335. */
  50336. mainTextureFixedSize?: number;
  50337. /**
  50338. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50339. */
  50340. alphaBlendingMode: number;
  50341. /**
  50342. * The camera attached to the layer.
  50343. */
  50344. camera: Nullable<Camera>;
  50345. /**
  50346. * The rendering group to draw the layer in.
  50347. */
  50348. renderingGroupId: number;
  50349. }
  50350. /**
  50351. * The effect layer Helps adding post process effect blended with the main pass.
  50352. *
  50353. * This can be for instance use to generate glow or higlight effects on the scene.
  50354. *
  50355. * The effect layer class can not be used directly and is intented to inherited from to be
  50356. * customized per effects.
  50357. */
  50358. export abstract class EffectLayer {
  50359. private _vertexBuffers;
  50360. private _indexBuffer;
  50361. private _cachedDefines;
  50362. private _effectLayerMapGenerationEffect;
  50363. private _effectLayerOptions;
  50364. private _mergeEffect;
  50365. protected _scene: Scene;
  50366. protected _engine: Engine;
  50367. protected _maxSize: number;
  50368. protected _mainTextureDesiredSize: ISize;
  50369. protected _mainTexture: RenderTargetTexture;
  50370. protected _shouldRender: boolean;
  50371. protected _postProcesses: PostProcess[];
  50372. protected _textures: BaseTexture[];
  50373. protected _emissiveTextureAndColor: {
  50374. texture: Nullable<BaseTexture>;
  50375. color: Color4;
  50376. };
  50377. /**
  50378. * The name of the layer
  50379. */
  50380. name: string;
  50381. /**
  50382. * The clear color of the texture used to generate the glow map.
  50383. */
  50384. neutralColor: Color4;
  50385. /**
  50386. * Specifies wether the highlight layer is enabled or not.
  50387. */
  50388. isEnabled: boolean;
  50389. /**
  50390. * Gets the camera attached to the layer.
  50391. */
  50392. readonly camera: Nullable<Camera>;
  50393. /**
  50394. * Gets the rendering group id the layer should render in.
  50395. */
  50396. renderingGroupId: number;
  50397. /**
  50398. * An event triggered when the effect layer has been disposed.
  50399. */
  50400. onDisposeObservable: Observable<EffectLayer>;
  50401. /**
  50402. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50403. */
  50404. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50405. /**
  50406. * An event triggered when the generated texture is being merged in the scene.
  50407. */
  50408. onBeforeComposeObservable: Observable<EffectLayer>;
  50409. /**
  50410. * An event triggered when the mesh is rendered into the effect render target.
  50411. */
  50412. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  50413. /**
  50414. * An event triggered after the mesh has been rendered into the effect render target.
  50415. */
  50416. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  50417. /**
  50418. * An event triggered when the generated texture has been merged in the scene.
  50419. */
  50420. onAfterComposeObservable: Observable<EffectLayer>;
  50421. /**
  50422. * An event triggered when the efffect layer changes its size.
  50423. */
  50424. onSizeChangedObservable: Observable<EffectLayer>;
  50425. /** @hidden */
  50426. static _SceneComponentInitialization: (scene: Scene) => void;
  50427. /**
  50428. * Instantiates a new effect Layer and references it in the scene.
  50429. * @param name The name of the layer
  50430. * @param scene The scene to use the layer in
  50431. */
  50432. constructor(
  50433. /** The Friendly of the effect in the scene */
  50434. name: string, scene: Scene);
  50435. /**
  50436. * Get the effect name of the layer.
  50437. * @return The effect name
  50438. */
  50439. abstract getEffectName(): string;
  50440. /**
  50441. * Checks for the readiness of the element composing the layer.
  50442. * @param subMesh the mesh to check for
  50443. * @param useInstances specify wether or not to use instances to render the mesh
  50444. * @return true if ready otherwise, false
  50445. */
  50446. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50447. /**
  50448. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50449. * @returns true if the effect requires stencil during the main canvas render pass.
  50450. */
  50451. abstract needStencil(): boolean;
  50452. /**
  50453. * Create the merge effect. This is the shader use to blit the information back
  50454. * to the main canvas at the end of the scene rendering.
  50455. * @returns The effect containing the shader used to merge the effect on the main canvas
  50456. */
  50457. protected abstract _createMergeEffect(): Effect;
  50458. /**
  50459. * Creates the render target textures and post processes used in the effect layer.
  50460. */
  50461. protected abstract _createTextureAndPostProcesses(): void;
  50462. /**
  50463. * Implementation specific of rendering the generating effect on the main canvas.
  50464. * @param effect The effect used to render through
  50465. */
  50466. protected abstract _internalRender(effect: Effect): void;
  50467. /**
  50468. * Sets the required values for both the emissive texture and and the main color.
  50469. */
  50470. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50471. /**
  50472. * Free any resources and references associated to a mesh.
  50473. * Internal use
  50474. * @param mesh The mesh to free.
  50475. */
  50476. abstract _disposeMesh(mesh: Mesh): void;
  50477. /**
  50478. * Serializes this layer (Glow or Highlight for example)
  50479. * @returns a serialized layer object
  50480. */
  50481. abstract serialize?(): any;
  50482. /**
  50483. * Initializes the effect layer with the required options.
  50484. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50485. */
  50486. protected _init(options: Partial<IEffectLayerOptions>): void;
  50487. /**
  50488. * Generates the index buffer of the full screen quad blending to the main canvas.
  50489. */
  50490. private _generateIndexBuffer;
  50491. /**
  50492. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50493. */
  50494. private _generateVertexBuffer;
  50495. /**
  50496. * Sets the main texture desired size which is the closest power of two
  50497. * of the engine canvas size.
  50498. */
  50499. private _setMainTextureSize;
  50500. /**
  50501. * Creates the main texture for the effect layer.
  50502. */
  50503. protected _createMainTexture(): void;
  50504. /**
  50505. * Adds specific effects defines.
  50506. * @param defines The defines to add specifics to.
  50507. */
  50508. protected _addCustomEffectDefines(defines: string[]): void;
  50509. /**
  50510. * Checks for the readiness of the element composing the layer.
  50511. * @param subMesh the mesh to check for
  50512. * @param useInstances specify wether or not to use instances to render the mesh
  50513. * @param emissiveTexture the associated emissive texture used to generate the glow
  50514. * @return true if ready otherwise, false
  50515. */
  50516. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  50517. /**
  50518. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  50519. */
  50520. render(): void;
  50521. /**
  50522. * Determine if a given mesh will be used in the current effect.
  50523. * @param mesh mesh to test
  50524. * @returns true if the mesh will be used
  50525. */
  50526. hasMesh(mesh: AbstractMesh): boolean;
  50527. /**
  50528. * Returns true if the layer contains information to display, otherwise false.
  50529. * @returns true if the glow layer should be rendered
  50530. */
  50531. shouldRender(): boolean;
  50532. /**
  50533. * Returns true if the mesh should render, otherwise false.
  50534. * @param mesh The mesh to render
  50535. * @returns true if it should render otherwise false
  50536. */
  50537. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  50538. /**
  50539. * Returns true if the mesh can be rendered, otherwise false.
  50540. * @param mesh The mesh to render
  50541. * @param material The material used on the mesh
  50542. * @returns true if it can be rendered otherwise false
  50543. */
  50544. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50545. /**
  50546. * Returns true if the mesh should render, otherwise false.
  50547. * @param mesh The mesh to render
  50548. * @returns true if it should render otherwise false
  50549. */
  50550. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  50551. /**
  50552. * Renders the submesh passed in parameter to the generation map.
  50553. */
  50554. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  50555. /**
  50556. * Defines wether the current material of the mesh should be use to render the effect.
  50557. * @param mesh defines the current mesh to render
  50558. */
  50559. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  50560. /**
  50561. * Rebuild the required buffers.
  50562. * @hidden Internal use only.
  50563. */
  50564. _rebuild(): void;
  50565. /**
  50566. * Dispose only the render target textures and post process.
  50567. */
  50568. private _disposeTextureAndPostProcesses;
  50569. /**
  50570. * Dispose the highlight layer and free resources.
  50571. */
  50572. dispose(): void;
  50573. /**
  50574. * Gets the class name of the effect layer
  50575. * @returns the string with the class name of the effect layer
  50576. */
  50577. getClassName(): string;
  50578. /**
  50579. * Creates an effect layer from parsed effect layer data
  50580. * @param parsedEffectLayer defines effect layer data
  50581. * @param scene defines the current scene
  50582. * @param rootUrl defines the root URL containing the effect layer information
  50583. * @returns a parsed effect Layer
  50584. */
  50585. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  50586. }
  50587. }
  50588. declare module BABYLON {
  50589. interface AbstractScene {
  50590. /**
  50591. * The list of effect layers (highlights/glow) added to the scene
  50592. * @see http://doc.babylonjs.com/how_to/highlight_layer
  50593. * @see http://doc.babylonjs.com/how_to/glow_layer
  50594. */
  50595. effectLayers: Array<EffectLayer>;
  50596. /**
  50597. * Removes the given effect layer from this scene.
  50598. * @param toRemove defines the effect layer to remove
  50599. * @returns the index of the removed effect layer
  50600. */
  50601. removeEffectLayer(toRemove: EffectLayer): number;
  50602. /**
  50603. * Adds the given effect layer to this scene
  50604. * @param newEffectLayer defines the effect layer to add
  50605. */
  50606. addEffectLayer(newEffectLayer: EffectLayer): void;
  50607. }
  50608. /**
  50609. * Defines the layer scene component responsible to manage any effect layers
  50610. * in a given scene.
  50611. */
  50612. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  50613. /**
  50614. * The component name helpfull to identify the component in the list of scene components.
  50615. */
  50616. readonly name: string;
  50617. /**
  50618. * The scene the component belongs to.
  50619. */
  50620. scene: Scene;
  50621. private _engine;
  50622. private _renderEffects;
  50623. private _needStencil;
  50624. private _previousStencilState;
  50625. /**
  50626. * Creates a new instance of the component for the given scene
  50627. * @param scene Defines the scene to register the component in
  50628. */
  50629. constructor(scene: Scene);
  50630. /**
  50631. * Registers the component in a given scene
  50632. */
  50633. register(): void;
  50634. /**
  50635. * Rebuilds the elements related to this component in case of
  50636. * context lost for instance.
  50637. */
  50638. rebuild(): void;
  50639. /**
  50640. * Serializes the component data to the specified json object
  50641. * @param serializationObject The object to serialize to
  50642. */
  50643. serialize(serializationObject: any): void;
  50644. /**
  50645. * Adds all the elements from the container to the scene
  50646. * @param container the container holding the elements
  50647. */
  50648. addFromContainer(container: AbstractScene): void;
  50649. /**
  50650. * Removes all the elements in the container from the scene
  50651. * @param container contains the elements to remove
  50652. * @param dispose if the removed element should be disposed (default: false)
  50653. */
  50654. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50655. /**
  50656. * Disposes the component and the associated ressources.
  50657. */
  50658. dispose(): void;
  50659. private _isReadyForMesh;
  50660. private _renderMainTexture;
  50661. private _setStencil;
  50662. private _setStencilBack;
  50663. private _draw;
  50664. private _drawCamera;
  50665. private _drawRenderingGroup;
  50666. }
  50667. }
  50668. declare module BABYLON {
  50669. /** @hidden */
  50670. export var glowMapMergePixelShader: {
  50671. name: string;
  50672. shader: string;
  50673. };
  50674. }
  50675. declare module BABYLON {
  50676. /** @hidden */
  50677. export var glowMapMergeVertexShader: {
  50678. name: string;
  50679. shader: string;
  50680. };
  50681. }
  50682. declare module BABYLON {
  50683. interface AbstractScene {
  50684. /**
  50685. * Return a the first highlight layer of the scene with a given name.
  50686. * @param name The name of the highlight layer to look for.
  50687. * @return The highlight layer if found otherwise null.
  50688. */
  50689. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50690. }
  50691. /**
  50692. * Glow layer options. This helps customizing the behaviour
  50693. * of the glow layer.
  50694. */
  50695. export interface IGlowLayerOptions {
  50696. /**
  50697. * Multiplication factor apply to the canvas size to compute the render target size
  50698. * used to generated the glowing objects (the smaller the faster).
  50699. */
  50700. mainTextureRatio: number;
  50701. /**
  50702. * Enforces a fixed size texture to ensure resize independant blur.
  50703. */
  50704. mainTextureFixedSize?: number;
  50705. /**
  50706. * How big is the kernel of the blur texture.
  50707. */
  50708. blurKernelSize: number;
  50709. /**
  50710. * The camera attached to the layer.
  50711. */
  50712. camera: Nullable<Camera>;
  50713. /**
  50714. * Enable MSAA by chosing the number of samples.
  50715. */
  50716. mainTextureSamples?: number;
  50717. /**
  50718. * The rendering group to draw the layer in.
  50719. */
  50720. renderingGroupId: number;
  50721. }
  50722. /**
  50723. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50724. *
  50725. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  50726. *
  50727. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50728. */
  50729. export class GlowLayer extends EffectLayer {
  50730. /**
  50731. * Effect Name of the layer.
  50732. */
  50733. static readonly EffectName: string;
  50734. /**
  50735. * The default blur kernel size used for the glow.
  50736. */
  50737. static DefaultBlurKernelSize: number;
  50738. /**
  50739. * The default texture size ratio used for the glow.
  50740. */
  50741. static DefaultTextureRatio: number;
  50742. /**
  50743. * Sets the kernel size of the blur.
  50744. */
  50745. /**
  50746. * Gets the kernel size of the blur.
  50747. */
  50748. blurKernelSize: number;
  50749. /**
  50750. * Sets the glow intensity.
  50751. */
  50752. /**
  50753. * Gets the glow intensity.
  50754. */
  50755. intensity: number;
  50756. private _options;
  50757. private _intensity;
  50758. private _horizontalBlurPostprocess1;
  50759. private _verticalBlurPostprocess1;
  50760. private _horizontalBlurPostprocess2;
  50761. private _verticalBlurPostprocess2;
  50762. private _blurTexture1;
  50763. private _blurTexture2;
  50764. private _postProcesses1;
  50765. private _postProcesses2;
  50766. private _includedOnlyMeshes;
  50767. private _excludedMeshes;
  50768. private _meshesUsingTheirOwnMaterials;
  50769. /**
  50770. * Callback used to let the user override the color selection on a per mesh basis
  50771. */
  50772. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50773. /**
  50774. * Callback used to let the user override the texture selection on a per mesh basis
  50775. */
  50776. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50777. /**
  50778. * Instantiates a new glow Layer and references it to the scene.
  50779. * @param name The name of the layer
  50780. * @param scene The scene to use the layer in
  50781. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50782. */
  50783. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50784. /**
  50785. * Get the effect name of the layer.
  50786. * @return The effect name
  50787. */
  50788. getEffectName(): string;
  50789. /**
  50790. * Create the merge effect. This is the shader use to blit the information back
  50791. * to the main canvas at the end of the scene rendering.
  50792. */
  50793. protected _createMergeEffect(): Effect;
  50794. /**
  50795. * Creates the render target textures and post processes used in the glow layer.
  50796. */
  50797. protected _createTextureAndPostProcesses(): void;
  50798. /**
  50799. * Checks for the readiness of the element composing the layer.
  50800. * @param subMesh the mesh to check for
  50801. * @param useInstances specify wether or not to use instances to render the mesh
  50802. * @param emissiveTexture the associated emissive texture used to generate the glow
  50803. * @return true if ready otherwise, false
  50804. */
  50805. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50806. /**
  50807. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50808. */
  50809. needStencil(): boolean;
  50810. /**
  50811. * Returns true if the mesh can be rendered, otherwise false.
  50812. * @param mesh The mesh to render
  50813. * @param material The material used on the mesh
  50814. * @returns true if it can be rendered otherwise false
  50815. */
  50816. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50817. /**
  50818. * Implementation specific of rendering the generating effect on the main canvas.
  50819. * @param effect The effect used to render through
  50820. */
  50821. protected _internalRender(effect: Effect): void;
  50822. /**
  50823. * Sets the required values for both the emissive texture and and the main color.
  50824. */
  50825. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50826. /**
  50827. * Returns true if the mesh should render, otherwise false.
  50828. * @param mesh The mesh to render
  50829. * @returns true if it should render otherwise false
  50830. */
  50831. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50832. /**
  50833. * Adds specific effects defines.
  50834. * @param defines The defines to add specifics to.
  50835. */
  50836. protected _addCustomEffectDefines(defines: string[]): void;
  50837. /**
  50838. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  50839. * @param mesh The mesh to exclude from the glow layer
  50840. */
  50841. addExcludedMesh(mesh: Mesh): void;
  50842. /**
  50843. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  50844. * @param mesh The mesh to remove
  50845. */
  50846. removeExcludedMesh(mesh: Mesh): void;
  50847. /**
  50848. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  50849. * @param mesh The mesh to include in the glow layer
  50850. */
  50851. addIncludedOnlyMesh(mesh: Mesh): void;
  50852. /**
  50853. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  50854. * @param mesh The mesh to remove
  50855. */
  50856. removeIncludedOnlyMesh(mesh: Mesh): void;
  50857. /**
  50858. * Determine if a given mesh will be used in the glow layer
  50859. * @param mesh The mesh to test
  50860. * @returns true if the mesh will be highlighted by the current glow layer
  50861. */
  50862. hasMesh(mesh: AbstractMesh): boolean;
  50863. /**
  50864. * Defines wether the current material of the mesh should be use to render the effect.
  50865. * @param mesh defines the current mesh to render
  50866. */
  50867. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  50868. /**
  50869. * Add a mesh to be rendered through its own material and not with emissive only.
  50870. * @param mesh The mesh for which we need to use its material
  50871. */
  50872. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  50873. /**
  50874. * Remove a mesh from being rendered through its own material and not with emissive only.
  50875. * @param mesh The mesh for which we need to not use its material
  50876. */
  50877. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  50878. /**
  50879. * Free any resources and references associated to a mesh.
  50880. * Internal use
  50881. * @param mesh The mesh to free.
  50882. * @hidden
  50883. */
  50884. _disposeMesh(mesh: Mesh): void;
  50885. /**
  50886. * Gets the class name of the effect layer
  50887. * @returns the string with the class name of the effect layer
  50888. */
  50889. getClassName(): string;
  50890. /**
  50891. * Serializes this glow layer
  50892. * @returns a serialized glow layer object
  50893. */
  50894. serialize(): any;
  50895. /**
  50896. * Creates a Glow Layer from parsed glow layer data
  50897. * @param parsedGlowLayer defines glow layer data
  50898. * @param scene defines the current scene
  50899. * @param rootUrl defines the root URL containing the glow layer information
  50900. * @returns a parsed Glow Layer
  50901. */
  50902. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50903. }
  50904. }
  50905. declare module BABYLON {
  50906. /** @hidden */
  50907. export var glowBlurPostProcessPixelShader: {
  50908. name: string;
  50909. shader: string;
  50910. };
  50911. }
  50912. declare module BABYLON {
  50913. interface AbstractScene {
  50914. /**
  50915. * Return a the first highlight layer of the scene with a given name.
  50916. * @param name The name of the highlight layer to look for.
  50917. * @return The highlight layer if found otherwise null.
  50918. */
  50919. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50920. }
  50921. /**
  50922. * Highlight layer options. This helps customizing the behaviour
  50923. * of the highlight layer.
  50924. */
  50925. export interface IHighlightLayerOptions {
  50926. /**
  50927. * Multiplication factor apply to the canvas size to compute the render target size
  50928. * used to generated the glowing objects (the smaller the faster).
  50929. */
  50930. mainTextureRatio: number;
  50931. /**
  50932. * Enforces a fixed size texture to ensure resize independant blur.
  50933. */
  50934. mainTextureFixedSize?: number;
  50935. /**
  50936. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50937. * of the picture to blur (the smaller the faster).
  50938. */
  50939. blurTextureSizeRatio: number;
  50940. /**
  50941. * How big in texel of the blur texture is the vertical blur.
  50942. */
  50943. blurVerticalSize: number;
  50944. /**
  50945. * How big in texel of the blur texture is the horizontal blur.
  50946. */
  50947. blurHorizontalSize: number;
  50948. /**
  50949. * Alpha blending mode used to apply the blur. Default is combine.
  50950. */
  50951. alphaBlendingMode: number;
  50952. /**
  50953. * The camera attached to the layer.
  50954. */
  50955. camera: Nullable<Camera>;
  50956. /**
  50957. * Should we display highlight as a solid stroke?
  50958. */
  50959. isStroke?: boolean;
  50960. /**
  50961. * The rendering group to draw the layer in.
  50962. */
  50963. renderingGroupId: number;
  50964. }
  50965. /**
  50966. * The highlight layer Helps adding a glow effect around a mesh.
  50967. *
  50968. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  50969. * glowy meshes to your scene.
  50970. *
  50971. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50972. */
  50973. export class HighlightLayer extends EffectLayer {
  50974. name: string;
  50975. /**
  50976. * Effect Name of the highlight layer.
  50977. */
  50978. static readonly EffectName: string;
  50979. /**
  50980. * The neutral color used during the preparation of the glow effect.
  50981. * This is black by default as the blend operation is a blend operation.
  50982. */
  50983. static NeutralColor: Color4;
  50984. /**
  50985. * Stencil value used for glowing meshes.
  50986. */
  50987. static GlowingMeshStencilReference: number;
  50988. /**
  50989. * Stencil value used for the other meshes in the scene.
  50990. */
  50991. static NormalMeshStencilReference: number;
  50992. /**
  50993. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50994. */
  50995. innerGlow: boolean;
  50996. /**
  50997. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50998. */
  50999. outerGlow: boolean;
  51000. /**
  51001. * Specifies the horizontal size of the blur.
  51002. */
  51003. /**
  51004. * Gets the horizontal size of the blur.
  51005. */
  51006. blurHorizontalSize: number;
  51007. /**
  51008. * Specifies the vertical size of the blur.
  51009. */
  51010. /**
  51011. * Gets the vertical size of the blur.
  51012. */
  51013. blurVerticalSize: number;
  51014. /**
  51015. * An event triggered when the highlight layer is being blurred.
  51016. */
  51017. onBeforeBlurObservable: Observable<HighlightLayer>;
  51018. /**
  51019. * An event triggered when the highlight layer has been blurred.
  51020. */
  51021. onAfterBlurObservable: Observable<HighlightLayer>;
  51022. private _instanceGlowingMeshStencilReference;
  51023. private _options;
  51024. private _downSamplePostprocess;
  51025. private _horizontalBlurPostprocess;
  51026. private _verticalBlurPostprocess;
  51027. private _blurTexture;
  51028. private _meshes;
  51029. private _excludedMeshes;
  51030. /**
  51031. * Instantiates a new highlight Layer and references it to the scene..
  51032. * @param name The name of the layer
  51033. * @param scene The scene to use the layer in
  51034. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51035. */
  51036. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51037. /**
  51038. * Get the effect name of the layer.
  51039. * @return The effect name
  51040. */
  51041. getEffectName(): string;
  51042. /**
  51043. * Create the merge effect. This is the shader use to blit the information back
  51044. * to the main canvas at the end of the scene rendering.
  51045. */
  51046. protected _createMergeEffect(): Effect;
  51047. /**
  51048. * Creates the render target textures and post processes used in the highlight layer.
  51049. */
  51050. protected _createTextureAndPostProcesses(): void;
  51051. /**
  51052. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51053. */
  51054. needStencil(): boolean;
  51055. /**
  51056. * Checks for the readiness of the element composing the layer.
  51057. * @param subMesh the mesh to check for
  51058. * @param useInstances specify wether or not to use instances to render the mesh
  51059. * @param emissiveTexture the associated emissive texture used to generate the glow
  51060. * @return true if ready otherwise, false
  51061. */
  51062. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51063. /**
  51064. * Implementation specific of rendering the generating effect on the main canvas.
  51065. * @param effect The effect used to render through
  51066. */
  51067. protected _internalRender(effect: Effect): void;
  51068. /**
  51069. * Returns true if the layer contains information to display, otherwise false.
  51070. */
  51071. shouldRender(): boolean;
  51072. /**
  51073. * Returns true if the mesh should render, otherwise false.
  51074. * @param mesh The mesh to render
  51075. * @returns true if it should render otherwise false
  51076. */
  51077. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51078. /**
  51079. * Sets the required values for both the emissive texture and and the main color.
  51080. */
  51081. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51082. /**
  51083. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51084. * @param mesh The mesh to exclude from the highlight layer
  51085. */
  51086. addExcludedMesh(mesh: Mesh): void;
  51087. /**
  51088. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51089. * @param mesh The mesh to highlight
  51090. */
  51091. removeExcludedMesh(mesh: Mesh): void;
  51092. /**
  51093. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51094. * @param mesh mesh to test
  51095. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51096. */
  51097. hasMesh(mesh: AbstractMesh): boolean;
  51098. /**
  51099. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51100. * @param mesh The mesh to highlight
  51101. * @param color The color of the highlight
  51102. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51103. */
  51104. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51105. /**
  51106. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51107. * @param mesh The mesh to highlight
  51108. */
  51109. removeMesh(mesh: Mesh): void;
  51110. /**
  51111. * Force the stencil to the normal expected value for none glowing parts
  51112. */
  51113. private _defaultStencilReference;
  51114. /**
  51115. * Free any resources and references associated to a mesh.
  51116. * Internal use
  51117. * @param mesh The mesh to free.
  51118. * @hidden
  51119. */
  51120. _disposeMesh(mesh: Mesh): void;
  51121. /**
  51122. * Dispose the highlight layer and free resources.
  51123. */
  51124. dispose(): void;
  51125. /**
  51126. * Gets the class name of the effect layer
  51127. * @returns the string with the class name of the effect layer
  51128. */
  51129. getClassName(): string;
  51130. /**
  51131. * Serializes this Highlight layer
  51132. * @returns a serialized Highlight layer object
  51133. */
  51134. serialize(): any;
  51135. /**
  51136. * Creates a Highlight layer from parsed Highlight layer data
  51137. * @param parsedHightlightLayer defines the Highlight layer data
  51138. * @param scene defines the current scene
  51139. * @param rootUrl defines the root URL containing the Highlight layer information
  51140. * @returns a parsed Highlight layer
  51141. */
  51142. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51143. }
  51144. }
  51145. declare module BABYLON {
  51146. interface AbstractScene {
  51147. /**
  51148. * The list of layers (background and foreground) of the scene
  51149. */
  51150. layers: Array<Layer>;
  51151. }
  51152. /**
  51153. * Defines the layer scene component responsible to manage any layers
  51154. * in a given scene.
  51155. */
  51156. export class LayerSceneComponent implements ISceneComponent {
  51157. /**
  51158. * The component name helpfull to identify the component in the list of scene components.
  51159. */
  51160. readonly name: string;
  51161. /**
  51162. * The scene the component belongs to.
  51163. */
  51164. scene: Scene;
  51165. private _engine;
  51166. /**
  51167. * Creates a new instance of the component for the given scene
  51168. * @param scene Defines the scene to register the component in
  51169. */
  51170. constructor(scene: Scene);
  51171. /**
  51172. * Registers the component in a given scene
  51173. */
  51174. register(): void;
  51175. /**
  51176. * Rebuilds the elements related to this component in case of
  51177. * context lost for instance.
  51178. */
  51179. rebuild(): void;
  51180. /**
  51181. * Disposes the component and the associated ressources.
  51182. */
  51183. dispose(): void;
  51184. private _draw;
  51185. private _drawCameraPredicate;
  51186. private _drawCameraBackground;
  51187. private _drawCameraForeground;
  51188. private _drawRenderTargetPredicate;
  51189. private _drawRenderTargetBackground;
  51190. private _drawRenderTargetForeground;
  51191. /**
  51192. * Adds all the elements from the container to the scene
  51193. * @param container the container holding the elements
  51194. */
  51195. addFromContainer(container: AbstractScene): void;
  51196. /**
  51197. * Removes all the elements in the container from the scene
  51198. * @param container contains the elements to remove
  51199. * @param dispose if the removed element should be disposed (default: false)
  51200. */
  51201. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51202. }
  51203. }
  51204. declare module BABYLON {
  51205. /** @hidden */
  51206. export var layerPixelShader: {
  51207. name: string;
  51208. shader: string;
  51209. };
  51210. }
  51211. declare module BABYLON {
  51212. /** @hidden */
  51213. export var layerVertexShader: {
  51214. name: string;
  51215. shader: string;
  51216. };
  51217. }
  51218. declare module BABYLON {
  51219. /**
  51220. * This represents a full screen 2d layer.
  51221. * This can be useful to display a picture in the background of your scene for instance.
  51222. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51223. */
  51224. export class Layer {
  51225. /**
  51226. * Define the name of the layer.
  51227. */
  51228. name: string;
  51229. /**
  51230. * Define the texture the layer should display.
  51231. */
  51232. texture: Nullable<Texture>;
  51233. /**
  51234. * Is the layer in background or foreground.
  51235. */
  51236. isBackground: boolean;
  51237. /**
  51238. * Define the color of the layer (instead of texture).
  51239. */
  51240. color: Color4;
  51241. /**
  51242. * Define the scale of the layer in order to zoom in out of the texture.
  51243. */
  51244. scale: Vector2;
  51245. /**
  51246. * Define an offset for the layer in order to shift the texture.
  51247. */
  51248. offset: Vector2;
  51249. /**
  51250. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51251. */
  51252. alphaBlendingMode: number;
  51253. /**
  51254. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51255. * Alpha test will not mix with the background color in case of transparency.
  51256. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51257. */
  51258. alphaTest: boolean;
  51259. /**
  51260. * Define a mask to restrict the layer to only some of the scene cameras.
  51261. */
  51262. layerMask: number;
  51263. /**
  51264. * Define the list of render target the layer is visible into.
  51265. */
  51266. renderTargetTextures: RenderTargetTexture[];
  51267. /**
  51268. * Define if the layer is only used in renderTarget or if it also
  51269. * renders in the main frame buffer of the canvas.
  51270. */
  51271. renderOnlyInRenderTargetTextures: boolean;
  51272. private _scene;
  51273. private _vertexBuffers;
  51274. private _indexBuffer;
  51275. private _effect;
  51276. private _alphaTestEffect;
  51277. /**
  51278. * An event triggered when the layer is disposed.
  51279. */
  51280. onDisposeObservable: Observable<Layer>;
  51281. private _onDisposeObserver;
  51282. /**
  51283. * Back compatibility with callback before the onDisposeObservable existed.
  51284. * The set callback will be triggered when the layer has been disposed.
  51285. */
  51286. onDispose: () => void;
  51287. /**
  51288. * An event triggered before rendering the scene
  51289. */
  51290. onBeforeRenderObservable: Observable<Layer>;
  51291. private _onBeforeRenderObserver;
  51292. /**
  51293. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51294. * The set callback will be triggered just before rendering the layer.
  51295. */
  51296. onBeforeRender: () => void;
  51297. /**
  51298. * An event triggered after rendering the scene
  51299. */
  51300. onAfterRenderObservable: Observable<Layer>;
  51301. private _onAfterRenderObserver;
  51302. /**
  51303. * Back compatibility with callback before the onAfterRenderObservable existed.
  51304. * The set callback will be triggered just after rendering the layer.
  51305. */
  51306. onAfterRender: () => void;
  51307. /**
  51308. * Instantiates a new layer.
  51309. * This represents a full screen 2d layer.
  51310. * This can be useful to display a picture in the background of your scene for instance.
  51311. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51312. * @param name Define the name of the layer in the scene
  51313. * @param imgUrl Define the url of the texture to display in the layer
  51314. * @param scene Define the scene the layer belongs to
  51315. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51316. * @param color Defines a color for the layer
  51317. */
  51318. constructor(
  51319. /**
  51320. * Define the name of the layer.
  51321. */
  51322. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51323. private _createIndexBuffer;
  51324. /** @hidden */
  51325. _rebuild(): void;
  51326. /**
  51327. * Renders the layer in the scene.
  51328. */
  51329. render(): void;
  51330. /**
  51331. * Disposes and releases the associated ressources.
  51332. */
  51333. dispose(): void;
  51334. }
  51335. }
  51336. declare module BABYLON {
  51337. /** @hidden */
  51338. export var lensFlarePixelShader: {
  51339. name: string;
  51340. shader: string;
  51341. };
  51342. }
  51343. declare module BABYLON {
  51344. /** @hidden */
  51345. export var lensFlareVertexShader: {
  51346. name: string;
  51347. shader: string;
  51348. };
  51349. }
  51350. declare module BABYLON {
  51351. /**
  51352. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51353. * It is usually composed of several `lensFlare`.
  51354. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51355. */
  51356. export class LensFlareSystem {
  51357. /**
  51358. * Define the name of the lens flare system
  51359. */
  51360. name: string;
  51361. /**
  51362. * List of lens flares used in this system.
  51363. */
  51364. lensFlares: LensFlare[];
  51365. /**
  51366. * Define a limit from the border the lens flare can be visible.
  51367. */
  51368. borderLimit: number;
  51369. /**
  51370. * Define a viewport border we do not want to see the lens flare in.
  51371. */
  51372. viewportBorder: number;
  51373. /**
  51374. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51375. */
  51376. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51377. /**
  51378. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51379. */
  51380. layerMask: number;
  51381. /**
  51382. * Define the id of the lens flare system in the scene.
  51383. * (equal to name by default)
  51384. */
  51385. id: string;
  51386. private _scene;
  51387. private _emitter;
  51388. private _vertexBuffers;
  51389. private _indexBuffer;
  51390. private _effect;
  51391. private _positionX;
  51392. private _positionY;
  51393. private _isEnabled;
  51394. /** @hidden */
  51395. static _SceneComponentInitialization: (scene: Scene) => void;
  51396. /**
  51397. * Instantiates a lens flare system.
  51398. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51399. * It is usually composed of several `lensFlare`.
  51400. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51401. * @param name Define the name of the lens flare system in the scene
  51402. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51403. * @param scene Define the scene the lens flare system belongs to
  51404. */
  51405. constructor(
  51406. /**
  51407. * Define the name of the lens flare system
  51408. */
  51409. name: string, emitter: any, scene: Scene);
  51410. /**
  51411. * Define if the lens flare system is enabled.
  51412. */
  51413. isEnabled: boolean;
  51414. /**
  51415. * Get the scene the effects belongs to.
  51416. * @returns the scene holding the lens flare system
  51417. */
  51418. getScene(): Scene;
  51419. /**
  51420. * Get the emitter of the lens flare system.
  51421. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51422. * @returns the emitter of the lens flare system
  51423. */
  51424. getEmitter(): any;
  51425. /**
  51426. * Set the emitter of the lens flare system.
  51427. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51428. * @param newEmitter Define the new emitter of the system
  51429. */
  51430. setEmitter(newEmitter: any): void;
  51431. /**
  51432. * Get the lens flare system emitter position.
  51433. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  51434. * @returns the position
  51435. */
  51436. getEmitterPosition(): Vector3;
  51437. /**
  51438. * @hidden
  51439. */
  51440. computeEffectivePosition(globalViewport: Viewport): boolean;
  51441. /** @hidden */
  51442. _isVisible(): boolean;
  51443. /**
  51444. * @hidden
  51445. */
  51446. render(): boolean;
  51447. /**
  51448. * Dispose and release the lens flare with its associated resources.
  51449. */
  51450. dispose(): void;
  51451. /**
  51452. * Parse a lens flare system from a JSON repressentation
  51453. * @param parsedLensFlareSystem Define the JSON to parse
  51454. * @param scene Define the scene the parsed system should be instantiated in
  51455. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  51456. * @returns the parsed system
  51457. */
  51458. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  51459. /**
  51460. * Serialize the current Lens Flare System into a JSON representation.
  51461. * @returns the serialized JSON
  51462. */
  51463. serialize(): any;
  51464. }
  51465. }
  51466. declare module BABYLON {
  51467. /**
  51468. * This represents one of the lens effect in a `lensFlareSystem`.
  51469. * It controls one of the indiviual texture used in the effect.
  51470. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51471. */
  51472. export class LensFlare {
  51473. /**
  51474. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51475. */
  51476. size: number;
  51477. /**
  51478. * 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.
  51479. */
  51480. position: number;
  51481. /**
  51482. * Define the lens color.
  51483. */
  51484. color: Color3;
  51485. /**
  51486. * Define the lens texture.
  51487. */
  51488. texture: Nullable<Texture>;
  51489. /**
  51490. * Define the alpha mode to render this particular lens.
  51491. */
  51492. alphaMode: number;
  51493. private _system;
  51494. /**
  51495. * Creates a new Lens Flare.
  51496. * This represents one of the lens effect in a `lensFlareSystem`.
  51497. * It controls one of the indiviual texture used in the effect.
  51498. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51499. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  51500. * @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.
  51501. * @param color Define the lens color
  51502. * @param imgUrl Define the lens texture url
  51503. * @param system Define the `lensFlareSystem` this flare is part of
  51504. * @returns The newly created Lens Flare
  51505. */
  51506. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  51507. /**
  51508. * Instantiates a new Lens Flare.
  51509. * This represents one of the lens effect in a `lensFlareSystem`.
  51510. * It controls one of the indiviual texture used in the effect.
  51511. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51512. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  51513. * @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.
  51514. * @param color Define the lens color
  51515. * @param imgUrl Define the lens texture url
  51516. * @param system Define the `lensFlareSystem` this flare is part of
  51517. */
  51518. constructor(
  51519. /**
  51520. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51521. */
  51522. size: number,
  51523. /**
  51524. * 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.
  51525. */
  51526. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  51527. /**
  51528. * Dispose and release the lens flare with its associated resources.
  51529. */
  51530. dispose(): void;
  51531. }
  51532. }
  51533. declare module BABYLON {
  51534. interface AbstractScene {
  51535. /**
  51536. * The list of lens flare system added to the scene
  51537. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51538. */
  51539. lensFlareSystems: Array<LensFlareSystem>;
  51540. /**
  51541. * Removes the given lens flare system from this scene.
  51542. * @param toRemove The lens flare system to remove
  51543. * @returns The index of the removed lens flare system
  51544. */
  51545. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  51546. /**
  51547. * Adds the given lens flare system to this scene
  51548. * @param newLensFlareSystem The lens flare system to add
  51549. */
  51550. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  51551. /**
  51552. * Gets a lens flare system using its name
  51553. * @param name defines the name to look for
  51554. * @returns the lens flare system or null if not found
  51555. */
  51556. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  51557. /**
  51558. * Gets a lens flare system using its id
  51559. * @param id defines the id to look for
  51560. * @returns the lens flare system or null if not found
  51561. */
  51562. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  51563. }
  51564. /**
  51565. * Defines the lens flare scene component responsible to manage any lens flares
  51566. * in a given scene.
  51567. */
  51568. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  51569. /**
  51570. * The component name helpfull to identify the component in the list of scene components.
  51571. */
  51572. readonly name: string;
  51573. /**
  51574. * The scene the component belongs to.
  51575. */
  51576. scene: Scene;
  51577. /**
  51578. * Creates a new instance of the component for the given scene
  51579. * @param scene Defines the scene to register the component in
  51580. */
  51581. constructor(scene: Scene);
  51582. /**
  51583. * Registers the component in a given scene
  51584. */
  51585. register(): void;
  51586. /**
  51587. * Rebuilds the elements related to this component in case of
  51588. * context lost for instance.
  51589. */
  51590. rebuild(): void;
  51591. /**
  51592. * Adds all the elements from the container to the scene
  51593. * @param container the container holding the elements
  51594. */
  51595. addFromContainer(container: AbstractScene): void;
  51596. /**
  51597. * Removes all the elements in the container from the scene
  51598. * @param container contains the elements to remove
  51599. * @param dispose if the removed element should be disposed (default: false)
  51600. */
  51601. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51602. /**
  51603. * Serializes the component data to the specified json object
  51604. * @param serializationObject The object to serialize to
  51605. */
  51606. serialize(serializationObject: any): void;
  51607. /**
  51608. * Disposes the component and the associated ressources.
  51609. */
  51610. dispose(): void;
  51611. private _draw;
  51612. }
  51613. }
  51614. declare module BABYLON {
  51615. /**
  51616. * Defines the shadow generator component responsible to manage any shadow generators
  51617. * in a given scene.
  51618. */
  51619. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51620. /**
  51621. * The component name helpfull to identify the component in the list of scene components.
  51622. */
  51623. readonly name: string;
  51624. /**
  51625. * The scene the component belongs to.
  51626. */
  51627. scene: Scene;
  51628. /**
  51629. * Creates a new instance of the component for the given scene
  51630. * @param scene Defines the scene to register the component in
  51631. */
  51632. constructor(scene: Scene);
  51633. /**
  51634. * Registers the component in a given scene
  51635. */
  51636. register(): void;
  51637. /**
  51638. * Rebuilds the elements related to this component in case of
  51639. * context lost for instance.
  51640. */
  51641. rebuild(): void;
  51642. /**
  51643. * Serializes the component data to the specified json object
  51644. * @param serializationObject The object to serialize to
  51645. */
  51646. serialize(serializationObject: any): void;
  51647. /**
  51648. * Adds all the elements from the container to the scene
  51649. * @param container the container holding the elements
  51650. */
  51651. addFromContainer(container: AbstractScene): void;
  51652. /**
  51653. * Removes all the elements in the container from the scene
  51654. * @param container contains the elements to remove
  51655. * @param dispose if the removed element should be disposed (default: false)
  51656. */
  51657. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51658. /**
  51659. * Rebuilds the elements related to this component in case of
  51660. * context lost for instance.
  51661. */
  51662. dispose(): void;
  51663. private _gatherRenderTargets;
  51664. }
  51665. }
  51666. declare module BABYLON {
  51667. /**
  51668. * A point light is a light defined by an unique point in world space.
  51669. * The light is emitted in every direction from this point.
  51670. * A good example of a point light is a standard light bulb.
  51671. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51672. */
  51673. export class PointLight extends ShadowLight {
  51674. private _shadowAngle;
  51675. /**
  51676. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51677. * This specifies what angle the shadow will use to be created.
  51678. *
  51679. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51680. */
  51681. /**
  51682. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51683. * This specifies what angle the shadow will use to be created.
  51684. *
  51685. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51686. */
  51687. shadowAngle: number;
  51688. /**
  51689. * Gets the direction if it has been set.
  51690. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51691. */
  51692. /**
  51693. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51694. */
  51695. direction: Vector3;
  51696. /**
  51697. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51698. * A PointLight emits the light in every direction.
  51699. * It can cast shadows.
  51700. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51701. * ```javascript
  51702. * var pointLight = new PointLight("pl", camera.position, scene);
  51703. * ```
  51704. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51705. * @param name The light friendly name
  51706. * @param position The position of the point light in the scene
  51707. * @param scene The scene the lights belongs to
  51708. */
  51709. constructor(name: string, position: Vector3, scene: Scene);
  51710. /**
  51711. * Returns the string "PointLight"
  51712. * @returns the class name
  51713. */
  51714. getClassName(): string;
  51715. /**
  51716. * Returns the integer 0.
  51717. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51718. */
  51719. getTypeID(): number;
  51720. /**
  51721. * Specifies wether or not the shadowmap should be a cube texture.
  51722. * @returns true if the shadowmap needs to be a cube texture.
  51723. */
  51724. needCube(): boolean;
  51725. /**
  51726. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51727. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51728. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51729. */
  51730. getShadowDirection(faceIndex?: number): Vector3;
  51731. /**
  51732. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51733. * - fov = PI / 2
  51734. * - aspect ratio : 1.0
  51735. * - z-near and far equal to the active camera minZ and maxZ.
  51736. * Returns the PointLight.
  51737. */
  51738. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51739. protected _buildUniformLayout(): void;
  51740. /**
  51741. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51742. * @param effect The effect to update
  51743. * @param lightIndex The index of the light in the effect to update
  51744. * @returns The point light
  51745. */
  51746. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  51747. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51748. /**
  51749. * Prepares the list of defines specific to the light type.
  51750. * @param defines the list of defines
  51751. * @param lightIndex defines the index of the light for the effect
  51752. */
  51753. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51754. }
  51755. }
  51756. declare module BABYLON {
  51757. /**
  51758. * Header information of HDR texture files.
  51759. */
  51760. export interface HDRInfo {
  51761. /**
  51762. * The height of the texture in pixels.
  51763. */
  51764. height: number;
  51765. /**
  51766. * The width of the texture in pixels.
  51767. */
  51768. width: number;
  51769. /**
  51770. * The index of the beginning of the data in the binary file.
  51771. */
  51772. dataPosition: number;
  51773. }
  51774. /**
  51775. * This groups tools to convert HDR texture to native colors array.
  51776. */
  51777. export class HDRTools {
  51778. private static Ldexp;
  51779. private static Rgbe2float;
  51780. private static readStringLine;
  51781. /**
  51782. * Reads header information from an RGBE texture stored in a native array.
  51783. * More information on this format are available here:
  51784. * https://en.wikipedia.org/wiki/RGBE_image_format
  51785. *
  51786. * @param uint8array The binary file stored in native array.
  51787. * @return The header information.
  51788. */
  51789. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51790. /**
  51791. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51792. * This RGBE texture needs to store the information as a panorama.
  51793. *
  51794. * More information on this format are available here:
  51795. * https://en.wikipedia.org/wiki/RGBE_image_format
  51796. *
  51797. * @param buffer The binary file stored in an array buffer.
  51798. * @param size The expected size of the extracted cubemap.
  51799. * @return The Cube Map information.
  51800. */
  51801. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51802. /**
  51803. * Returns the pixels data extracted from an RGBE texture.
  51804. * This pixels will be stored left to right up to down in the R G B order in one array.
  51805. *
  51806. * More information on this format are available here:
  51807. * https://en.wikipedia.org/wiki/RGBE_image_format
  51808. *
  51809. * @param uint8array The binary file stored in an array buffer.
  51810. * @param hdrInfo The header information of the file.
  51811. * @return The pixels data in RGB right to left up to down order.
  51812. */
  51813. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51814. private static RGBE_ReadPixels_RLE;
  51815. }
  51816. }
  51817. declare module BABYLON {
  51818. /**
  51819. * This represents a texture coming from an HDR input.
  51820. *
  51821. * The only supported format is currently panorama picture stored in RGBE format.
  51822. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51823. */
  51824. export class HDRCubeTexture extends BaseTexture {
  51825. private static _facesMapping;
  51826. private _generateHarmonics;
  51827. private _noMipmap;
  51828. private _textureMatrix;
  51829. private _size;
  51830. private _onLoad;
  51831. private _onError;
  51832. /**
  51833. * The texture URL.
  51834. */
  51835. url: string;
  51836. /**
  51837. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51838. */
  51839. coordinatesMode: number;
  51840. protected _isBlocking: boolean;
  51841. /**
  51842. * Sets wether or not the texture is blocking during loading.
  51843. */
  51844. /**
  51845. * Gets wether or not the texture is blocking during loading.
  51846. */
  51847. isBlocking: boolean;
  51848. protected _rotationY: number;
  51849. /**
  51850. * Sets texture matrix rotation angle around Y axis in radians.
  51851. */
  51852. /**
  51853. * Gets texture matrix rotation angle around Y axis radians.
  51854. */
  51855. rotationY: number;
  51856. /**
  51857. * Gets or sets the center of the bounding box associated with the cube texture
  51858. * It must define where the camera used to render the texture was set
  51859. */
  51860. boundingBoxPosition: Vector3;
  51861. private _boundingBoxSize;
  51862. /**
  51863. * Gets or sets the size of the bounding box associated with the cube texture
  51864. * When defined, the cubemap will switch to local mode
  51865. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51866. * @example https://www.babylonjs-playground.com/#RNASML
  51867. */
  51868. boundingBoxSize: Vector3;
  51869. /**
  51870. * Instantiates an HDRTexture from the following parameters.
  51871. *
  51872. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51873. * @param scene The scene the texture will be used in
  51874. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51875. * @param noMipmap Forces to not generate the mipmap if true
  51876. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51877. * @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)
  51878. * @param reserved Reserved flag for internal use.
  51879. */
  51880. 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>);
  51881. /**
  51882. * Get the current class name of the texture useful for serialization or dynamic coding.
  51883. * @returns "HDRCubeTexture"
  51884. */
  51885. getClassName(): string;
  51886. /**
  51887. * Occurs when the file is raw .hdr file.
  51888. */
  51889. private loadTexture;
  51890. clone(): HDRCubeTexture;
  51891. delayLoad(): void;
  51892. /**
  51893. * Get the texture reflection matrix used to rotate/transform the reflection.
  51894. * @returns the reflection matrix
  51895. */
  51896. getReflectionTextureMatrix(): Matrix;
  51897. /**
  51898. * Set the texture reflection matrix used to rotate/transform the reflection.
  51899. * @param value Define the reflection matrix to set
  51900. */
  51901. setReflectionTextureMatrix(value: Matrix): void;
  51902. /**
  51903. * Parses a JSON representation of an HDR Texture in order to create the texture
  51904. * @param parsedTexture Define the JSON representation
  51905. * @param scene Define the scene the texture should be created in
  51906. * @param rootUrl Define the root url in case we need to load relative dependencies
  51907. * @returns the newly created texture after parsing
  51908. */
  51909. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51910. serialize(): any;
  51911. }
  51912. }
  51913. declare module BABYLON {
  51914. /**
  51915. * Class used to control physics engine
  51916. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51917. */
  51918. export class PhysicsEngine implements IPhysicsEngine {
  51919. private _physicsPlugin;
  51920. /**
  51921. * Global value used to control the smallest number supported by the simulation
  51922. */
  51923. static Epsilon: number;
  51924. private _impostors;
  51925. private _joints;
  51926. private _subTimeStep;
  51927. /**
  51928. * Gets the gravity vector used by the simulation
  51929. */
  51930. gravity: Vector3;
  51931. /**
  51932. * Factory used to create the default physics plugin.
  51933. * @returns The default physics plugin
  51934. */
  51935. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51936. /**
  51937. * Creates a new Physics Engine
  51938. * @param gravity defines the gravity vector used by the simulation
  51939. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51940. */
  51941. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51942. /**
  51943. * Sets the gravity vector used by the simulation
  51944. * @param gravity defines the gravity vector to use
  51945. */
  51946. setGravity(gravity: Vector3): void;
  51947. /**
  51948. * Set the time step of the physics engine.
  51949. * Default is 1/60.
  51950. * To slow it down, enter 1/600 for example.
  51951. * To speed it up, 1/30
  51952. * @param newTimeStep defines the new timestep to apply to this world.
  51953. */
  51954. setTimeStep(newTimeStep?: number): void;
  51955. /**
  51956. * Get the time step of the physics engine.
  51957. * @returns the current time step
  51958. */
  51959. getTimeStep(): number;
  51960. /**
  51961. * Set the sub time step of the physics engine.
  51962. * Default is 0 meaning there is no sub steps
  51963. * To increase physics resolution precision, set a small value (like 1 ms)
  51964. * @param subTimeStep defines the new sub timestep used for physics resolution.
  51965. */
  51966. setSubTimeStep(subTimeStep?: number): void;
  51967. /**
  51968. * Get the sub time step of the physics engine.
  51969. * @returns the current sub time step
  51970. */
  51971. getSubTimeStep(): number;
  51972. /**
  51973. * Release all resources
  51974. */
  51975. dispose(): void;
  51976. /**
  51977. * Gets the name of the current physics plugin
  51978. * @returns the name of the plugin
  51979. */
  51980. getPhysicsPluginName(): string;
  51981. /**
  51982. * Adding a new impostor for the impostor tracking.
  51983. * This will be done by the impostor itself.
  51984. * @param impostor the impostor to add
  51985. */
  51986. addImpostor(impostor: PhysicsImpostor): void;
  51987. /**
  51988. * Remove an impostor from the engine.
  51989. * This impostor and its mesh will not longer be updated by the physics engine.
  51990. * @param impostor the impostor to remove
  51991. */
  51992. removeImpostor(impostor: PhysicsImpostor): void;
  51993. /**
  51994. * Add a joint to the physics engine
  51995. * @param mainImpostor defines the main impostor to which the joint is added.
  51996. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51997. * @param joint defines the joint that will connect both impostors.
  51998. */
  51999. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52000. /**
  52001. * Removes a joint from the simulation
  52002. * @param mainImpostor defines the impostor used with the joint
  52003. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52004. * @param joint defines the joint to remove
  52005. */
  52006. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52007. /**
  52008. * Called by the scene. No need to call it.
  52009. * @param delta defines the timespam between frames
  52010. */
  52011. _step(delta: number): void;
  52012. /**
  52013. * Gets the current plugin used to run the simulation
  52014. * @returns current plugin
  52015. */
  52016. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52017. /**
  52018. * Gets the list of physic impostors
  52019. * @returns an array of PhysicsImpostor
  52020. */
  52021. getImpostors(): Array<PhysicsImpostor>;
  52022. /**
  52023. * Gets the impostor for a physics enabled object
  52024. * @param object defines the object impersonated by the impostor
  52025. * @returns the PhysicsImpostor or null if not found
  52026. */
  52027. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52028. /**
  52029. * Gets the impostor for a physics body object
  52030. * @param body defines physics body used by the impostor
  52031. * @returns the PhysicsImpostor or null if not found
  52032. */
  52033. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52034. /**
  52035. * Does a raycast in the physics world
  52036. * @param from when should the ray start?
  52037. * @param to when should the ray end?
  52038. * @returns PhysicsRaycastResult
  52039. */
  52040. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52041. }
  52042. }
  52043. declare module BABYLON {
  52044. /** @hidden */
  52045. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52046. private _useDeltaForWorldStep;
  52047. world: any;
  52048. name: string;
  52049. private _physicsMaterials;
  52050. private _fixedTimeStep;
  52051. private _cannonRaycastResult;
  52052. private _raycastResult;
  52053. private _physicsBodysToRemoveAfterStep;
  52054. BJSCANNON: any;
  52055. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52056. setGravity(gravity: Vector3): void;
  52057. setTimeStep(timeStep: number): void;
  52058. getTimeStep(): number;
  52059. executeStep(delta: number): void;
  52060. private _removeMarkedPhysicsBodiesFromWorld;
  52061. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52062. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52063. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52064. private _processChildMeshes;
  52065. removePhysicsBody(impostor: PhysicsImpostor): void;
  52066. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52067. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52068. private _addMaterial;
  52069. private _checkWithEpsilon;
  52070. private _createShape;
  52071. private _createHeightmap;
  52072. private _minus90X;
  52073. private _plus90X;
  52074. private _tmpPosition;
  52075. private _tmpDeltaPosition;
  52076. private _tmpUnityRotation;
  52077. private _updatePhysicsBodyTransformation;
  52078. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52079. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52080. isSupported(): boolean;
  52081. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52082. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52083. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52084. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52085. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52086. getBodyMass(impostor: PhysicsImpostor): number;
  52087. getBodyFriction(impostor: PhysicsImpostor): number;
  52088. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52089. getBodyRestitution(impostor: PhysicsImpostor): number;
  52090. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52091. sleepBody(impostor: PhysicsImpostor): void;
  52092. wakeUpBody(impostor: PhysicsImpostor): void;
  52093. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52094. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52095. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52096. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52097. getRadius(impostor: PhysicsImpostor): number;
  52098. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52099. dispose(): void;
  52100. private _extendNamespace;
  52101. /**
  52102. * Does a raycast in the physics world
  52103. * @param from when should the ray start?
  52104. * @param to when should the ray end?
  52105. * @returns PhysicsRaycastResult
  52106. */
  52107. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52108. }
  52109. }
  52110. declare module BABYLON {
  52111. /** @hidden */
  52112. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52113. world: any;
  52114. name: string;
  52115. BJSOIMO: any;
  52116. private _raycastResult;
  52117. constructor(iterations?: number, oimoInjection?: any);
  52118. setGravity(gravity: Vector3): void;
  52119. setTimeStep(timeStep: number): void;
  52120. getTimeStep(): number;
  52121. private _tmpImpostorsArray;
  52122. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52123. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52124. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52125. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52126. private _tmpPositionVector;
  52127. removePhysicsBody(impostor: PhysicsImpostor): void;
  52128. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52129. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52130. isSupported(): boolean;
  52131. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52132. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52133. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52134. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52135. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52136. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52137. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52138. getBodyMass(impostor: PhysicsImpostor): number;
  52139. getBodyFriction(impostor: PhysicsImpostor): number;
  52140. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52141. getBodyRestitution(impostor: PhysicsImpostor): number;
  52142. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52143. sleepBody(impostor: PhysicsImpostor): void;
  52144. wakeUpBody(impostor: PhysicsImpostor): void;
  52145. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52146. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52147. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52148. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52149. getRadius(impostor: PhysicsImpostor): number;
  52150. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52151. dispose(): void;
  52152. /**
  52153. * Does a raycast in the physics world
  52154. * @param from when should the ray start?
  52155. * @param to when should the ray end?
  52156. * @returns PhysicsRaycastResult
  52157. */
  52158. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52159. }
  52160. }
  52161. declare module BABYLON {
  52162. /**
  52163. * Class containing static functions to help procedurally build meshes
  52164. */
  52165. export class RibbonBuilder {
  52166. /**
  52167. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52168. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52169. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52170. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52171. * * 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
  52172. * * 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
  52173. * * 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
  52174. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52175. * * 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
  52176. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52177. * * 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
  52178. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52179. * * 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
  52180. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52182. * @param name defines the name of the mesh
  52183. * @param options defines the options used to create the mesh
  52184. * @param scene defines the hosting scene
  52185. * @returns the ribbon mesh
  52186. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52187. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52188. */
  52189. static CreateRibbon(name: string, options: {
  52190. pathArray: Vector3[][];
  52191. closeArray?: boolean;
  52192. closePath?: boolean;
  52193. offset?: number;
  52194. updatable?: boolean;
  52195. sideOrientation?: number;
  52196. frontUVs?: Vector4;
  52197. backUVs?: Vector4;
  52198. instance?: Mesh;
  52199. invertUV?: boolean;
  52200. uvs?: Vector2[];
  52201. colors?: Color4[];
  52202. }, scene?: Nullable<Scene>): Mesh;
  52203. }
  52204. }
  52205. declare module BABYLON {
  52206. /**
  52207. * Class containing static functions to help procedurally build meshes
  52208. */
  52209. export class ShapeBuilder {
  52210. /**
  52211. * 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.
  52212. * * 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.
  52213. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52214. * * 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.
  52215. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52216. * * 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
  52217. * * 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
  52218. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52219. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52220. * * 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
  52221. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52223. * @param name defines the name of the mesh
  52224. * @param options defines the options used to create the mesh
  52225. * @param scene defines the hosting scene
  52226. * @returns the extruded shape mesh
  52227. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52228. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52229. */
  52230. static ExtrudeShape(name: string, options: {
  52231. shape: Vector3[];
  52232. path: Vector3[];
  52233. scale?: number;
  52234. rotation?: number;
  52235. cap?: number;
  52236. updatable?: boolean;
  52237. sideOrientation?: number;
  52238. frontUVs?: Vector4;
  52239. backUVs?: Vector4;
  52240. instance?: Mesh;
  52241. invertUV?: boolean;
  52242. }, scene?: Nullable<Scene>): Mesh;
  52243. /**
  52244. * Creates an custom extruded shape mesh.
  52245. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52246. * * 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.
  52247. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52248. * * 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
  52249. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52250. * * 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
  52251. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52252. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52253. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52254. * * 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
  52255. * * 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
  52256. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52258. * * 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
  52259. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52261. * @param name defines the name of the mesh
  52262. * @param options defines the options used to create the mesh
  52263. * @param scene defines the hosting scene
  52264. * @returns the custom extruded shape mesh
  52265. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52266. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52267. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52268. */
  52269. static ExtrudeShapeCustom(name: string, options: {
  52270. shape: Vector3[];
  52271. path: Vector3[];
  52272. scaleFunction?: any;
  52273. rotationFunction?: any;
  52274. ribbonCloseArray?: boolean;
  52275. ribbonClosePath?: boolean;
  52276. cap?: number;
  52277. updatable?: boolean;
  52278. sideOrientation?: number;
  52279. frontUVs?: Vector4;
  52280. backUVs?: Vector4;
  52281. instance?: Mesh;
  52282. invertUV?: boolean;
  52283. }, scene?: Nullable<Scene>): Mesh;
  52284. private static _ExtrudeShapeGeneric;
  52285. }
  52286. }
  52287. declare module BABYLON {
  52288. /**
  52289. * AmmoJS Physics plugin
  52290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52291. * @see https://github.com/kripken/ammo.js/
  52292. */
  52293. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52294. private _useDeltaForWorldStep;
  52295. /**
  52296. * Reference to the Ammo library
  52297. */
  52298. bjsAMMO: any;
  52299. /**
  52300. * Created ammoJS world which physics bodies are added to
  52301. */
  52302. world: any;
  52303. /**
  52304. * Name of the plugin
  52305. */
  52306. name: string;
  52307. private _timeStep;
  52308. private _fixedTimeStep;
  52309. private _maxSteps;
  52310. private _tmpQuaternion;
  52311. private _tmpAmmoTransform;
  52312. private _tmpAmmoQuaternion;
  52313. private _tmpAmmoConcreteContactResultCallback;
  52314. private _collisionConfiguration;
  52315. private _dispatcher;
  52316. private _overlappingPairCache;
  52317. private _solver;
  52318. private _softBodySolver;
  52319. private _tmpAmmoVectorA;
  52320. private _tmpAmmoVectorB;
  52321. private _tmpAmmoVectorC;
  52322. private _tmpAmmoVectorD;
  52323. private _tmpContactCallbackResult;
  52324. private _tmpAmmoVectorRCA;
  52325. private _tmpAmmoVectorRCB;
  52326. private _raycastResult;
  52327. private static readonly DISABLE_COLLISION_FLAG;
  52328. private static readonly KINEMATIC_FLAG;
  52329. private static readonly DISABLE_DEACTIVATION_FLAG;
  52330. /**
  52331. * Initializes the ammoJS plugin
  52332. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52333. * @param ammoInjection can be used to inject your own ammo reference
  52334. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  52335. */
  52336. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  52337. /**
  52338. * Sets the gravity of the physics world (m/(s^2))
  52339. * @param gravity Gravity to set
  52340. */
  52341. setGravity(gravity: Vector3): void;
  52342. /**
  52343. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52344. * @param timeStep timestep to use in seconds
  52345. */
  52346. setTimeStep(timeStep: number): void;
  52347. /**
  52348. * 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)
  52349. * @param fixedTimeStep fixedTimeStep to use in seconds
  52350. */
  52351. setFixedTimeStep(fixedTimeStep: number): void;
  52352. /**
  52353. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52354. * @param maxSteps the maximum number of steps by the physics engine per frame
  52355. */
  52356. setMaxSteps(maxSteps: number): void;
  52357. /**
  52358. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52359. * @returns the current timestep in seconds
  52360. */
  52361. getTimeStep(): number;
  52362. /**
  52363. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  52364. */
  52365. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  52366. private _isImpostorInContact;
  52367. private _isImpostorPairInContact;
  52368. private _stepSimulation;
  52369. /**
  52370. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52371. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52372. * After the step the babylon meshes are set to the position of the physics imposters
  52373. * @param delta amount of time to step forward
  52374. * @param impostors array of imposters to update before/after the step
  52375. */
  52376. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52377. /**
  52378. * Update babylon mesh to match physics world object
  52379. * @param impostor imposter to match
  52380. */
  52381. private _afterSoftStep;
  52382. /**
  52383. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52384. * @param impostor imposter to match
  52385. */
  52386. private _ropeStep;
  52387. /**
  52388. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52389. * @param impostor imposter to match
  52390. */
  52391. private _softbodyOrClothStep;
  52392. private _tmpVector;
  52393. private _tmpMatrix;
  52394. /**
  52395. * Applies an impulse on the imposter
  52396. * @param impostor imposter to apply impulse to
  52397. * @param force amount of force to be applied to the imposter
  52398. * @param contactPoint the location to apply the impulse on the imposter
  52399. */
  52400. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52401. /**
  52402. * Applies a force on the imposter
  52403. * @param impostor imposter to apply force
  52404. * @param force amount of force to be applied to the imposter
  52405. * @param contactPoint the location to apply the force on the imposter
  52406. */
  52407. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52408. /**
  52409. * Creates a physics body using the plugin
  52410. * @param impostor the imposter to create the physics body on
  52411. */
  52412. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52413. /**
  52414. * Removes the physics body from the imposter and disposes of the body's memory
  52415. * @param impostor imposter to remove the physics body from
  52416. */
  52417. removePhysicsBody(impostor: PhysicsImpostor): void;
  52418. /**
  52419. * Generates a joint
  52420. * @param impostorJoint the imposter joint to create the joint with
  52421. */
  52422. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52423. /**
  52424. * Removes a joint
  52425. * @param impostorJoint the imposter joint to remove the joint from
  52426. */
  52427. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52428. private _addMeshVerts;
  52429. /**
  52430. * Initialise the soft body vertices to match its object's (mesh) vertices
  52431. * Softbody vertices (nodes) are in world space and to match this
  52432. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  52433. * @param impostor to create the softbody for
  52434. */
  52435. private _softVertexData;
  52436. /**
  52437. * Create an impostor's soft body
  52438. * @param impostor to create the softbody for
  52439. */
  52440. private _createSoftbody;
  52441. /**
  52442. * Create cloth for an impostor
  52443. * @param impostor to create the softbody for
  52444. */
  52445. private _createCloth;
  52446. /**
  52447. * Create rope for an impostor
  52448. * @param impostor to create the softbody for
  52449. */
  52450. private _createRope;
  52451. /**
  52452. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  52453. * @param impostor to create the custom physics shape for
  52454. */
  52455. private _createCustom;
  52456. private _addHullVerts;
  52457. private _createShape;
  52458. /**
  52459. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52460. * @param impostor imposter containing the physics body and babylon object
  52461. */
  52462. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52463. /**
  52464. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52465. * @param impostor imposter containing the physics body and babylon object
  52466. * @param newPosition new position
  52467. * @param newRotation new rotation
  52468. */
  52469. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52470. /**
  52471. * If this plugin is supported
  52472. * @returns true if its supported
  52473. */
  52474. isSupported(): boolean;
  52475. /**
  52476. * Sets the linear velocity of the physics body
  52477. * @param impostor imposter to set the velocity on
  52478. * @param velocity velocity to set
  52479. */
  52480. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52481. /**
  52482. * Sets the angular velocity of the physics body
  52483. * @param impostor imposter to set the velocity on
  52484. * @param velocity velocity to set
  52485. */
  52486. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52487. /**
  52488. * gets the linear velocity
  52489. * @param impostor imposter to get linear velocity from
  52490. * @returns linear velocity
  52491. */
  52492. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52493. /**
  52494. * gets the angular velocity
  52495. * @param impostor imposter to get angular velocity from
  52496. * @returns angular velocity
  52497. */
  52498. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52499. /**
  52500. * Sets the mass of physics body
  52501. * @param impostor imposter to set the mass on
  52502. * @param mass mass to set
  52503. */
  52504. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52505. /**
  52506. * Gets the mass of the physics body
  52507. * @param impostor imposter to get the mass from
  52508. * @returns mass
  52509. */
  52510. getBodyMass(impostor: PhysicsImpostor): number;
  52511. /**
  52512. * Gets friction of the impostor
  52513. * @param impostor impostor to get friction from
  52514. * @returns friction value
  52515. */
  52516. getBodyFriction(impostor: PhysicsImpostor): number;
  52517. /**
  52518. * Sets friction of the impostor
  52519. * @param impostor impostor to set friction on
  52520. * @param friction friction value
  52521. */
  52522. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52523. /**
  52524. * Gets restitution of the impostor
  52525. * @param impostor impostor to get restitution from
  52526. * @returns restitution value
  52527. */
  52528. getBodyRestitution(impostor: PhysicsImpostor): number;
  52529. /**
  52530. * Sets resitution of the impostor
  52531. * @param impostor impostor to set resitution on
  52532. * @param restitution resitution value
  52533. */
  52534. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52535. /**
  52536. * Gets pressure inside the impostor
  52537. * @param impostor impostor to get pressure from
  52538. * @returns pressure value
  52539. */
  52540. getBodyPressure(impostor: PhysicsImpostor): number;
  52541. /**
  52542. * Sets pressure inside a soft body impostor
  52543. * Cloth and rope must remain 0 pressure
  52544. * @param impostor impostor to set pressure on
  52545. * @param pressure pressure value
  52546. */
  52547. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  52548. /**
  52549. * Gets stiffness of the impostor
  52550. * @param impostor impostor to get stiffness from
  52551. * @returns pressure value
  52552. */
  52553. getBodyStiffness(impostor: PhysicsImpostor): number;
  52554. /**
  52555. * Sets stiffness of the impostor
  52556. * @param impostor impostor to set stiffness on
  52557. * @param stiffness stiffness value from 0 to 1
  52558. */
  52559. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  52560. /**
  52561. * Gets velocityIterations of the impostor
  52562. * @param impostor impostor to get velocity iterations from
  52563. * @returns velocityIterations value
  52564. */
  52565. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  52566. /**
  52567. * Sets velocityIterations of the impostor
  52568. * @param impostor impostor to set velocity iterations on
  52569. * @param velocityIterations velocityIterations value
  52570. */
  52571. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  52572. /**
  52573. * Gets positionIterations of the impostor
  52574. * @param impostor impostor to get position iterations from
  52575. * @returns positionIterations value
  52576. */
  52577. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  52578. /**
  52579. * Sets positionIterations of the impostor
  52580. * @param impostor impostor to set position on
  52581. * @param positionIterations positionIterations value
  52582. */
  52583. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  52584. /**
  52585. * Append an anchor to a cloth object
  52586. * @param impostor is the cloth impostor to add anchor to
  52587. * @param otherImpostor is the rigid impostor to anchor to
  52588. * @param width ratio across width from 0 to 1
  52589. * @param height ratio up height from 0 to 1
  52590. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  52591. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52592. */
  52593. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52594. /**
  52595. * Append an hook to a rope object
  52596. * @param impostor is the rope impostor to add hook to
  52597. * @param otherImpostor is the rigid impostor to hook to
  52598. * @param length ratio along the rope from 0 to 1
  52599. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  52600. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52601. */
  52602. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52603. /**
  52604. * Sleeps the physics body and stops it from being active
  52605. * @param impostor impostor to sleep
  52606. */
  52607. sleepBody(impostor: PhysicsImpostor): void;
  52608. /**
  52609. * Activates the physics body
  52610. * @param impostor impostor to activate
  52611. */
  52612. wakeUpBody(impostor: PhysicsImpostor): void;
  52613. /**
  52614. * Updates the distance parameters of the joint
  52615. * @param joint joint to update
  52616. * @param maxDistance maximum distance of the joint
  52617. * @param minDistance minimum distance of the joint
  52618. */
  52619. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52620. /**
  52621. * Sets a motor on the joint
  52622. * @param joint joint to set motor on
  52623. * @param speed speed of the motor
  52624. * @param maxForce maximum force of the motor
  52625. * @param motorIndex index of the motor
  52626. */
  52627. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52628. /**
  52629. * Sets the motors limit
  52630. * @param joint joint to set limit on
  52631. * @param upperLimit upper limit
  52632. * @param lowerLimit lower limit
  52633. */
  52634. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52635. /**
  52636. * Syncs the position and rotation of a mesh with the impostor
  52637. * @param mesh mesh to sync
  52638. * @param impostor impostor to update the mesh with
  52639. */
  52640. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52641. /**
  52642. * Gets the radius of the impostor
  52643. * @param impostor impostor to get radius from
  52644. * @returns the radius
  52645. */
  52646. getRadius(impostor: PhysicsImpostor): number;
  52647. /**
  52648. * Gets the box size of the impostor
  52649. * @param impostor impostor to get box size from
  52650. * @param result the resulting box size
  52651. */
  52652. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52653. /**
  52654. * Disposes of the impostor
  52655. */
  52656. dispose(): void;
  52657. /**
  52658. * Does a raycast in the physics world
  52659. * @param from when should the ray start?
  52660. * @param to when should the ray end?
  52661. * @returns PhysicsRaycastResult
  52662. */
  52663. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52664. }
  52665. }
  52666. declare module BABYLON {
  52667. interface AbstractScene {
  52668. /**
  52669. * The list of reflection probes added to the scene
  52670. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52671. */
  52672. reflectionProbes: Array<ReflectionProbe>;
  52673. /**
  52674. * Removes the given reflection probe from this scene.
  52675. * @param toRemove The reflection probe to remove
  52676. * @returns The index of the removed reflection probe
  52677. */
  52678. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52679. /**
  52680. * Adds the given reflection probe to this scene.
  52681. * @param newReflectionProbe The reflection probe to add
  52682. */
  52683. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52684. }
  52685. /**
  52686. * Class used to generate realtime reflection / refraction cube textures
  52687. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52688. */
  52689. export class ReflectionProbe {
  52690. /** defines the name of the probe */
  52691. name: string;
  52692. private _scene;
  52693. private _renderTargetTexture;
  52694. private _projectionMatrix;
  52695. private _viewMatrix;
  52696. private _target;
  52697. private _add;
  52698. private _attachedMesh;
  52699. private _invertYAxis;
  52700. /** Gets or sets probe position (center of the cube map) */
  52701. position: Vector3;
  52702. /**
  52703. * Creates a new reflection probe
  52704. * @param name defines the name of the probe
  52705. * @param size defines the texture resolution (for each face)
  52706. * @param scene defines the hosting scene
  52707. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  52708. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  52709. */
  52710. constructor(
  52711. /** defines the name of the probe */
  52712. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  52713. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  52714. samples: number;
  52715. /** Gets or sets the refresh rate to use (on every frame by default) */
  52716. refreshRate: number;
  52717. /**
  52718. * Gets the hosting scene
  52719. * @returns a Scene
  52720. */
  52721. getScene(): Scene;
  52722. /** Gets the internal CubeTexture used to render to */
  52723. readonly cubeTexture: RenderTargetTexture;
  52724. /** Gets the list of meshes to render */
  52725. readonly renderList: Nullable<AbstractMesh[]>;
  52726. /**
  52727. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52728. * @param mesh defines the mesh to attach to
  52729. */
  52730. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52731. /**
  52732. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52733. * @param renderingGroupId The rendering group id corresponding to its index
  52734. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52735. */
  52736. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52737. /**
  52738. * Clean all associated resources
  52739. */
  52740. dispose(): void;
  52741. /**
  52742. * Converts the reflection probe information to a readable string for debug purpose.
  52743. * @param fullDetails Supports for multiple levels of logging within scene loading
  52744. * @returns the human readable reflection probe info
  52745. */
  52746. toString(fullDetails?: boolean): string;
  52747. /**
  52748. * Get the class name of the relfection probe.
  52749. * @returns "ReflectionProbe"
  52750. */
  52751. getClassName(): string;
  52752. /**
  52753. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  52754. * @returns The JSON representation of the texture
  52755. */
  52756. serialize(): any;
  52757. /**
  52758. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  52759. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  52760. * @param scene Define the scene the parsed reflection probe should be instantiated in
  52761. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  52762. * @returns The parsed reflection probe if successful
  52763. */
  52764. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52765. }
  52766. }
  52767. declare module BABYLON {
  52768. /** @hidden */
  52769. export var _BabylonLoaderRegistered: boolean;
  52770. /**
  52771. * Helps setting up some configuration for the babylon file loader.
  52772. */
  52773. export class BabylonFileLoaderConfiguration {
  52774. /**
  52775. * The loader does not allow injecting custom physix engine into the plugins.
  52776. * Unfortunately in ES6, we need to manually inject them into the plugin.
  52777. * So you could set this variable to your engine import to make it work.
  52778. */
  52779. static LoaderInjectedPhysicsEngine: any;
  52780. }
  52781. }
  52782. declare module BABYLON {
  52783. /**
  52784. * The Physically based simple base material of BJS.
  52785. *
  52786. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52787. * It is used as the base class for both the specGloss and metalRough conventions.
  52788. */
  52789. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52790. /**
  52791. * Number of Simultaneous lights allowed on the material.
  52792. */
  52793. maxSimultaneousLights: number;
  52794. /**
  52795. * If sets to true, disables all the lights affecting the material.
  52796. */
  52797. disableLighting: boolean;
  52798. /**
  52799. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52800. */
  52801. environmentTexture: BaseTexture;
  52802. /**
  52803. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52804. */
  52805. invertNormalMapX: boolean;
  52806. /**
  52807. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52808. */
  52809. invertNormalMapY: boolean;
  52810. /**
  52811. * Normal map used in the model.
  52812. */
  52813. normalTexture: BaseTexture;
  52814. /**
  52815. * Emissivie color used to self-illuminate the model.
  52816. */
  52817. emissiveColor: Color3;
  52818. /**
  52819. * Emissivie texture used to self-illuminate the model.
  52820. */
  52821. emissiveTexture: BaseTexture;
  52822. /**
  52823. * Occlusion Channel Strenght.
  52824. */
  52825. occlusionStrength: number;
  52826. /**
  52827. * Occlusion Texture of the material (adding extra occlusion effects).
  52828. */
  52829. occlusionTexture: BaseTexture;
  52830. /**
  52831. * Defines the alpha limits in alpha test mode.
  52832. */
  52833. alphaCutOff: number;
  52834. /**
  52835. * Gets the current double sided mode.
  52836. */
  52837. /**
  52838. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52839. */
  52840. doubleSided: boolean;
  52841. /**
  52842. * Stores the pre-calculated light information of a mesh in a texture.
  52843. */
  52844. lightmapTexture: BaseTexture;
  52845. /**
  52846. * If true, the light map contains occlusion information instead of lighting info.
  52847. */
  52848. useLightmapAsShadowmap: boolean;
  52849. /**
  52850. * Instantiates a new PBRMaterial instance.
  52851. *
  52852. * @param name The material name
  52853. * @param scene The scene the material will be use in.
  52854. */
  52855. constructor(name: string, scene: Scene);
  52856. getClassName(): string;
  52857. }
  52858. }
  52859. declare module BABYLON {
  52860. /**
  52861. * The PBR material of BJS following the metal roughness convention.
  52862. *
  52863. * This fits to the PBR convention in the GLTF definition:
  52864. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52865. */
  52866. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52867. /**
  52868. * The base color has two different interpretations depending on the value of metalness.
  52869. * When the material is a metal, the base color is the specific measured reflectance value
  52870. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52871. * of the material.
  52872. */
  52873. baseColor: Color3;
  52874. /**
  52875. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52876. * well as opacity information in the alpha channel.
  52877. */
  52878. baseTexture: BaseTexture;
  52879. /**
  52880. * Specifies the metallic scalar value of the material.
  52881. * Can also be used to scale the metalness values of the metallic texture.
  52882. */
  52883. metallic: number;
  52884. /**
  52885. * Specifies the roughness scalar value of the material.
  52886. * Can also be used to scale the roughness values of the metallic texture.
  52887. */
  52888. roughness: number;
  52889. /**
  52890. * Texture containing both the metallic value in the B channel and the
  52891. * roughness value in the G channel to keep better precision.
  52892. */
  52893. metallicRoughnessTexture: BaseTexture;
  52894. /**
  52895. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52896. *
  52897. * @param name The material name
  52898. * @param scene The scene the material will be use in.
  52899. */
  52900. constructor(name: string, scene: Scene);
  52901. /**
  52902. * Return the currrent class name of the material.
  52903. */
  52904. getClassName(): string;
  52905. /**
  52906. * Makes a duplicate of the current material.
  52907. * @param name - name to use for the new material.
  52908. */
  52909. clone(name: string): PBRMetallicRoughnessMaterial;
  52910. /**
  52911. * Serialize the material to a parsable JSON object.
  52912. */
  52913. serialize(): any;
  52914. /**
  52915. * Parses a JSON object correponding to the serialize function.
  52916. */
  52917. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  52918. }
  52919. }
  52920. declare module BABYLON {
  52921. /**
  52922. * The PBR material of BJS following the specular glossiness convention.
  52923. *
  52924. * This fits to the PBR convention in the GLTF definition:
  52925. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52926. */
  52927. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52928. /**
  52929. * Specifies the diffuse color of the material.
  52930. */
  52931. diffuseColor: Color3;
  52932. /**
  52933. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52934. * channel.
  52935. */
  52936. diffuseTexture: BaseTexture;
  52937. /**
  52938. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52939. */
  52940. specularColor: Color3;
  52941. /**
  52942. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52943. */
  52944. glossiness: number;
  52945. /**
  52946. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52947. */
  52948. specularGlossinessTexture: BaseTexture;
  52949. /**
  52950. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52951. *
  52952. * @param name The material name
  52953. * @param scene The scene the material will be use in.
  52954. */
  52955. constructor(name: string, scene: Scene);
  52956. /**
  52957. * Return the currrent class name of the material.
  52958. */
  52959. getClassName(): string;
  52960. /**
  52961. * Makes a duplicate of the current material.
  52962. * @param name - name to use for the new material.
  52963. */
  52964. clone(name: string): PBRSpecularGlossinessMaterial;
  52965. /**
  52966. * Serialize the material to a parsable JSON object.
  52967. */
  52968. serialize(): any;
  52969. /**
  52970. * Parses a JSON object correponding to the serialize function.
  52971. */
  52972. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52973. }
  52974. }
  52975. declare module BABYLON {
  52976. /**
  52977. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52978. * It can help converting any input color in a desired output one. This can then be used to create effects
  52979. * from sepia, black and white to sixties or futuristic rendering...
  52980. *
  52981. * The only supported format is currently 3dl.
  52982. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52983. */
  52984. export class ColorGradingTexture extends BaseTexture {
  52985. /**
  52986. * The current texture matrix. (will always be identity in color grading texture)
  52987. */
  52988. private _textureMatrix;
  52989. /**
  52990. * The texture URL.
  52991. */
  52992. url: string;
  52993. /**
  52994. * Empty line regex stored for GC.
  52995. */
  52996. private static _noneEmptyLineRegex;
  52997. private _engine;
  52998. /**
  52999. * Instantiates a ColorGradingTexture from the following parameters.
  53000. *
  53001. * @param url The location of the color gradind data (currently only supporting 3dl)
  53002. * @param scene The scene the texture will be used in
  53003. */
  53004. constructor(url: string, scene: Scene);
  53005. /**
  53006. * Returns the texture matrix used in most of the material.
  53007. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53008. */
  53009. getTextureMatrix(): Matrix;
  53010. /**
  53011. * Occurs when the file being loaded is a .3dl LUT file.
  53012. */
  53013. private load3dlTexture;
  53014. /**
  53015. * Starts the loading process of the texture.
  53016. */
  53017. private loadTexture;
  53018. /**
  53019. * Clones the color gradind texture.
  53020. */
  53021. clone(): ColorGradingTexture;
  53022. /**
  53023. * Called during delayed load for textures.
  53024. */
  53025. delayLoad(): void;
  53026. /**
  53027. * Parses a color grading texture serialized by Babylon.
  53028. * @param parsedTexture The texture information being parsedTexture
  53029. * @param scene The scene to load the texture in
  53030. * @param rootUrl The root url of the data assets to load
  53031. * @return A color gradind texture
  53032. */
  53033. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53034. /**
  53035. * Serializes the LUT texture to json format.
  53036. */
  53037. serialize(): any;
  53038. }
  53039. }
  53040. declare module BABYLON {
  53041. /**
  53042. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53043. */
  53044. export class EquiRectangularCubeTexture extends BaseTexture {
  53045. /** The six faces of the cube. */
  53046. private static _FacesMapping;
  53047. private _noMipmap;
  53048. private _onLoad;
  53049. private _onError;
  53050. /** The size of the cubemap. */
  53051. private _size;
  53052. /** The buffer of the image. */
  53053. private _buffer;
  53054. /** The width of the input image. */
  53055. private _width;
  53056. /** The height of the input image. */
  53057. private _height;
  53058. /** The URL to the image. */
  53059. url: string;
  53060. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53061. coordinatesMode: number;
  53062. /**
  53063. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53064. * @param url The location of the image
  53065. * @param scene The scene the texture will be used in
  53066. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53067. * @param noMipmap Forces to not generate the mipmap if true
  53068. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53069. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53070. * @param onLoad — defines a callback called when texture is loaded
  53071. * @param onError — defines a callback called if there is an error
  53072. */
  53073. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53074. /**
  53075. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53076. */
  53077. private loadImage;
  53078. /**
  53079. * Convert the image buffer into a cubemap and create a CubeTexture.
  53080. */
  53081. private loadTexture;
  53082. /**
  53083. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53084. * @param buffer The ArrayBuffer that should be converted.
  53085. * @returns The buffer as Float32Array.
  53086. */
  53087. private getFloat32ArrayFromArrayBuffer;
  53088. /**
  53089. * Get the current class name of the texture useful for serialization or dynamic coding.
  53090. * @returns "EquiRectangularCubeTexture"
  53091. */
  53092. getClassName(): string;
  53093. /**
  53094. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53095. * @returns A clone of the current EquiRectangularCubeTexture.
  53096. */
  53097. clone(): EquiRectangularCubeTexture;
  53098. }
  53099. }
  53100. declare module BABYLON {
  53101. /**
  53102. * Based on jsTGALoader - Javascript loader for TGA file
  53103. * By Vincent Thibault
  53104. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53105. */
  53106. export class TGATools {
  53107. private static _TYPE_INDEXED;
  53108. private static _TYPE_RGB;
  53109. private static _TYPE_GREY;
  53110. private static _TYPE_RLE_INDEXED;
  53111. private static _TYPE_RLE_RGB;
  53112. private static _TYPE_RLE_GREY;
  53113. private static _ORIGIN_MASK;
  53114. private static _ORIGIN_SHIFT;
  53115. private static _ORIGIN_BL;
  53116. private static _ORIGIN_BR;
  53117. private static _ORIGIN_UL;
  53118. private static _ORIGIN_UR;
  53119. /**
  53120. * Gets the header of a TGA file
  53121. * @param data defines the TGA data
  53122. * @returns the header
  53123. */
  53124. static GetTGAHeader(data: Uint8Array): any;
  53125. /**
  53126. * Uploads TGA content to a Babylon Texture
  53127. * @hidden
  53128. */
  53129. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53130. /** @hidden */
  53131. 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;
  53132. /** @hidden */
  53133. 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;
  53134. /** @hidden */
  53135. 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;
  53136. /** @hidden */
  53137. 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;
  53138. /** @hidden */
  53139. 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;
  53140. /** @hidden */
  53141. 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;
  53142. }
  53143. }
  53144. declare module BABYLON {
  53145. /**
  53146. * Implementation of the TGA Texture Loader.
  53147. * @hidden
  53148. */
  53149. export class _TGATextureLoader implements IInternalTextureLoader {
  53150. /**
  53151. * Defines wether the loader supports cascade loading the different faces.
  53152. */
  53153. readonly supportCascades: boolean;
  53154. /**
  53155. * This returns if the loader support the current file information.
  53156. * @param extension defines the file extension of the file being loaded
  53157. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53158. * @param fallback defines the fallback internal texture if any
  53159. * @param isBase64 defines whether the texture is encoded as a base64
  53160. * @param isBuffer defines whether the texture data are stored as a buffer
  53161. * @returns true if the loader can load the specified file
  53162. */
  53163. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53164. /**
  53165. * Transform the url before loading if required.
  53166. * @param rootUrl the url of the texture
  53167. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53168. * @returns the transformed texture
  53169. */
  53170. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53171. /**
  53172. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53173. * @param rootUrl the url of the texture
  53174. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53175. * @returns the fallback texture
  53176. */
  53177. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53178. /**
  53179. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53180. * @param data contains the texture data
  53181. * @param texture defines the BabylonJS internal texture
  53182. * @param createPolynomials will be true if polynomials have been requested
  53183. * @param onLoad defines the callback to trigger once the texture is ready
  53184. * @param onError defines the callback to trigger in case of error
  53185. */
  53186. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53187. /**
  53188. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53189. * @param data contains the texture data
  53190. * @param texture defines the BabylonJS internal texture
  53191. * @param callback defines the method to call once ready to upload
  53192. */
  53193. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53194. }
  53195. }
  53196. declare module BABYLON {
  53197. /**
  53198. * Info about the .basis files
  53199. */
  53200. class BasisFileInfo {
  53201. /**
  53202. * If the file has alpha
  53203. */
  53204. hasAlpha: boolean;
  53205. /**
  53206. * Info about each image of the basis file
  53207. */
  53208. images: Array<{
  53209. levels: Array<{
  53210. width: number;
  53211. height: number;
  53212. transcodedPixels: ArrayBufferView;
  53213. }>;
  53214. }>;
  53215. }
  53216. /**
  53217. * Result of transcoding a basis file
  53218. */
  53219. class TranscodeResult {
  53220. /**
  53221. * Info about the .basis file
  53222. */
  53223. fileInfo: BasisFileInfo;
  53224. /**
  53225. * Format to use when loading the file
  53226. */
  53227. format: number;
  53228. }
  53229. /**
  53230. * Configuration options for the Basis transcoder
  53231. */
  53232. export class BasisTranscodeConfiguration {
  53233. /**
  53234. * Supported compression formats used to determine the supported output format of the transcoder
  53235. */
  53236. supportedCompressionFormats?: {
  53237. /**
  53238. * etc1 compression format
  53239. */
  53240. etc1?: boolean;
  53241. /**
  53242. * s3tc compression format
  53243. */
  53244. s3tc?: boolean;
  53245. /**
  53246. * pvrtc compression format
  53247. */
  53248. pvrtc?: boolean;
  53249. /**
  53250. * etc2 compression format
  53251. */
  53252. etc2?: boolean;
  53253. };
  53254. /**
  53255. * If mipmap levels should be loaded for transcoded images (Default: true)
  53256. */
  53257. loadMipmapLevels?: boolean;
  53258. /**
  53259. * Index of a single image to load (Default: all images)
  53260. */
  53261. loadSingleImage?: number;
  53262. }
  53263. /**
  53264. * Used to load .Basis files
  53265. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53266. */
  53267. export class BasisTools {
  53268. private static _IgnoreSupportedFormats;
  53269. /**
  53270. * URL to use when loading the basis transcoder
  53271. */
  53272. static JSModuleURL: string;
  53273. /**
  53274. * URL to use when loading the wasm module for the transcoder
  53275. */
  53276. static WasmModuleURL: string;
  53277. /**
  53278. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53279. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53280. * @returns internal format corresponding to the Basis format
  53281. */
  53282. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53283. private static _WorkerPromise;
  53284. private static _Worker;
  53285. private static _actionId;
  53286. private static _CreateWorkerAsync;
  53287. /**
  53288. * Transcodes a loaded image file to compressed pixel data
  53289. * @param imageData image data to transcode
  53290. * @param config configuration options for the transcoding
  53291. * @returns a promise resulting in the transcoded image
  53292. */
  53293. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53294. /**
  53295. * Loads a texture from the transcode result
  53296. * @param texture texture load to
  53297. * @param transcodeResult the result of transcoding the basis file to load from
  53298. */
  53299. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  53300. }
  53301. }
  53302. declare module BABYLON {
  53303. /**
  53304. * Loader for .basis file format
  53305. */
  53306. export class _BasisTextureLoader implements IInternalTextureLoader {
  53307. /**
  53308. * Defines whether the loader supports cascade loading the different faces.
  53309. */
  53310. readonly supportCascades: boolean;
  53311. /**
  53312. * This returns if the loader support the current file information.
  53313. * @param extension defines the file extension of the file being loaded
  53314. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53315. * @param fallback defines the fallback internal texture if any
  53316. * @param isBase64 defines whether the texture is encoded as a base64
  53317. * @param isBuffer defines whether the texture data are stored as a buffer
  53318. * @returns true if the loader can load the specified file
  53319. */
  53320. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53321. /**
  53322. * Transform the url before loading if required.
  53323. * @param rootUrl the url of the texture
  53324. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53325. * @returns the transformed texture
  53326. */
  53327. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53328. /**
  53329. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53330. * @param rootUrl the url of the texture
  53331. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53332. * @returns the fallback texture
  53333. */
  53334. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53335. /**
  53336. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  53337. * @param data contains the texture data
  53338. * @param texture defines the BabylonJS internal texture
  53339. * @param createPolynomials will be true if polynomials have been requested
  53340. * @param onLoad defines the callback to trigger once the texture is ready
  53341. * @param onError defines the callback to trigger in case of error
  53342. */
  53343. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53344. /**
  53345. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53346. * @param data contains the texture data
  53347. * @param texture defines the BabylonJS internal texture
  53348. * @param callback defines the method to call once ready to upload
  53349. */
  53350. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53351. }
  53352. }
  53353. declare module BABYLON {
  53354. /**
  53355. * 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.
  53356. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53357. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53358. */
  53359. export class CustomProceduralTexture extends ProceduralTexture {
  53360. private _animate;
  53361. private _time;
  53362. private _config;
  53363. private _texturePath;
  53364. /**
  53365. * Instantiates a new Custom Procedural Texture.
  53366. * 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.
  53367. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53368. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53369. * @param name Define the name of the texture
  53370. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53371. * @param size Define the size of the texture to create
  53372. * @param scene Define the scene the texture belongs to
  53373. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53374. * @param generateMipMaps Define if the texture should creates mip maps or not
  53375. */
  53376. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53377. private _loadJson;
  53378. /**
  53379. * Is the texture ready to be used ? (rendered at least once)
  53380. * @returns true if ready, otherwise, false.
  53381. */
  53382. isReady(): boolean;
  53383. /**
  53384. * Render the texture to its associated render target.
  53385. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53386. */
  53387. render(useCameraPostProcess?: boolean): void;
  53388. /**
  53389. * Update the list of dependant textures samplers in the shader.
  53390. */
  53391. updateTextures(): void;
  53392. /**
  53393. * Update the uniform values of the procedural texture in the shader.
  53394. */
  53395. updateShaderUniforms(): void;
  53396. /**
  53397. * Define if the texture animates or not.
  53398. */
  53399. animate: boolean;
  53400. }
  53401. }
  53402. declare module BABYLON {
  53403. /** @hidden */
  53404. export var noisePixelShader: {
  53405. name: string;
  53406. shader: string;
  53407. };
  53408. }
  53409. declare module BABYLON {
  53410. /**
  53411. * Class used to generate noise procedural textures
  53412. */
  53413. export class NoiseProceduralTexture extends ProceduralTexture {
  53414. private _time;
  53415. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53416. brightness: number;
  53417. /** Defines the number of octaves to process */
  53418. octaves: number;
  53419. /** Defines the level of persistence (0.8 by default) */
  53420. persistence: number;
  53421. /** Gets or sets animation speed factor (default is 1) */
  53422. animationSpeedFactor: number;
  53423. /**
  53424. * Creates a new NoiseProceduralTexture
  53425. * @param name defines the name fo the texture
  53426. * @param size defines the size of the texture (default is 256)
  53427. * @param scene defines the hosting scene
  53428. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53429. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53430. */
  53431. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53432. private _updateShaderUniforms;
  53433. protected _getDefines(): string;
  53434. /** Generate the current state of the procedural texture */
  53435. render(useCameraPostProcess?: boolean): void;
  53436. /**
  53437. * Serializes this noise procedural texture
  53438. * @returns a serialized noise procedural texture object
  53439. */
  53440. serialize(): any;
  53441. /**
  53442. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53443. * @param parsedTexture defines parsed texture data
  53444. * @param scene defines the current scene
  53445. * @param rootUrl defines the root URL containing noise procedural texture information
  53446. * @returns a parsed NoiseProceduralTexture
  53447. */
  53448. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  53449. }
  53450. }
  53451. declare module BABYLON {
  53452. /**
  53453. * Raw cube texture where the raw buffers are passed in
  53454. */
  53455. export class RawCubeTexture extends CubeTexture {
  53456. /**
  53457. * Creates a cube texture where the raw buffers are passed in.
  53458. * @param scene defines the scene the texture is attached to
  53459. * @param data defines the array of data to use to create each face
  53460. * @param size defines the size of the textures
  53461. * @param format defines the format of the data
  53462. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  53463. * @param generateMipMaps defines if the engine should generate the mip levels
  53464. * @param invertY defines if data must be stored with Y axis inverted
  53465. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  53466. * @param compression defines the compression used (null by default)
  53467. */
  53468. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  53469. /**
  53470. * Updates the raw cube texture.
  53471. * @param data defines the data to store
  53472. * @param format defines the data format
  53473. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53474. * @param invertY defines if data must be stored with Y axis inverted
  53475. * @param compression defines the compression used (null by default)
  53476. * @param level defines which level of the texture to update
  53477. */
  53478. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  53479. /**
  53480. * Updates a raw cube texture with RGBD encoded data.
  53481. * @param data defines the array of data [mipmap][face] to use to create each face
  53482. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  53483. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53484. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53485. * @returns a promsie that resolves when the operation is complete
  53486. */
  53487. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  53488. /**
  53489. * Clones the raw cube texture.
  53490. * @return a new cube texture
  53491. */
  53492. clone(): CubeTexture;
  53493. /** @hidden */
  53494. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53495. }
  53496. }
  53497. declare module BABYLON {
  53498. /**
  53499. * Class used to store 3D textures containing user data
  53500. */
  53501. export class RawTexture3D extends Texture {
  53502. /** Gets or sets the texture format to use */
  53503. format: number;
  53504. private _engine;
  53505. /**
  53506. * Create a new RawTexture3D
  53507. * @param data defines the data of the texture
  53508. * @param width defines the width of the texture
  53509. * @param height defines the height of the texture
  53510. * @param depth defines the depth of the texture
  53511. * @param format defines the texture format to use
  53512. * @param scene defines the hosting scene
  53513. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53514. * @param invertY defines if texture must be stored with Y axis inverted
  53515. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53516. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53517. */
  53518. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53519. /** Gets or sets the texture format to use */
  53520. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53521. /**
  53522. * Update the texture with new data
  53523. * @param data defines the data to store in the texture
  53524. */
  53525. update(data: ArrayBufferView): void;
  53526. }
  53527. }
  53528. declare module BABYLON {
  53529. /**
  53530. * Class used to store 2D array textures containing user data
  53531. */
  53532. export class RawTexture2DArray extends Texture {
  53533. /** Gets or sets the texture format to use */
  53534. format: number;
  53535. private _engine;
  53536. /**
  53537. * Create a new RawTexture2DArray
  53538. * @param data defines the data of the texture
  53539. * @param width defines the width of the texture
  53540. * @param height defines the height of the texture
  53541. * @param depth defines the number of layers of the texture
  53542. * @param format defines the texture format to use
  53543. * @param scene defines the hosting scene
  53544. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53545. * @param invertY defines if texture must be stored with Y axis inverted
  53546. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53547. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53548. */
  53549. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53550. /** Gets or sets the texture format to use */
  53551. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53552. /**
  53553. * Update the texture with new data
  53554. * @param data defines the data to store in the texture
  53555. */
  53556. update(data: ArrayBufferView): void;
  53557. }
  53558. }
  53559. declare module BABYLON {
  53560. /**
  53561. * Creates a refraction texture used by refraction channel of the standard material.
  53562. * It is like a mirror but to see through a material.
  53563. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53564. */
  53565. export class RefractionTexture extends RenderTargetTexture {
  53566. /**
  53567. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  53568. * 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.
  53569. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53570. */
  53571. refractionPlane: Plane;
  53572. /**
  53573. * Define how deep under the surface we should see.
  53574. */
  53575. depth: number;
  53576. /**
  53577. * Creates a refraction texture used by refraction channel of the standard material.
  53578. * It is like a mirror but to see through a material.
  53579. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53580. * @param name Define the texture name
  53581. * @param size Define the size of the underlying texture
  53582. * @param scene Define the scene the refraction belongs to
  53583. * @param generateMipMaps Define if we need to generate mips level for the refraction
  53584. */
  53585. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  53586. /**
  53587. * Clone the refraction texture.
  53588. * @returns the cloned texture
  53589. */
  53590. clone(): RefractionTexture;
  53591. /**
  53592. * Serialize the texture to a JSON representation you could use in Parse later on
  53593. * @returns the serialized JSON representation
  53594. */
  53595. serialize(): any;
  53596. }
  53597. }
  53598. declare module BABYLON {
  53599. /**
  53600. * Defines the options related to the creation of an HtmlElementTexture
  53601. */
  53602. export interface IHtmlElementTextureOptions {
  53603. /**
  53604. * Defines wether mip maps should be created or not.
  53605. */
  53606. generateMipMaps?: boolean;
  53607. /**
  53608. * Defines the sampling mode of the texture.
  53609. */
  53610. samplingMode?: number;
  53611. /**
  53612. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  53613. */
  53614. engine: Nullable<ThinEngine>;
  53615. /**
  53616. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  53617. */
  53618. scene: Nullable<Scene>;
  53619. }
  53620. /**
  53621. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  53622. * To be as efficient as possible depending on your constraints nothing aside the first upload
  53623. * is automatically managed.
  53624. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  53625. * in your application.
  53626. *
  53627. * As the update is not automatic, you need to call them manually.
  53628. */
  53629. export class HtmlElementTexture extends BaseTexture {
  53630. /**
  53631. * The texture URL.
  53632. */
  53633. element: HTMLVideoElement | HTMLCanvasElement;
  53634. private static readonly DefaultOptions;
  53635. private _textureMatrix;
  53636. private _engine;
  53637. private _isVideo;
  53638. private _generateMipMaps;
  53639. private _samplingMode;
  53640. /**
  53641. * Instantiates a HtmlElementTexture from the following parameters.
  53642. *
  53643. * @param name Defines the name of the texture
  53644. * @param element Defines the video or canvas the texture is filled with
  53645. * @param options Defines the other none mandatory texture creation options
  53646. */
  53647. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  53648. private _createInternalTexture;
  53649. /**
  53650. * Returns the texture matrix used in most of the material.
  53651. */
  53652. getTextureMatrix(): Matrix;
  53653. /**
  53654. * Updates the content of the texture.
  53655. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  53656. */
  53657. update(invertY?: Nullable<boolean>): void;
  53658. }
  53659. }
  53660. declare module BABYLON {
  53661. /**
  53662. * Enum used to define the target of a block
  53663. */
  53664. export enum NodeMaterialBlockTargets {
  53665. /** Vertex shader */
  53666. Vertex = 1,
  53667. /** Fragment shader */
  53668. Fragment = 2,
  53669. /** Neutral */
  53670. Neutral = 4,
  53671. /** Vertex and Fragment */
  53672. VertexAndFragment = 3
  53673. }
  53674. }
  53675. declare module BABYLON {
  53676. /**
  53677. * Defines the kind of connection point for node based material
  53678. */
  53679. export enum NodeMaterialBlockConnectionPointTypes {
  53680. /** Float */
  53681. Float = 1,
  53682. /** Int */
  53683. Int = 2,
  53684. /** Vector2 */
  53685. Vector2 = 4,
  53686. /** Vector3 */
  53687. Vector3 = 8,
  53688. /** Vector4 */
  53689. Vector4 = 16,
  53690. /** Color3 */
  53691. Color3 = 32,
  53692. /** Color4 */
  53693. Color4 = 64,
  53694. /** Matrix */
  53695. Matrix = 128,
  53696. /** Detect type based on connection */
  53697. AutoDetect = 1024,
  53698. /** Output type that will be defined by input type */
  53699. BasedOnInput = 2048
  53700. }
  53701. }
  53702. declare module BABYLON {
  53703. /**
  53704. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  53705. */
  53706. export enum NodeMaterialBlockConnectionPointMode {
  53707. /** Value is an uniform */
  53708. Uniform = 0,
  53709. /** Value is a mesh attribute */
  53710. Attribute = 1,
  53711. /** Value is a varying between vertex and fragment shaders */
  53712. Varying = 2,
  53713. /** Mode is undefined */
  53714. Undefined = 3
  53715. }
  53716. }
  53717. declare module BABYLON {
  53718. /**
  53719. * Enum used to define system values e.g. values automatically provided by the system
  53720. */
  53721. export enum NodeMaterialSystemValues {
  53722. /** World */
  53723. World = 1,
  53724. /** View */
  53725. View = 2,
  53726. /** Projection */
  53727. Projection = 3,
  53728. /** ViewProjection */
  53729. ViewProjection = 4,
  53730. /** WorldView */
  53731. WorldView = 5,
  53732. /** WorldViewProjection */
  53733. WorldViewProjection = 6,
  53734. /** CameraPosition */
  53735. CameraPosition = 7,
  53736. /** Fog Color */
  53737. FogColor = 8,
  53738. /** Delta time */
  53739. DeltaTime = 9
  53740. }
  53741. }
  53742. declare module BABYLON {
  53743. /**
  53744. * Root class for all node material optimizers
  53745. */
  53746. export class NodeMaterialOptimizer {
  53747. /**
  53748. * Function used to optimize a NodeMaterial graph
  53749. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53750. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53751. */
  53752. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53753. }
  53754. }
  53755. declare module BABYLON {
  53756. /**
  53757. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  53758. */
  53759. export class TransformBlock extends NodeMaterialBlock {
  53760. /**
  53761. * Defines the value to use to complement W value to transform it to a Vector4
  53762. */
  53763. complementW: number;
  53764. /**
  53765. * Defines the value to use to complement z value to transform it to a Vector4
  53766. */
  53767. complementZ: number;
  53768. /**
  53769. * Creates a new TransformBlock
  53770. * @param name defines the block name
  53771. */
  53772. constructor(name: string);
  53773. /**
  53774. * Gets the current class name
  53775. * @returns the class name
  53776. */
  53777. getClassName(): string;
  53778. /**
  53779. * Gets the vector input
  53780. */
  53781. readonly vector: NodeMaterialConnectionPoint;
  53782. /**
  53783. * Gets the output component
  53784. */
  53785. readonly output: NodeMaterialConnectionPoint;
  53786. /**
  53787. * Gets the matrix transform input
  53788. */
  53789. readonly transform: NodeMaterialConnectionPoint;
  53790. protected _buildBlock(state: NodeMaterialBuildState): this;
  53791. serialize(): any;
  53792. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53793. protected _dumpPropertiesCode(): string;
  53794. }
  53795. }
  53796. declare module BABYLON {
  53797. /**
  53798. * Block used to output the vertex position
  53799. */
  53800. export class VertexOutputBlock extends NodeMaterialBlock {
  53801. /**
  53802. * Creates a new VertexOutputBlock
  53803. * @param name defines the block name
  53804. */
  53805. constructor(name: string);
  53806. /**
  53807. * Gets the current class name
  53808. * @returns the class name
  53809. */
  53810. getClassName(): string;
  53811. /**
  53812. * Gets the vector input component
  53813. */
  53814. readonly vector: NodeMaterialConnectionPoint;
  53815. protected _buildBlock(state: NodeMaterialBuildState): this;
  53816. }
  53817. }
  53818. declare module BABYLON {
  53819. /**
  53820. * Block used to output the final color
  53821. */
  53822. export class FragmentOutputBlock extends NodeMaterialBlock {
  53823. /**
  53824. * Create a new FragmentOutputBlock
  53825. * @param name defines the block name
  53826. */
  53827. constructor(name: string);
  53828. /**
  53829. * Gets the current class name
  53830. * @returns the class name
  53831. */
  53832. getClassName(): string;
  53833. /**
  53834. * Gets the rgba input component
  53835. */
  53836. readonly rgba: NodeMaterialConnectionPoint;
  53837. /**
  53838. * Gets the rgb input component
  53839. */
  53840. readonly rgb: NodeMaterialConnectionPoint;
  53841. /**
  53842. * Gets the a input component
  53843. */
  53844. readonly a: NodeMaterialConnectionPoint;
  53845. protected _buildBlock(state: NodeMaterialBuildState): this;
  53846. }
  53847. }
  53848. declare module BABYLON {
  53849. /**
  53850. * Block used to read a reflection texture from a sampler
  53851. */
  53852. export class ReflectionTextureBlock extends NodeMaterialBlock {
  53853. private _define3DName;
  53854. private _defineCubicName;
  53855. private _defineExplicitName;
  53856. private _defineProjectionName;
  53857. private _defineLocalCubicName;
  53858. private _defineSphericalName;
  53859. private _definePlanarName;
  53860. private _defineEquirectangularName;
  53861. private _defineMirroredEquirectangularFixedName;
  53862. private _defineEquirectangularFixedName;
  53863. private _defineSkyboxName;
  53864. private _cubeSamplerName;
  53865. private _2DSamplerName;
  53866. private _positionUVWName;
  53867. private _directionWName;
  53868. private _reflectionCoordsName;
  53869. private _reflection2DCoordsName;
  53870. private _reflectionColorName;
  53871. private _reflectionMatrixName;
  53872. /**
  53873. * Gets or sets the texture associated with the node
  53874. */
  53875. texture: Nullable<BaseTexture>;
  53876. /**
  53877. * Create a new TextureBlock
  53878. * @param name defines the block name
  53879. */
  53880. constructor(name: string);
  53881. /**
  53882. * Gets the current class name
  53883. * @returns the class name
  53884. */
  53885. getClassName(): string;
  53886. /**
  53887. * Gets the world position input component
  53888. */
  53889. readonly position: NodeMaterialConnectionPoint;
  53890. /**
  53891. * Gets the world position input component
  53892. */
  53893. readonly worldPosition: NodeMaterialConnectionPoint;
  53894. /**
  53895. * Gets the world normal input component
  53896. */
  53897. readonly worldNormal: NodeMaterialConnectionPoint;
  53898. /**
  53899. * Gets the world input component
  53900. */
  53901. readonly world: NodeMaterialConnectionPoint;
  53902. /**
  53903. * Gets the camera (or eye) position component
  53904. */
  53905. readonly cameraPosition: NodeMaterialConnectionPoint;
  53906. /**
  53907. * Gets the view input component
  53908. */
  53909. readonly view: NodeMaterialConnectionPoint;
  53910. /**
  53911. * Gets the rgb output component
  53912. */
  53913. readonly rgb: NodeMaterialConnectionPoint;
  53914. /**
  53915. * Gets the r output component
  53916. */
  53917. readonly r: NodeMaterialConnectionPoint;
  53918. /**
  53919. * Gets the g output component
  53920. */
  53921. readonly g: NodeMaterialConnectionPoint;
  53922. /**
  53923. * Gets the b output component
  53924. */
  53925. readonly b: NodeMaterialConnectionPoint;
  53926. autoConfigure(material: NodeMaterial): void;
  53927. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53928. isReady(): boolean;
  53929. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53930. private _injectVertexCode;
  53931. private _writeOutput;
  53932. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53933. protected _dumpPropertiesCode(): string;
  53934. serialize(): any;
  53935. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53936. }
  53937. }
  53938. declare module BABYLON {
  53939. /**
  53940. * Interface used to configure the node material editor
  53941. */
  53942. export interface INodeMaterialEditorOptions {
  53943. /** Define the URl to load node editor script */
  53944. editorURL?: string;
  53945. }
  53946. /** @hidden */
  53947. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53948. /** BONES */
  53949. NUM_BONE_INFLUENCERS: number;
  53950. BonesPerMesh: number;
  53951. BONETEXTURE: boolean;
  53952. /** MORPH TARGETS */
  53953. MORPHTARGETS: boolean;
  53954. MORPHTARGETS_NORMAL: boolean;
  53955. MORPHTARGETS_TANGENT: boolean;
  53956. MORPHTARGETS_UV: boolean;
  53957. NUM_MORPH_INFLUENCERS: number;
  53958. /** IMAGE PROCESSING */
  53959. IMAGEPROCESSING: boolean;
  53960. VIGNETTE: boolean;
  53961. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53962. VIGNETTEBLENDMODEOPAQUE: boolean;
  53963. TONEMAPPING: boolean;
  53964. TONEMAPPING_ACES: boolean;
  53965. CONTRAST: boolean;
  53966. EXPOSURE: boolean;
  53967. COLORCURVES: boolean;
  53968. COLORGRADING: boolean;
  53969. COLORGRADING3D: boolean;
  53970. SAMPLER3DGREENDEPTH: boolean;
  53971. SAMPLER3DBGRMAP: boolean;
  53972. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53973. /** MISC. */
  53974. BUMPDIRECTUV: number;
  53975. constructor();
  53976. setValue(name: string, value: boolean): void;
  53977. }
  53978. /**
  53979. * Class used to configure NodeMaterial
  53980. */
  53981. export interface INodeMaterialOptions {
  53982. /**
  53983. * Defines if blocks should emit comments
  53984. */
  53985. emitComments: boolean;
  53986. }
  53987. /**
  53988. * Class used to create a node based material built by assembling shader blocks
  53989. */
  53990. export class NodeMaterial extends PushMaterial {
  53991. private static _BuildIdGenerator;
  53992. private _options;
  53993. private _vertexCompilationState;
  53994. private _fragmentCompilationState;
  53995. private _sharedData;
  53996. private _buildId;
  53997. private _buildWasSuccessful;
  53998. private _cachedWorldViewMatrix;
  53999. private _cachedWorldViewProjectionMatrix;
  54000. private _optimizers;
  54001. private _animationFrame;
  54002. /** Define the URl to load node editor script */
  54003. static EditorURL: string;
  54004. private BJSNODEMATERIALEDITOR;
  54005. /** Get the inspector from bundle or global */
  54006. private _getGlobalNodeMaterialEditor;
  54007. /**
  54008. * Gets or sets data used by visual editor
  54009. * @see https://nme.babylonjs.com
  54010. */
  54011. editorData: any;
  54012. /**
  54013. * 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)
  54014. */
  54015. ignoreAlpha: boolean;
  54016. /**
  54017. * Defines the maximum number of lights that can be used in the material
  54018. */
  54019. maxSimultaneousLights: number;
  54020. /**
  54021. * Observable raised when the material is built
  54022. */
  54023. onBuildObservable: Observable<NodeMaterial>;
  54024. /**
  54025. * Gets or sets the root nodes of the material vertex shader
  54026. */
  54027. _vertexOutputNodes: NodeMaterialBlock[];
  54028. /**
  54029. * Gets or sets the root nodes of the material fragment (pixel) shader
  54030. */
  54031. _fragmentOutputNodes: NodeMaterialBlock[];
  54032. /** Gets or sets options to control the node material overall behavior */
  54033. options: INodeMaterialOptions;
  54034. /**
  54035. * Default configuration related to image processing available in the standard Material.
  54036. */
  54037. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54038. /**
  54039. * Gets the image processing configuration used either in this material.
  54040. */
  54041. /**
  54042. * Sets the Default image processing configuration used either in the this material.
  54043. *
  54044. * If sets to null, the scene one is in use.
  54045. */
  54046. imageProcessingConfiguration: ImageProcessingConfiguration;
  54047. /**
  54048. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54049. */
  54050. attachedBlocks: NodeMaterialBlock[];
  54051. /**
  54052. * Create a new node based material
  54053. * @param name defines the material name
  54054. * @param scene defines the hosting scene
  54055. * @param options defines creation option
  54056. */
  54057. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54058. /**
  54059. * Gets the current class name of the material e.g. "NodeMaterial"
  54060. * @returns the class name
  54061. */
  54062. getClassName(): string;
  54063. /**
  54064. * Keep track of the image processing observer to allow dispose and replace.
  54065. */
  54066. private _imageProcessingObserver;
  54067. /**
  54068. * Attaches a new image processing configuration to the Standard Material.
  54069. * @param configuration
  54070. */
  54071. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54072. /**
  54073. * Get a block by its name
  54074. * @param name defines the name of the block to retrieve
  54075. * @returns the required block or null if not found
  54076. */
  54077. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  54078. /**
  54079. * Get a block by its name
  54080. * @param predicate defines the predicate used to find the good candidate
  54081. * @returns the required block or null if not found
  54082. */
  54083. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  54084. /**
  54085. * Get an input block by its name
  54086. * @param predicate defines the predicate used to find the good candidate
  54087. * @returns the required input block or null if not found
  54088. */
  54089. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  54090. /**
  54091. * Gets the list of input blocks attached to this material
  54092. * @returns an array of InputBlocks
  54093. */
  54094. getInputBlocks(): InputBlock[];
  54095. /**
  54096. * Adds a new optimizer to the list of optimizers
  54097. * @param optimizer defines the optimizers to add
  54098. * @returns the current material
  54099. */
  54100. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54101. /**
  54102. * Remove an optimizer from the list of optimizers
  54103. * @param optimizer defines the optimizers to remove
  54104. * @returns the current material
  54105. */
  54106. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54107. /**
  54108. * Add a new block to the list of output nodes
  54109. * @param node defines the node to add
  54110. * @returns the current material
  54111. */
  54112. addOutputNode(node: NodeMaterialBlock): this;
  54113. /**
  54114. * Remove a block from the list of root nodes
  54115. * @param node defines the node to remove
  54116. * @returns the current material
  54117. */
  54118. removeOutputNode(node: NodeMaterialBlock): this;
  54119. private _addVertexOutputNode;
  54120. private _removeVertexOutputNode;
  54121. private _addFragmentOutputNode;
  54122. private _removeFragmentOutputNode;
  54123. /**
  54124. * Specifies if the material will require alpha blending
  54125. * @returns a boolean specifying if alpha blending is needed
  54126. */
  54127. needAlphaBlending(): boolean;
  54128. /**
  54129. * Specifies if this material should be rendered in alpha test mode
  54130. * @returns a boolean specifying if an alpha test is needed.
  54131. */
  54132. needAlphaTesting(): boolean;
  54133. private _initializeBlock;
  54134. private _resetDualBlocks;
  54135. /**
  54136. * Remove a block from the current node material
  54137. * @param block defines the block to remove
  54138. */
  54139. removeBlock(block: NodeMaterialBlock): void;
  54140. /**
  54141. * Build the material and generates the inner effect
  54142. * @param verbose defines if the build should log activity
  54143. */
  54144. build(verbose?: boolean): void;
  54145. /**
  54146. * Runs an otpimization phase to try to improve the shader code
  54147. */
  54148. optimize(): void;
  54149. private _prepareDefinesForAttributes;
  54150. /**
  54151. * Get if the submesh is ready to be used and all its information available.
  54152. * Child classes can use it to update shaders
  54153. * @param mesh defines the mesh to check
  54154. * @param subMesh defines which submesh to check
  54155. * @param useInstances specifies that instances should be used
  54156. * @returns a boolean indicating that the submesh is ready or not
  54157. */
  54158. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54159. /**
  54160. * Get a string representing the shaders built by the current node graph
  54161. */
  54162. readonly compiledShaders: string;
  54163. /**
  54164. * Binds the world matrix to the material
  54165. * @param world defines the world transformation matrix
  54166. */
  54167. bindOnlyWorldMatrix(world: Matrix): void;
  54168. /**
  54169. * Binds the submesh to this material by preparing the effect and shader to draw
  54170. * @param world defines the world transformation matrix
  54171. * @param mesh defines the mesh containing the submesh
  54172. * @param subMesh defines the submesh to bind the material to
  54173. */
  54174. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54175. /**
  54176. * Gets the active textures from the material
  54177. * @returns an array of textures
  54178. */
  54179. getActiveTextures(): BaseTexture[];
  54180. /**
  54181. * Gets the list of texture blocks
  54182. * @returns an array of texture blocks
  54183. */
  54184. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  54185. /**
  54186. * Specifies if the material uses a texture
  54187. * @param texture defines the texture to check against the material
  54188. * @returns a boolean specifying if the material uses the texture
  54189. */
  54190. hasTexture(texture: BaseTexture): boolean;
  54191. /**
  54192. * Disposes the material
  54193. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54194. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54195. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54196. */
  54197. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54198. /** Creates the node editor window. */
  54199. private _createNodeEditor;
  54200. /**
  54201. * Launch the node material editor
  54202. * @param config Define the configuration of the editor
  54203. * @return a promise fulfilled when the node editor is visible
  54204. */
  54205. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54206. /**
  54207. * Clear the current material
  54208. */
  54209. clear(): void;
  54210. /**
  54211. * Clear the current material and set it to a default state
  54212. */
  54213. setToDefault(): void;
  54214. /**
  54215. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  54216. * @param url defines the url to load from
  54217. * @returns a promise that will fullfil when the material is fully loaded
  54218. */
  54219. loadAsync(url: string): Promise<void>;
  54220. private _gatherBlocks;
  54221. /**
  54222. * Generate a string containing the code declaration required to create an equivalent of this material
  54223. * @returns a string
  54224. */
  54225. generateCode(): string;
  54226. /**
  54227. * Serializes this material in a JSON representation
  54228. * @returns the serialized material object
  54229. */
  54230. serialize(): any;
  54231. private _restoreConnections;
  54232. /**
  54233. * Clear the current graph and load a new one from a serialization object
  54234. * @param source defines the JSON representation of the material
  54235. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54236. */
  54237. loadFromSerialization(source: any, rootUrl?: string): void;
  54238. /**
  54239. * Creates a node material from parsed material data
  54240. * @param source defines the JSON representation of the material
  54241. * @param scene defines the hosting scene
  54242. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54243. * @returns a new node material
  54244. */
  54245. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  54246. /**
  54247. * Creates a new node material set to default basic configuration
  54248. * @param name defines the name of the material
  54249. * @param scene defines the hosting scene
  54250. * @returns a new NodeMaterial
  54251. */
  54252. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  54253. }
  54254. }
  54255. declare module BABYLON {
  54256. /**
  54257. * Block used to read a texture from a sampler
  54258. */
  54259. export class TextureBlock extends NodeMaterialBlock {
  54260. private _defineName;
  54261. private _linearDefineName;
  54262. private _tempTextureRead;
  54263. private _samplerName;
  54264. private _transformedUVName;
  54265. private _textureTransformName;
  54266. private _textureInfoName;
  54267. private _mainUVName;
  54268. private _mainUVDefineName;
  54269. /**
  54270. * Gets or sets the texture associated with the node
  54271. */
  54272. texture: Nullable<Texture>;
  54273. /**
  54274. * Create a new TextureBlock
  54275. * @param name defines the block name
  54276. */
  54277. constructor(name: string);
  54278. /**
  54279. * Gets the current class name
  54280. * @returns the class name
  54281. */
  54282. getClassName(): string;
  54283. /**
  54284. * Gets the uv input component
  54285. */
  54286. readonly uv: NodeMaterialConnectionPoint;
  54287. /**
  54288. * Gets the rgba output component
  54289. */
  54290. readonly rgba: NodeMaterialConnectionPoint;
  54291. /**
  54292. * Gets the rgb output component
  54293. */
  54294. readonly rgb: NodeMaterialConnectionPoint;
  54295. /**
  54296. * Gets the r output component
  54297. */
  54298. readonly r: NodeMaterialConnectionPoint;
  54299. /**
  54300. * Gets the g output component
  54301. */
  54302. readonly g: NodeMaterialConnectionPoint;
  54303. /**
  54304. * Gets the b output component
  54305. */
  54306. readonly b: NodeMaterialConnectionPoint;
  54307. /**
  54308. * Gets the a output component
  54309. */
  54310. readonly a: NodeMaterialConnectionPoint;
  54311. readonly target: NodeMaterialBlockTargets;
  54312. autoConfigure(material: NodeMaterial): void;
  54313. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54314. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54315. private _getTextureBase;
  54316. isReady(): boolean;
  54317. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54318. private readonly _isMixed;
  54319. private _injectVertexCode;
  54320. private _writeTextureRead;
  54321. private _writeOutput;
  54322. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54323. protected _dumpPropertiesCode(): string;
  54324. serialize(): any;
  54325. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54326. }
  54327. }
  54328. declare module BABYLON {
  54329. /**
  54330. * Class used to store shared data between 2 NodeMaterialBuildState
  54331. */
  54332. export class NodeMaterialBuildStateSharedData {
  54333. /**
  54334. * Gets the list of emitted varyings
  54335. */
  54336. temps: string[];
  54337. /**
  54338. * Gets the list of emitted varyings
  54339. */
  54340. varyings: string[];
  54341. /**
  54342. * Gets the varying declaration string
  54343. */
  54344. varyingDeclaration: string;
  54345. /**
  54346. * Input blocks
  54347. */
  54348. inputBlocks: InputBlock[];
  54349. /**
  54350. * Input blocks
  54351. */
  54352. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  54353. /**
  54354. * Bindable blocks (Blocks that need to set data to the effect)
  54355. */
  54356. bindableBlocks: NodeMaterialBlock[];
  54357. /**
  54358. * List of blocks that can provide a compilation fallback
  54359. */
  54360. blocksWithFallbacks: NodeMaterialBlock[];
  54361. /**
  54362. * List of blocks that can provide a define update
  54363. */
  54364. blocksWithDefines: NodeMaterialBlock[];
  54365. /**
  54366. * List of blocks that can provide a repeatable content
  54367. */
  54368. repeatableContentBlocks: NodeMaterialBlock[];
  54369. /**
  54370. * List of blocks that can provide a dynamic list of uniforms
  54371. */
  54372. dynamicUniformBlocks: NodeMaterialBlock[];
  54373. /**
  54374. * List of blocks that can block the isReady function for the material
  54375. */
  54376. blockingBlocks: NodeMaterialBlock[];
  54377. /**
  54378. * Gets the list of animated inputs
  54379. */
  54380. animatedInputs: InputBlock[];
  54381. /**
  54382. * Build Id used to avoid multiple recompilations
  54383. */
  54384. buildId: number;
  54385. /** List of emitted variables */
  54386. variableNames: {
  54387. [key: string]: number;
  54388. };
  54389. /** List of emitted defines */
  54390. defineNames: {
  54391. [key: string]: number;
  54392. };
  54393. /** Should emit comments? */
  54394. emitComments: boolean;
  54395. /** Emit build activity */
  54396. verbose: boolean;
  54397. /** Gets or sets the hosting scene */
  54398. scene: Scene;
  54399. /**
  54400. * Gets the compilation hints emitted at compilation time
  54401. */
  54402. hints: {
  54403. needWorldViewMatrix: boolean;
  54404. needWorldViewProjectionMatrix: boolean;
  54405. needAlphaBlending: boolean;
  54406. needAlphaTesting: boolean;
  54407. };
  54408. /**
  54409. * List of compilation checks
  54410. */
  54411. checks: {
  54412. emitVertex: boolean;
  54413. emitFragment: boolean;
  54414. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  54415. };
  54416. /** Creates a new shared data */
  54417. constructor();
  54418. /**
  54419. * Emits console errors and exceptions if there is a failing check
  54420. */
  54421. emitErrors(): void;
  54422. }
  54423. }
  54424. declare module BABYLON {
  54425. /**
  54426. * Class used to store node based material build state
  54427. */
  54428. export class NodeMaterialBuildState {
  54429. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  54430. supportUniformBuffers: boolean;
  54431. /**
  54432. * Gets the list of emitted attributes
  54433. */
  54434. attributes: string[];
  54435. /**
  54436. * Gets the list of emitted uniforms
  54437. */
  54438. uniforms: string[];
  54439. /**
  54440. * Gets the list of emitted constants
  54441. */
  54442. constants: string[];
  54443. /**
  54444. * Gets the list of emitted samplers
  54445. */
  54446. samplers: string[];
  54447. /**
  54448. * Gets the list of emitted functions
  54449. */
  54450. functions: {
  54451. [key: string]: string;
  54452. };
  54453. /**
  54454. * Gets the list of emitted extensions
  54455. */
  54456. extensions: {
  54457. [key: string]: string;
  54458. };
  54459. /**
  54460. * Gets the target of the compilation state
  54461. */
  54462. target: NodeMaterialBlockTargets;
  54463. /**
  54464. * Gets the list of emitted counters
  54465. */
  54466. counters: {
  54467. [key: string]: number;
  54468. };
  54469. /**
  54470. * Shared data between multiple NodeMaterialBuildState instances
  54471. */
  54472. sharedData: NodeMaterialBuildStateSharedData;
  54473. /** @hidden */
  54474. _vertexState: NodeMaterialBuildState;
  54475. /** @hidden */
  54476. _attributeDeclaration: string;
  54477. /** @hidden */
  54478. _uniformDeclaration: string;
  54479. /** @hidden */
  54480. _constantDeclaration: string;
  54481. /** @hidden */
  54482. _samplerDeclaration: string;
  54483. /** @hidden */
  54484. _varyingTransfer: string;
  54485. private _repeatableContentAnchorIndex;
  54486. /** @hidden */
  54487. _builtCompilationString: string;
  54488. /**
  54489. * Gets the emitted compilation strings
  54490. */
  54491. compilationString: string;
  54492. /**
  54493. * Finalize the compilation strings
  54494. * @param state defines the current compilation state
  54495. */
  54496. finalize(state: NodeMaterialBuildState): void;
  54497. /** @hidden */
  54498. readonly _repeatableContentAnchor: string;
  54499. /** @hidden */
  54500. _getFreeVariableName(prefix: string): string;
  54501. /** @hidden */
  54502. _getFreeDefineName(prefix: string): string;
  54503. /** @hidden */
  54504. _excludeVariableName(name: string): void;
  54505. /** @hidden */
  54506. _emit2DSampler(name: string): void;
  54507. /** @hidden */
  54508. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  54509. /** @hidden */
  54510. _emitExtension(name: string, extension: string): void;
  54511. /** @hidden */
  54512. _emitFunction(name: string, code: string, comments: string): void;
  54513. /** @hidden */
  54514. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  54515. replaceStrings?: {
  54516. search: RegExp;
  54517. replace: string;
  54518. }[];
  54519. repeatKey?: string;
  54520. }): string;
  54521. /** @hidden */
  54522. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  54523. repeatKey?: string;
  54524. removeAttributes?: boolean;
  54525. removeUniforms?: boolean;
  54526. removeVaryings?: boolean;
  54527. removeIfDef?: boolean;
  54528. replaceStrings?: {
  54529. search: RegExp;
  54530. replace: string;
  54531. }[];
  54532. }, storeKey?: string): void;
  54533. /** @hidden */
  54534. _registerTempVariable(name: string): boolean;
  54535. /** @hidden */
  54536. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  54537. /** @hidden */
  54538. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54539. /** @hidden */
  54540. _emitFloat(value: number): string;
  54541. }
  54542. }
  54543. declare module BABYLON {
  54544. /**
  54545. * Defines a block that can be used inside a node based material
  54546. */
  54547. export class NodeMaterialBlock {
  54548. private _buildId;
  54549. private _buildTarget;
  54550. private _target;
  54551. private _isFinalMerger;
  54552. private _isInput;
  54553. protected _isUnique: boolean;
  54554. /** @hidden */
  54555. _codeVariableName: string;
  54556. /** @hidden */
  54557. _inputs: NodeMaterialConnectionPoint[];
  54558. /** @hidden */
  54559. _outputs: NodeMaterialConnectionPoint[];
  54560. /** @hidden */
  54561. _preparationId: number;
  54562. /**
  54563. * Gets or sets the name of the block
  54564. */
  54565. name: string;
  54566. /**
  54567. * Gets or sets the unique id of the node
  54568. */
  54569. uniqueId: number;
  54570. /**
  54571. * Gets or sets the comments associated with this block
  54572. */
  54573. comments: string;
  54574. /**
  54575. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  54576. */
  54577. readonly isUnique: boolean;
  54578. /**
  54579. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  54580. */
  54581. readonly isFinalMerger: boolean;
  54582. /**
  54583. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  54584. */
  54585. readonly isInput: boolean;
  54586. /**
  54587. * Gets or sets the build Id
  54588. */
  54589. buildId: number;
  54590. /**
  54591. * Gets or sets the target of the block
  54592. */
  54593. target: NodeMaterialBlockTargets;
  54594. /**
  54595. * Gets the list of input points
  54596. */
  54597. readonly inputs: NodeMaterialConnectionPoint[];
  54598. /** Gets the list of output points */
  54599. readonly outputs: NodeMaterialConnectionPoint[];
  54600. /**
  54601. * Find an input by its name
  54602. * @param name defines the name of the input to look for
  54603. * @returns the input or null if not found
  54604. */
  54605. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54606. /**
  54607. * Find an output by its name
  54608. * @param name defines the name of the outputto look for
  54609. * @returns the output or null if not found
  54610. */
  54611. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54612. /**
  54613. * Creates a new NodeMaterialBlock
  54614. * @param name defines the block name
  54615. * @param target defines the target of that block (Vertex by default)
  54616. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  54617. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  54618. */
  54619. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  54620. /**
  54621. * Initialize the block and prepare the context for build
  54622. * @param state defines the state that will be used for the build
  54623. */
  54624. initialize(state: NodeMaterialBuildState): void;
  54625. /**
  54626. * Bind data to effect. Will only be called for blocks with isBindable === true
  54627. * @param effect defines the effect to bind data to
  54628. * @param nodeMaterial defines the hosting NodeMaterial
  54629. * @param mesh defines the mesh that will be rendered
  54630. */
  54631. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54632. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  54633. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  54634. protected _writeFloat(value: number): string;
  54635. /**
  54636. * Gets the current class name e.g. "NodeMaterialBlock"
  54637. * @returns the class name
  54638. */
  54639. getClassName(): string;
  54640. /**
  54641. * Register a new input. Must be called inside a block constructor
  54642. * @param name defines the connection point name
  54643. * @param type defines the connection point type
  54644. * @param isOptional defines a boolean indicating that this input can be omitted
  54645. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  54646. * @returns the current block
  54647. */
  54648. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  54649. /**
  54650. * Register a new output. Must be called inside a block constructor
  54651. * @param name defines the connection point name
  54652. * @param type defines the connection point type
  54653. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  54654. * @returns the current block
  54655. */
  54656. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  54657. /**
  54658. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  54659. * @param forOutput defines an optional connection point to check compatibility with
  54660. * @returns the first available input or null
  54661. */
  54662. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  54663. /**
  54664. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  54665. * @param forBlock defines an optional block to check compatibility with
  54666. * @returns the first available input or null
  54667. */
  54668. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  54669. /**
  54670. * Gets the sibling of the given output
  54671. * @param current defines the current output
  54672. * @returns the next output in the list or null
  54673. */
  54674. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  54675. /**
  54676. * Connect current block with another block
  54677. * @param other defines the block to connect with
  54678. * @param options define the various options to help pick the right connections
  54679. * @returns the current block
  54680. */
  54681. connectTo(other: NodeMaterialBlock, options?: {
  54682. input?: string;
  54683. output?: string;
  54684. outputSwizzle?: string;
  54685. }): this | undefined;
  54686. protected _buildBlock(state: NodeMaterialBuildState): void;
  54687. /**
  54688. * Add uniforms, samplers and uniform buffers at compilation time
  54689. * @param state defines the state to update
  54690. * @param nodeMaterial defines the node material requesting the update
  54691. * @param defines defines the material defines to update
  54692. * @param uniformBuffers defines the list of uniform buffer names
  54693. */
  54694. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  54695. /**
  54696. * Add potential fallbacks if shader compilation fails
  54697. * @param mesh defines the mesh to be rendered
  54698. * @param fallbacks defines the current prioritized list of fallbacks
  54699. */
  54700. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54701. /**
  54702. * Initialize defines for shader compilation
  54703. * @param mesh defines the mesh to be rendered
  54704. * @param nodeMaterial defines the node material requesting the update
  54705. * @param defines defines the material defines to update
  54706. * @param useInstances specifies that instances should be used
  54707. */
  54708. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54709. /**
  54710. * Update defines for shader compilation
  54711. * @param mesh defines the mesh to be rendered
  54712. * @param nodeMaterial defines the node material requesting the update
  54713. * @param defines defines the material defines to update
  54714. * @param useInstances specifies that instances should be used
  54715. */
  54716. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54717. /**
  54718. * Lets the block try to connect some inputs automatically
  54719. * @param material defines the hosting NodeMaterial
  54720. */
  54721. autoConfigure(material: NodeMaterial): void;
  54722. /**
  54723. * Function called when a block is declared as repeatable content generator
  54724. * @param vertexShaderState defines the current compilation state for the vertex shader
  54725. * @param fragmentShaderState defines the current compilation state for the fragment shader
  54726. * @param mesh defines the mesh to be rendered
  54727. * @param defines defines the material defines to update
  54728. */
  54729. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54730. /**
  54731. * Checks if the block is ready
  54732. * @param mesh defines the mesh to be rendered
  54733. * @param nodeMaterial defines the node material requesting the update
  54734. * @param defines defines the material defines to update
  54735. * @param useInstances specifies that instances should be used
  54736. * @returns true if the block is ready
  54737. */
  54738. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  54739. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  54740. private _processBuild;
  54741. /**
  54742. * Compile the current node and generate the shader code
  54743. * @param state defines the current compilation state (uniforms, samplers, current string)
  54744. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  54745. * @returns true if already built
  54746. */
  54747. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  54748. protected _inputRename(name: string): string;
  54749. protected _outputRename(name: string): string;
  54750. protected _dumpPropertiesCode(): string;
  54751. /** @hidden */
  54752. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  54753. /** @hidden */
  54754. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  54755. /**
  54756. * Clone the current block to a new identical block
  54757. * @param scene defines the hosting scene
  54758. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54759. * @returns a copy of the current block
  54760. */
  54761. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  54762. /**
  54763. * Serializes this block in a JSON representation
  54764. * @returns the serialized block object
  54765. */
  54766. serialize(): any;
  54767. /** @hidden */
  54768. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54769. /**
  54770. * Release resources
  54771. */
  54772. dispose(): void;
  54773. }
  54774. }
  54775. declare module BABYLON {
  54776. /**
  54777. * Enum defining the type of animations supported by InputBlock
  54778. */
  54779. export enum AnimatedInputBlockTypes {
  54780. /** No animation */
  54781. None = 0,
  54782. /** Time based animation. Will only work for floats */
  54783. Time = 1
  54784. }
  54785. }
  54786. declare module BABYLON {
  54787. /**
  54788. * Block used to expose an input value
  54789. */
  54790. export class InputBlock extends NodeMaterialBlock {
  54791. private _mode;
  54792. private _associatedVariableName;
  54793. private _storedValue;
  54794. private _valueCallback;
  54795. private _type;
  54796. private _animationType;
  54797. /** Gets or set a value used to limit the range of float values */
  54798. min: number;
  54799. /** Gets or set a value used to limit the range of float values */
  54800. max: number;
  54801. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  54802. matrixMode: number;
  54803. /** @hidden */
  54804. _systemValue: Nullable<NodeMaterialSystemValues>;
  54805. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  54806. visibleInInspector: boolean;
  54807. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  54808. isConstant: boolean;
  54809. /**
  54810. * Gets or sets the connection point type (default is float)
  54811. */
  54812. readonly type: NodeMaterialBlockConnectionPointTypes;
  54813. /**
  54814. * Creates a new InputBlock
  54815. * @param name defines the block name
  54816. * @param target defines the target of that block (Vertex by default)
  54817. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  54818. */
  54819. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  54820. /**
  54821. * Gets the output component
  54822. */
  54823. readonly output: NodeMaterialConnectionPoint;
  54824. /**
  54825. * Set the source of this connection point to a vertex attribute
  54826. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  54827. * @returns the current connection point
  54828. */
  54829. setAsAttribute(attributeName?: string): InputBlock;
  54830. /**
  54831. * Set the source of this connection point to a system value
  54832. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  54833. * @returns the current connection point
  54834. */
  54835. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  54836. /**
  54837. * Gets or sets the value of that point.
  54838. * Please note that this value will be ignored if valueCallback is defined
  54839. */
  54840. value: any;
  54841. /**
  54842. * Gets or sets a callback used to get the value of that point.
  54843. * Please note that setting this value will force the connection point to ignore the value property
  54844. */
  54845. valueCallback: () => any;
  54846. /**
  54847. * Gets or sets the associated variable name in the shader
  54848. */
  54849. associatedVariableName: string;
  54850. /** Gets or sets the type of animation applied to the input */
  54851. animationType: AnimatedInputBlockTypes;
  54852. /**
  54853. * Gets a boolean indicating that this connection point not defined yet
  54854. */
  54855. readonly isUndefined: boolean;
  54856. /**
  54857. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  54858. * In this case the connection point name must be the name of the uniform to use.
  54859. * Can only be set on inputs
  54860. */
  54861. isUniform: boolean;
  54862. /**
  54863. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  54864. * In this case the connection point name must be the name of the attribute to use
  54865. * Can only be set on inputs
  54866. */
  54867. isAttribute: boolean;
  54868. /**
  54869. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  54870. * Can only be set on exit points
  54871. */
  54872. isVarying: boolean;
  54873. /**
  54874. * Gets a boolean indicating that the current connection point is a system value
  54875. */
  54876. readonly isSystemValue: boolean;
  54877. /**
  54878. * Gets or sets the current well known value or null if not defined as a system value
  54879. */
  54880. systemValue: Nullable<NodeMaterialSystemValues>;
  54881. /**
  54882. * Gets the current class name
  54883. * @returns the class name
  54884. */
  54885. getClassName(): string;
  54886. /**
  54887. * Animate the input if animationType !== None
  54888. * @param scene defines the rendering scene
  54889. */
  54890. animate(scene: Scene): void;
  54891. private _emitDefine;
  54892. initialize(state: NodeMaterialBuildState): void;
  54893. /**
  54894. * Set the input block to its default value (based on its type)
  54895. */
  54896. setDefaultValue(): void;
  54897. private _emitConstant;
  54898. private _emit;
  54899. /** @hidden */
  54900. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  54901. /** @hidden */
  54902. _transmit(effect: Effect, scene: Scene): void;
  54903. protected _buildBlock(state: NodeMaterialBuildState): void;
  54904. protected _dumpPropertiesCode(): string;
  54905. serialize(): any;
  54906. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54907. }
  54908. }
  54909. declare module BABYLON {
  54910. /**
  54911. * Enum used to define the compatibility state between two connection points
  54912. */
  54913. export enum NodeMaterialConnectionPointCompatibilityStates {
  54914. /** Points are compatibles */
  54915. Compatible = 0,
  54916. /** Points are incompatible because of their types */
  54917. TypeIncompatible = 1,
  54918. /** Points are incompatible because of their targets (vertex vs fragment) */
  54919. TargetIncompatible = 2
  54920. }
  54921. /**
  54922. * Defines the direction of a connection point
  54923. */
  54924. export enum NodeMaterialConnectionPointDirection {
  54925. /** Input */
  54926. Input = 0,
  54927. /** Output */
  54928. Output = 1
  54929. }
  54930. /**
  54931. * Defines a connection point for a block
  54932. */
  54933. export class NodeMaterialConnectionPoint {
  54934. /** @hidden */
  54935. _ownerBlock: NodeMaterialBlock;
  54936. /** @hidden */
  54937. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54938. private _endpoints;
  54939. private _associatedVariableName;
  54940. private _direction;
  54941. /** @hidden */
  54942. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54943. /** @hidden */
  54944. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54945. private _type;
  54946. /** @hidden */
  54947. _enforceAssociatedVariableName: boolean;
  54948. /** Gets the direction of the point */
  54949. readonly direction: NodeMaterialConnectionPointDirection;
  54950. /**
  54951. * Gets or sets the additional types supported by this connection point
  54952. */
  54953. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  54954. /**
  54955. * Gets or sets the additional types excluded by this connection point
  54956. */
  54957. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  54958. /**
  54959. * Observable triggered when this point is connected
  54960. */
  54961. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  54962. /**
  54963. * Gets or sets the associated variable name in the shader
  54964. */
  54965. associatedVariableName: string;
  54966. /**
  54967. * Gets or sets the connection point type (default is float)
  54968. */
  54969. type: NodeMaterialBlockConnectionPointTypes;
  54970. /**
  54971. * Gets or sets the connection point name
  54972. */
  54973. name: string;
  54974. /**
  54975. * Gets or sets a boolean indicating that this connection point can be omitted
  54976. */
  54977. isOptional: boolean;
  54978. /**
  54979. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  54980. */
  54981. define: string;
  54982. /** @hidden */
  54983. _prioritizeVertex: boolean;
  54984. private _target;
  54985. /** Gets or sets the target of that connection point */
  54986. target: NodeMaterialBlockTargets;
  54987. /**
  54988. * Gets a boolean indicating that the current point is connected
  54989. */
  54990. readonly isConnected: boolean;
  54991. /**
  54992. * Gets a boolean indicating that the current point is connected to an input block
  54993. */
  54994. readonly isConnectedToInputBlock: boolean;
  54995. /**
  54996. * Gets a the connected input block (if any)
  54997. */
  54998. readonly connectInputBlock: Nullable<InputBlock>;
  54999. /** Get the other side of the connection (if any) */
  55000. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55001. /** Get the block that owns this connection point */
  55002. readonly ownerBlock: NodeMaterialBlock;
  55003. /** Get the block connected on the other side of this connection (if any) */
  55004. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55005. /** Get the block connected on the endpoints of this connection (if any) */
  55006. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55007. /** Gets the list of connected endpoints */
  55008. readonly endpoints: NodeMaterialConnectionPoint[];
  55009. /** Gets a boolean indicating if that output point is connected to at least one input */
  55010. readonly hasEndpoints: boolean;
  55011. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  55012. readonly isConnectedInVertexShader: boolean;
  55013. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  55014. readonly isConnectedInFragmentShader: boolean;
  55015. /**
  55016. * Creates a new connection point
  55017. * @param name defines the connection point name
  55018. * @param ownerBlock defines the block hosting this connection point
  55019. * @param direction defines the direction of the connection point
  55020. */
  55021. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  55022. /**
  55023. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55024. * @returns the class name
  55025. */
  55026. getClassName(): string;
  55027. /**
  55028. * Gets a boolean indicating if the current point can be connected to another point
  55029. * @param connectionPoint defines the other connection point
  55030. * @returns a boolean
  55031. */
  55032. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55033. /**
  55034. * Gets a number indicating if the current point can be connected to another point
  55035. * @param connectionPoint defines the other connection point
  55036. * @returns a number defining the compatibility state
  55037. */
  55038. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  55039. /**
  55040. * Connect this point to another connection point
  55041. * @param connectionPoint defines the other connection point
  55042. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  55043. * @returns the current connection point
  55044. */
  55045. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  55046. /**
  55047. * Disconnect this point from one of his endpoint
  55048. * @param endpoint defines the other connection point
  55049. * @returns the current connection point
  55050. */
  55051. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55052. /**
  55053. * Serializes this point in a JSON representation
  55054. * @returns the serialized point object
  55055. */
  55056. serialize(): any;
  55057. /**
  55058. * Release resources
  55059. */
  55060. dispose(): void;
  55061. }
  55062. }
  55063. declare module BABYLON {
  55064. /**
  55065. * Block used to add support for vertex skinning (bones)
  55066. */
  55067. export class BonesBlock extends NodeMaterialBlock {
  55068. /**
  55069. * Creates a new BonesBlock
  55070. * @param name defines the block name
  55071. */
  55072. constructor(name: string);
  55073. /**
  55074. * Initialize the block and prepare the context for build
  55075. * @param state defines the state that will be used for the build
  55076. */
  55077. initialize(state: NodeMaterialBuildState): void;
  55078. /**
  55079. * Gets the current class name
  55080. * @returns the class name
  55081. */
  55082. getClassName(): string;
  55083. /**
  55084. * Gets the matrix indices input component
  55085. */
  55086. readonly matricesIndices: NodeMaterialConnectionPoint;
  55087. /**
  55088. * Gets the matrix weights input component
  55089. */
  55090. readonly matricesWeights: NodeMaterialConnectionPoint;
  55091. /**
  55092. * Gets the extra matrix indices input component
  55093. */
  55094. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55095. /**
  55096. * Gets the extra matrix weights input component
  55097. */
  55098. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55099. /**
  55100. * Gets the world input component
  55101. */
  55102. readonly world: NodeMaterialConnectionPoint;
  55103. /**
  55104. * Gets the output component
  55105. */
  55106. readonly output: NodeMaterialConnectionPoint;
  55107. autoConfigure(material: NodeMaterial): void;
  55108. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55109. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55110. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55111. protected _buildBlock(state: NodeMaterialBuildState): this;
  55112. }
  55113. }
  55114. declare module BABYLON {
  55115. /**
  55116. * Block used to add support for instances
  55117. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55118. */
  55119. export class InstancesBlock extends NodeMaterialBlock {
  55120. /**
  55121. * Creates a new InstancesBlock
  55122. * @param name defines the block name
  55123. */
  55124. constructor(name: string);
  55125. /**
  55126. * Gets the current class name
  55127. * @returns the class name
  55128. */
  55129. getClassName(): string;
  55130. /**
  55131. * Gets the first world row input component
  55132. */
  55133. readonly world0: NodeMaterialConnectionPoint;
  55134. /**
  55135. * Gets the second world row input component
  55136. */
  55137. readonly world1: NodeMaterialConnectionPoint;
  55138. /**
  55139. * Gets the third world row input component
  55140. */
  55141. readonly world2: NodeMaterialConnectionPoint;
  55142. /**
  55143. * Gets the forth world row input component
  55144. */
  55145. readonly world3: NodeMaterialConnectionPoint;
  55146. /**
  55147. * Gets the world input component
  55148. */
  55149. readonly world: NodeMaterialConnectionPoint;
  55150. /**
  55151. * Gets the output component
  55152. */
  55153. readonly output: NodeMaterialConnectionPoint;
  55154. autoConfigure(material: NodeMaterial): void;
  55155. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55156. protected _buildBlock(state: NodeMaterialBuildState): this;
  55157. }
  55158. }
  55159. declare module BABYLON {
  55160. /**
  55161. * Block used to add morph targets support to vertex shader
  55162. */
  55163. export class MorphTargetsBlock extends NodeMaterialBlock {
  55164. private _repeatableContentAnchor;
  55165. private _repeatebleContentGenerated;
  55166. /**
  55167. * Create a new MorphTargetsBlock
  55168. * @param name defines the block name
  55169. */
  55170. constructor(name: string);
  55171. /**
  55172. * Gets the current class name
  55173. * @returns the class name
  55174. */
  55175. getClassName(): string;
  55176. /**
  55177. * Gets the position input component
  55178. */
  55179. readonly position: NodeMaterialConnectionPoint;
  55180. /**
  55181. * Gets the normal input component
  55182. */
  55183. readonly normal: NodeMaterialConnectionPoint;
  55184. /**
  55185. * Gets the tangent input component
  55186. */
  55187. readonly tangent: NodeMaterialConnectionPoint;
  55188. /**
  55189. * Gets the tangent input component
  55190. */
  55191. readonly uv: NodeMaterialConnectionPoint;
  55192. /**
  55193. * Gets the position output component
  55194. */
  55195. readonly positionOutput: NodeMaterialConnectionPoint;
  55196. /**
  55197. * Gets the normal output component
  55198. */
  55199. readonly normalOutput: NodeMaterialConnectionPoint;
  55200. /**
  55201. * Gets the tangent output component
  55202. */
  55203. readonly tangentOutput: NodeMaterialConnectionPoint;
  55204. /**
  55205. * Gets the tangent output component
  55206. */
  55207. readonly uvOutput: NodeMaterialConnectionPoint;
  55208. initialize(state: NodeMaterialBuildState): void;
  55209. autoConfigure(material: NodeMaterial): void;
  55210. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55211. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55212. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55213. protected _buildBlock(state: NodeMaterialBuildState): this;
  55214. }
  55215. }
  55216. declare module BABYLON {
  55217. /**
  55218. * Block used to get data information from a light
  55219. */
  55220. export class LightInformationBlock extends NodeMaterialBlock {
  55221. private _lightDataUniformName;
  55222. private _lightColorUniformName;
  55223. private _lightTypeDefineName;
  55224. /**
  55225. * Gets or sets the light associated with this block
  55226. */
  55227. light: Nullable<Light>;
  55228. /**
  55229. * Creates a new LightInformationBlock
  55230. * @param name defines the block name
  55231. */
  55232. constructor(name: string);
  55233. /**
  55234. * Gets the current class name
  55235. * @returns the class name
  55236. */
  55237. getClassName(): string;
  55238. /**
  55239. * Gets the world position input component
  55240. */
  55241. readonly worldPosition: NodeMaterialConnectionPoint;
  55242. /**
  55243. * Gets the direction output component
  55244. */
  55245. readonly direction: NodeMaterialConnectionPoint;
  55246. /**
  55247. * Gets the direction output component
  55248. */
  55249. readonly color: NodeMaterialConnectionPoint;
  55250. /**
  55251. * Gets the direction output component
  55252. */
  55253. readonly intensity: NodeMaterialConnectionPoint;
  55254. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55255. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55256. protected _buildBlock(state: NodeMaterialBuildState): this;
  55257. serialize(): any;
  55258. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55259. }
  55260. }
  55261. declare module BABYLON {
  55262. /**
  55263. * Block used to add image processing support to fragment shader
  55264. */
  55265. export class ImageProcessingBlock extends NodeMaterialBlock {
  55266. /**
  55267. * Create a new ImageProcessingBlock
  55268. * @param name defines the block name
  55269. */
  55270. constructor(name: string);
  55271. /**
  55272. * Gets the current class name
  55273. * @returns the class name
  55274. */
  55275. getClassName(): string;
  55276. /**
  55277. * Gets the color input component
  55278. */
  55279. readonly color: NodeMaterialConnectionPoint;
  55280. /**
  55281. * Gets the output component
  55282. */
  55283. readonly output: NodeMaterialConnectionPoint;
  55284. /**
  55285. * Initialize the block and prepare the context for build
  55286. * @param state defines the state that will be used for the build
  55287. */
  55288. initialize(state: NodeMaterialBuildState): void;
  55289. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  55290. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55291. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55292. protected _buildBlock(state: NodeMaterialBuildState): this;
  55293. }
  55294. }
  55295. declare module BABYLON {
  55296. /**
  55297. * Block used to pertub normals based on a normal map
  55298. */
  55299. export class PerturbNormalBlock extends NodeMaterialBlock {
  55300. private _tangentSpaceParameterName;
  55301. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  55302. invertX: boolean;
  55303. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  55304. invertY: boolean;
  55305. /**
  55306. * Create a new PerturbNormalBlock
  55307. * @param name defines the block name
  55308. */
  55309. constructor(name: string);
  55310. /**
  55311. * Gets the current class name
  55312. * @returns the class name
  55313. */
  55314. getClassName(): string;
  55315. /**
  55316. * Gets the world position input component
  55317. */
  55318. readonly worldPosition: NodeMaterialConnectionPoint;
  55319. /**
  55320. * Gets the world normal input component
  55321. */
  55322. readonly worldNormal: NodeMaterialConnectionPoint;
  55323. /**
  55324. * Gets the uv input component
  55325. */
  55326. readonly uv: NodeMaterialConnectionPoint;
  55327. /**
  55328. * Gets the normal map color input component
  55329. */
  55330. readonly normalMapColor: NodeMaterialConnectionPoint;
  55331. /**
  55332. * Gets the strength input component
  55333. */
  55334. readonly strength: NodeMaterialConnectionPoint;
  55335. /**
  55336. * Gets the output component
  55337. */
  55338. readonly output: NodeMaterialConnectionPoint;
  55339. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55340. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55341. autoConfigure(material: NodeMaterial): void;
  55342. protected _buildBlock(state: NodeMaterialBuildState): this;
  55343. protected _dumpPropertiesCode(): string;
  55344. serialize(): any;
  55345. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55346. }
  55347. }
  55348. declare module BABYLON {
  55349. /**
  55350. * Block used to discard a pixel if a value is smaller than a cutoff
  55351. */
  55352. export class DiscardBlock extends NodeMaterialBlock {
  55353. /**
  55354. * Create a new DiscardBlock
  55355. * @param name defines the block name
  55356. */
  55357. constructor(name: string);
  55358. /**
  55359. * Gets the current class name
  55360. * @returns the class name
  55361. */
  55362. getClassName(): string;
  55363. /**
  55364. * Gets the color input component
  55365. */
  55366. readonly value: NodeMaterialConnectionPoint;
  55367. /**
  55368. * Gets the cutoff input component
  55369. */
  55370. readonly cutoff: NodeMaterialConnectionPoint;
  55371. protected _buildBlock(state: NodeMaterialBuildState): this;
  55372. }
  55373. }
  55374. declare module BABYLON {
  55375. /**
  55376. * Block used to test if the fragment shader is front facing
  55377. */
  55378. export class FrontFacingBlock extends NodeMaterialBlock {
  55379. /**
  55380. * Creates a new FrontFacingBlock
  55381. * @param name defines the block name
  55382. */
  55383. constructor(name: string);
  55384. /**
  55385. * Gets the current class name
  55386. * @returns the class name
  55387. */
  55388. getClassName(): string;
  55389. /**
  55390. * Gets the output component
  55391. */
  55392. readonly output: NodeMaterialConnectionPoint;
  55393. protected _buildBlock(state: NodeMaterialBuildState): this;
  55394. }
  55395. }
  55396. declare module BABYLON {
  55397. /**
  55398. * Block used to get the derivative value on x and y of a given input
  55399. */
  55400. export class DerivativeBlock extends NodeMaterialBlock {
  55401. /**
  55402. * Create a new DerivativeBlock
  55403. * @param name defines the block name
  55404. */
  55405. constructor(name: string);
  55406. /**
  55407. * Gets the current class name
  55408. * @returns the class name
  55409. */
  55410. getClassName(): string;
  55411. /**
  55412. * Gets the input component
  55413. */
  55414. readonly input: NodeMaterialConnectionPoint;
  55415. /**
  55416. * Gets the derivative output on x
  55417. */
  55418. readonly dx: NodeMaterialConnectionPoint;
  55419. /**
  55420. * Gets the derivative output on y
  55421. */
  55422. readonly dy: NodeMaterialConnectionPoint;
  55423. protected _buildBlock(state: NodeMaterialBuildState): this;
  55424. }
  55425. }
  55426. declare module BABYLON {
  55427. /**
  55428. * Block used to add support for scene fog
  55429. */
  55430. export class FogBlock extends NodeMaterialBlock {
  55431. private _fogDistanceName;
  55432. private _fogParameters;
  55433. /**
  55434. * Create a new FogBlock
  55435. * @param name defines the block name
  55436. */
  55437. constructor(name: string);
  55438. /**
  55439. * Gets the current class name
  55440. * @returns the class name
  55441. */
  55442. getClassName(): string;
  55443. /**
  55444. * Gets the world position input component
  55445. */
  55446. readonly worldPosition: NodeMaterialConnectionPoint;
  55447. /**
  55448. * Gets the view input component
  55449. */
  55450. readonly view: NodeMaterialConnectionPoint;
  55451. /**
  55452. * Gets the color input component
  55453. */
  55454. readonly input: NodeMaterialConnectionPoint;
  55455. /**
  55456. * Gets the fog color input component
  55457. */
  55458. readonly fogColor: NodeMaterialConnectionPoint;
  55459. /**
  55460. * Gets the output component
  55461. */
  55462. readonly output: NodeMaterialConnectionPoint;
  55463. autoConfigure(material: NodeMaterial): void;
  55464. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55465. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55466. protected _buildBlock(state: NodeMaterialBuildState): this;
  55467. }
  55468. }
  55469. declare module BABYLON {
  55470. /**
  55471. * Block used to add light in the fragment shader
  55472. */
  55473. export class LightBlock extends NodeMaterialBlock {
  55474. private _lightId;
  55475. /**
  55476. * Gets or sets the light associated with this block
  55477. */
  55478. light: Nullable<Light>;
  55479. /**
  55480. * Create a new LightBlock
  55481. * @param name defines the block name
  55482. */
  55483. constructor(name: string);
  55484. /**
  55485. * Gets the current class name
  55486. * @returns the class name
  55487. */
  55488. getClassName(): string;
  55489. /**
  55490. * Gets the world position input component
  55491. */
  55492. readonly worldPosition: NodeMaterialConnectionPoint;
  55493. /**
  55494. * Gets the world normal input component
  55495. */
  55496. readonly worldNormal: NodeMaterialConnectionPoint;
  55497. /**
  55498. * Gets the camera (or eye) position component
  55499. */
  55500. readonly cameraPosition: NodeMaterialConnectionPoint;
  55501. /**
  55502. * Gets the glossiness component
  55503. */
  55504. readonly glossiness: NodeMaterialConnectionPoint;
  55505. /**
  55506. * Gets the glossinness power component
  55507. */
  55508. readonly glossPower: NodeMaterialConnectionPoint;
  55509. /**
  55510. * Gets the diffuse color component
  55511. */
  55512. readonly diffuseColor: NodeMaterialConnectionPoint;
  55513. /**
  55514. * Gets the specular color component
  55515. */
  55516. readonly specularColor: NodeMaterialConnectionPoint;
  55517. /**
  55518. * Gets the diffuse output component
  55519. */
  55520. readonly diffuseOutput: NodeMaterialConnectionPoint;
  55521. /**
  55522. * Gets the specular output component
  55523. */
  55524. readonly specularOutput: NodeMaterialConnectionPoint;
  55525. autoConfigure(material: NodeMaterial): void;
  55526. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55527. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  55528. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55529. private _injectVertexCode;
  55530. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55531. serialize(): any;
  55532. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55533. }
  55534. }
  55535. declare module BABYLON {
  55536. /**
  55537. * Block used to multiply 2 values
  55538. */
  55539. export class MultiplyBlock extends NodeMaterialBlock {
  55540. /**
  55541. * Creates a new MultiplyBlock
  55542. * @param name defines the block name
  55543. */
  55544. constructor(name: string);
  55545. /**
  55546. * Gets the current class name
  55547. * @returns the class name
  55548. */
  55549. getClassName(): string;
  55550. /**
  55551. * Gets the left operand input component
  55552. */
  55553. readonly left: NodeMaterialConnectionPoint;
  55554. /**
  55555. * Gets the right operand input component
  55556. */
  55557. readonly right: NodeMaterialConnectionPoint;
  55558. /**
  55559. * Gets the output component
  55560. */
  55561. readonly output: NodeMaterialConnectionPoint;
  55562. protected _buildBlock(state: NodeMaterialBuildState): this;
  55563. }
  55564. }
  55565. declare module BABYLON {
  55566. /**
  55567. * Block used to add 2 vectors
  55568. */
  55569. export class AddBlock extends NodeMaterialBlock {
  55570. /**
  55571. * Creates a new AddBlock
  55572. * @param name defines the block name
  55573. */
  55574. constructor(name: string);
  55575. /**
  55576. * Gets the current class name
  55577. * @returns the class name
  55578. */
  55579. getClassName(): string;
  55580. /**
  55581. * Gets the left operand input component
  55582. */
  55583. readonly left: NodeMaterialConnectionPoint;
  55584. /**
  55585. * Gets the right operand input component
  55586. */
  55587. readonly right: NodeMaterialConnectionPoint;
  55588. /**
  55589. * Gets the output component
  55590. */
  55591. readonly output: NodeMaterialConnectionPoint;
  55592. protected _buildBlock(state: NodeMaterialBuildState): this;
  55593. }
  55594. }
  55595. declare module BABYLON {
  55596. /**
  55597. * Block used to scale a vector by a float
  55598. */
  55599. export class ScaleBlock extends NodeMaterialBlock {
  55600. /**
  55601. * Creates a new ScaleBlock
  55602. * @param name defines the block name
  55603. */
  55604. constructor(name: string);
  55605. /**
  55606. * Gets the current class name
  55607. * @returns the class name
  55608. */
  55609. getClassName(): string;
  55610. /**
  55611. * Gets the input component
  55612. */
  55613. readonly input: NodeMaterialConnectionPoint;
  55614. /**
  55615. * Gets the factor input component
  55616. */
  55617. readonly factor: NodeMaterialConnectionPoint;
  55618. /**
  55619. * Gets the output component
  55620. */
  55621. readonly output: NodeMaterialConnectionPoint;
  55622. protected _buildBlock(state: NodeMaterialBuildState): this;
  55623. }
  55624. }
  55625. declare module BABYLON {
  55626. /**
  55627. * Block used to clamp a float
  55628. */
  55629. export class ClampBlock extends NodeMaterialBlock {
  55630. /** Gets or sets the minimum range */
  55631. minimum: number;
  55632. /** Gets or sets the maximum range */
  55633. maximum: number;
  55634. /**
  55635. * Creates a new ClampBlock
  55636. * @param name defines the block name
  55637. */
  55638. constructor(name: string);
  55639. /**
  55640. * Gets the current class name
  55641. * @returns the class name
  55642. */
  55643. getClassName(): string;
  55644. /**
  55645. * Gets the value input component
  55646. */
  55647. readonly value: NodeMaterialConnectionPoint;
  55648. /**
  55649. * Gets the output component
  55650. */
  55651. readonly output: NodeMaterialConnectionPoint;
  55652. protected _buildBlock(state: NodeMaterialBuildState): this;
  55653. protected _dumpPropertiesCode(): string;
  55654. serialize(): any;
  55655. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55656. }
  55657. }
  55658. declare module BABYLON {
  55659. /**
  55660. * Block used to apply a cross product between 2 vectors
  55661. */
  55662. export class CrossBlock extends NodeMaterialBlock {
  55663. /**
  55664. * Creates a new CrossBlock
  55665. * @param name defines the block name
  55666. */
  55667. constructor(name: string);
  55668. /**
  55669. * Gets the current class name
  55670. * @returns the class name
  55671. */
  55672. getClassName(): string;
  55673. /**
  55674. * Gets the left operand input component
  55675. */
  55676. readonly left: NodeMaterialConnectionPoint;
  55677. /**
  55678. * Gets the right operand input component
  55679. */
  55680. readonly right: NodeMaterialConnectionPoint;
  55681. /**
  55682. * Gets the output component
  55683. */
  55684. readonly output: NodeMaterialConnectionPoint;
  55685. protected _buildBlock(state: NodeMaterialBuildState): this;
  55686. }
  55687. }
  55688. declare module BABYLON {
  55689. /**
  55690. * Block used to apply a dot product between 2 vectors
  55691. */
  55692. export class DotBlock extends NodeMaterialBlock {
  55693. /**
  55694. * Creates a new DotBlock
  55695. * @param name defines the block name
  55696. */
  55697. constructor(name: string);
  55698. /**
  55699. * Gets the current class name
  55700. * @returns the class name
  55701. */
  55702. getClassName(): string;
  55703. /**
  55704. * Gets the left operand input component
  55705. */
  55706. readonly left: NodeMaterialConnectionPoint;
  55707. /**
  55708. * Gets the right operand input component
  55709. */
  55710. readonly right: NodeMaterialConnectionPoint;
  55711. /**
  55712. * Gets the output component
  55713. */
  55714. readonly output: NodeMaterialConnectionPoint;
  55715. protected _buildBlock(state: NodeMaterialBuildState): this;
  55716. }
  55717. }
  55718. declare module BABYLON {
  55719. /**
  55720. * Block used to remap a float from a range to a new one
  55721. */
  55722. export class RemapBlock extends NodeMaterialBlock {
  55723. /**
  55724. * Gets or sets the source range
  55725. */
  55726. sourceRange: Vector2;
  55727. /**
  55728. * Gets or sets the target range
  55729. */
  55730. targetRange: Vector2;
  55731. /**
  55732. * Creates a new RemapBlock
  55733. * @param name defines the block name
  55734. */
  55735. constructor(name: string);
  55736. /**
  55737. * Gets the current class name
  55738. * @returns the class name
  55739. */
  55740. getClassName(): string;
  55741. /**
  55742. * Gets the input component
  55743. */
  55744. readonly input: NodeMaterialConnectionPoint;
  55745. /**
  55746. * Gets the source min input component
  55747. */
  55748. readonly sourceMin: NodeMaterialConnectionPoint;
  55749. /**
  55750. * Gets the source max input component
  55751. */
  55752. readonly sourceMax: NodeMaterialConnectionPoint;
  55753. /**
  55754. * Gets the target min input component
  55755. */
  55756. readonly targetMin: NodeMaterialConnectionPoint;
  55757. /**
  55758. * Gets the target max input component
  55759. */
  55760. readonly targetMax: NodeMaterialConnectionPoint;
  55761. /**
  55762. * Gets the output component
  55763. */
  55764. readonly output: NodeMaterialConnectionPoint;
  55765. protected _buildBlock(state: NodeMaterialBuildState): this;
  55766. protected _dumpPropertiesCode(): string;
  55767. serialize(): any;
  55768. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55769. }
  55770. }
  55771. declare module BABYLON {
  55772. /**
  55773. * Block used to normalize a vector
  55774. */
  55775. export class NormalizeBlock extends NodeMaterialBlock {
  55776. /**
  55777. * Creates a new NormalizeBlock
  55778. * @param name defines the block name
  55779. */
  55780. constructor(name: string);
  55781. /**
  55782. * Gets the current class name
  55783. * @returns the class name
  55784. */
  55785. getClassName(): string;
  55786. /**
  55787. * Gets the input component
  55788. */
  55789. readonly input: NodeMaterialConnectionPoint;
  55790. /**
  55791. * Gets the output component
  55792. */
  55793. readonly output: NodeMaterialConnectionPoint;
  55794. protected _buildBlock(state: NodeMaterialBuildState): this;
  55795. }
  55796. }
  55797. declare module BABYLON {
  55798. /**
  55799. * Operations supported by the Trigonometry block
  55800. */
  55801. export enum TrigonometryBlockOperations {
  55802. /** Cos */
  55803. Cos = 0,
  55804. /** Sin */
  55805. Sin = 1,
  55806. /** Abs */
  55807. Abs = 2,
  55808. /** Exp */
  55809. Exp = 3,
  55810. /** Exp2 */
  55811. Exp2 = 4,
  55812. /** Round */
  55813. Round = 5,
  55814. /** Floor */
  55815. Floor = 6,
  55816. /** Ceiling */
  55817. Ceiling = 7,
  55818. /** Square root */
  55819. Sqrt = 8,
  55820. /** Log */
  55821. Log = 9,
  55822. /** Tangent */
  55823. Tan = 10,
  55824. /** Arc tangent */
  55825. ArcTan = 11,
  55826. /** Arc cosinus */
  55827. ArcCos = 12,
  55828. /** Arc sinus */
  55829. ArcSin = 13,
  55830. /** Fraction */
  55831. Fract = 14,
  55832. /** Sign */
  55833. Sign = 15,
  55834. /** To radians (from degrees) */
  55835. Radians = 16,
  55836. /** To degrees (from radians) */
  55837. Degrees = 17
  55838. }
  55839. /**
  55840. * Block used to apply trigonometry operation to floats
  55841. */
  55842. export class TrigonometryBlock extends NodeMaterialBlock {
  55843. /**
  55844. * Gets or sets the operation applied by the block
  55845. */
  55846. operation: TrigonometryBlockOperations;
  55847. /**
  55848. * Creates a new TrigonometryBlock
  55849. * @param name defines the block name
  55850. */
  55851. constructor(name: string);
  55852. /**
  55853. * Gets the current class name
  55854. * @returns the class name
  55855. */
  55856. getClassName(): string;
  55857. /**
  55858. * Gets the input component
  55859. */
  55860. readonly input: NodeMaterialConnectionPoint;
  55861. /**
  55862. * Gets the output component
  55863. */
  55864. readonly output: NodeMaterialConnectionPoint;
  55865. protected _buildBlock(state: NodeMaterialBuildState): this;
  55866. serialize(): any;
  55867. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55868. protected _dumpPropertiesCode(): string;
  55869. }
  55870. }
  55871. declare module BABYLON {
  55872. /**
  55873. * Block used to create a Color3/4 out of individual inputs (one for each component)
  55874. */
  55875. export class ColorMergerBlock extends NodeMaterialBlock {
  55876. /**
  55877. * Create a new ColorMergerBlock
  55878. * @param name defines the block name
  55879. */
  55880. constructor(name: string);
  55881. /**
  55882. * Gets the current class name
  55883. * @returns the class name
  55884. */
  55885. getClassName(): string;
  55886. /**
  55887. * Gets the rgb component (input)
  55888. */
  55889. readonly rgbIn: NodeMaterialConnectionPoint;
  55890. /**
  55891. * Gets the r component (input)
  55892. */
  55893. readonly r: NodeMaterialConnectionPoint;
  55894. /**
  55895. * Gets the g component (input)
  55896. */
  55897. readonly g: NodeMaterialConnectionPoint;
  55898. /**
  55899. * Gets the b component (input)
  55900. */
  55901. readonly b: NodeMaterialConnectionPoint;
  55902. /**
  55903. * Gets the a component (input)
  55904. */
  55905. readonly a: NodeMaterialConnectionPoint;
  55906. /**
  55907. * Gets the rgba component (output)
  55908. */
  55909. readonly rgba: NodeMaterialConnectionPoint;
  55910. /**
  55911. * Gets the rgb component (output)
  55912. */
  55913. readonly rgbOut: NodeMaterialConnectionPoint;
  55914. /**
  55915. * Gets the rgb component (output)
  55916. * @deprecated Please use rgbOut instead.
  55917. */
  55918. readonly rgb: NodeMaterialConnectionPoint;
  55919. protected _buildBlock(state: NodeMaterialBuildState): this;
  55920. }
  55921. }
  55922. declare module BABYLON {
  55923. /**
  55924. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  55925. */
  55926. export class VectorMergerBlock extends NodeMaterialBlock {
  55927. /**
  55928. * Create a new VectorMergerBlock
  55929. * @param name defines the block name
  55930. */
  55931. constructor(name: string);
  55932. /**
  55933. * Gets the current class name
  55934. * @returns the class name
  55935. */
  55936. getClassName(): string;
  55937. /**
  55938. * Gets the xyz component (input)
  55939. */
  55940. readonly xyzIn: NodeMaterialConnectionPoint;
  55941. /**
  55942. * Gets the xy component (input)
  55943. */
  55944. readonly xyIn: NodeMaterialConnectionPoint;
  55945. /**
  55946. * Gets the x component (input)
  55947. */
  55948. readonly x: NodeMaterialConnectionPoint;
  55949. /**
  55950. * Gets the y component (input)
  55951. */
  55952. readonly y: NodeMaterialConnectionPoint;
  55953. /**
  55954. * Gets the z component (input)
  55955. */
  55956. readonly z: NodeMaterialConnectionPoint;
  55957. /**
  55958. * Gets the w component (input)
  55959. */
  55960. readonly w: NodeMaterialConnectionPoint;
  55961. /**
  55962. * Gets the xyzw component (output)
  55963. */
  55964. readonly xyzw: NodeMaterialConnectionPoint;
  55965. /**
  55966. * Gets the xyz component (output)
  55967. */
  55968. readonly xyzOut: NodeMaterialConnectionPoint;
  55969. /**
  55970. * Gets the xy component (output)
  55971. */
  55972. readonly xyOut: NodeMaterialConnectionPoint;
  55973. /**
  55974. * Gets the xy component (output)
  55975. * @deprecated Please use xyOut instead.
  55976. */
  55977. readonly xy: NodeMaterialConnectionPoint;
  55978. /**
  55979. * Gets the xyz component (output)
  55980. * @deprecated Please use xyzOut instead.
  55981. */
  55982. readonly xyz: NodeMaterialConnectionPoint;
  55983. protected _buildBlock(state: NodeMaterialBuildState): this;
  55984. }
  55985. }
  55986. declare module BABYLON {
  55987. /**
  55988. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  55989. */
  55990. export class ColorSplitterBlock extends NodeMaterialBlock {
  55991. /**
  55992. * Create a new ColorSplitterBlock
  55993. * @param name defines the block name
  55994. */
  55995. constructor(name: string);
  55996. /**
  55997. * Gets the current class name
  55998. * @returns the class name
  55999. */
  56000. getClassName(): string;
  56001. /**
  56002. * Gets the rgba component (input)
  56003. */
  56004. readonly rgba: NodeMaterialConnectionPoint;
  56005. /**
  56006. * Gets the rgb component (input)
  56007. */
  56008. readonly rgbIn: NodeMaterialConnectionPoint;
  56009. /**
  56010. * Gets the rgb component (output)
  56011. */
  56012. readonly rgbOut: NodeMaterialConnectionPoint;
  56013. /**
  56014. * Gets the r component (output)
  56015. */
  56016. readonly r: NodeMaterialConnectionPoint;
  56017. /**
  56018. * Gets the g component (output)
  56019. */
  56020. readonly g: NodeMaterialConnectionPoint;
  56021. /**
  56022. * Gets the b component (output)
  56023. */
  56024. readonly b: NodeMaterialConnectionPoint;
  56025. /**
  56026. * Gets the a component (output)
  56027. */
  56028. readonly a: NodeMaterialConnectionPoint;
  56029. protected _inputRename(name: string): string;
  56030. protected _outputRename(name: string): string;
  56031. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56032. }
  56033. }
  56034. declare module BABYLON {
  56035. /**
  56036. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56037. */
  56038. export class VectorSplitterBlock extends NodeMaterialBlock {
  56039. /**
  56040. * Create a new VectorSplitterBlock
  56041. * @param name defines the block name
  56042. */
  56043. constructor(name: string);
  56044. /**
  56045. * Gets the current class name
  56046. * @returns the class name
  56047. */
  56048. getClassName(): string;
  56049. /**
  56050. * Gets the xyzw component (input)
  56051. */
  56052. readonly xyzw: NodeMaterialConnectionPoint;
  56053. /**
  56054. * Gets the xyz component (input)
  56055. */
  56056. readonly xyzIn: NodeMaterialConnectionPoint;
  56057. /**
  56058. * Gets the xy component (input)
  56059. */
  56060. readonly xyIn: NodeMaterialConnectionPoint;
  56061. /**
  56062. * Gets the xyz component (output)
  56063. */
  56064. readonly xyzOut: NodeMaterialConnectionPoint;
  56065. /**
  56066. * Gets the xy component (output)
  56067. */
  56068. readonly xyOut: NodeMaterialConnectionPoint;
  56069. /**
  56070. * Gets the x component (output)
  56071. */
  56072. readonly x: NodeMaterialConnectionPoint;
  56073. /**
  56074. * Gets the y component (output)
  56075. */
  56076. readonly y: NodeMaterialConnectionPoint;
  56077. /**
  56078. * Gets the z component (output)
  56079. */
  56080. readonly z: NodeMaterialConnectionPoint;
  56081. /**
  56082. * Gets the w component (output)
  56083. */
  56084. readonly w: NodeMaterialConnectionPoint;
  56085. protected _inputRename(name: string): string;
  56086. protected _outputRename(name: string): string;
  56087. protected _buildBlock(state: NodeMaterialBuildState): this;
  56088. }
  56089. }
  56090. declare module BABYLON {
  56091. /**
  56092. * Block used to lerp between 2 values
  56093. */
  56094. export class LerpBlock extends NodeMaterialBlock {
  56095. /**
  56096. * Creates a new LerpBlock
  56097. * @param name defines the block name
  56098. */
  56099. constructor(name: string);
  56100. /**
  56101. * Gets the current class name
  56102. * @returns the class name
  56103. */
  56104. getClassName(): string;
  56105. /**
  56106. * Gets the left operand input component
  56107. */
  56108. readonly left: NodeMaterialConnectionPoint;
  56109. /**
  56110. * Gets the right operand input component
  56111. */
  56112. readonly right: NodeMaterialConnectionPoint;
  56113. /**
  56114. * Gets the gradient operand input component
  56115. */
  56116. readonly gradient: NodeMaterialConnectionPoint;
  56117. /**
  56118. * Gets the output component
  56119. */
  56120. readonly output: NodeMaterialConnectionPoint;
  56121. protected _buildBlock(state: NodeMaterialBuildState): this;
  56122. }
  56123. }
  56124. declare module BABYLON {
  56125. /**
  56126. * Block used to divide 2 vectors
  56127. */
  56128. export class DivideBlock extends NodeMaterialBlock {
  56129. /**
  56130. * Creates a new DivideBlock
  56131. * @param name defines the block name
  56132. */
  56133. constructor(name: string);
  56134. /**
  56135. * Gets the current class name
  56136. * @returns the class name
  56137. */
  56138. getClassName(): string;
  56139. /**
  56140. * Gets the left operand input component
  56141. */
  56142. readonly left: NodeMaterialConnectionPoint;
  56143. /**
  56144. * Gets the right operand input component
  56145. */
  56146. readonly right: NodeMaterialConnectionPoint;
  56147. /**
  56148. * Gets the output component
  56149. */
  56150. readonly output: NodeMaterialConnectionPoint;
  56151. protected _buildBlock(state: NodeMaterialBuildState): this;
  56152. }
  56153. }
  56154. declare module BABYLON {
  56155. /**
  56156. * Block used to subtract 2 vectors
  56157. */
  56158. export class SubtractBlock extends NodeMaterialBlock {
  56159. /**
  56160. * Creates a new SubtractBlock
  56161. * @param name defines the block name
  56162. */
  56163. constructor(name: string);
  56164. /**
  56165. * Gets the current class name
  56166. * @returns the class name
  56167. */
  56168. getClassName(): string;
  56169. /**
  56170. * Gets the left operand input component
  56171. */
  56172. readonly left: NodeMaterialConnectionPoint;
  56173. /**
  56174. * Gets the right operand input component
  56175. */
  56176. readonly right: NodeMaterialConnectionPoint;
  56177. /**
  56178. * Gets the output component
  56179. */
  56180. readonly output: NodeMaterialConnectionPoint;
  56181. protected _buildBlock(state: NodeMaterialBuildState): this;
  56182. }
  56183. }
  56184. declare module BABYLON {
  56185. /**
  56186. * Block used to step a value
  56187. */
  56188. export class StepBlock extends NodeMaterialBlock {
  56189. /**
  56190. * Creates a new StepBlock
  56191. * @param name defines the block name
  56192. */
  56193. constructor(name: string);
  56194. /**
  56195. * Gets the current class name
  56196. * @returns the class name
  56197. */
  56198. getClassName(): string;
  56199. /**
  56200. * Gets the value operand input component
  56201. */
  56202. readonly value: NodeMaterialConnectionPoint;
  56203. /**
  56204. * Gets the edge operand input component
  56205. */
  56206. readonly edge: NodeMaterialConnectionPoint;
  56207. /**
  56208. * Gets the output component
  56209. */
  56210. readonly output: NodeMaterialConnectionPoint;
  56211. protected _buildBlock(state: NodeMaterialBuildState): this;
  56212. }
  56213. }
  56214. declare module BABYLON {
  56215. /**
  56216. * Block used to get the opposite (1 - x) of a value
  56217. */
  56218. export class OneMinusBlock extends NodeMaterialBlock {
  56219. /**
  56220. * Creates a new OneMinusBlock
  56221. * @param name defines the block name
  56222. */
  56223. constructor(name: string);
  56224. /**
  56225. * Gets the current class name
  56226. * @returns the class name
  56227. */
  56228. getClassName(): string;
  56229. /**
  56230. * Gets the input component
  56231. */
  56232. readonly input: NodeMaterialConnectionPoint;
  56233. /**
  56234. * Gets the output component
  56235. */
  56236. readonly output: NodeMaterialConnectionPoint;
  56237. protected _buildBlock(state: NodeMaterialBuildState): this;
  56238. }
  56239. }
  56240. declare module BABYLON {
  56241. /**
  56242. * Block used to get the view direction
  56243. */
  56244. export class ViewDirectionBlock extends NodeMaterialBlock {
  56245. /**
  56246. * Creates a new ViewDirectionBlock
  56247. * @param name defines the block name
  56248. */
  56249. constructor(name: string);
  56250. /**
  56251. * Gets the current class name
  56252. * @returns the class name
  56253. */
  56254. getClassName(): string;
  56255. /**
  56256. * Gets the world position component
  56257. */
  56258. readonly worldPosition: NodeMaterialConnectionPoint;
  56259. /**
  56260. * Gets the camera position component
  56261. */
  56262. readonly cameraPosition: NodeMaterialConnectionPoint;
  56263. /**
  56264. * Gets the output component
  56265. */
  56266. readonly output: NodeMaterialConnectionPoint;
  56267. autoConfigure(material: NodeMaterial): void;
  56268. protected _buildBlock(state: NodeMaterialBuildState): this;
  56269. }
  56270. }
  56271. declare module BABYLON {
  56272. /**
  56273. * Block used to compute fresnel value
  56274. */
  56275. export class FresnelBlock extends NodeMaterialBlock {
  56276. /**
  56277. * Create a new FresnelBlock
  56278. * @param name defines the block name
  56279. */
  56280. constructor(name: string);
  56281. /**
  56282. * Gets the current class name
  56283. * @returns the class name
  56284. */
  56285. getClassName(): string;
  56286. /**
  56287. * Gets the world normal input component
  56288. */
  56289. readonly worldNormal: NodeMaterialConnectionPoint;
  56290. /**
  56291. * Gets the view direction input component
  56292. */
  56293. readonly viewDirection: NodeMaterialConnectionPoint;
  56294. /**
  56295. * Gets the bias input component
  56296. */
  56297. readonly bias: NodeMaterialConnectionPoint;
  56298. /**
  56299. * Gets the camera (or eye) position component
  56300. */
  56301. readonly power: NodeMaterialConnectionPoint;
  56302. /**
  56303. * Gets the fresnel output component
  56304. */
  56305. readonly fresnel: NodeMaterialConnectionPoint;
  56306. autoConfigure(material: NodeMaterial): void;
  56307. protected _buildBlock(state: NodeMaterialBuildState): this;
  56308. }
  56309. }
  56310. declare module BABYLON {
  56311. /**
  56312. * Block used to get the max of 2 values
  56313. */
  56314. export class MaxBlock extends NodeMaterialBlock {
  56315. /**
  56316. * Creates a new MaxBlock
  56317. * @param name defines the block name
  56318. */
  56319. constructor(name: string);
  56320. /**
  56321. * Gets the current class name
  56322. * @returns the class name
  56323. */
  56324. getClassName(): string;
  56325. /**
  56326. * Gets the left operand input component
  56327. */
  56328. readonly left: NodeMaterialConnectionPoint;
  56329. /**
  56330. * Gets the right operand input component
  56331. */
  56332. readonly right: NodeMaterialConnectionPoint;
  56333. /**
  56334. * Gets the output component
  56335. */
  56336. readonly output: NodeMaterialConnectionPoint;
  56337. protected _buildBlock(state: NodeMaterialBuildState): this;
  56338. }
  56339. }
  56340. declare module BABYLON {
  56341. /**
  56342. * Block used to get the min of 2 values
  56343. */
  56344. export class MinBlock extends NodeMaterialBlock {
  56345. /**
  56346. * Creates a new MinBlock
  56347. * @param name defines the block name
  56348. */
  56349. constructor(name: string);
  56350. /**
  56351. * Gets the current class name
  56352. * @returns the class name
  56353. */
  56354. getClassName(): string;
  56355. /**
  56356. * Gets the left operand input component
  56357. */
  56358. readonly left: NodeMaterialConnectionPoint;
  56359. /**
  56360. * Gets the right operand input component
  56361. */
  56362. readonly right: NodeMaterialConnectionPoint;
  56363. /**
  56364. * Gets the output component
  56365. */
  56366. readonly output: NodeMaterialConnectionPoint;
  56367. protected _buildBlock(state: NodeMaterialBuildState): this;
  56368. }
  56369. }
  56370. declare module BABYLON {
  56371. /**
  56372. * Block used to get the distance between 2 values
  56373. */
  56374. export class DistanceBlock extends NodeMaterialBlock {
  56375. /**
  56376. * Creates a new DistanceBlock
  56377. * @param name defines the block name
  56378. */
  56379. constructor(name: string);
  56380. /**
  56381. * Gets the current class name
  56382. * @returns the class name
  56383. */
  56384. getClassName(): string;
  56385. /**
  56386. * Gets the left operand input component
  56387. */
  56388. readonly left: NodeMaterialConnectionPoint;
  56389. /**
  56390. * Gets the right operand input component
  56391. */
  56392. readonly right: NodeMaterialConnectionPoint;
  56393. /**
  56394. * Gets the output component
  56395. */
  56396. readonly output: NodeMaterialConnectionPoint;
  56397. protected _buildBlock(state: NodeMaterialBuildState): this;
  56398. }
  56399. }
  56400. declare module BABYLON {
  56401. /**
  56402. * Block used to get the length of a vector
  56403. */
  56404. export class LengthBlock extends NodeMaterialBlock {
  56405. /**
  56406. * Creates a new LengthBlock
  56407. * @param name defines the block name
  56408. */
  56409. constructor(name: string);
  56410. /**
  56411. * Gets the current class name
  56412. * @returns the class name
  56413. */
  56414. getClassName(): string;
  56415. /**
  56416. * Gets the value input component
  56417. */
  56418. readonly value: NodeMaterialConnectionPoint;
  56419. /**
  56420. * Gets the output component
  56421. */
  56422. readonly output: NodeMaterialConnectionPoint;
  56423. protected _buildBlock(state: NodeMaterialBuildState): this;
  56424. }
  56425. }
  56426. declare module BABYLON {
  56427. /**
  56428. * Block used to get negative version of a value (i.e. x * -1)
  56429. */
  56430. export class NegateBlock extends NodeMaterialBlock {
  56431. /**
  56432. * Creates a new NegateBlock
  56433. * @param name defines the block name
  56434. */
  56435. constructor(name: string);
  56436. /**
  56437. * Gets the current class name
  56438. * @returns the class name
  56439. */
  56440. getClassName(): string;
  56441. /**
  56442. * Gets the value input component
  56443. */
  56444. readonly value: NodeMaterialConnectionPoint;
  56445. /**
  56446. * Gets the output component
  56447. */
  56448. readonly output: NodeMaterialConnectionPoint;
  56449. protected _buildBlock(state: NodeMaterialBuildState): this;
  56450. }
  56451. }
  56452. declare module BABYLON {
  56453. /**
  56454. * Block used to get the value of the first parameter raised to the power of the second
  56455. */
  56456. export class PowBlock extends NodeMaterialBlock {
  56457. /**
  56458. * Creates a new PowBlock
  56459. * @param name defines the block name
  56460. */
  56461. constructor(name: string);
  56462. /**
  56463. * Gets the current class name
  56464. * @returns the class name
  56465. */
  56466. getClassName(): string;
  56467. /**
  56468. * Gets the value operand input component
  56469. */
  56470. readonly value: NodeMaterialConnectionPoint;
  56471. /**
  56472. * Gets the power operand input component
  56473. */
  56474. readonly power: NodeMaterialConnectionPoint;
  56475. /**
  56476. * Gets the output component
  56477. */
  56478. readonly output: NodeMaterialConnectionPoint;
  56479. protected _buildBlock(state: NodeMaterialBuildState): this;
  56480. }
  56481. }
  56482. declare module BABYLON {
  56483. /**
  56484. * Block used to get a random number
  56485. */
  56486. export class RandomNumberBlock extends NodeMaterialBlock {
  56487. /**
  56488. * Creates a new RandomNumberBlock
  56489. * @param name defines the block name
  56490. */
  56491. constructor(name: string);
  56492. /**
  56493. * Gets the current class name
  56494. * @returns the class name
  56495. */
  56496. getClassName(): string;
  56497. /**
  56498. * Gets the seed input component
  56499. */
  56500. readonly seed: NodeMaterialConnectionPoint;
  56501. /**
  56502. * Gets the output component
  56503. */
  56504. readonly output: NodeMaterialConnectionPoint;
  56505. protected _buildBlock(state: NodeMaterialBuildState): this;
  56506. }
  56507. }
  56508. declare module BABYLON {
  56509. /**
  56510. * Block used to compute arc tangent of 2 values
  56511. */
  56512. export class ArcTan2Block extends NodeMaterialBlock {
  56513. /**
  56514. * Creates a new ArcTan2Block
  56515. * @param name defines the block name
  56516. */
  56517. constructor(name: string);
  56518. /**
  56519. * Gets the current class name
  56520. * @returns the class name
  56521. */
  56522. getClassName(): string;
  56523. /**
  56524. * Gets the x operand input component
  56525. */
  56526. readonly x: NodeMaterialConnectionPoint;
  56527. /**
  56528. * Gets the y operand input component
  56529. */
  56530. readonly y: NodeMaterialConnectionPoint;
  56531. /**
  56532. * Gets the output component
  56533. */
  56534. readonly output: NodeMaterialConnectionPoint;
  56535. protected _buildBlock(state: NodeMaterialBuildState): this;
  56536. }
  56537. }
  56538. declare module BABYLON {
  56539. /**
  56540. * Block used to smooth step a value
  56541. */
  56542. export class SmoothStepBlock extends NodeMaterialBlock {
  56543. /**
  56544. * Creates a new SmoothStepBlock
  56545. * @param name defines the block name
  56546. */
  56547. constructor(name: string);
  56548. /**
  56549. * Gets the current class name
  56550. * @returns the class name
  56551. */
  56552. getClassName(): string;
  56553. /**
  56554. * Gets the value operand input component
  56555. */
  56556. readonly value: NodeMaterialConnectionPoint;
  56557. /**
  56558. * Gets the first edge operand input component
  56559. */
  56560. readonly edge0: NodeMaterialConnectionPoint;
  56561. /**
  56562. * Gets the second edge operand input component
  56563. */
  56564. readonly edge1: NodeMaterialConnectionPoint;
  56565. /**
  56566. * Gets the output component
  56567. */
  56568. readonly output: NodeMaterialConnectionPoint;
  56569. protected _buildBlock(state: NodeMaterialBuildState): this;
  56570. }
  56571. }
  56572. declare module BABYLON {
  56573. /**
  56574. * Block used to get the reciprocal (1 / x) of a value
  56575. */
  56576. export class ReciprocalBlock extends NodeMaterialBlock {
  56577. /**
  56578. * Creates a new ReciprocalBlock
  56579. * @param name defines the block name
  56580. */
  56581. constructor(name: string);
  56582. /**
  56583. * Gets the current class name
  56584. * @returns the class name
  56585. */
  56586. getClassName(): string;
  56587. /**
  56588. * Gets the input component
  56589. */
  56590. readonly input: NodeMaterialConnectionPoint;
  56591. /**
  56592. * Gets the output component
  56593. */
  56594. readonly output: NodeMaterialConnectionPoint;
  56595. protected _buildBlock(state: NodeMaterialBuildState): this;
  56596. }
  56597. }
  56598. declare module BABYLON {
  56599. /**
  56600. * Block used to replace a color by another one
  56601. */
  56602. export class ReplaceColorBlock extends NodeMaterialBlock {
  56603. /**
  56604. * Creates a new ReplaceColorBlock
  56605. * @param name defines the block name
  56606. */
  56607. constructor(name: string);
  56608. /**
  56609. * Gets the current class name
  56610. * @returns the class name
  56611. */
  56612. getClassName(): string;
  56613. /**
  56614. * Gets the value input component
  56615. */
  56616. readonly value: NodeMaterialConnectionPoint;
  56617. /**
  56618. * Gets the reference input component
  56619. */
  56620. readonly reference: NodeMaterialConnectionPoint;
  56621. /**
  56622. * Gets the distance input component
  56623. */
  56624. readonly distance: NodeMaterialConnectionPoint;
  56625. /**
  56626. * Gets the replacement input component
  56627. */
  56628. readonly replacement: NodeMaterialConnectionPoint;
  56629. /**
  56630. * Gets the output component
  56631. */
  56632. readonly output: NodeMaterialConnectionPoint;
  56633. protected _buildBlock(state: NodeMaterialBuildState): this;
  56634. }
  56635. }
  56636. declare module BABYLON {
  56637. /**
  56638. * Block used to posterize a value
  56639. * @see https://en.wikipedia.org/wiki/Posterization
  56640. */
  56641. export class PosterizeBlock extends NodeMaterialBlock {
  56642. /**
  56643. * Creates a new PosterizeBlock
  56644. * @param name defines the block name
  56645. */
  56646. constructor(name: string);
  56647. /**
  56648. * Gets the current class name
  56649. * @returns the class name
  56650. */
  56651. getClassName(): string;
  56652. /**
  56653. * Gets the value input component
  56654. */
  56655. readonly value: NodeMaterialConnectionPoint;
  56656. /**
  56657. * Gets the steps input component
  56658. */
  56659. readonly steps: NodeMaterialConnectionPoint;
  56660. /**
  56661. * Gets the output component
  56662. */
  56663. readonly output: NodeMaterialConnectionPoint;
  56664. protected _buildBlock(state: NodeMaterialBuildState): this;
  56665. }
  56666. }
  56667. declare module BABYLON {
  56668. /**
  56669. * Operations supported by the Wave block
  56670. */
  56671. export enum WaveBlockKind {
  56672. /** SawTooth */
  56673. SawTooth = 0,
  56674. /** Square */
  56675. Square = 1,
  56676. /** Triangle */
  56677. Triangle = 2
  56678. }
  56679. /**
  56680. * Block used to apply wave operation to floats
  56681. */
  56682. export class WaveBlock extends NodeMaterialBlock {
  56683. /**
  56684. * Gets or sets the kibnd of wave to be applied by the block
  56685. */
  56686. kind: WaveBlockKind;
  56687. /**
  56688. * Creates a new WaveBlock
  56689. * @param name defines the block name
  56690. */
  56691. constructor(name: string);
  56692. /**
  56693. * Gets the current class name
  56694. * @returns the class name
  56695. */
  56696. getClassName(): string;
  56697. /**
  56698. * Gets the input component
  56699. */
  56700. readonly input: NodeMaterialConnectionPoint;
  56701. /**
  56702. * Gets the output component
  56703. */
  56704. readonly output: NodeMaterialConnectionPoint;
  56705. protected _buildBlock(state: NodeMaterialBuildState): this;
  56706. serialize(): any;
  56707. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56708. }
  56709. }
  56710. declare module BABYLON {
  56711. /**
  56712. * Class used to store a color step for the GradientBlock
  56713. */
  56714. export class GradientBlockColorStep {
  56715. /**
  56716. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  56717. */
  56718. step: number;
  56719. /**
  56720. * Gets or sets the color associated with this step
  56721. */
  56722. color: Color3;
  56723. /**
  56724. * Creates a new GradientBlockColorStep
  56725. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  56726. * @param color defines the color associated with this step
  56727. */
  56728. constructor(
  56729. /**
  56730. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  56731. */
  56732. step: number,
  56733. /**
  56734. * Gets or sets the color associated with this step
  56735. */
  56736. color: Color3);
  56737. }
  56738. /**
  56739. * Block used to return a color from a gradient based on an input value between 0 and 1
  56740. */
  56741. export class GradientBlock extends NodeMaterialBlock {
  56742. /**
  56743. * Gets or sets the list of color steps
  56744. */
  56745. colorSteps: GradientBlockColorStep[];
  56746. /**
  56747. * Creates a new GradientBlock
  56748. * @param name defines the block name
  56749. */
  56750. constructor(name: string);
  56751. /**
  56752. * Gets the current class name
  56753. * @returns the class name
  56754. */
  56755. getClassName(): string;
  56756. /**
  56757. * Gets the gradient input component
  56758. */
  56759. readonly gradient: NodeMaterialConnectionPoint;
  56760. /**
  56761. * Gets the output component
  56762. */
  56763. readonly output: NodeMaterialConnectionPoint;
  56764. private _writeColorConstant;
  56765. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56766. serialize(): any;
  56767. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56768. protected _dumpPropertiesCode(): string;
  56769. }
  56770. }
  56771. declare module BABYLON {
  56772. /**
  56773. * Block used to normalize lerp between 2 values
  56774. */
  56775. export class NLerpBlock extends NodeMaterialBlock {
  56776. /**
  56777. * Creates a new NLerpBlock
  56778. * @param name defines the block name
  56779. */
  56780. constructor(name: string);
  56781. /**
  56782. * Gets the current class name
  56783. * @returns the class name
  56784. */
  56785. getClassName(): string;
  56786. /**
  56787. * Gets the left operand input component
  56788. */
  56789. readonly left: NodeMaterialConnectionPoint;
  56790. /**
  56791. * Gets the right operand input component
  56792. */
  56793. readonly right: NodeMaterialConnectionPoint;
  56794. /**
  56795. * Gets the gradient operand input component
  56796. */
  56797. readonly gradient: NodeMaterialConnectionPoint;
  56798. /**
  56799. * Gets the output component
  56800. */
  56801. readonly output: NodeMaterialConnectionPoint;
  56802. protected _buildBlock(state: NodeMaterialBuildState): this;
  56803. }
  56804. }
  56805. declare module BABYLON {
  56806. /**
  56807. * block used to Generate a Worley Noise 3D Noise Pattern
  56808. */
  56809. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  56810. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56811. manhattanDistance: boolean;
  56812. /**
  56813. * Creates a new WorleyNoise3DBlock
  56814. * @param name defines the block name
  56815. */
  56816. constructor(name: string);
  56817. /**
  56818. * Gets the current class name
  56819. * @returns the class name
  56820. */
  56821. getClassName(): string;
  56822. /**
  56823. * Gets the seed input component
  56824. */
  56825. readonly seed: NodeMaterialConnectionPoint;
  56826. /**
  56827. * Gets the jitter input component
  56828. */
  56829. readonly jitter: NodeMaterialConnectionPoint;
  56830. /**
  56831. * Gets the output component
  56832. */
  56833. readonly output: NodeMaterialConnectionPoint;
  56834. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56835. /**
  56836. * Exposes the properties to the UI?
  56837. */
  56838. protected _dumpPropertiesCode(): string;
  56839. /**
  56840. * Exposes the properties to the Seralize?
  56841. */
  56842. serialize(): any;
  56843. /**
  56844. * Exposes the properties to the deseralize?
  56845. */
  56846. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56847. }
  56848. }
  56849. declare module BABYLON {
  56850. /**
  56851. * block used to Generate a Simplex Perlin 3d Noise Pattern
  56852. */
  56853. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  56854. /**
  56855. * Creates a new SimplexPerlin3DBlock
  56856. * @param name defines the block name
  56857. */
  56858. constructor(name: string);
  56859. /**
  56860. * Gets the current class name
  56861. * @returns the class name
  56862. */
  56863. getClassName(): string;
  56864. /**
  56865. * Gets the seed operand input component
  56866. */
  56867. readonly seed: NodeMaterialConnectionPoint;
  56868. /**
  56869. * Gets the output component
  56870. */
  56871. readonly output: NodeMaterialConnectionPoint;
  56872. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56873. }
  56874. }
  56875. declare module BABYLON {
  56876. /**
  56877. * Block used to blend normals
  56878. */
  56879. export class NormalBlendBlock extends NodeMaterialBlock {
  56880. /**
  56881. * Creates a new NormalBlendBlock
  56882. * @param name defines the block name
  56883. */
  56884. constructor(name: string);
  56885. /**
  56886. * Gets the current class name
  56887. * @returns the class name
  56888. */
  56889. getClassName(): string;
  56890. /**
  56891. * Gets the first input component
  56892. */
  56893. readonly normalMap0: NodeMaterialConnectionPoint;
  56894. /**
  56895. * Gets the second input component
  56896. */
  56897. readonly normalMap1: NodeMaterialConnectionPoint;
  56898. /**
  56899. * Gets the output component
  56900. */
  56901. readonly output: NodeMaterialConnectionPoint;
  56902. protected _buildBlock(state: NodeMaterialBuildState): this;
  56903. }
  56904. }
  56905. declare module BABYLON {
  56906. /**
  56907. * Block used to rotate a 2d vector by a given angle
  56908. */
  56909. export class Rotate2dBlock extends NodeMaterialBlock {
  56910. /**
  56911. * Creates a new Rotate2dBlock
  56912. * @param name defines the block name
  56913. */
  56914. constructor(name: string);
  56915. /**
  56916. * Gets the current class name
  56917. * @returns the class name
  56918. */
  56919. getClassName(): string;
  56920. /**
  56921. * Gets the input vector
  56922. */
  56923. readonly input: NodeMaterialConnectionPoint;
  56924. /**
  56925. * Gets the input angle
  56926. */
  56927. readonly angle: NodeMaterialConnectionPoint;
  56928. /**
  56929. * Gets the output component
  56930. */
  56931. readonly output: NodeMaterialConnectionPoint;
  56932. autoConfigure(material: NodeMaterial): void;
  56933. protected _buildBlock(state: NodeMaterialBuildState): this;
  56934. }
  56935. }
  56936. declare module BABYLON {
  56937. /**
  56938. * Block used to get the reflected vector from a direction and a normal
  56939. */
  56940. export class ReflectBlock extends NodeMaterialBlock {
  56941. /**
  56942. * Creates a new ReflectBlock
  56943. * @param name defines the block name
  56944. */
  56945. constructor(name: string);
  56946. /**
  56947. * Gets the current class name
  56948. * @returns the class name
  56949. */
  56950. getClassName(): string;
  56951. /**
  56952. * Gets the incident component
  56953. */
  56954. readonly incident: NodeMaterialConnectionPoint;
  56955. /**
  56956. * Gets the normal component
  56957. */
  56958. readonly normal: NodeMaterialConnectionPoint;
  56959. /**
  56960. * Gets the output component
  56961. */
  56962. readonly output: NodeMaterialConnectionPoint;
  56963. protected _buildBlock(state: NodeMaterialBuildState): this;
  56964. }
  56965. }
  56966. declare module BABYLON {
  56967. /**
  56968. * Block used to get the refracted vector from a direction and a normal
  56969. */
  56970. export class RefractBlock extends NodeMaterialBlock {
  56971. /**
  56972. * Creates a new RefractBlock
  56973. * @param name defines the block name
  56974. */
  56975. constructor(name: string);
  56976. /**
  56977. * Gets the current class name
  56978. * @returns the class name
  56979. */
  56980. getClassName(): string;
  56981. /**
  56982. * Gets the incident component
  56983. */
  56984. readonly incident: NodeMaterialConnectionPoint;
  56985. /**
  56986. * Gets the normal component
  56987. */
  56988. readonly normal: NodeMaterialConnectionPoint;
  56989. /**
  56990. * Gets the index of refraction component
  56991. */
  56992. readonly ior: NodeMaterialConnectionPoint;
  56993. /**
  56994. * Gets the output component
  56995. */
  56996. readonly output: NodeMaterialConnectionPoint;
  56997. protected _buildBlock(state: NodeMaterialBuildState): this;
  56998. }
  56999. }
  57000. declare module BABYLON {
  57001. /**
  57002. * Block used to desaturate a color
  57003. */
  57004. export class DesaturateBlock extends NodeMaterialBlock {
  57005. /**
  57006. * Creates a new DesaturateBlock
  57007. * @param name defines the block name
  57008. */
  57009. constructor(name: string);
  57010. /**
  57011. * Gets the current class name
  57012. * @returns the class name
  57013. */
  57014. getClassName(): string;
  57015. /**
  57016. * Gets the color operand input component
  57017. */
  57018. readonly color: NodeMaterialConnectionPoint;
  57019. /**
  57020. * Gets the level operand input component
  57021. */
  57022. readonly level: NodeMaterialConnectionPoint;
  57023. /**
  57024. * Gets the output component
  57025. */
  57026. readonly output: NodeMaterialConnectionPoint;
  57027. protected _buildBlock(state: NodeMaterialBuildState): this;
  57028. }
  57029. }
  57030. declare module BABYLON {
  57031. /**
  57032. * Effect Render Options
  57033. */
  57034. export interface IEffectRendererOptions {
  57035. /**
  57036. * Defines the vertices positions.
  57037. */
  57038. positions?: number[];
  57039. /**
  57040. * Defines the indices.
  57041. */
  57042. indices?: number[];
  57043. }
  57044. /**
  57045. * Helper class to render one or more effects
  57046. */
  57047. export class EffectRenderer {
  57048. private engine;
  57049. private static _DefaultOptions;
  57050. private _vertexBuffers;
  57051. private _indexBuffer;
  57052. private _ringBufferIndex;
  57053. private _ringScreenBuffer;
  57054. private _fullscreenViewport;
  57055. private _getNextFrameBuffer;
  57056. /**
  57057. * Creates an effect renderer
  57058. * @param engine the engine to use for rendering
  57059. * @param options defines the options of the effect renderer
  57060. */
  57061. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  57062. /**
  57063. * Sets the current viewport in normalized coordinates 0-1
  57064. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  57065. */
  57066. setViewport(viewport?: Viewport): void;
  57067. /**
  57068. * Binds the embedded attributes buffer to the effect.
  57069. * @param effect Defines the effect to bind the attributes for
  57070. */
  57071. bindBuffers(effect: Effect): void;
  57072. /**
  57073. * Sets the current effect wrapper to use during draw.
  57074. * The effect needs to be ready before calling this api.
  57075. * This also sets the default full screen position attribute.
  57076. * @param effectWrapper Defines the effect to draw with
  57077. */
  57078. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  57079. /**
  57080. * Draws a full screen quad.
  57081. */
  57082. draw(): void;
  57083. /**
  57084. * renders one or more effects to a specified texture
  57085. * @param effectWrappers list of effects to renderer
  57086. * @param outputTexture texture to draw to, if null it will render to the screen
  57087. */
  57088. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  57089. /**
  57090. * Disposes of the effect renderer
  57091. */
  57092. dispose(): void;
  57093. }
  57094. /**
  57095. * Options to create an EffectWrapper
  57096. */
  57097. interface EffectWrapperCreationOptions {
  57098. /**
  57099. * Engine to use to create the effect
  57100. */
  57101. engine: ThinEngine;
  57102. /**
  57103. * Fragment shader for the effect
  57104. */
  57105. fragmentShader: string;
  57106. /**
  57107. * Vertex shader for the effect
  57108. */
  57109. vertexShader?: string;
  57110. /**
  57111. * Attributes to use in the shader
  57112. */
  57113. attributeNames?: Array<string>;
  57114. /**
  57115. * Uniforms to use in the shader
  57116. */
  57117. uniformNames?: Array<string>;
  57118. /**
  57119. * Texture sampler names to use in the shader
  57120. */
  57121. samplerNames?: Array<string>;
  57122. /**
  57123. * The friendly name of the effect displayed in Spector.
  57124. */
  57125. name?: string;
  57126. }
  57127. /**
  57128. * Wraps an effect to be used for rendering
  57129. */
  57130. export class EffectWrapper {
  57131. /**
  57132. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  57133. */
  57134. onApplyObservable: Observable<{}>;
  57135. /**
  57136. * The underlying effect
  57137. */
  57138. effect: Effect;
  57139. /**
  57140. * Creates an effect to be renderer
  57141. * @param creationOptions options to create the effect
  57142. */
  57143. constructor(creationOptions: EffectWrapperCreationOptions);
  57144. /**
  57145. * Disposes of the effect wrapper
  57146. */
  57147. dispose(): void;
  57148. }
  57149. }
  57150. declare module BABYLON {
  57151. /**
  57152. * Helper class to push actions to a pool of workers.
  57153. */
  57154. export class WorkerPool implements IDisposable {
  57155. private _workerInfos;
  57156. private _pendingActions;
  57157. /**
  57158. * Constructor
  57159. * @param workers Array of workers to use for actions
  57160. */
  57161. constructor(workers: Array<Worker>);
  57162. /**
  57163. * Terminates all workers and clears any pending actions.
  57164. */
  57165. dispose(): void;
  57166. /**
  57167. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57168. * pended until a worker has completed its action.
  57169. * @param action The action to perform. Call onComplete when the action is complete.
  57170. */
  57171. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57172. private _execute;
  57173. }
  57174. }
  57175. declare module BABYLON {
  57176. /**
  57177. * Configuration for Draco compression
  57178. */
  57179. export interface IDracoCompressionConfiguration {
  57180. /**
  57181. * Configuration for the decoder.
  57182. */
  57183. decoder: {
  57184. /**
  57185. * The url to the WebAssembly module.
  57186. */
  57187. wasmUrl?: string;
  57188. /**
  57189. * The url to the WebAssembly binary.
  57190. */
  57191. wasmBinaryUrl?: string;
  57192. /**
  57193. * The url to the fallback JavaScript module.
  57194. */
  57195. fallbackUrl?: string;
  57196. };
  57197. }
  57198. /**
  57199. * Draco compression (https://google.github.io/draco/)
  57200. *
  57201. * This class wraps the Draco module.
  57202. *
  57203. * **Encoder**
  57204. *
  57205. * The encoder is not currently implemented.
  57206. *
  57207. * **Decoder**
  57208. *
  57209. * 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.
  57210. *
  57211. * To update the configuration, use the following code:
  57212. * ```javascript
  57213. * DracoCompression.Configuration = {
  57214. * decoder: {
  57215. * wasmUrl: "<url to the WebAssembly library>",
  57216. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  57217. * fallbackUrl: "<url to the fallback JavaScript library>",
  57218. * }
  57219. * };
  57220. * ```
  57221. *
  57222. * 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.
  57223. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  57224. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  57225. *
  57226. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  57227. * ```javascript
  57228. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  57229. * ```
  57230. *
  57231. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  57232. */
  57233. export class DracoCompression implements IDisposable {
  57234. private _workerPoolPromise?;
  57235. private _decoderModulePromise?;
  57236. /**
  57237. * The configuration. Defaults to the following urls:
  57238. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  57239. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  57240. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  57241. */
  57242. static Configuration: IDracoCompressionConfiguration;
  57243. /**
  57244. * Returns true if the decoder configuration is available.
  57245. */
  57246. static readonly DecoderAvailable: boolean;
  57247. /**
  57248. * Default number of workers to create when creating the draco compression object.
  57249. */
  57250. static DefaultNumWorkers: number;
  57251. private static GetDefaultNumWorkers;
  57252. private static _Default;
  57253. /**
  57254. * Default instance for the draco compression object.
  57255. */
  57256. static readonly Default: DracoCompression;
  57257. /**
  57258. * Constructor
  57259. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57260. */
  57261. constructor(numWorkers?: number);
  57262. /**
  57263. * Stop all async operations and release resources.
  57264. */
  57265. dispose(): void;
  57266. /**
  57267. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  57268. * @returns a promise that resolves when ready
  57269. */
  57270. whenReadyAsync(): Promise<void>;
  57271. /**
  57272. * Decode Draco compressed mesh data to vertex data.
  57273. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  57274. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  57275. * @returns A promise that resolves with the decoded vertex data
  57276. */
  57277. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  57278. [kind: string]: number;
  57279. }): Promise<VertexData>;
  57280. }
  57281. }
  57282. declare module BABYLON {
  57283. /**
  57284. * Class for building Constructive Solid Geometry
  57285. */
  57286. export class CSG {
  57287. private polygons;
  57288. /**
  57289. * The world matrix
  57290. */
  57291. matrix: Matrix;
  57292. /**
  57293. * Stores the position
  57294. */
  57295. position: Vector3;
  57296. /**
  57297. * Stores the rotation
  57298. */
  57299. rotation: Vector3;
  57300. /**
  57301. * Stores the rotation quaternion
  57302. */
  57303. rotationQuaternion: Nullable<Quaternion>;
  57304. /**
  57305. * Stores the scaling vector
  57306. */
  57307. scaling: Vector3;
  57308. /**
  57309. * Convert the Mesh to CSG
  57310. * @param mesh The Mesh to convert to CSG
  57311. * @returns A new CSG from the Mesh
  57312. */
  57313. static FromMesh(mesh: Mesh): CSG;
  57314. /**
  57315. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  57316. * @param polygons Polygons used to construct a CSG solid
  57317. */
  57318. private static FromPolygons;
  57319. /**
  57320. * Clones, or makes a deep copy, of the CSG
  57321. * @returns A new CSG
  57322. */
  57323. clone(): CSG;
  57324. /**
  57325. * Unions this CSG with another CSG
  57326. * @param csg The CSG to union against this CSG
  57327. * @returns The unioned CSG
  57328. */
  57329. union(csg: CSG): CSG;
  57330. /**
  57331. * Unions this CSG with another CSG in place
  57332. * @param csg The CSG to union against this CSG
  57333. */
  57334. unionInPlace(csg: CSG): void;
  57335. /**
  57336. * Subtracts this CSG with another CSG
  57337. * @param csg The CSG to subtract against this CSG
  57338. * @returns A new CSG
  57339. */
  57340. subtract(csg: CSG): CSG;
  57341. /**
  57342. * Subtracts this CSG with another CSG in place
  57343. * @param csg The CSG to subtact against this CSG
  57344. */
  57345. subtractInPlace(csg: CSG): void;
  57346. /**
  57347. * Intersect this CSG with another CSG
  57348. * @param csg The CSG to intersect against this CSG
  57349. * @returns A new CSG
  57350. */
  57351. intersect(csg: CSG): CSG;
  57352. /**
  57353. * Intersects this CSG with another CSG in place
  57354. * @param csg The CSG to intersect against this CSG
  57355. */
  57356. intersectInPlace(csg: CSG): void;
  57357. /**
  57358. * Return a new CSG solid with solid and empty space switched. This solid is
  57359. * not modified.
  57360. * @returns A new CSG solid with solid and empty space switched
  57361. */
  57362. inverse(): CSG;
  57363. /**
  57364. * Inverses the CSG in place
  57365. */
  57366. inverseInPlace(): void;
  57367. /**
  57368. * This is used to keep meshes transformations so they can be restored
  57369. * when we build back a Babylon Mesh
  57370. * NB : All CSG operations are performed in world coordinates
  57371. * @param csg The CSG to copy the transform attributes from
  57372. * @returns This CSG
  57373. */
  57374. copyTransformAttributes(csg: CSG): CSG;
  57375. /**
  57376. * Build Raw mesh from CSG
  57377. * Coordinates here are in world space
  57378. * @param name The name of the mesh geometry
  57379. * @param scene The Scene
  57380. * @param keepSubMeshes Specifies if the submeshes should be kept
  57381. * @returns A new Mesh
  57382. */
  57383. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57384. /**
  57385. * Build Mesh from CSG taking material and transforms into account
  57386. * @param name The name of the Mesh
  57387. * @param material The material of the Mesh
  57388. * @param scene The Scene
  57389. * @param keepSubMeshes Specifies if submeshes should be kept
  57390. * @returns The new Mesh
  57391. */
  57392. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57393. }
  57394. }
  57395. declare module BABYLON {
  57396. /**
  57397. * Class used to create a trail following a mesh
  57398. */
  57399. export class TrailMesh extends Mesh {
  57400. private _generator;
  57401. private _autoStart;
  57402. private _running;
  57403. private _diameter;
  57404. private _length;
  57405. private _sectionPolygonPointsCount;
  57406. private _sectionVectors;
  57407. private _sectionNormalVectors;
  57408. private _beforeRenderObserver;
  57409. /**
  57410. * @constructor
  57411. * @param name The value used by scene.getMeshByName() to do a lookup.
  57412. * @param generator The mesh to generate a trail.
  57413. * @param scene The scene to add this mesh to.
  57414. * @param diameter Diameter of trailing mesh. Default is 1.
  57415. * @param length Length of trailing mesh. Default is 60.
  57416. * @param autoStart Automatically start trailing mesh. Default true.
  57417. */
  57418. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  57419. /**
  57420. * "TrailMesh"
  57421. * @returns "TrailMesh"
  57422. */
  57423. getClassName(): string;
  57424. private _createMesh;
  57425. /**
  57426. * Start trailing mesh.
  57427. */
  57428. start(): void;
  57429. /**
  57430. * Stop trailing mesh.
  57431. */
  57432. stop(): void;
  57433. /**
  57434. * Update trailing mesh geometry.
  57435. */
  57436. update(): void;
  57437. /**
  57438. * Returns a new TrailMesh object.
  57439. * @param name is a string, the name given to the new mesh
  57440. * @param newGenerator use new generator object for cloned trail mesh
  57441. * @returns a new mesh
  57442. */
  57443. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  57444. /**
  57445. * Serializes this trail mesh
  57446. * @param serializationObject object to write serialization to
  57447. */
  57448. serialize(serializationObject: any): void;
  57449. /**
  57450. * Parses a serialized trail mesh
  57451. * @param parsedMesh the serialized mesh
  57452. * @param scene the scene to create the trail mesh in
  57453. * @returns the created trail mesh
  57454. */
  57455. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  57456. }
  57457. }
  57458. declare module BABYLON {
  57459. /**
  57460. * Class containing static functions to help procedurally build meshes
  57461. */
  57462. export class TiledBoxBuilder {
  57463. /**
  57464. * Creates a box mesh
  57465. * 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)
  57466. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57467. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57468. * * 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
  57469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57470. * @param name defines the name of the mesh
  57471. * @param options defines the options used to create the mesh
  57472. * @param scene defines the hosting scene
  57473. * @returns the box mesh
  57474. */
  57475. static CreateTiledBox(name: string, options: {
  57476. pattern?: number;
  57477. width?: number;
  57478. height?: number;
  57479. depth?: number;
  57480. tileSize?: number;
  57481. tileWidth?: number;
  57482. tileHeight?: number;
  57483. alignHorizontal?: number;
  57484. alignVertical?: number;
  57485. faceUV?: Vector4[];
  57486. faceColors?: Color4[];
  57487. sideOrientation?: number;
  57488. updatable?: boolean;
  57489. }, scene?: Nullable<Scene>): Mesh;
  57490. }
  57491. }
  57492. declare module BABYLON {
  57493. /**
  57494. * Class containing static functions to help procedurally build meshes
  57495. */
  57496. export class TorusKnotBuilder {
  57497. /**
  57498. * Creates a torus knot mesh
  57499. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57500. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57501. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57502. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57504. * * 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
  57505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57506. * @param name defines the name of the mesh
  57507. * @param options defines the options used to create the mesh
  57508. * @param scene defines the hosting scene
  57509. * @returns the torus knot mesh
  57510. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57511. */
  57512. static CreateTorusKnot(name: string, options: {
  57513. radius?: number;
  57514. tube?: number;
  57515. radialSegments?: number;
  57516. tubularSegments?: number;
  57517. p?: number;
  57518. q?: number;
  57519. updatable?: boolean;
  57520. sideOrientation?: number;
  57521. frontUVs?: Vector4;
  57522. backUVs?: Vector4;
  57523. }, scene: any): Mesh;
  57524. }
  57525. }
  57526. declare module BABYLON {
  57527. /**
  57528. * Polygon
  57529. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  57530. */
  57531. export class Polygon {
  57532. /**
  57533. * Creates a rectangle
  57534. * @param xmin bottom X coord
  57535. * @param ymin bottom Y coord
  57536. * @param xmax top X coord
  57537. * @param ymax top Y coord
  57538. * @returns points that make the resulting rectation
  57539. */
  57540. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  57541. /**
  57542. * Creates a circle
  57543. * @param radius radius of circle
  57544. * @param cx scale in x
  57545. * @param cy scale in y
  57546. * @param numberOfSides number of sides that make up the circle
  57547. * @returns points that make the resulting circle
  57548. */
  57549. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  57550. /**
  57551. * Creates a polygon from input string
  57552. * @param input Input polygon data
  57553. * @returns the parsed points
  57554. */
  57555. static Parse(input: string): Vector2[];
  57556. /**
  57557. * Starts building a polygon from x and y coordinates
  57558. * @param x x coordinate
  57559. * @param y y coordinate
  57560. * @returns the started path2
  57561. */
  57562. static StartingAt(x: number, y: number): Path2;
  57563. }
  57564. /**
  57565. * Builds a polygon
  57566. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  57567. */
  57568. export class PolygonMeshBuilder {
  57569. private _points;
  57570. private _outlinepoints;
  57571. private _holes;
  57572. private _name;
  57573. private _scene;
  57574. private _epoints;
  57575. private _eholes;
  57576. private _addToepoint;
  57577. /**
  57578. * Babylon reference to the earcut plugin.
  57579. */
  57580. bjsEarcut: any;
  57581. /**
  57582. * Creates a PolygonMeshBuilder
  57583. * @param name name of the builder
  57584. * @param contours Path of the polygon
  57585. * @param scene scene to add to when creating the mesh
  57586. * @param earcutInjection can be used to inject your own earcut reference
  57587. */
  57588. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  57589. /**
  57590. * Adds a whole within the polygon
  57591. * @param hole Array of points defining the hole
  57592. * @returns this
  57593. */
  57594. addHole(hole: Vector2[]): PolygonMeshBuilder;
  57595. /**
  57596. * Creates the polygon
  57597. * @param updatable If the mesh should be updatable
  57598. * @param depth The depth of the mesh created
  57599. * @returns the created mesh
  57600. */
  57601. build(updatable?: boolean, depth?: number): Mesh;
  57602. /**
  57603. * Creates the polygon
  57604. * @param depth The depth of the mesh created
  57605. * @returns the created VertexData
  57606. */
  57607. buildVertexData(depth?: number): VertexData;
  57608. /**
  57609. * Adds a side to the polygon
  57610. * @param positions points that make the polygon
  57611. * @param normals normals of the polygon
  57612. * @param uvs uvs of the polygon
  57613. * @param indices indices of the polygon
  57614. * @param bounds bounds of the polygon
  57615. * @param points points of the polygon
  57616. * @param depth depth of the polygon
  57617. * @param flip flip of the polygon
  57618. */
  57619. private addSide;
  57620. }
  57621. }
  57622. declare module BABYLON {
  57623. /**
  57624. * Class containing static functions to help procedurally build meshes
  57625. */
  57626. export class PolygonBuilder {
  57627. /**
  57628. * Creates a polygon mesh
  57629. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57630. * * 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
  57631. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57633. * * 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)
  57634. * * Remember you can only change the shape positions, not their number when updating a polygon
  57635. * @param name defines the name of the mesh
  57636. * @param options defines the options used to create the mesh
  57637. * @param scene defines the hosting scene
  57638. * @param earcutInjection can be used to inject your own earcut reference
  57639. * @returns the polygon mesh
  57640. */
  57641. static CreatePolygon(name: string, options: {
  57642. shape: Vector3[];
  57643. holes?: Vector3[][];
  57644. depth?: number;
  57645. faceUV?: Vector4[];
  57646. faceColors?: Color4[];
  57647. updatable?: boolean;
  57648. sideOrientation?: number;
  57649. frontUVs?: Vector4;
  57650. backUVs?: Vector4;
  57651. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57652. /**
  57653. * Creates an extruded polygon mesh, with depth in the Y direction.
  57654. * * 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)
  57655. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57656. * @param name defines the name of the mesh
  57657. * @param options defines the options used to create the mesh
  57658. * @param scene defines the hosting scene
  57659. * @param earcutInjection can be used to inject your own earcut reference
  57660. * @returns the polygon mesh
  57661. */
  57662. static ExtrudePolygon(name: string, options: {
  57663. shape: Vector3[];
  57664. holes?: Vector3[][];
  57665. depth?: number;
  57666. faceUV?: Vector4[];
  57667. faceColors?: Color4[];
  57668. updatable?: boolean;
  57669. sideOrientation?: number;
  57670. frontUVs?: Vector4;
  57671. backUVs?: Vector4;
  57672. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57673. }
  57674. }
  57675. declare module BABYLON {
  57676. /**
  57677. * Class containing static functions to help procedurally build meshes
  57678. */
  57679. export class LatheBuilder {
  57680. /**
  57681. * Creates lathe mesh.
  57682. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57683. * * 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
  57684. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57685. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57686. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57687. * * 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
  57688. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57689. * * 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
  57690. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57691. * * 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
  57692. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57694. * @param name defines the name of the mesh
  57695. * @param options defines the options used to create the mesh
  57696. * @param scene defines the hosting scene
  57697. * @returns the lathe mesh
  57698. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57699. */
  57700. static CreateLathe(name: string, options: {
  57701. shape: Vector3[];
  57702. radius?: number;
  57703. tessellation?: number;
  57704. clip?: number;
  57705. arc?: number;
  57706. closed?: boolean;
  57707. updatable?: boolean;
  57708. sideOrientation?: number;
  57709. frontUVs?: Vector4;
  57710. backUVs?: Vector4;
  57711. cap?: number;
  57712. invertUV?: boolean;
  57713. }, scene?: Nullable<Scene>): Mesh;
  57714. }
  57715. }
  57716. declare module BABYLON {
  57717. /**
  57718. * Class containing static functions to help procedurally build meshes
  57719. */
  57720. export class TiledPlaneBuilder {
  57721. /**
  57722. * Creates a tiled plane mesh
  57723. * * The parameter `pattern` will, depending on value, do nothing or
  57724. * * * flip (reflect about central vertical) alternate tiles across and up
  57725. * * * flip every tile on alternate rows
  57726. * * * rotate (180 degs) alternate tiles across and up
  57727. * * * rotate every tile on alternate rows
  57728. * * * flip and rotate alternate tiles across and up
  57729. * * * flip and rotate every tile on alternate rows
  57730. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  57731. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  57732. * * 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
  57733. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57734. * * 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)
  57735. * * 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)
  57736. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57737. * @param name defines the name of the mesh
  57738. * @param options defines the options used to create the mesh
  57739. * @param scene defines the hosting scene
  57740. * @returns the box mesh
  57741. */
  57742. static CreateTiledPlane(name: string, options: {
  57743. pattern?: number;
  57744. tileSize?: number;
  57745. tileWidth?: number;
  57746. tileHeight?: number;
  57747. size?: number;
  57748. width?: number;
  57749. height?: number;
  57750. alignHorizontal?: number;
  57751. alignVertical?: number;
  57752. sideOrientation?: number;
  57753. frontUVs?: Vector4;
  57754. backUVs?: Vector4;
  57755. updatable?: boolean;
  57756. }, scene?: Nullable<Scene>): Mesh;
  57757. }
  57758. }
  57759. declare module BABYLON {
  57760. /**
  57761. * Class containing static functions to help procedurally build meshes
  57762. */
  57763. export class TubeBuilder {
  57764. /**
  57765. * Creates a tube mesh.
  57766. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57767. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57768. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57769. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57770. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57771. * * 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)
  57772. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57773. * * 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
  57774. * * 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
  57775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57776. * * 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
  57777. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57779. * @param name defines the name of the mesh
  57780. * @param options defines the options used to create the mesh
  57781. * @param scene defines the hosting scene
  57782. * @returns the tube mesh
  57783. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57784. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57785. */
  57786. static CreateTube(name: string, options: {
  57787. path: Vector3[];
  57788. radius?: number;
  57789. tessellation?: number;
  57790. radiusFunction?: {
  57791. (i: number, distance: number): number;
  57792. };
  57793. cap?: number;
  57794. arc?: number;
  57795. updatable?: boolean;
  57796. sideOrientation?: number;
  57797. frontUVs?: Vector4;
  57798. backUVs?: Vector4;
  57799. instance?: Mesh;
  57800. invertUV?: boolean;
  57801. }, scene?: Nullable<Scene>): Mesh;
  57802. }
  57803. }
  57804. declare module BABYLON {
  57805. /**
  57806. * Class containing static functions to help procedurally build meshes
  57807. */
  57808. export class IcoSphereBuilder {
  57809. /**
  57810. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57811. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57812. * * 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`)
  57813. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57814. * * 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
  57815. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57816. * * 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
  57817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57818. * @param name defines the name of the mesh
  57819. * @param options defines the options used to create the mesh
  57820. * @param scene defines the hosting scene
  57821. * @returns the icosahedron mesh
  57822. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57823. */
  57824. static CreateIcoSphere(name: string, options: {
  57825. radius?: number;
  57826. radiusX?: number;
  57827. radiusY?: number;
  57828. radiusZ?: number;
  57829. flat?: boolean;
  57830. subdivisions?: number;
  57831. sideOrientation?: number;
  57832. frontUVs?: Vector4;
  57833. backUVs?: Vector4;
  57834. updatable?: boolean;
  57835. }, scene?: Nullable<Scene>): Mesh;
  57836. }
  57837. }
  57838. declare module BABYLON {
  57839. /**
  57840. * Class containing static functions to help procedurally build meshes
  57841. */
  57842. export class DecalBuilder {
  57843. /**
  57844. * Creates a decal mesh.
  57845. * 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
  57846. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57847. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57848. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57849. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57850. * @param name defines the name of the mesh
  57851. * @param sourceMesh defines the mesh where the decal must be applied
  57852. * @param options defines the options used to create the mesh
  57853. * @param scene defines the hosting scene
  57854. * @returns the decal mesh
  57855. * @see https://doc.babylonjs.com/how_to/decals
  57856. */
  57857. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57858. position?: Vector3;
  57859. normal?: Vector3;
  57860. size?: Vector3;
  57861. angle?: number;
  57862. }): Mesh;
  57863. }
  57864. }
  57865. declare module BABYLON {
  57866. /**
  57867. * Class containing static functions to help procedurally build meshes
  57868. */
  57869. export class MeshBuilder {
  57870. /**
  57871. * Creates a box mesh
  57872. * * The parameter `size` sets the size (float) of each box side (default 1)
  57873. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57874. * * 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)
  57875. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57876. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57877. * * 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
  57878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57879. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57880. * @param name defines the name of the mesh
  57881. * @param options defines the options used to create the mesh
  57882. * @param scene defines the hosting scene
  57883. * @returns the box mesh
  57884. */
  57885. static CreateBox(name: string, options: {
  57886. size?: number;
  57887. width?: number;
  57888. height?: number;
  57889. depth?: number;
  57890. faceUV?: Vector4[];
  57891. faceColors?: Color4[];
  57892. sideOrientation?: number;
  57893. frontUVs?: Vector4;
  57894. backUVs?: Vector4;
  57895. updatable?: boolean;
  57896. }, scene?: Nullable<Scene>): Mesh;
  57897. /**
  57898. * Creates a tiled box mesh
  57899. * * faceTiles sets the pattern, tile size and number of tiles for a face
  57900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57901. * @param name defines the name of the mesh
  57902. * @param options defines the options used to create the mesh
  57903. * @param scene defines the hosting scene
  57904. * @returns the tiled box mesh
  57905. */
  57906. static CreateTiledBox(name: string, options: {
  57907. pattern?: number;
  57908. size?: number;
  57909. width?: number;
  57910. height?: number;
  57911. depth: number;
  57912. tileSize?: number;
  57913. tileWidth?: number;
  57914. tileHeight?: number;
  57915. faceUV?: Vector4[];
  57916. faceColors?: Color4[];
  57917. alignHorizontal?: number;
  57918. alignVertical?: number;
  57919. sideOrientation?: number;
  57920. updatable?: boolean;
  57921. }, scene?: Nullable<Scene>): Mesh;
  57922. /**
  57923. * Creates a sphere mesh
  57924. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  57925. * * 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`)
  57926. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  57927. * * 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
  57928. * * 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)
  57929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57930. * * 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
  57931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57932. * @param name defines the name of the mesh
  57933. * @param options defines the options used to create the mesh
  57934. * @param scene defines the hosting scene
  57935. * @returns the sphere mesh
  57936. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  57937. */
  57938. static CreateSphere(name: string, options: {
  57939. segments?: number;
  57940. diameter?: number;
  57941. diameterX?: number;
  57942. diameterY?: number;
  57943. diameterZ?: number;
  57944. arc?: number;
  57945. slice?: number;
  57946. sideOrientation?: number;
  57947. frontUVs?: Vector4;
  57948. backUVs?: Vector4;
  57949. updatable?: boolean;
  57950. }, scene?: Nullable<Scene>): Mesh;
  57951. /**
  57952. * Creates a plane polygonal mesh. By default, this is a disc
  57953. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  57954. * * 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
  57955. * * 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
  57956. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57957. * * 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
  57958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57959. * @param name defines the name of the mesh
  57960. * @param options defines the options used to create the mesh
  57961. * @param scene defines the hosting scene
  57962. * @returns the plane polygonal mesh
  57963. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  57964. */
  57965. static CreateDisc(name: string, options: {
  57966. radius?: number;
  57967. tessellation?: number;
  57968. arc?: number;
  57969. updatable?: boolean;
  57970. sideOrientation?: number;
  57971. frontUVs?: Vector4;
  57972. backUVs?: Vector4;
  57973. }, scene?: Nullable<Scene>): Mesh;
  57974. /**
  57975. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57976. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57977. * * 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`)
  57978. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57979. * * 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
  57980. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57981. * * 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
  57982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57983. * @param name defines the name of the mesh
  57984. * @param options defines the options used to create the mesh
  57985. * @param scene defines the hosting scene
  57986. * @returns the icosahedron mesh
  57987. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57988. */
  57989. static CreateIcoSphere(name: string, options: {
  57990. radius?: number;
  57991. radiusX?: number;
  57992. radiusY?: number;
  57993. radiusZ?: number;
  57994. flat?: boolean;
  57995. subdivisions?: number;
  57996. sideOrientation?: number;
  57997. frontUVs?: Vector4;
  57998. backUVs?: Vector4;
  57999. updatable?: boolean;
  58000. }, scene?: Nullable<Scene>): Mesh;
  58001. /**
  58002. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58003. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58004. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58005. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58006. * * 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
  58007. * * 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
  58008. * * 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
  58009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58010. * * 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
  58011. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58012. * * 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
  58013. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58014. * * 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
  58015. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58017. * @param name defines the name of the mesh
  58018. * @param options defines the options used to create the mesh
  58019. * @param scene defines the hosting scene
  58020. * @returns the ribbon mesh
  58021. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58022. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58023. */
  58024. static CreateRibbon(name: string, options: {
  58025. pathArray: Vector3[][];
  58026. closeArray?: boolean;
  58027. closePath?: boolean;
  58028. offset?: number;
  58029. updatable?: boolean;
  58030. sideOrientation?: number;
  58031. frontUVs?: Vector4;
  58032. backUVs?: Vector4;
  58033. instance?: Mesh;
  58034. invertUV?: boolean;
  58035. uvs?: Vector2[];
  58036. colors?: Color4[];
  58037. }, scene?: Nullable<Scene>): Mesh;
  58038. /**
  58039. * Creates a cylinder or a cone mesh
  58040. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  58041. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  58042. * * 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.
  58043. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  58044. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  58045. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  58046. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  58047. * * 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).
  58048. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  58049. * * 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).
  58050. * * 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
  58051. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  58052. * * 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
  58053. * * 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.
  58054. * * If `enclose` is false, a ring surface is one element.
  58055. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  58056. * * 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
  58057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58058. * * 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
  58059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58060. * @param name defines the name of the mesh
  58061. * @param options defines the options used to create the mesh
  58062. * @param scene defines the hosting scene
  58063. * @returns the cylinder mesh
  58064. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  58065. */
  58066. static CreateCylinder(name: string, options: {
  58067. height?: number;
  58068. diameterTop?: number;
  58069. diameterBottom?: number;
  58070. diameter?: number;
  58071. tessellation?: number;
  58072. subdivisions?: number;
  58073. arc?: number;
  58074. faceColors?: Color4[];
  58075. faceUV?: Vector4[];
  58076. updatable?: boolean;
  58077. hasRings?: boolean;
  58078. enclose?: boolean;
  58079. cap?: number;
  58080. sideOrientation?: number;
  58081. frontUVs?: Vector4;
  58082. backUVs?: Vector4;
  58083. }, scene?: Nullable<Scene>): Mesh;
  58084. /**
  58085. * Creates a torus mesh
  58086. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  58087. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  58088. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  58089. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58090. * * 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
  58091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58092. * @param name defines the name of the mesh
  58093. * @param options defines the options used to create the mesh
  58094. * @param scene defines the hosting scene
  58095. * @returns the torus mesh
  58096. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  58097. */
  58098. static CreateTorus(name: string, options: {
  58099. diameter?: number;
  58100. thickness?: number;
  58101. tessellation?: number;
  58102. updatable?: boolean;
  58103. sideOrientation?: number;
  58104. frontUVs?: Vector4;
  58105. backUVs?: Vector4;
  58106. }, scene?: Nullable<Scene>): Mesh;
  58107. /**
  58108. * Creates a torus knot mesh
  58109. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58110. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58111. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58112. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58113. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58114. * * 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
  58115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58116. * @param name defines the name of the mesh
  58117. * @param options defines the options used to create the mesh
  58118. * @param scene defines the hosting scene
  58119. * @returns the torus knot mesh
  58120. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58121. */
  58122. static CreateTorusKnot(name: string, options: {
  58123. radius?: number;
  58124. tube?: number;
  58125. radialSegments?: number;
  58126. tubularSegments?: number;
  58127. p?: number;
  58128. q?: number;
  58129. updatable?: boolean;
  58130. sideOrientation?: number;
  58131. frontUVs?: Vector4;
  58132. backUVs?: Vector4;
  58133. }, scene?: Nullable<Scene>): Mesh;
  58134. /**
  58135. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  58136. * * 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
  58137. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  58138. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  58139. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  58140. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  58141. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  58142. * * 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
  58143. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  58144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58145. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  58146. * @param name defines the name of the new line system
  58147. * @param options defines the options used to create the line system
  58148. * @param scene defines the hosting scene
  58149. * @returns a new line system mesh
  58150. */
  58151. static CreateLineSystem(name: string, options: {
  58152. lines: Vector3[][];
  58153. updatable?: boolean;
  58154. instance?: Nullable<LinesMesh>;
  58155. colors?: Nullable<Color4[][]>;
  58156. useVertexAlpha?: boolean;
  58157. }, scene: Nullable<Scene>): LinesMesh;
  58158. /**
  58159. * Creates a line mesh
  58160. * 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
  58161. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58162. * * The parameter `points` is an array successive Vector3
  58163. * * 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
  58164. * * The optional parameter `colors` is an array of successive Color4, one per line point
  58165. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  58166. * * When updating an instance, remember that only point positions can change, not the number of points
  58167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58168. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  58169. * @param name defines the name of the new line system
  58170. * @param options defines the options used to create the line system
  58171. * @param scene defines the hosting scene
  58172. * @returns a new line mesh
  58173. */
  58174. static CreateLines(name: string, options: {
  58175. points: Vector3[];
  58176. updatable?: boolean;
  58177. instance?: Nullable<LinesMesh>;
  58178. colors?: Color4[];
  58179. useVertexAlpha?: boolean;
  58180. }, scene?: Nullable<Scene>): LinesMesh;
  58181. /**
  58182. * Creates a dashed line mesh
  58183. * * 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
  58184. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58185. * * The parameter `points` is an array successive Vector3
  58186. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  58187. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  58188. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  58189. * * 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
  58190. * * When updating an instance, remember that only point positions can change, not the number of points
  58191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58192. * @param name defines the name of the mesh
  58193. * @param options defines the options used to create the mesh
  58194. * @param scene defines the hosting scene
  58195. * @returns the dashed line mesh
  58196. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  58197. */
  58198. static CreateDashedLines(name: string, options: {
  58199. points: Vector3[];
  58200. dashSize?: number;
  58201. gapSize?: number;
  58202. dashNb?: number;
  58203. updatable?: boolean;
  58204. instance?: LinesMesh;
  58205. }, scene?: Nullable<Scene>): LinesMesh;
  58206. /**
  58207. * 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.
  58208. * * 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.
  58209. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58210. * * 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.
  58211. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58212. * * 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
  58213. * * 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
  58214. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58216. * * 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
  58217. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58219. * @param name defines the name of the mesh
  58220. * @param options defines the options used to create the mesh
  58221. * @param scene defines the hosting scene
  58222. * @returns the extruded shape mesh
  58223. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58224. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58225. */
  58226. static ExtrudeShape(name: string, options: {
  58227. shape: Vector3[];
  58228. path: Vector3[];
  58229. scale?: number;
  58230. rotation?: number;
  58231. cap?: number;
  58232. updatable?: boolean;
  58233. sideOrientation?: number;
  58234. frontUVs?: Vector4;
  58235. backUVs?: Vector4;
  58236. instance?: Mesh;
  58237. invertUV?: boolean;
  58238. }, scene?: Nullable<Scene>): Mesh;
  58239. /**
  58240. * Creates an custom extruded shape mesh.
  58241. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58242. * * 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.
  58243. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58244. * * 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
  58245. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58246. * * 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
  58247. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58248. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58249. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58250. * * 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
  58251. * * 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
  58252. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58253. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58254. * * 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
  58255. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58257. * @param name defines the name of the mesh
  58258. * @param options defines the options used to create the mesh
  58259. * @param scene defines the hosting scene
  58260. * @returns the custom extruded shape mesh
  58261. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58262. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58263. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58264. */
  58265. static ExtrudeShapeCustom(name: string, options: {
  58266. shape: Vector3[];
  58267. path: Vector3[];
  58268. scaleFunction?: any;
  58269. rotationFunction?: any;
  58270. ribbonCloseArray?: boolean;
  58271. ribbonClosePath?: boolean;
  58272. cap?: number;
  58273. updatable?: boolean;
  58274. sideOrientation?: number;
  58275. frontUVs?: Vector4;
  58276. backUVs?: Vector4;
  58277. instance?: Mesh;
  58278. invertUV?: boolean;
  58279. }, scene?: Nullable<Scene>): Mesh;
  58280. /**
  58281. * Creates lathe mesh.
  58282. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58283. * * 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
  58284. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58285. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58286. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58287. * * 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
  58288. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58289. * * 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
  58290. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58291. * * 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
  58292. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58294. * @param name defines the name of the mesh
  58295. * @param options defines the options used to create the mesh
  58296. * @param scene defines the hosting scene
  58297. * @returns the lathe mesh
  58298. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58299. */
  58300. static CreateLathe(name: string, options: {
  58301. shape: Vector3[];
  58302. radius?: number;
  58303. tessellation?: number;
  58304. clip?: number;
  58305. arc?: number;
  58306. closed?: boolean;
  58307. updatable?: boolean;
  58308. sideOrientation?: number;
  58309. frontUVs?: Vector4;
  58310. backUVs?: Vector4;
  58311. cap?: number;
  58312. invertUV?: boolean;
  58313. }, scene?: Nullable<Scene>): Mesh;
  58314. /**
  58315. * Creates a tiled plane mesh
  58316. * * You can set a limited pattern arrangement with the tiles
  58317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58318. * * 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
  58319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58320. * @param name defines the name of the mesh
  58321. * @param options defines the options used to create the mesh
  58322. * @param scene defines the hosting scene
  58323. * @returns the plane mesh
  58324. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58325. */
  58326. static CreateTiledPlane(name: string, options: {
  58327. pattern?: number;
  58328. tileSize?: number;
  58329. tileWidth?: number;
  58330. tileHeight?: number;
  58331. size?: number;
  58332. width?: number;
  58333. height?: number;
  58334. alignHorizontal?: number;
  58335. alignVertical?: number;
  58336. sideOrientation?: number;
  58337. frontUVs?: Vector4;
  58338. backUVs?: Vector4;
  58339. updatable?: boolean;
  58340. }, scene?: Nullable<Scene>): Mesh;
  58341. /**
  58342. * Creates a plane mesh
  58343. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  58344. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  58345. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  58346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58347. * * 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
  58348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58349. * @param name defines the name of the mesh
  58350. * @param options defines the options used to create the mesh
  58351. * @param scene defines the hosting scene
  58352. * @returns the plane mesh
  58353. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58354. */
  58355. static CreatePlane(name: string, options: {
  58356. size?: number;
  58357. width?: number;
  58358. height?: number;
  58359. sideOrientation?: number;
  58360. frontUVs?: Vector4;
  58361. backUVs?: Vector4;
  58362. updatable?: boolean;
  58363. sourcePlane?: Plane;
  58364. }, scene?: Nullable<Scene>): Mesh;
  58365. /**
  58366. * Creates a ground mesh
  58367. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  58368. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  58369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58370. * @param name defines the name of the mesh
  58371. * @param options defines the options used to create the mesh
  58372. * @param scene defines the hosting scene
  58373. * @returns the ground mesh
  58374. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  58375. */
  58376. static CreateGround(name: string, options: {
  58377. width?: number;
  58378. height?: number;
  58379. subdivisions?: number;
  58380. subdivisionsX?: number;
  58381. subdivisionsY?: number;
  58382. updatable?: boolean;
  58383. }, scene?: Nullable<Scene>): Mesh;
  58384. /**
  58385. * Creates a tiled ground mesh
  58386. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  58387. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  58388. * * 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
  58389. * * 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
  58390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58391. * @param name defines the name of the mesh
  58392. * @param options defines the options used to create the mesh
  58393. * @param scene defines the hosting scene
  58394. * @returns the tiled ground mesh
  58395. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  58396. */
  58397. static CreateTiledGround(name: string, options: {
  58398. xmin: number;
  58399. zmin: number;
  58400. xmax: number;
  58401. zmax: number;
  58402. subdivisions?: {
  58403. w: number;
  58404. h: number;
  58405. };
  58406. precision?: {
  58407. w: number;
  58408. h: number;
  58409. };
  58410. updatable?: boolean;
  58411. }, scene?: Nullable<Scene>): Mesh;
  58412. /**
  58413. * Creates a ground mesh from a height map
  58414. * * The parameter `url` sets the URL of the height map image resource.
  58415. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  58416. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  58417. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  58418. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  58419. * * 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.
  58420. * * 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).
  58421. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  58422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58423. * @param name defines the name of the mesh
  58424. * @param url defines the url to the height map
  58425. * @param options defines the options used to create the mesh
  58426. * @param scene defines the hosting scene
  58427. * @returns the ground mesh
  58428. * @see https://doc.babylonjs.com/babylon101/height_map
  58429. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  58430. */
  58431. static CreateGroundFromHeightMap(name: string, url: string, options: {
  58432. width?: number;
  58433. height?: number;
  58434. subdivisions?: number;
  58435. minHeight?: number;
  58436. maxHeight?: number;
  58437. colorFilter?: Color3;
  58438. alphaFilter?: number;
  58439. updatable?: boolean;
  58440. onReady?: (mesh: GroundMesh) => void;
  58441. }, scene?: Nullable<Scene>): GroundMesh;
  58442. /**
  58443. * Creates a polygon mesh
  58444. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58445. * * 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
  58446. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58448. * * 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)
  58449. * * Remember you can only change the shape positions, not their number when updating a polygon
  58450. * @param name defines the name of the mesh
  58451. * @param options defines the options used to create the mesh
  58452. * @param scene defines the hosting scene
  58453. * @param earcutInjection can be used to inject your own earcut reference
  58454. * @returns the polygon mesh
  58455. */
  58456. static CreatePolygon(name: string, options: {
  58457. shape: Vector3[];
  58458. holes?: Vector3[][];
  58459. depth?: number;
  58460. faceUV?: Vector4[];
  58461. faceColors?: Color4[];
  58462. updatable?: boolean;
  58463. sideOrientation?: number;
  58464. frontUVs?: Vector4;
  58465. backUVs?: Vector4;
  58466. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58467. /**
  58468. * Creates an extruded polygon mesh, with depth in the Y direction.
  58469. * * 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)
  58470. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58471. * @param name defines the name of the mesh
  58472. * @param options defines the options used to create the mesh
  58473. * @param scene defines the hosting scene
  58474. * @param earcutInjection can be used to inject your own earcut reference
  58475. * @returns the polygon mesh
  58476. */
  58477. static ExtrudePolygon(name: string, options: {
  58478. shape: Vector3[];
  58479. holes?: Vector3[][];
  58480. depth?: number;
  58481. faceUV?: Vector4[];
  58482. faceColors?: Color4[];
  58483. updatable?: boolean;
  58484. sideOrientation?: number;
  58485. frontUVs?: Vector4;
  58486. backUVs?: Vector4;
  58487. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58488. /**
  58489. * Creates a tube mesh.
  58490. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58491. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58492. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58493. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58494. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58495. * * 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)
  58496. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58497. * * 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
  58498. * * 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
  58499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58500. * * 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
  58501. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58503. * @param name defines the name of the mesh
  58504. * @param options defines the options used to create the mesh
  58505. * @param scene defines the hosting scene
  58506. * @returns the tube mesh
  58507. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58508. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58509. */
  58510. static CreateTube(name: string, options: {
  58511. path: Vector3[];
  58512. radius?: number;
  58513. tessellation?: number;
  58514. radiusFunction?: {
  58515. (i: number, distance: number): number;
  58516. };
  58517. cap?: number;
  58518. arc?: number;
  58519. updatable?: boolean;
  58520. sideOrientation?: number;
  58521. frontUVs?: Vector4;
  58522. backUVs?: Vector4;
  58523. instance?: Mesh;
  58524. invertUV?: boolean;
  58525. }, scene?: Nullable<Scene>): Mesh;
  58526. /**
  58527. * Creates a polyhedron mesh
  58528. * * 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
  58529. * * The parameter `size` (positive float, default 1) sets the polygon size
  58530. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58531. * * 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`
  58532. * * 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
  58533. * * 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)`)
  58534. * * 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
  58535. * * 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
  58536. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58537. * * 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
  58538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58539. * @param name defines the name of the mesh
  58540. * @param options defines the options used to create the mesh
  58541. * @param scene defines the hosting scene
  58542. * @returns the polyhedron mesh
  58543. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58544. */
  58545. static CreatePolyhedron(name: string, options: {
  58546. type?: number;
  58547. size?: number;
  58548. sizeX?: number;
  58549. sizeY?: number;
  58550. sizeZ?: number;
  58551. custom?: any;
  58552. faceUV?: Vector4[];
  58553. faceColors?: Color4[];
  58554. flat?: boolean;
  58555. updatable?: boolean;
  58556. sideOrientation?: number;
  58557. frontUVs?: Vector4;
  58558. backUVs?: Vector4;
  58559. }, scene?: Nullable<Scene>): Mesh;
  58560. /**
  58561. * Creates a decal mesh.
  58562. * 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
  58563. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58564. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58565. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58566. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58567. * @param name defines the name of the mesh
  58568. * @param sourceMesh defines the mesh where the decal must be applied
  58569. * @param options defines the options used to create the mesh
  58570. * @param scene defines the hosting scene
  58571. * @returns the decal mesh
  58572. * @see https://doc.babylonjs.com/how_to/decals
  58573. */
  58574. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58575. position?: Vector3;
  58576. normal?: Vector3;
  58577. size?: Vector3;
  58578. angle?: number;
  58579. }): Mesh;
  58580. }
  58581. }
  58582. declare module BABYLON {
  58583. /**
  58584. * A simplifier interface for future simplification implementations
  58585. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58586. */
  58587. export interface ISimplifier {
  58588. /**
  58589. * Simplification of a given mesh according to the given settings.
  58590. * Since this requires computation, it is assumed that the function runs async.
  58591. * @param settings The settings of the simplification, including quality and distance
  58592. * @param successCallback A callback that will be called after the mesh was simplified.
  58593. * @param errorCallback in case of an error, this callback will be called. optional.
  58594. */
  58595. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  58596. }
  58597. /**
  58598. * Expected simplification settings.
  58599. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  58600. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58601. */
  58602. export interface ISimplificationSettings {
  58603. /**
  58604. * Gets or sets the expected quality
  58605. */
  58606. quality: number;
  58607. /**
  58608. * Gets or sets the distance when this optimized version should be used
  58609. */
  58610. distance: number;
  58611. /**
  58612. * Gets an already optimized mesh
  58613. */
  58614. optimizeMesh?: boolean;
  58615. }
  58616. /**
  58617. * Class used to specify simplification options
  58618. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58619. */
  58620. export class SimplificationSettings implements ISimplificationSettings {
  58621. /** expected quality */
  58622. quality: number;
  58623. /** distance when this optimized version should be used */
  58624. distance: number;
  58625. /** already optimized mesh */
  58626. optimizeMesh?: boolean | undefined;
  58627. /**
  58628. * Creates a SimplificationSettings
  58629. * @param quality expected quality
  58630. * @param distance distance when this optimized version should be used
  58631. * @param optimizeMesh already optimized mesh
  58632. */
  58633. constructor(
  58634. /** expected quality */
  58635. quality: number,
  58636. /** distance when this optimized version should be used */
  58637. distance: number,
  58638. /** already optimized mesh */
  58639. optimizeMesh?: boolean | undefined);
  58640. }
  58641. /**
  58642. * Interface used to define a simplification task
  58643. */
  58644. export interface ISimplificationTask {
  58645. /**
  58646. * Array of settings
  58647. */
  58648. settings: Array<ISimplificationSettings>;
  58649. /**
  58650. * Simplification type
  58651. */
  58652. simplificationType: SimplificationType;
  58653. /**
  58654. * Mesh to simplify
  58655. */
  58656. mesh: Mesh;
  58657. /**
  58658. * Callback called on success
  58659. */
  58660. successCallback?: () => void;
  58661. /**
  58662. * Defines if parallel processing can be used
  58663. */
  58664. parallelProcessing: boolean;
  58665. }
  58666. /**
  58667. * Queue used to order the simplification tasks
  58668. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58669. */
  58670. export class SimplificationQueue {
  58671. private _simplificationArray;
  58672. /**
  58673. * Gets a boolean indicating that the process is still running
  58674. */
  58675. running: boolean;
  58676. /**
  58677. * Creates a new queue
  58678. */
  58679. constructor();
  58680. /**
  58681. * Adds a new simplification task
  58682. * @param task defines a task to add
  58683. */
  58684. addTask(task: ISimplificationTask): void;
  58685. /**
  58686. * Execute next task
  58687. */
  58688. executeNext(): void;
  58689. /**
  58690. * Execute a simplification task
  58691. * @param task defines the task to run
  58692. */
  58693. runSimplification(task: ISimplificationTask): void;
  58694. private getSimplifier;
  58695. }
  58696. /**
  58697. * The implemented types of simplification
  58698. * At the moment only Quadratic Error Decimation is implemented
  58699. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58700. */
  58701. export enum SimplificationType {
  58702. /** Quadratic error decimation */
  58703. QUADRATIC = 0
  58704. }
  58705. }
  58706. declare module BABYLON {
  58707. interface Scene {
  58708. /** @hidden (Backing field) */
  58709. _simplificationQueue: SimplificationQueue;
  58710. /**
  58711. * Gets or sets the simplification queue attached to the scene
  58712. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58713. */
  58714. simplificationQueue: SimplificationQueue;
  58715. }
  58716. interface Mesh {
  58717. /**
  58718. * Simplify the mesh according to the given array of settings.
  58719. * Function will return immediately and will simplify async
  58720. * @param settings a collection of simplification settings
  58721. * @param parallelProcessing should all levels calculate parallel or one after the other
  58722. * @param simplificationType the type of simplification to run
  58723. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  58724. * @returns the current mesh
  58725. */
  58726. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  58727. }
  58728. /**
  58729. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  58730. * created in a scene
  58731. */
  58732. export class SimplicationQueueSceneComponent implements ISceneComponent {
  58733. /**
  58734. * The component name helpfull to identify the component in the list of scene components.
  58735. */
  58736. readonly name: string;
  58737. /**
  58738. * The scene the component belongs to.
  58739. */
  58740. scene: Scene;
  58741. /**
  58742. * Creates a new instance of the component for the given scene
  58743. * @param scene Defines the scene to register the component in
  58744. */
  58745. constructor(scene: Scene);
  58746. /**
  58747. * Registers the component in a given scene
  58748. */
  58749. register(): void;
  58750. /**
  58751. * Rebuilds the elements related to this component in case of
  58752. * context lost for instance.
  58753. */
  58754. rebuild(): void;
  58755. /**
  58756. * Disposes the component and the associated ressources
  58757. */
  58758. dispose(): void;
  58759. private _beforeCameraUpdate;
  58760. }
  58761. }
  58762. declare module BABYLON {
  58763. /**
  58764. * Navigation plugin interface to add navigation constrained by a navigation mesh
  58765. */
  58766. export interface INavigationEnginePlugin {
  58767. /**
  58768. * plugin name
  58769. */
  58770. name: string;
  58771. /**
  58772. * Creates a navigation mesh
  58773. * @param meshes array of all the geometry used to compute the navigatio mesh
  58774. * @param parameters bunch of parameters used to filter geometry
  58775. */
  58776. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58777. /**
  58778. * Create a navigation mesh debug mesh
  58779. * @param scene is where the mesh will be added
  58780. * @returns debug display mesh
  58781. */
  58782. createDebugNavMesh(scene: Scene): Mesh;
  58783. /**
  58784. * Get a navigation mesh constrained position, closest to the parameter position
  58785. * @param position world position
  58786. * @returns the closest point to position constrained by the navigation mesh
  58787. */
  58788. getClosestPoint(position: Vector3): Vector3;
  58789. /**
  58790. * Get a navigation mesh constrained position, within a particular radius
  58791. * @param position world position
  58792. * @param maxRadius the maximum distance to the constrained world position
  58793. * @returns the closest point to position constrained by the navigation mesh
  58794. */
  58795. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58796. /**
  58797. * Compute the final position from a segment made of destination-position
  58798. * @param position world position
  58799. * @param destination world position
  58800. * @returns the resulting point along the navmesh
  58801. */
  58802. moveAlong(position: Vector3, destination: Vector3): Vector3;
  58803. /**
  58804. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58805. * @param start world position
  58806. * @param end world position
  58807. * @returns array containing world position composing the path
  58808. */
  58809. computePath(start: Vector3, end: Vector3): Vector3[];
  58810. /**
  58811. * If this plugin is supported
  58812. * @returns true if plugin is supported
  58813. */
  58814. isSupported(): boolean;
  58815. /**
  58816. * Create a new Crowd so you can add agents
  58817. * @param maxAgents the maximum agent count in the crowd
  58818. * @param maxAgentRadius the maximum radius an agent can have
  58819. * @param scene to attach the crowd to
  58820. * @returns the crowd you can add agents to
  58821. */
  58822. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58823. /**
  58824. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  58825. * The queries will try to find a solution within those bounds
  58826. * default is (1,1,1)
  58827. * @param extent x,y,z value that define the extent around the queries point of reference
  58828. */
  58829. setDefaultQueryExtent(extent: Vector3): void;
  58830. /**
  58831. * Get the Bounding box extent specified by setDefaultQueryExtent
  58832. * @returns the box extent values
  58833. */
  58834. getDefaultQueryExtent(): Vector3;
  58835. /**
  58836. * Release all resources
  58837. */
  58838. dispose(): void;
  58839. }
  58840. /**
  58841. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  58842. */
  58843. export interface ICrowd {
  58844. /**
  58845. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58846. * You can attach anything to that node. The node position is updated in the scene update tick.
  58847. * @param pos world position that will be constrained by the navigation mesh
  58848. * @param parameters agent parameters
  58849. * @param transform hooked to the agent that will be update by the scene
  58850. * @returns agent index
  58851. */
  58852. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58853. /**
  58854. * Returns the agent position in world space
  58855. * @param index agent index returned by addAgent
  58856. * @returns world space position
  58857. */
  58858. getAgentPosition(index: number): Vector3;
  58859. /**
  58860. * Gets the agent velocity in world space
  58861. * @param index agent index returned by addAgent
  58862. * @returns world space velocity
  58863. */
  58864. getAgentVelocity(index: number): Vector3;
  58865. /**
  58866. * remove a particular agent previously created
  58867. * @param index agent index returned by addAgent
  58868. */
  58869. removeAgent(index: number): void;
  58870. /**
  58871. * get the list of all agents attached to this crowd
  58872. * @returns list of agent indices
  58873. */
  58874. getAgents(): number[];
  58875. /**
  58876. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58877. * @param deltaTime in seconds
  58878. */
  58879. update(deltaTime: number): void;
  58880. /**
  58881. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58882. * @param index agent index returned by addAgent
  58883. * @param destination targeted world position
  58884. */
  58885. agentGoto(index: number, destination: Vector3): void;
  58886. /**
  58887. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  58888. * The queries will try to find a solution within those bounds
  58889. * default is (1,1,1)
  58890. * @param extent x,y,z value that define the extent around the queries point of reference
  58891. */
  58892. setDefaultQueryExtent(extent: Vector3): void;
  58893. /**
  58894. * Get the Bounding box extent specified by setDefaultQueryExtent
  58895. * @returns the box extent values
  58896. */
  58897. getDefaultQueryExtent(): Vector3;
  58898. /**
  58899. * Release all resources
  58900. */
  58901. dispose(): void;
  58902. }
  58903. /**
  58904. * Configures an agent
  58905. */
  58906. export interface IAgentParameters {
  58907. /**
  58908. * Agent radius. [Limit: >= 0]
  58909. */
  58910. radius: number;
  58911. /**
  58912. * Agent height. [Limit: > 0]
  58913. */
  58914. height: number;
  58915. /**
  58916. * Maximum allowed acceleration. [Limit: >= 0]
  58917. */
  58918. maxAcceleration: number;
  58919. /**
  58920. * Maximum allowed speed. [Limit: >= 0]
  58921. */
  58922. maxSpeed: number;
  58923. /**
  58924. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  58925. */
  58926. collisionQueryRange: number;
  58927. /**
  58928. * The path visibility optimization range. [Limit: > 0]
  58929. */
  58930. pathOptimizationRange: number;
  58931. /**
  58932. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  58933. */
  58934. separationWeight: number;
  58935. }
  58936. /**
  58937. * Configures the navigation mesh creation
  58938. */
  58939. export interface INavMeshParameters {
  58940. /**
  58941. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  58942. */
  58943. cs: number;
  58944. /**
  58945. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  58946. */
  58947. ch: number;
  58948. /**
  58949. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  58950. */
  58951. walkableSlopeAngle: number;
  58952. /**
  58953. * Minimum floor to 'ceiling' height that will still allow the floor area to
  58954. * be considered walkable. [Limit: >= 3] [Units: vx]
  58955. */
  58956. walkableHeight: number;
  58957. /**
  58958. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  58959. */
  58960. walkableClimb: number;
  58961. /**
  58962. * The distance to erode/shrink the walkable area of the heightfield away from
  58963. * obstructions. [Limit: >=0] [Units: vx]
  58964. */
  58965. walkableRadius: number;
  58966. /**
  58967. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  58968. */
  58969. maxEdgeLen: number;
  58970. /**
  58971. * The maximum distance a simplfied contour's border edges should deviate
  58972. * the original raw contour. [Limit: >=0] [Units: vx]
  58973. */
  58974. maxSimplificationError: number;
  58975. /**
  58976. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  58977. */
  58978. minRegionArea: number;
  58979. /**
  58980. * Any regions with a span count smaller than this value will, if possible,
  58981. * be merged with larger regions. [Limit: >=0] [Units: vx]
  58982. */
  58983. mergeRegionArea: number;
  58984. /**
  58985. * The maximum number of vertices allowed for polygons generated during the
  58986. * contour to polygon conversion process. [Limit: >= 3]
  58987. */
  58988. maxVertsPerPoly: number;
  58989. /**
  58990. * Sets the sampling distance to use when generating the detail mesh.
  58991. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  58992. */
  58993. detailSampleDist: number;
  58994. /**
  58995. * The maximum distance the detail mesh surface should deviate from heightfield
  58996. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  58997. */
  58998. detailSampleMaxError: number;
  58999. }
  59000. }
  59001. declare module BABYLON {
  59002. /**
  59003. * RecastJS navigation plugin
  59004. */
  59005. export class RecastJSPlugin implements INavigationEnginePlugin {
  59006. /**
  59007. * Reference to the Recast library
  59008. */
  59009. bjsRECAST: any;
  59010. /**
  59011. * plugin name
  59012. */
  59013. name: string;
  59014. /**
  59015. * the first navmesh created. We might extend this to support multiple navmeshes
  59016. */
  59017. navMesh: any;
  59018. /**
  59019. * Initializes the recastJS plugin
  59020. * @param recastInjection can be used to inject your own recast reference
  59021. */
  59022. constructor(recastInjection?: any);
  59023. /**
  59024. * Creates a navigation mesh
  59025. * @param meshes array of all the geometry used to compute the navigatio mesh
  59026. * @param parameters bunch of parameters used to filter geometry
  59027. */
  59028. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59029. /**
  59030. * Create a navigation mesh debug mesh
  59031. * @param scene is where the mesh will be added
  59032. * @returns debug display mesh
  59033. */
  59034. createDebugNavMesh(scene: Scene): Mesh;
  59035. /**
  59036. * Get a navigation mesh constrained position, closest to the parameter position
  59037. * @param position world position
  59038. * @returns the closest point to position constrained by the navigation mesh
  59039. */
  59040. getClosestPoint(position: Vector3): Vector3;
  59041. /**
  59042. * Get a navigation mesh constrained position, within a particular radius
  59043. * @param position world position
  59044. * @param maxRadius the maximum distance to the constrained world position
  59045. * @returns the closest point to position constrained by the navigation mesh
  59046. */
  59047. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59048. /**
  59049. * Compute the final position from a segment made of destination-position
  59050. * @param position world position
  59051. * @param destination world position
  59052. * @returns the resulting point along the navmesh
  59053. */
  59054. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59055. /**
  59056. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59057. * @param start world position
  59058. * @param end world position
  59059. * @returns array containing world position composing the path
  59060. */
  59061. computePath(start: Vector3, end: Vector3): Vector3[];
  59062. /**
  59063. * Create a new Crowd so you can add agents
  59064. * @param maxAgents the maximum agent count in the crowd
  59065. * @param maxAgentRadius the maximum radius an agent can have
  59066. * @param scene to attach the crowd to
  59067. * @returns the crowd you can add agents to
  59068. */
  59069. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59070. /**
  59071. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59072. * The queries will try to find a solution within those bounds
  59073. * default is (1,1,1)
  59074. * @param extent x,y,z value that define the extent around the queries point of reference
  59075. */
  59076. setDefaultQueryExtent(extent: Vector3): void;
  59077. /**
  59078. * Get the Bounding box extent specified by setDefaultQueryExtent
  59079. * @returns the box extent values
  59080. */
  59081. getDefaultQueryExtent(): Vector3;
  59082. /**
  59083. * Disposes
  59084. */
  59085. dispose(): void;
  59086. /**
  59087. * If this plugin is supported
  59088. * @returns true if plugin is supported
  59089. */
  59090. isSupported(): boolean;
  59091. }
  59092. /**
  59093. * Recast detour crowd implementation
  59094. */
  59095. export class RecastJSCrowd implements ICrowd {
  59096. /**
  59097. * Recast/detour plugin
  59098. */
  59099. bjsRECASTPlugin: RecastJSPlugin;
  59100. /**
  59101. * Link to the detour crowd
  59102. */
  59103. recastCrowd: any;
  59104. /**
  59105. * One transform per agent
  59106. */
  59107. transforms: TransformNode[];
  59108. /**
  59109. * All agents created
  59110. */
  59111. agents: number[];
  59112. /**
  59113. * Link to the scene is kept to unregister the crowd from the scene
  59114. */
  59115. private _scene;
  59116. /**
  59117. * Observer for crowd updates
  59118. */
  59119. private _onBeforeAnimationsObserver;
  59120. /**
  59121. * Constructor
  59122. * @param plugin recastJS plugin
  59123. * @param maxAgents the maximum agent count in the crowd
  59124. * @param maxAgentRadius the maximum radius an agent can have
  59125. * @param scene to attach the crowd to
  59126. * @returns the crowd you can add agents to
  59127. */
  59128. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  59129. /**
  59130. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59131. * You can attach anything to that node. The node position is updated in the scene update tick.
  59132. * @param pos world position that will be constrained by the navigation mesh
  59133. * @param parameters agent parameters
  59134. * @param transform hooked to the agent that will be update by the scene
  59135. * @returns agent index
  59136. */
  59137. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59138. /**
  59139. * Returns the agent position in world space
  59140. * @param index agent index returned by addAgent
  59141. * @returns world space position
  59142. */
  59143. getAgentPosition(index: number): Vector3;
  59144. /**
  59145. * Returns the agent velocity in world space
  59146. * @param index agent index returned by addAgent
  59147. * @returns world space velocity
  59148. */
  59149. getAgentVelocity(index: number): Vector3;
  59150. /**
  59151. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59152. * @param index agent index returned by addAgent
  59153. * @param destination targeted world position
  59154. */
  59155. agentGoto(index: number, destination: Vector3): void;
  59156. /**
  59157. * remove a particular agent previously created
  59158. * @param index agent index returned by addAgent
  59159. */
  59160. removeAgent(index: number): void;
  59161. /**
  59162. * get the list of all agents attached to this crowd
  59163. * @returns list of agent indices
  59164. */
  59165. getAgents(): number[];
  59166. /**
  59167. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59168. * @param deltaTime in seconds
  59169. */
  59170. update(deltaTime: number): void;
  59171. /**
  59172. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59173. * The queries will try to find a solution within those bounds
  59174. * default is (1,1,1)
  59175. * @param extent x,y,z value that define the extent around the queries point of reference
  59176. */
  59177. setDefaultQueryExtent(extent: Vector3): void;
  59178. /**
  59179. * Get the Bounding box extent specified by setDefaultQueryExtent
  59180. * @returns the box extent values
  59181. */
  59182. getDefaultQueryExtent(): Vector3;
  59183. /**
  59184. * Release all resources
  59185. */
  59186. dispose(): void;
  59187. }
  59188. }
  59189. declare module BABYLON {
  59190. /**
  59191. * Class used to enable access to IndexedDB
  59192. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  59193. */
  59194. export class Database implements IOfflineProvider {
  59195. private _callbackManifestChecked;
  59196. private _currentSceneUrl;
  59197. private _db;
  59198. private _enableSceneOffline;
  59199. private _enableTexturesOffline;
  59200. private _manifestVersionFound;
  59201. private _mustUpdateRessources;
  59202. private _hasReachedQuota;
  59203. private _isSupported;
  59204. private _idbFactory;
  59205. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  59206. private static IsUASupportingBlobStorage;
  59207. /**
  59208. * Gets a boolean indicating if Database storate is enabled (off by default)
  59209. */
  59210. static IDBStorageEnabled: boolean;
  59211. /**
  59212. * Gets a boolean indicating if scene must be saved in the database
  59213. */
  59214. readonly enableSceneOffline: boolean;
  59215. /**
  59216. * Gets a boolean indicating if textures must be saved in the database
  59217. */
  59218. readonly enableTexturesOffline: boolean;
  59219. /**
  59220. * Creates a new Database
  59221. * @param urlToScene defines the url to load the scene
  59222. * @param callbackManifestChecked defines the callback to use when manifest is checked
  59223. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  59224. */
  59225. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  59226. private static _ParseURL;
  59227. private static _ReturnFullUrlLocation;
  59228. private _checkManifestFile;
  59229. /**
  59230. * Open the database and make it available
  59231. * @param successCallback defines the callback to call on success
  59232. * @param errorCallback defines the callback to call on error
  59233. */
  59234. open(successCallback: () => void, errorCallback: () => void): void;
  59235. /**
  59236. * Loads an image from the database
  59237. * @param url defines the url to load from
  59238. * @param image defines the target DOM image
  59239. */
  59240. loadImage(url: string, image: HTMLImageElement): void;
  59241. private _loadImageFromDBAsync;
  59242. private _saveImageIntoDBAsync;
  59243. private _checkVersionFromDB;
  59244. private _loadVersionFromDBAsync;
  59245. private _saveVersionIntoDBAsync;
  59246. /**
  59247. * Loads a file from database
  59248. * @param url defines the URL to load from
  59249. * @param sceneLoaded defines a callback to call on success
  59250. * @param progressCallBack defines a callback to call when progress changed
  59251. * @param errorCallback defines a callback to call on error
  59252. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  59253. */
  59254. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  59255. private _loadFileAsync;
  59256. private _saveFileAsync;
  59257. /**
  59258. * Validates if xhr data is correct
  59259. * @param xhr defines the request to validate
  59260. * @param dataType defines the expected data type
  59261. * @returns true if data is correct
  59262. */
  59263. private static _ValidateXHRData;
  59264. }
  59265. }
  59266. declare module BABYLON {
  59267. /** @hidden */
  59268. export var gpuUpdateParticlesPixelShader: {
  59269. name: string;
  59270. shader: string;
  59271. };
  59272. }
  59273. declare module BABYLON {
  59274. /** @hidden */
  59275. export var gpuUpdateParticlesVertexShader: {
  59276. name: string;
  59277. shader: string;
  59278. };
  59279. }
  59280. declare module BABYLON {
  59281. /** @hidden */
  59282. export var clipPlaneFragmentDeclaration2: {
  59283. name: string;
  59284. shader: string;
  59285. };
  59286. }
  59287. declare module BABYLON {
  59288. /** @hidden */
  59289. export var gpuRenderParticlesPixelShader: {
  59290. name: string;
  59291. shader: string;
  59292. };
  59293. }
  59294. declare module BABYLON {
  59295. /** @hidden */
  59296. export var clipPlaneVertexDeclaration2: {
  59297. name: string;
  59298. shader: string;
  59299. };
  59300. }
  59301. declare module BABYLON {
  59302. /** @hidden */
  59303. export var gpuRenderParticlesVertexShader: {
  59304. name: string;
  59305. shader: string;
  59306. };
  59307. }
  59308. declare module BABYLON {
  59309. /**
  59310. * This represents a GPU particle system in Babylon
  59311. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  59312. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  59313. */
  59314. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  59315. /**
  59316. * The layer mask we are rendering the particles through.
  59317. */
  59318. layerMask: number;
  59319. private _capacity;
  59320. private _activeCount;
  59321. private _currentActiveCount;
  59322. private _accumulatedCount;
  59323. private _renderEffect;
  59324. private _updateEffect;
  59325. private _buffer0;
  59326. private _buffer1;
  59327. private _spriteBuffer;
  59328. private _updateVAO;
  59329. private _renderVAO;
  59330. private _targetIndex;
  59331. private _sourceBuffer;
  59332. private _targetBuffer;
  59333. private _engine;
  59334. private _currentRenderId;
  59335. private _started;
  59336. private _stopped;
  59337. private _timeDelta;
  59338. private _randomTexture;
  59339. private _randomTexture2;
  59340. private _attributesStrideSize;
  59341. private _updateEffectOptions;
  59342. private _randomTextureSize;
  59343. private _actualFrame;
  59344. private readonly _rawTextureWidth;
  59345. /**
  59346. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  59347. */
  59348. static readonly IsSupported: boolean;
  59349. /**
  59350. * An event triggered when the system is disposed.
  59351. */
  59352. onDisposeObservable: Observable<GPUParticleSystem>;
  59353. /**
  59354. * Gets the maximum number of particles active at the same time.
  59355. * @returns The max number of active particles.
  59356. */
  59357. getCapacity(): number;
  59358. /**
  59359. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  59360. * to override the particles.
  59361. */
  59362. forceDepthWrite: boolean;
  59363. /**
  59364. * Gets or set the number of active particles
  59365. */
  59366. activeParticleCount: number;
  59367. private _preWarmDone;
  59368. /**
  59369. * Is this system ready to be used/rendered
  59370. * @return true if the system is ready
  59371. */
  59372. isReady(): boolean;
  59373. /**
  59374. * Gets if the system has been started. (Note: this will still be true after stop is called)
  59375. * @returns True if it has been started, otherwise false.
  59376. */
  59377. isStarted(): boolean;
  59378. /**
  59379. * Starts the particle system and begins to emit
  59380. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  59381. */
  59382. start(delay?: number): void;
  59383. /**
  59384. * Stops the particle system.
  59385. */
  59386. stop(): void;
  59387. /**
  59388. * Remove all active particles
  59389. */
  59390. reset(): void;
  59391. /**
  59392. * Returns the string "GPUParticleSystem"
  59393. * @returns a string containing the class name
  59394. */
  59395. getClassName(): string;
  59396. private _colorGradientsTexture;
  59397. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  59398. /**
  59399. * Adds a new color gradient
  59400. * @param gradient defines the gradient to use (between 0 and 1)
  59401. * @param color1 defines the color to affect to the specified gradient
  59402. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  59403. * @returns the current particle system
  59404. */
  59405. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  59406. /**
  59407. * Remove a specific color gradient
  59408. * @param gradient defines the gradient to remove
  59409. * @returns the current particle system
  59410. */
  59411. removeColorGradient(gradient: number): GPUParticleSystem;
  59412. private _angularSpeedGradientsTexture;
  59413. private _sizeGradientsTexture;
  59414. private _velocityGradientsTexture;
  59415. private _limitVelocityGradientsTexture;
  59416. private _dragGradientsTexture;
  59417. private _addFactorGradient;
  59418. /**
  59419. * Adds a new size gradient
  59420. * @param gradient defines the gradient to use (between 0 and 1)
  59421. * @param factor defines the size factor to affect to the specified gradient
  59422. * @returns the current particle system
  59423. */
  59424. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  59425. /**
  59426. * Remove a specific size gradient
  59427. * @param gradient defines the gradient to remove
  59428. * @returns the current particle system
  59429. */
  59430. removeSizeGradient(gradient: number): GPUParticleSystem;
  59431. /**
  59432. * Adds a new angular speed gradient
  59433. * @param gradient defines the gradient to use (between 0 and 1)
  59434. * @param factor defines the angular speed to affect to the specified gradient
  59435. * @returns the current particle system
  59436. */
  59437. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  59438. /**
  59439. * Remove a specific angular speed gradient
  59440. * @param gradient defines the gradient to remove
  59441. * @returns the current particle system
  59442. */
  59443. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  59444. /**
  59445. * Adds a new velocity gradient
  59446. * @param gradient defines the gradient to use (between 0 and 1)
  59447. * @param factor defines the velocity to affect to the specified gradient
  59448. * @returns the current particle system
  59449. */
  59450. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59451. /**
  59452. * Remove a specific velocity gradient
  59453. * @param gradient defines the gradient to remove
  59454. * @returns the current particle system
  59455. */
  59456. removeVelocityGradient(gradient: number): GPUParticleSystem;
  59457. /**
  59458. * Adds a new limit velocity gradient
  59459. * @param gradient defines the gradient to use (between 0 and 1)
  59460. * @param factor defines the limit velocity value to affect to the specified gradient
  59461. * @returns the current particle system
  59462. */
  59463. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59464. /**
  59465. * Remove a specific limit velocity gradient
  59466. * @param gradient defines the gradient to remove
  59467. * @returns the current particle system
  59468. */
  59469. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  59470. /**
  59471. * Adds a new drag gradient
  59472. * @param gradient defines the gradient to use (between 0 and 1)
  59473. * @param factor defines the drag value to affect to the specified gradient
  59474. * @returns the current particle system
  59475. */
  59476. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  59477. /**
  59478. * Remove a specific drag gradient
  59479. * @param gradient defines the gradient to remove
  59480. * @returns the current particle system
  59481. */
  59482. removeDragGradient(gradient: number): GPUParticleSystem;
  59483. /**
  59484. * Not supported by GPUParticleSystem
  59485. * @param gradient defines the gradient to use (between 0 and 1)
  59486. * @param factor defines the emit rate value to affect to the specified gradient
  59487. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59488. * @returns the current particle system
  59489. */
  59490. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59491. /**
  59492. * Not supported by GPUParticleSystem
  59493. * @param gradient defines the gradient to remove
  59494. * @returns the current particle system
  59495. */
  59496. removeEmitRateGradient(gradient: number): IParticleSystem;
  59497. /**
  59498. * Not supported by GPUParticleSystem
  59499. * @param gradient defines the gradient to use (between 0 and 1)
  59500. * @param factor defines the start size value to affect to the specified gradient
  59501. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59502. * @returns the current particle system
  59503. */
  59504. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59505. /**
  59506. * Not supported by GPUParticleSystem
  59507. * @param gradient defines the gradient to remove
  59508. * @returns the current particle system
  59509. */
  59510. removeStartSizeGradient(gradient: number): IParticleSystem;
  59511. /**
  59512. * Not supported by GPUParticleSystem
  59513. * @param gradient defines the gradient to use (between 0 and 1)
  59514. * @param min defines the color remap minimal range
  59515. * @param max defines the color remap maximal range
  59516. * @returns the current particle system
  59517. */
  59518. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  59519. /**
  59520. * Not supported by GPUParticleSystem
  59521. * @param gradient defines the gradient to remove
  59522. * @returns the current particle system
  59523. */
  59524. removeColorRemapGradient(): IParticleSystem;
  59525. /**
  59526. * Not supported by GPUParticleSystem
  59527. * @param gradient defines the gradient to use (between 0 and 1)
  59528. * @param min defines the alpha remap minimal range
  59529. * @param max defines the alpha remap maximal range
  59530. * @returns the current particle system
  59531. */
  59532. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  59533. /**
  59534. * Not supported by GPUParticleSystem
  59535. * @param gradient defines the gradient to remove
  59536. * @returns the current particle system
  59537. */
  59538. removeAlphaRemapGradient(): IParticleSystem;
  59539. /**
  59540. * Not supported by GPUParticleSystem
  59541. * @param gradient defines the gradient to use (between 0 and 1)
  59542. * @param color defines the color to affect to the specified gradient
  59543. * @returns the current particle system
  59544. */
  59545. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  59546. /**
  59547. * Not supported by GPUParticleSystem
  59548. * @param gradient defines the gradient to remove
  59549. * @returns the current particle system
  59550. */
  59551. removeRampGradient(): IParticleSystem;
  59552. /**
  59553. * Not supported by GPUParticleSystem
  59554. * @returns the list of ramp gradients
  59555. */
  59556. getRampGradients(): Nullable<Array<Color3Gradient>>;
  59557. /**
  59558. * Not supported by GPUParticleSystem
  59559. * Gets or sets a boolean indicating that ramp gradients must be used
  59560. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  59561. */
  59562. useRampGradients: boolean;
  59563. /**
  59564. * Not supported by GPUParticleSystem
  59565. * @param gradient defines the gradient to use (between 0 and 1)
  59566. * @param factor defines the life time factor to affect to the specified gradient
  59567. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59568. * @returns the current particle system
  59569. */
  59570. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59571. /**
  59572. * Not supported by GPUParticleSystem
  59573. * @param gradient defines the gradient to remove
  59574. * @returns the current particle system
  59575. */
  59576. removeLifeTimeGradient(gradient: number): IParticleSystem;
  59577. /**
  59578. * Instantiates a GPU particle system.
  59579. * 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.
  59580. * @param name The name of the particle system
  59581. * @param options The options used to create the system
  59582. * @param scene The scene the particle system belongs to
  59583. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  59584. */
  59585. constructor(name: string, options: Partial<{
  59586. capacity: number;
  59587. randomTextureSize: number;
  59588. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  59589. protected _reset(): void;
  59590. private _createUpdateVAO;
  59591. private _createRenderVAO;
  59592. private _initialize;
  59593. /** @hidden */
  59594. _recreateUpdateEffect(): void;
  59595. /** @hidden */
  59596. _recreateRenderEffect(): void;
  59597. /**
  59598. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  59599. * @param preWarm defines if we are in the pre-warmimg phase
  59600. */
  59601. animate(preWarm?: boolean): void;
  59602. private _createFactorGradientTexture;
  59603. private _createSizeGradientTexture;
  59604. private _createAngularSpeedGradientTexture;
  59605. private _createVelocityGradientTexture;
  59606. private _createLimitVelocityGradientTexture;
  59607. private _createDragGradientTexture;
  59608. private _createColorGradientTexture;
  59609. /**
  59610. * Renders the particle system in its current state
  59611. * @param preWarm defines if the system should only update the particles but not render them
  59612. * @returns the current number of particles
  59613. */
  59614. render(preWarm?: boolean): number;
  59615. /**
  59616. * Rebuilds the particle system
  59617. */
  59618. rebuild(): void;
  59619. private _releaseBuffers;
  59620. private _releaseVAOs;
  59621. /**
  59622. * Disposes the particle system and free the associated resources
  59623. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  59624. */
  59625. dispose(disposeTexture?: boolean): void;
  59626. /**
  59627. * Clones the particle system.
  59628. * @param name The name of the cloned object
  59629. * @param newEmitter The new emitter to use
  59630. * @returns the cloned particle system
  59631. */
  59632. clone(name: string, newEmitter: any): GPUParticleSystem;
  59633. /**
  59634. * Serializes the particle system to a JSON object.
  59635. * @returns the JSON object
  59636. */
  59637. serialize(): any;
  59638. /**
  59639. * Parses a JSON object to create a GPU particle system.
  59640. * @param parsedParticleSystem The JSON object to parse
  59641. * @param scene The scene to create the particle system in
  59642. * @param rootUrl The root url to use to load external dependencies like texture
  59643. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  59644. * @returns the parsed GPU particle system
  59645. */
  59646. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  59647. }
  59648. }
  59649. declare module BABYLON {
  59650. /**
  59651. * Represents a set of particle systems working together to create a specific effect
  59652. */
  59653. export class ParticleSystemSet implements IDisposable {
  59654. /**
  59655. * Gets or sets base Assets URL
  59656. */
  59657. static BaseAssetsUrl: string;
  59658. private _emitterCreationOptions;
  59659. private _emitterNode;
  59660. /**
  59661. * Gets the particle system list
  59662. */
  59663. systems: IParticleSystem[];
  59664. /**
  59665. * Gets the emitter node used with this set
  59666. */
  59667. readonly emitterNode: Nullable<TransformNode>;
  59668. /**
  59669. * Creates a new emitter mesh as a sphere
  59670. * @param options defines the options used to create the sphere
  59671. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  59672. * @param scene defines the hosting scene
  59673. */
  59674. setEmitterAsSphere(options: {
  59675. diameter: number;
  59676. segments: number;
  59677. color: Color3;
  59678. }, renderingGroupId: number, scene: Scene): void;
  59679. /**
  59680. * Starts all particle systems of the set
  59681. * @param emitter defines an optional mesh to use as emitter for the particle systems
  59682. */
  59683. start(emitter?: AbstractMesh): void;
  59684. /**
  59685. * Release all associated resources
  59686. */
  59687. dispose(): void;
  59688. /**
  59689. * Serialize the set into a JSON compatible object
  59690. * @returns a JSON compatible representation of the set
  59691. */
  59692. serialize(): any;
  59693. /**
  59694. * Parse a new ParticleSystemSet from a serialized source
  59695. * @param data defines a JSON compatible representation of the set
  59696. * @param scene defines the hosting scene
  59697. * @param gpu defines if we want GPU particles or CPU particles
  59698. * @returns a new ParticleSystemSet
  59699. */
  59700. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  59701. }
  59702. }
  59703. declare module BABYLON {
  59704. /**
  59705. * This class is made for on one-liner static method to help creating particle system set.
  59706. */
  59707. export class ParticleHelper {
  59708. /**
  59709. * Gets or sets base Assets URL
  59710. */
  59711. static BaseAssetsUrl: string;
  59712. /**
  59713. * Create a default particle system that you can tweak
  59714. * @param emitter defines the emitter to use
  59715. * @param capacity defines the system capacity (default is 500 particles)
  59716. * @param scene defines the hosting scene
  59717. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  59718. * @returns the new Particle system
  59719. */
  59720. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  59721. /**
  59722. * This is the main static method (one-liner) of this helper to create different particle systems
  59723. * @param type This string represents the type to the particle system to create
  59724. * @param scene The scene where the particle system should live
  59725. * @param gpu If the system will use gpu
  59726. * @returns the ParticleSystemSet created
  59727. */
  59728. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  59729. /**
  59730. * Static function used to export a particle system to a ParticleSystemSet variable.
  59731. * Please note that the emitter shape is not exported
  59732. * @param systems defines the particle systems to export
  59733. * @returns the created particle system set
  59734. */
  59735. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  59736. }
  59737. }
  59738. declare module BABYLON {
  59739. interface Engine {
  59740. /**
  59741. * Create an effect to use with particle systems.
  59742. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  59743. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  59744. * @param uniformsNames defines a list of attribute names
  59745. * @param samplers defines an array of string used to represent textures
  59746. * @param defines defines the string containing the defines to use to compile the shaders
  59747. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  59748. * @param onCompiled defines a function to call when the effect creation is successful
  59749. * @param onError defines a function to call when the effect creation has failed
  59750. * @returns the new Effect
  59751. */
  59752. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  59753. }
  59754. interface Mesh {
  59755. /**
  59756. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  59757. * @returns an array of IParticleSystem
  59758. */
  59759. getEmittedParticleSystems(): IParticleSystem[];
  59760. /**
  59761. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  59762. * @returns an array of IParticleSystem
  59763. */
  59764. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  59765. }
  59766. /**
  59767. * @hidden
  59768. */
  59769. export var _IDoNeedToBeInTheBuild: number;
  59770. }
  59771. declare module BABYLON {
  59772. /** Defines the 4 color options */
  59773. export enum PointColor {
  59774. /** color value */
  59775. Color = 2,
  59776. /** uv value */
  59777. UV = 1,
  59778. /** random value */
  59779. Random = 0,
  59780. /** stated value */
  59781. Stated = 3
  59782. }
  59783. /**
  59784. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  59785. * 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.
  59786. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  59787. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  59788. *
  59789. * Full documentation here : TO BE ENTERED
  59790. */
  59791. export class PointsCloudSystem implements IDisposable {
  59792. /**
  59793. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  59794. * Example : var p = SPS.particles[i];
  59795. */
  59796. particles: CloudPoint[];
  59797. /**
  59798. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  59799. */
  59800. nbParticles: number;
  59801. /**
  59802. * This a counter for your own usage. It's not set by any SPS functions.
  59803. */
  59804. counter: number;
  59805. /**
  59806. * The PCS name. This name is also given to the underlying mesh.
  59807. */
  59808. name: string;
  59809. /**
  59810. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  59811. */
  59812. mesh: Mesh;
  59813. /**
  59814. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  59815. * Please read :
  59816. */
  59817. vars: any;
  59818. /**
  59819. * @hidden
  59820. */
  59821. _size: number;
  59822. private _scene;
  59823. private _promises;
  59824. private _positions;
  59825. private _indices;
  59826. private _normals;
  59827. private _colors;
  59828. private _uvs;
  59829. private _indices32;
  59830. private _positions32;
  59831. private _colors32;
  59832. private _uvs32;
  59833. private _updatable;
  59834. private _isVisibilityBoxLocked;
  59835. private _alwaysVisible;
  59836. private _groups;
  59837. private _groupCounter;
  59838. private _computeParticleColor;
  59839. private _computeParticleTexture;
  59840. private _computeParticleRotation;
  59841. private _computeBoundingBox;
  59842. private _isReady;
  59843. /**
  59844. * Creates a PCS (Points Cloud System) object
  59845. * @param name (String) is the PCS name, this will be the underlying mesh name
  59846. * @param pointSize (number) is the size for each point
  59847. * @param scene (Scene) is the scene in which the PCS is added
  59848. * @param options defines the options of the PCS e.g.
  59849. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  59850. */
  59851. constructor(name: string, pointSize: number, scene: Scene, options?: {
  59852. updatable?: boolean;
  59853. });
  59854. /**
  59855. * Builds the PCS underlying mesh. Returns a standard Mesh.
  59856. * If no points were added to the PCS, the returned mesh is just a single point.
  59857. * @returns a promise for the created mesh
  59858. */
  59859. buildMeshAsync(): Promise<Mesh>;
  59860. /**
  59861. * @hidden
  59862. */
  59863. private _buildMesh;
  59864. private _addParticle;
  59865. private _randomUnitVector;
  59866. private _getColorIndicesForCoord;
  59867. private _setPointsColorOrUV;
  59868. private _colorFromTexture;
  59869. private _calculateDensity;
  59870. /**
  59871. * Adds points to the PCS in random positions within a unit sphere
  59872. * @param nb (positive integer) the number of particles to be created from this model
  59873. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  59874. * @returns the number of groups in the system
  59875. */
  59876. addPoints(nb: number, pointFunction?: any): number;
  59877. /**
  59878. * Adds points to the PCS from the surface of the model shape
  59879. * @param mesh is any Mesh object that will be used as a surface model for the points
  59880. * @param nb (positive integer) the number of particles to be created from this model
  59881. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  59882. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  59883. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  59884. * @returns the number of groups in the system
  59885. */
  59886. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  59887. /**
  59888. * Adds points to the PCS inside the model shape
  59889. * @param mesh is any Mesh object that will be used as a surface model for the points
  59890. * @param nb (positive integer) the number of particles to be created from this model
  59891. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  59892. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  59893. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  59894. * @returns the number of groups in the system
  59895. */
  59896. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  59897. /**
  59898. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  59899. * This method calls `updateParticle()` for each particle of the SPS.
  59900. * For an animated SPS, it is usually called within the render loop.
  59901. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  59902. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  59903. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  59904. * @returns the PCS.
  59905. */
  59906. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  59907. /**
  59908. * Disposes the PCS.
  59909. */
  59910. dispose(): void;
  59911. /**
  59912. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  59913. * doc :
  59914. * @returns the PCS.
  59915. */
  59916. refreshVisibleSize(): PointsCloudSystem;
  59917. /**
  59918. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  59919. * @param size the size (float) of the visibility box
  59920. * note : this doesn't lock the PCS mesh bounding box.
  59921. * doc :
  59922. */
  59923. setVisibilityBox(size: number): void;
  59924. /**
  59925. * Gets whether the PCS is always visible or not
  59926. * doc :
  59927. */
  59928. /**
  59929. * Sets the PCS as always visible or not
  59930. * doc :
  59931. */
  59932. isAlwaysVisible: boolean;
  59933. /**
  59934. * Tells to `setParticles()` to compute the particle rotations or not
  59935. * Default value : false. The PCS is faster when it's set to false
  59936. * Note : particle rotations are only applied to parent particles
  59937. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  59938. */
  59939. computeParticleRotation: boolean;
  59940. /**
  59941. * Tells to `setParticles()` to compute the particle colors or not.
  59942. * Default value : true. The PCS is faster when it's set to false.
  59943. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  59944. */
  59945. /**
  59946. * Gets if `setParticles()` computes the particle colors or not.
  59947. * Default value : false. The PCS is faster when it's set to false.
  59948. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  59949. */
  59950. computeParticleColor: boolean;
  59951. /**
  59952. * Gets if `setParticles()` computes the particle textures or not.
  59953. * Default value : false. The PCS is faster when it's set to false.
  59954. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  59955. */
  59956. computeParticleTexture: boolean;
  59957. /**
  59958. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  59959. */
  59960. /**
  59961. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  59962. */
  59963. computeBoundingBox: boolean;
  59964. /**
  59965. * This function does nothing. It may be overwritten to set all the particle first values.
  59966. * The PCS doesn't call this function, you may have to call it by your own.
  59967. * doc :
  59968. */
  59969. initParticles(): void;
  59970. /**
  59971. * This function does nothing. It may be overwritten to recycle a particle
  59972. * The PCS doesn't call this function, you can to call it
  59973. * doc :
  59974. * @param particle The particle to recycle
  59975. * @returns the recycled particle
  59976. */
  59977. recycleParticle(particle: CloudPoint): CloudPoint;
  59978. /**
  59979. * Updates a particle : this function should be overwritten by the user.
  59980. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  59981. * doc :
  59982. * @example : just set a particle position or velocity and recycle conditions
  59983. * @param particle The particle to update
  59984. * @returns the updated particle
  59985. */
  59986. updateParticle(particle: CloudPoint): CloudPoint;
  59987. /**
  59988. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  59989. * This does nothing and may be overwritten by the user.
  59990. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  59991. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  59992. * @param update the boolean update value actually passed to setParticles()
  59993. */
  59994. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  59995. /**
  59996. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  59997. * This will be passed three parameters.
  59998. * This does nothing and may be overwritten by the user.
  59999. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  60000. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  60001. * @param update the boolean update value actually passed to setParticles()
  60002. */
  60003. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  60004. }
  60005. }
  60006. declare module BABYLON {
  60007. /**
  60008. * Represents one particle of a points cloud system.
  60009. */
  60010. export class CloudPoint {
  60011. /**
  60012. * particle global index
  60013. */
  60014. idx: number;
  60015. /**
  60016. * The color of the particle
  60017. */
  60018. color: Nullable<Color4>;
  60019. /**
  60020. * The world space position of the particle.
  60021. */
  60022. position: Vector3;
  60023. /**
  60024. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  60025. */
  60026. rotation: Vector3;
  60027. /**
  60028. * The world space rotation quaternion of the particle.
  60029. */
  60030. rotationQuaternion: Nullable<Quaternion>;
  60031. /**
  60032. * The uv of the particle.
  60033. */
  60034. uv: Nullable<Vector2>;
  60035. /**
  60036. * The current speed of the particle.
  60037. */
  60038. velocity: Vector3;
  60039. /**
  60040. * The pivot point in the particle local space.
  60041. */
  60042. pivot: Vector3;
  60043. /**
  60044. * Must the particle be translated from its pivot point in its local space ?
  60045. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  60046. * Default : false
  60047. */
  60048. translateFromPivot: boolean;
  60049. /**
  60050. * Index of this particle in the global "positions" array (Internal use)
  60051. * @hidden
  60052. */
  60053. _pos: number;
  60054. /**
  60055. * @hidden Index of this particle in the global "indices" array (Internal use)
  60056. */
  60057. _ind: number;
  60058. /**
  60059. * Group this particle belongs to
  60060. */
  60061. _group: PointsGroup;
  60062. /**
  60063. * Group id of this particle
  60064. */
  60065. groupId: number;
  60066. /**
  60067. * Index of the particle in its group id (Internal use)
  60068. */
  60069. idxInGroup: number;
  60070. /**
  60071. * @hidden Particle BoundingInfo object (Internal use)
  60072. */
  60073. _boundingInfo: BoundingInfo;
  60074. /**
  60075. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  60076. */
  60077. _pcs: PointsCloudSystem;
  60078. /**
  60079. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  60080. */
  60081. _stillInvisible: boolean;
  60082. /**
  60083. * @hidden Last computed particle rotation matrix
  60084. */
  60085. _rotationMatrix: number[];
  60086. /**
  60087. * Parent particle Id, if any.
  60088. * Default null.
  60089. */
  60090. parentId: Nullable<number>;
  60091. /**
  60092. * @hidden Internal global position in the PCS.
  60093. */
  60094. _globalPosition: Vector3;
  60095. /**
  60096. * Creates a Point Cloud object.
  60097. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  60098. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  60099. * @param group (PointsGroup) is the group the particle belongs to
  60100. * @param groupId (integer) is the group identifier in the PCS.
  60101. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  60102. * @param pcs defines the PCS it is associated to
  60103. */
  60104. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  60105. /**
  60106. * get point size
  60107. */
  60108. /**
  60109. * Set point size
  60110. */
  60111. size: Vector3;
  60112. /**
  60113. * Legacy support, changed quaternion to rotationQuaternion
  60114. */
  60115. /**
  60116. * Legacy support, changed quaternion to rotationQuaternion
  60117. */
  60118. quaternion: Nullable<Quaternion>;
  60119. /**
  60120. * Returns a boolean. True if the particle intersects a mesh, else false
  60121. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  60122. * @param target is the object (point or mesh) what the intersection is computed against
  60123. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  60124. * @returns true if it intersects
  60125. */
  60126. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  60127. /**
  60128. * get the rotation matrix of the particle
  60129. * @hidden
  60130. */
  60131. getRotationMatrix(m: Matrix): void;
  60132. }
  60133. /**
  60134. * Represents a group of points in a points cloud system
  60135. * * PCS internal tool, don't use it manually.
  60136. */
  60137. export class PointsGroup {
  60138. /**
  60139. * The group id
  60140. * @hidden
  60141. */
  60142. groupID: number;
  60143. /**
  60144. * image data for group (internal use)
  60145. * @hidden
  60146. */
  60147. _groupImageData: Nullable<ArrayBufferView>;
  60148. /**
  60149. * Image Width (internal use)
  60150. * @hidden
  60151. */
  60152. _groupImgWidth: number;
  60153. /**
  60154. * Image Height (internal use)
  60155. * @hidden
  60156. */
  60157. _groupImgHeight: number;
  60158. /**
  60159. * Custom position function (internal use)
  60160. * @hidden
  60161. */
  60162. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  60163. /**
  60164. * density per facet for surface points
  60165. * @hidden
  60166. */
  60167. _groupDensity: number[];
  60168. /**
  60169. * Only when points are colored by texture carries pointer to texture list array
  60170. * @hidden
  60171. */
  60172. _textureNb: number;
  60173. /**
  60174. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  60175. * PCS internal tool, don't use it manually.
  60176. * @hidden
  60177. */
  60178. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  60179. }
  60180. }
  60181. declare module BABYLON {
  60182. interface Scene {
  60183. /** @hidden (Backing field) */
  60184. _physicsEngine: Nullable<IPhysicsEngine>;
  60185. /** @hidden */
  60186. _physicsTimeAccumulator: number;
  60187. /**
  60188. * Gets the current physics engine
  60189. * @returns a IPhysicsEngine or null if none attached
  60190. */
  60191. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  60192. /**
  60193. * Enables physics to the current scene
  60194. * @param gravity defines the scene's gravity for the physics engine
  60195. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  60196. * @return a boolean indicating if the physics engine was initialized
  60197. */
  60198. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  60199. /**
  60200. * Disables and disposes the physics engine associated with the scene
  60201. */
  60202. disablePhysicsEngine(): void;
  60203. /**
  60204. * Gets a boolean indicating if there is an active physics engine
  60205. * @returns a boolean indicating if there is an active physics engine
  60206. */
  60207. isPhysicsEnabled(): boolean;
  60208. /**
  60209. * Deletes a physics compound impostor
  60210. * @param compound defines the compound to delete
  60211. */
  60212. deleteCompoundImpostor(compound: any): void;
  60213. /**
  60214. * An event triggered when physic simulation is about to be run
  60215. */
  60216. onBeforePhysicsObservable: Observable<Scene>;
  60217. /**
  60218. * An event triggered when physic simulation has been done
  60219. */
  60220. onAfterPhysicsObservable: Observable<Scene>;
  60221. }
  60222. interface AbstractMesh {
  60223. /** @hidden */
  60224. _physicsImpostor: Nullable<PhysicsImpostor>;
  60225. /**
  60226. * Gets or sets impostor used for physic simulation
  60227. * @see http://doc.babylonjs.com/features/physics_engine
  60228. */
  60229. physicsImpostor: Nullable<PhysicsImpostor>;
  60230. /**
  60231. * Gets the current physics impostor
  60232. * @see http://doc.babylonjs.com/features/physics_engine
  60233. * @returns a physics impostor or null
  60234. */
  60235. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  60236. /** Apply a physic impulse to the mesh
  60237. * @param force defines the force to apply
  60238. * @param contactPoint defines where to apply the force
  60239. * @returns the current mesh
  60240. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  60241. */
  60242. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  60243. /**
  60244. * Creates a physic joint between two meshes
  60245. * @param otherMesh defines the other mesh to use
  60246. * @param pivot1 defines the pivot to use on this mesh
  60247. * @param pivot2 defines the pivot to use on the other mesh
  60248. * @param options defines additional options (can be plugin dependent)
  60249. * @returns the current mesh
  60250. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  60251. */
  60252. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  60253. /** @hidden */
  60254. _disposePhysicsObserver: Nullable<Observer<Node>>;
  60255. }
  60256. /**
  60257. * Defines the physics engine scene component responsible to manage a physics engine
  60258. */
  60259. export class PhysicsEngineSceneComponent implements ISceneComponent {
  60260. /**
  60261. * The component name helpful to identify the component in the list of scene components.
  60262. */
  60263. readonly name: string;
  60264. /**
  60265. * The scene the component belongs to.
  60266. */
  60267. scene: Scene;
  60268. /**
  60269. * Creates a new instance of the component for the given scene
  60270. * @param scene Defines the scene to register the component in
  60271. */
  60272. constructor(scene: Scene);
  60273. /**
  60274. * Registers the component in a given scene
  60275. */
  60276. register(): void;
  60277. /**
  60278. * Rebuilds the elements related to this component in case of
  60279. * context lost for instance.
  60280. */
  60281. rebuild(): void;
  60282. /**
  60283. * Disposes the component and the associated ressources
  60284. */
  60285. dispose(): void;
  60286. }
  60287. }
  60288. declare module BABYLON {
  60289. /**
  60290. * A helper for physics simulations
  60291. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60292. */
  60293. export class PhysicsHelper {
  60294. private _scene;
  60295. private _physicsEngine;
  60296. /**
  60297. * Initializes the Physics helper
  60298. * @param scene Babylon.js scene
  60299. */
  60300. constructor(scene: Scene);
  60301. /**
  60302. * Applies a radial explosion impulse
  60303. * @param origin the origin of the explosion
  60304. * @param radiusOrEventOptions the radius or the options of radial explosion
  60305. * @param strength the explosion strength
  60306. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60307. * @returns A physics radial explosion event, or null
  60308. */
  60309. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60310. /**
  60311. * Applies a radial explosion force
  60312. * @param origin the origin of the explosion
  60313. * @param radiusOrEventOptions the radius or the options of radial explosion
  60314. * @param strength the explosion strength
  60315. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60316. * @returns A physics radial explosion event, or null
  60317. */
  60318. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60319. /**
  60320. * Creates a gravitational field
  60321. * @param origin the origin of the explosion
  60322. * @param radiusOrEventOptions the radius or the options of radial explosion
  60323. * @param strength the explosion strength
  60324. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60325. * @returns A physics gravitational field event, or null
  60326. */
  60327. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  60328. /**
  60329. * Creates a physics updraft event
  60330. * @param origin the origin of the updraft
  60331. * @param radiusOrEventOptions the radius or the options of the updraft
  60332. * @param strength the strength of the updraft
  60333. * @param height the height of the updraft
  60334. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  60335. * @returns A physics updraft event, or null
  60336. */
  60337. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  60338. /**
  60339. * Creates a physics vortex event
  60340. * @param origin the of the vortex
  60341. * @param radiusOrEventOptions the radius or the options of the vortex
  60342. * @param strength the strength of the vortex
  60343. * @param height the height of the vortex
  60344. * @returns a Physics vortex event, or null
  60345. * A physics vortex event or null
  60346. */
  60347. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  60348. }
  60349. /**
  60350. * Represents a physics radial explosion event
  60351. */
  60352. class PhysicsRadialExplosionEvent {
  60353. private _scene;
  60354. private _options;
  60355. private _sphere;
  60356. private _dataFetched;
  60357. /**
  60358. * Initializes a radial explosioin event
  60359. * @param _scene BabylonJS scene
  60360. * @param _options The options for the vortex event
  60361. */
  60362. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  60363. /**
  60364. * Returns the data related to the radial explosion event (sphere).
  60365. * @returns The radial explosion event data
  60366. */
  60367. getData(): PhysicsRadialExplosionEventData;
  60368. /**
  60369. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  60370. * @param impostor A physics imposter
  60371. * @param origin the origin of the explosion
  60372. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  60373. */
  60374. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  60375. /**
  60376. * Triggers affecterd impostors callbacks
  60377. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  60378. */
  60379. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  60380. /**
  60381. * Disposes the sphere.
  60382. * @param force Specifies if the sphere should be disposed by force
  60383. */
  60384. dispose(force?: boolean): void;
  60385. /*** Helpers ***/
  60386. private _prepareSphere;
  60387. private _intersectsWithSphere;
  60388. }
  60389. /**
  60390. * Represents a gravitational field event
  60391. */
  60392. class PhysicsGravitationalFieldEvent {
  60393. private _physicsHelper;
  60394. private _scene;
  60395. private _origin;
  60396. private _options;
  60397. private _tickCallback;
  60398. private _sphere;
  60399. private _dataFetched;
  60400. /**
  60401. * Initializes the physics gravitational field event
  60402. * @param _physicsHelper A physics helper
  60403. * @param _scene BabylonJS scene
  60404. * @param _origin The origin position of the gravitational field event
  60405. * @param _options The options for the vortex event
  60406. */
  60407. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  60408. /**
  60409. * Returns the data related to the gravitational field event (sphere).
  60410. * @returns A gravitational field event
  60411. */
  60412. getData(): PhysicsGravitationalFieldEventData;
  60413. /**
  60414. * Enables the gravitational field.
  60415. */
  60416. enable(): void;
  60417. /**
  60418. * Disables the gravitational field.
  60419. */
  60420. disable(): void;
  60421. /**
  60422. * Disposes the sphere.
  60423. * @param force The force to dispose from the gravitational field event
  60424. */
  60425. dispose(force?: boolean): void;
  60426. private _tick;
  60427. }
  60428. /**
  60429. * Represents a physics updraft event
  60430. */
  60431. class PhysicsUpdraftEvent {
  60432. private _scene;
  60433. private _origin;
  60434. private _options;
  60435. private _physicsEngine;
  60436. private _originTop;
  60437. private _originDirection;
  60438. private _tickCallback;
  60439. private _cylinder;
  60440. private _cylinderPosition;
  60441. private _dataFetched;
  60442. /**
  60443. * Initializes the physics updraft event
  60444. * @param _scene BabylonJS scene
  60445. * @param _origin The origin position of the updraft
  60446. * @param _options The options for the updraft event
  60447. */
  60448. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  60449. /**
  60450. * Returns the data related to the updraft event (cylinder).
  60451. * @returns A physics updraft event
  60452. */
  60453. getData(): PhysicsUpdraftEventData;
  60454. /**
  60455. * Enables the updraft.
  60456. */
  60457. enable(): void;
  60458. /**
  60459. * Disables the updraft.
  60460. */
  60461. disable(): void;
  60462. /**
  60463. * Disposes the cylinder.
  60464. * @param force Specifies if the updraft should be disposed by force
  60465. */
  60466. dispose(force?: boolean): void;
  60467. private getImpostorHitData;
  60468. private _tick;
  60469. /*** Helpers ***/
  60470. private _prepareCylinder;
  60471. private _intersectsWithCylinder;
  60472. }
  60473. /**
  60474. * Represents a physics vortex event
  60475. */
  60476. class PhysicsVortexEvent {
  60477. private _scene;
  60478. private _origin;
  60479. private _options;
  60480. private _physicsEngine;
  60481. private _originTop;
  60482. private _tickCallback;
  60483. private _cylinder;
  60484. private _cylinderPosition;
  60485. private _dataFetched;
  60486. /**
  60487. * Initializes the physics vortex event
  60488. * @param _scene The BabylonJS scene
  60489. * @param _origin The origin position of the vortex
  60490. * @param _options The options for the vortex event
  60491. */
  60492. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  60493. /**
  60494. * Returns the data related to the vortex event (cylinder).
  60495. * @returns The physics vortex event data
  60496. */
  60497. getData(): PhysicsVortexEventData;
  60498. /**
  60499. * Enables the vortex.
  60500. */
  60501. enable(): void;
  60502. /**
  60503. * Disables the cortex.
  60504. */
  60505. disable(): void;
  60506. /**
  60507. * Disposes the sphere.
  60508. * @param force
  60509. */
  60510. dispose(force?: boolean): void;
  60511. private getImpostorHitData;
  60512. private _tick;
  60513. /*** Helpers ***/
  60514. private _prepareCylinder;
  60515. private _intersectsWithCylinder;
  60516. }
  60517. /**
  60518. * Options fot the radial explosion event
  60519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60520. */
  60521. export class PhysicsRadialExplosionEventOptions {
  60522. /**
  60523. * The radius of the sphere for the radial explosion.
  60524. */
  60525. radius: number;
  60526. /**
  60527. * The strenth of the explosion.
  60528. */
  60529. strength: number;
  60530. /**
  60531. * The strenght of the force in correspondence to the distance of the affected object
  60532. */
  60533. falloff: PhysicsRadialImpulseFalloff;
  60534. /**
  60535. * Sphere options for the radial explosion.
  60536. */
  60537. sphere: {
  60538. segments: number;
  60539. diameter: number;
  60540. };
  60541. /**
  60542. * Sphere options for the radial explosion.
  60543. */
  60544. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  60545. }
  60546. /**
  60547. * Options fot the updraft event
  60548. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60549. */
  60550. export class PhysicsUpdraftEventOptions {
  60551. /**
  60552. * The radius of the cylinder for the vortex
  60553. */
  60554. radius: number;
  60555. /**
  60556. * The strenth of the updraft.
  60557. */
  60558. strength: number;
  60559. /**
  60560. * The height of the cylinder for the updraft.
  60561. */
  60562. height: number;
  60563. /**
  60564. * The mode for the the updraft.
  60565. */
  60566. updraftMode: PhysicsUpdraftMode;
  60567. }
  60568. /**
  60569. * Options fot the vortex event
  60570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60571. */
  60572. export class PhysicsVortexEventOptions {
  60573. /**
  60574. * The radius of the cylinder for the vortex
  60575. */
  60576. radius: number;
  60577. /**
  60578. * The strenth of the vortex.
  60579. */
  60580. strength: number;
  60581. /**
  60582. * The height of the cylinder for the vortex.
  60583. */
  60584. height: number;
  60585. /**
  60586. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  60587. */
  60588. centripetalForceThreshold: number;
  60589. /**
  60590. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  60591. */
  60592. centripetalForceMultiplier: number;
  60593. /**
  60594. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  60595. */
  60596. centrifugalForceMultiplier: number;
  60597. /**
  60598. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  60599. */
  60600. updraftForceMultiplier: number;
  60601. }
  60602. /**
  60603. * The strenght of the force in correspondence to the distance of the affected object
  60604. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60605. */
  60606. export enum PhysicsRadialImpulseFalloff {
  60607. /** Defines that impulse is constant in strength across it's whole radius */
  60608. Constant = 0,
  60609. /** Defines that impulse gets weaker if it's further from the origin */
  60610. Linear = 1
  60611. }
  60612. /**
  60613. * The strength of the force in correspondence to the distance of the affected object
  60614. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60615. */
  60616. export enum PhysicsUpdraftMode {
  60617. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  60618. Center = 0,
  60619. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  60620. Perpendicular = 1
  60621. }
  60622. /**
  60623. * Interface for a physics hit data
  60624. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60625. */
  60626. export interface PhysicsHitData {
  60627. /**
  60628. * The force applied at the contact point
  60629. */
  60630. force: Vector3;
  60631. /**
  60632. * The contact point
  60633. */
  60634. contactPoint: Vector3;
  60635. /**
  60636. * The distance from the origin to the contact point
  60637. */
  60638. distanceFromOrigin: number;
  60639. }
  60640. /**
  60641. * Interface for radial explosion event data
  60642. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60643. */
  60644. export interface PhysicsRadialExplosionEventData {
  60645. /**
  60646. * A sphere used for the radial explosion event
  60647. */
  60648. sphere: Mesh;
  60649. }
  60650. /**
  60651. * Interface for gravitational field event data
  60652. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60653. */
  60654. export interface PhysicsGravitationalFieldEventData {
  60655. /**
  60656. * A sphere mesh used for the gravitational field event
  60657. */
  60658. sphere: Mesh;
  60659. }
  60660. /**
  60661. * Interface for updraft event data
  60662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60663. */
  60664. export interface PhysicsUpdraftEventData {
  60665. /**
  60666. * A cylinder used for the updraft event
  60667. */
  60668. cylinder: Mesh;
  60669. }
  60670. /**
  60671. * Interface for vortex event data
  60672. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60673. */
  60674. export interface PhysicsVortexEventData {
  60675. /**
  60676. * A cylinder used for the vortex event
  60677. */
  60678. cylinder: Mesh;
  60679. }
  60680. /**
  60681. * Interface for an affected physics impostor
  60682. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60683. */
  60684. export interface PhysicsAffectedImpostorWithData {
  60685. /**
  60686. * The impostor affected by the effect
  60687. */
  60688. impostor: PhysicsImpostor;
  60689. /**
  60690. * The data about the hit/horce from the explosion
  60691. */
  60692. hitData: PhysicsHitData;
  60693. }
  60694. }
  60695. declare module BABYLON {
  60696. /** @hidden */
  60697. export var blackAndWhitePixelShader: {
  60698. name: string;
  60699. shader: string;
  60700. };
  60701. }
  60702. declare module BABYLON {
  60703. /**
  60704. * Post process used to render in black and white
  60705. */
  60706. export class BlackAndWhitePostProcess extends PostProcess {
  60707. /**
  60708. * Linear about to convert he result to black and white (default: 1)
  60709. */
  60710. degree: number;
  60711. /**
  60712. * Creates a black and white post process
  60713. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  60714. * @param name The name of the effect.
  60715. * @param options The required width/height ratio to downsize to before computing the render pass.
  60716. * @param camera The camera to apply the render pass to.
  60717. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60718. * @param engine The engine which the post process will be applied. (default: current engine)
  60719. * @param reusable If the post process can be reused on the same frame. (default: false)
  60720. */
  60721. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60722. }
  60723. }
  60724. declare module BABYLON {
  60725. /**
  60726. * This represents a set of one or more post processes in Babylon.
  60727. * A post process can be used to apply a shader to a texture after it is rendered.
  60728. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60729. */
  60730. export class PostProcessRenderEffect {
  60731. private _postProcesses;
  60732. private _getPostProcesses;
  60733. private _singleInstance;
  60734. private _cameras;
  60735. private _indicesForCamera;
  60736. /**
  60737. * Name of the effect
  60738. * @hidden
  60739. */
  60740. _name: string;
  60741. /**
  60742. * Instantiates a post process render effect.
  60743. * A post process can be used to apply a shader to a texture after it is rendered.
  60744. * @param engine The engine the effect is tied to
  60745. * @param name The name of the effect
  60746. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  60747. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  60748. */
  60749. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  60750. /**
  60751. * Checks if all the post processes in the effect are supported.
  60752. */
  60753. readonly isSupported: boolean;
  60754. /**
  60755. * Updates the current state of the effect
  60756. * @hidden
  60757. */
  60758. _update(): void;
  60759. /**
  60760. * Attaches the effect on cameras
  60761. * @param cameras The camera to attach to.
  60762. * @hidden
  60763. */
  60764. _attachCameras(cameras: Camera): void;
  60765. /**
  60766. * Attaches the effect on cameras
  60767. * @param cameras The camera to attach to.
  60768. * @hidden
  60769. */
  60770. _attachCameras(cameras: Camera[]): void;
  60771. /**
  60772. * Detaches the effect on cameras
  60773. * @param cameras The camera to detatch from.
  60774. * @hidden
  60775. */
  60776. _detachCameras(cameras: Camera): void;
  60777. /**
  60778. * Detatches the effect on cameras
  60779. * @param cameras The camera to detatch from.
  60780. * @hidden
  60781. */
  60782. _detachCameras(cameras: Camera[]): void;
  60783. /**
  60784. * Enables the effect on given cameras
  60785. * @param cameras The camera to enable.
  60786. * @hidden
  60787. */
  60788. _enable(cameras: Camera): void;
  60789. /**
  60790. * Enables the effect on given cameras
  60791. * @param cameras The camera to enable.
  60792. * @hidden
  60793. */
  60794. _enable(cameras: Nullable<Camera[]>): void;
  60795. /**
  60796. * Disables the effect on the given cameras
  60797. * @param cameras The camera to disable.
  60798. * @hidden
  60799. */
  60800. _disable(cameras: Camera): void;
  60801. /**
  60802. * Disables the effect on the given cameras
  60803. * @param cameras The camera to disable.
  60804. * @hidden
  60805. */
  60806. _disable(cameras: Nullable<Camera[]>): void;
  60807. /**
  60808. * Gets a list of the post processes contained in the effect.
  60809. * @param camera The camera to get the post processes on.
  60810. * @returns The list of the post processes in the effect.
  60811. */
  60812. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  60813. }
  60814. }
  60815. declare module BABYLON {
  60816. /** @hidden */
  60817. export var extractHighlightsPixelShader: {
  60818. name: string;
  60819. shader: string;
  60820. };
  60821. }
  60822. declare module BABYLON {
  60823. /**
  60824. * 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.
  60825. */
  60826. export class ExtractHighlightsPostProcess extends PostProcess {
  60827. /**
  60828. * The luminance threshold, pixels below this value will be set to black.
  60829. */
  60830. threshold: number;
  60831. /** @hidden */
  60832. _exposure: number;
  60833. /**
  60834. * Post process which has the input texture to be used when performing highlight extraction
  60835. * @hidden
  60836. */
  60837. _inputPostProcess: Nullable<PostProcess>;
  60838. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60839. }
  60840. }
  60841. declare module BABYLON {
  60842. /** @hidden */
  60843. export var bloomMergePixelShader: {
  60844. name: string;
  60845. shader: string;
  60846. };
  60847. }
  60848. declare module BABYLON {
  60849. /**
  60850. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60851. */
  60852. export class BloomMergePostProcess extends PostProcess {
  60853. /** Weight of the bloom to be added to the original input. */
  60854. weight: number;
  60855. /**
  60856. * Creates a new instance of @see BloomMergePostProcess
  60857. * @param name The name of the effect.
  60858. * @param originalFromInput Post process which's input will be used for the merge.
  60859. * @param blurred Blurred highlights post process which's output will be used.
  60860. * @param weight Weight of the bloom to be added to the original input.
  60861. * @param options The required width/height ratio to downsize to before computing the render pass.
  60862. * @param camera The camera to apply the render pass to.
  60863. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60864. * @param engine The engine which the post process will be applied. (default: current engine)
  60865. * @param reusable If the post process can be reused on the same frame. (default: false)
  60866. * @param textureType Type of textures used when performing the post process. (default: 0)
  60867. * @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)
  60868. */
  60869. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  60870. /** Weight of the bloom to be added to the original input. */
  60871. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60872. }
  60873. }
  60874. declare module BABYLON {
  60875. /**
  60876. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  60877. */
  60878. export class BloomEffect extends PostProcessRenderEffect {
  60879. private bloomScale;
  60880. /**
  60881. * @hidden Internal
  60882. */
  60883. _effects: Array<PostProcess>;
  60884. /**
  60885. * @hidden Internal
  60886. */
  60887. _downscale: ExtractHighlightsPostProcess;
  60888. private _blurX;
  60889. private _blurY;
  60890. private _merge;
  60891. /**
  60892. * The luminance threshold to find bright areas of the image to bloom.
  60893. */
  60894. threshold: number;
  60895. /**
  60896. * The strength of the bloom.
  60897. */
  60898. weight: number;
  60899. /**
  60900. * Specifies the size of the bloom blur kernel, relative to the final output size
  60901. */
  60902. kernel: number;
  60903. /**
  60904. * Creates a new instance of @see BloomEffect
  60905. * @param scene The scene the effect belongs to.
  60906. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  60907. * @param bloomKernel The size of the kernel to be used when applying the blur.
  60908. * @param bloomWeight The the strength of bloom.
  60909. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60910. * @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)
  60911. */
  60912. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  60913. /**
  60914. * Disposes each of the internal effects for a given camera.
  60915. * @param camera The camera to dispose the effect on.
  60916. */
  60917. disposeEffects(camera: Camera): void;
  60918. /**
  60919. * @hidden Internal
  60920. */
  60921. _updateEffects(): void;
  60922. /**
  60923. * Internal
  60924. * @returns if all the contained post processes are ready.
  60925. * @hidden
  60926. */
  60927. _isReady(): boolean;
  60928. }
  60929. }
  60930. declare module BABYLON {
  60931. /** @hidden */
  60932. export var chromaticAberrationPixelShader: {
  60933. name: string;
  60934. shader: string;
  60935. };
  60936. }
  60937. declare module BABYLON {
  60938. /**
  60939. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  60940. */
  60941. export class ChromaticAberrationPostProcess extends PostProcess {
  60942. /**
  60943. * The amount of seperation of rgb channels (default: 30)
  60944. */
  60945. aberrationAmount: number;
  60946. /**
  60947. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  60948. */
  60949. radialIntensity: number;
  60950. /**
  60951. * 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))
  60952. */
  60953. direction: Vector2;
  60954. /**
  60955. * 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))
  60956. */
  60957. centerPosition: Vector2;
  60958. /**
  60959. * Creates a new instance ChromaticAberrationPostProcess
  60960. * @param name The name of the effect.
  60961. * @param screenWidth The width of the screen to apply the effect on.
  60962. * @param screenHeight The height of the screen to apply the effect on.
  60963. * @param options The required width/height ratio to downsize to before computing the render pass.
  60964. * @param camera The camera to apply the render pass to.
  60965. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60966. * @param engine The engine which the post process will be applied. (default: current engine)
  60967. * @param reusable If the post process can be reused on the same frame. (default: false)
  60968. * @param textureType Type of textures used when performing the post process. (default: 0)
  60969. * @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)
  60970. */
  60971. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60972. }
  60973. }
  60974. declare module BABYLON {
  60975. /** @hidden */
  60976. export var circleOfConfusionPixelShader: {
  60977. name: string;
  60978. shader: string;
  60979. };
  60980. }
  60981. declare module BABYLON {
  60982. /**
  60983. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  60984. */
  60985. export class CircleOfConfusionPostProcess extends PostProcess {
  60986. /**
  60987. * 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.
  60988. */
  60989. lensSize: number;
  60990. /**
  60991. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60992. */
  60993. fStop: number;
  60994. /**
  60995. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60996. */
  60997. focusDistance: number;
  60998. /**
  60999. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  61000. */
  61001. focalLength: number;
  61002. private _depthTexture;
  61003. /**
  61004. * Creates a new instance CircleOfConfusionPostProcess
  61005. * @param name The name of the effect.
  61006. * @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.
  61007. * @param options The required width/height ratio to downsize to before computing the render pass.
  61008. * @param camera The camera to apply the render pass to.
  61009. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61010. * @param engine The engine which the post process will be applied. (default: current engine)
  61011. * @param reusable If the post process can be reused on the same frame. (default: false)
  61012. * @param textureType Type of textures used when performing the post process. (default: 0)
  61013. * @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)
  61014. */
  61015. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61016. /**
  61017. * 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.
  61018. */
  61019. depthTexture: RenderTargetTexture;
  61020. }
  61021. }
  61022. declare module BABYLON {
  61023. /** @hidden */
  61024. export var colorCorrectionPixelShader: {
  61025. name: string;
  61026. shader: string;
  61027. };
  61028. }
  61029. declare module BABYLON {
  61030. /**
  61031. *
  61032. * This post-process allows the modification of rendered colors by using
  61033. * a 'look-up table' (LUT). This effect is also called Color Grading.
  61034. *
  61035. * The object needs to be provided an url to a texture containing the color
  61036. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  61037. * Use an image editing software to tweak the LUT to match your needs.
  61038. *
  61039. * For an example of a color LUT, see here:
  61040. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  61041. * For explanations on color grading, see here:
  61042. * @see http://udn.epicgames.com/Three/ColorGrading.html
  61043. *
  61044. */
  61045. export class ColorCorrectionPostProcess extends PostProcess {
  61046. private _colorTableTexture;
  61047. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61048. }
  61049. }
  61050. declare module BABYLON {
  61051. /** @hidden */
  61052. export var convolutionPixelShader: {
  61053. name: string;
  61054. shader: string;
  61055. };
  61056. }
  61057. declare module BABYLON {
  61058. /**
  61059. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  61060. * input texture to perform effects such as edge detection or sharpening
  61061. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61062. */
  61063. export class ConvolutionPostProcess extends PostProcess {
  61064. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61065. kernel: number[];
  61066. /**
  61067. * Creates a new instance ConvolutionPostProcess
  61068. * @param name The name of the effect.
  61069. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  61070. * @param options The required width/height ratio to downsize to before computing the render pass.
  61071. * @param camera The camera to apply the render pass to.
  61072. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61073. * @param engine The engine which the post process will be applied. (default: current engine)
  61074. * @param reusable If the post process can be reused on the same frame. (default: false)
  61075. * @param textureType Type of textures used when performing the post process. (default: 0)
  61076. */
  61077. constructor(name: string,
  61078. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61079. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61080. /**
  61081. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61082. */
  61083. static EdgeDetect0Kernel: number[];
  61084. /**
  61085. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61086. */
  61087. static EdgeDetect1Kernel: number[];
  61088. /**
  61089. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61090. */
  61091. static EdgeDetect2Kernel: number[];
  61092. /**
  61093. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61094. */
  61095. static SharpenKernel: number[];
  61096. /**
  61097. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61098. */
  61099. static EmbossKernel: number[];
  61100. /**
  61101. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61102. */
  61103. static GaussianKernel: number[];
  61104. }
  61105. }
  61106. declare module BABYLON {
  61107. /**
  61108. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  61109. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  61110. * based on samples that have a large difference in distance than the center pixel.
  61111. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  61112. */
  61113. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  61114. direction: Vector2;
  61115. /**
  61116. * Creates a new instance CircleOfConfusionPostProcess
  61117. * @param name The name of the effect.
  61118. * @param scene The scene the effect belongs to.
  61119. * @param direction The direction the blur should be applied.
  61120. * @param kernel The size of the kernel used to blur.
  61121. * @param options The required width/height ratio to downsize to before computing the render pass.
  61122. * @param camera The camera to apply the render pass to.
  61123. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  61124. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  61125. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61126. * @param engine The engine which the post process will be applied. (default: current engine)
  61127. * @param reusable If the post process can be reused on the same frame. (default: false)
  61128. * @param textureType Type of textures used when performing the post process. (default: 0)
  61129. * @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)
  61130. */
  61131. 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);
  61132. }
  61133. }
  61134. declare module BABYLON {
  61135. /** @hidden */
  61136. export var depthOfFieldMergePixelShader: {
  61137. name: string;
  61138. shader: string;
  61139. };
  61140. }
  61141. declare module BABYLON {
  61142. /**
  61143. * Options to be set when merging outputs from the default pipeline.
  61144. */
  61145. export class DepthOfFieldMergePostProcessOptions {
  61146. /**
  61147. * The original image to merge on top of
  61148. */
  61149. originalFromInput: PostProcess;
  61150. /**
  61151. * Parameters to perform the merge of the depth of field effect
  61152. */
  61153. depthOfField?: {
  61154. circleOfConfusion: PostProcess;
  61155. blurSteps: Array<PostProcess>;
  61156. };
  61157. /**
  61158. * Parameters to perform the merge of bloom effect
  61159. */
  61160. bloom?: {
  61161. blurred: PostProcess;
  61162. weight: number;
  61163. };
  61164. }
  61165. /**
  61166. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61167. */
  61168. export class DepthOfFieldMergePostProcess extends PostProcess {
  61169. private blurSteps;
  61170. /**
  61171. * Creates a new instance of DepthOfFieldMergePostProcess
  61172. * @param name The name of the effect.
  61173. * @param originalFromInput Post process which's input will be used for the merge.
  61174. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  61175. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  61176. * @param options The required width/height ratio to downsize to before computing the render pass.
  61177. * @param camera The camera to apply the render pass to.
  61178. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61179. * @param engine The engine which the post process will be applied. (default: current engine)
  61180. * @param reusable If the post process can be reused on the same frame. (default: false)
  61181. * @param textureType Type of textures used when performing the post process. (default: 0)
  61182. * @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)
  61183. */
  61184. 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);
  61185. /**
  61186. * Updates the effect with the current post process compile time values and recompiles the shader.
  61187. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  61188. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  61189. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  61190. * @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
  61191. * @param onCompiled Called when the shader has been compiled.
  61192. * @param onError Called if there is an error when compiling a shader.
  61193. */
  61194. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  61195. }
  61196. }
  61197. declare module BABYLON {
  61198. /**
  61199. * Specifies the level of max blur that should be applied when using the depth of field effect
  61200. */
  61201. export enum DepthOfFieldEffectBlurLevel {
  61202. /**
  61203. * Subtle blur
  61204. */
  61205. Low = 0,
  61206. /**
  61207. * Medium blur
  61208. */
  61209. Medium = 1,
  61210. /**
  61211. * Large blur
  61212. */
  61213. High = 2
  61214. }
  61215. /**
  61216. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  61217. */
  61218. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  61219. private _circleOfConfusion;
  61220. /**
  61221. * @hidden Internal, blurs from high to low
  61222. */
  61223. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  61224. private _depthOfFieldBlurY;
  61225. private _dofMerge;
  61226. /**
  61227. * @hidden Internal post processes in depth of field effect
  61228. */
  61229. _effects: Array<PostProcess>;
  61230. /**
  61231. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  61232. */
  61233. focalLength: number;
  61234. /**
  61235. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61236. */
  61237. fStop: number;
  61238. /**
  61239. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61240. */
  61241. focusDistance: number;
  61242. /**
  61243. * 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.
  61244. */
  61245. lensSize: number;
  61246. /**
  61247. * Creates a new instance DepthOfFieldEffect
  61248. * @param scene The scene the effect belongs to.
  61249. * @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.
  61250. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61251. * @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)
  61252. */
  61253. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  61254. /**
  61255. * Get the current class name of the current effet
  61256. * @returns "DepthOfFieldEffect"
  61257. */
  61258. getClassName(): string;
  61259. /**
  61260. * 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.
  61261. */
  61262. depthTexture: RenderTargetTexture;
  61263. /**
  61264. * Disposes each of the internal effects for a given camera.
  61265. * @param camera The camera to dispose the effect on.
  61266. */
  61267. disposeEffects(camera: Camera): void;
  61268. /**
  61269. * @hidden Internal
  61270. */
  61271. _updateEffects(): void;
  61272. /**
  61273. * Internal
  61274. * @returns if all the contained post processes are ready.
  61275. * @hidden
  61276. */
  61277. _isReady(): boolean;
  61278. }
  61279. }
  61280. declare module BABYLON {
  61281. /** @hidden */
  61282. export var displayPassPixelShader: {
  61283. name: string;
  61284. shader: string;
  61285. };
  61286. }
  61287. declare module BABYLON {
  61288. /**
  61289. * DisplayPassPostProcess which produces an output the same as it's input
  61290. */
  61291. export class DisplayPassPostProcess extends PostProcess {
  61292. /**
  61293. * Creates the DisplayPassPostProcess
  61294. * @param name The name of the effect.
  61295. * @param options The required width/height ratio to downsize to before computing the render pass.
  61296. * @param camera The camera to apply the render pass to.
  61297. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61298. * @param engine The engine which the post process will be applied. (default: current engine)
  61299. * @param reusable If the post process can be reused on the same frame. (default: false)
  61300. */
  61301. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61302. }
  61303. }
  61304. declare module BABYLON {
  61305. /** @hidden */
  61306. export var filterPixelShader: {
  61307. name: string;
  61308. shader: string;
  61309. };
  61310. }
  61311. declare module BABYLON {
  61312. /**
  61313. * Applies a kernel filter to the image
  61314. */
  61315. export class FilterPostProcess extends PostProcess {
  61316. /** The matrix to be applied to the image */
  61317. kernelMatrix: Matrix;
  61318. /**
  61319. *
  61320. * @param name The name of the effect.
  61321. * @param kernelMatrix The matrix to be applied to the image
  61322. * @param options The required width/height ratio to downsize to before computing the render pass.
  61323. * @param camera The camera to apply the render pass to.
  61324. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61325. * @param engine The engine which the post process will be applied. (default: current engine)
  61326. * @param reusable If the post process can be reused on the same frame. (default: false)
  61327. */
  61328. constructor(name: string,
  61329. /** The matrix to be applied to the image */
  61330. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61331. }
  61332. }
  61333. declare module BABYLON {
  61334. /** @hidden */
  61335. export var fxaaPixelShader: {
  61336. name: string;
  61337. shader: string;
  61338. };
  61339. }
  61340. declare module BABYLON {
  61341. /** @hidden */
  61342. export var fxaaVertexShader: {
  61343. name: string;
  61344. shader: string;
  61345. };
  61346. }
  61347. declare module BABYLON {
  61348. /**
  61349. * Fxaa post process
  61350. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  61351. */
  61352. export class FxaaPostProcess extends PostProcess {
  61353. /** @hidden */
  61354. texelWidth: number;
  61355. /** @hidden */
  61356. texelHeight: number;
  61357. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61358. private _getDefines;
  61359. }
  61360. }
  61361. declare module BABYLON {
  61362. /** @hidden */
  61363. export var grainPixelShader: {
  61364. name: string;
  61365. shader: string;
  61366. };
  61367. }
  61368. declare module BABYLON {
  61369. /**
  61370. * The GrainPostProcess adds noise to the image at mid luminance levels
  61371. */
  61372. export class GrainPostProcess extends PostProcess {
  61373. /**
  61374. * The intensity of the grain added (default: 30)
  61375. */
  61376. intensity: number;
  61377. /**
  61378. * If the grain should be randomized on every frame
  61379. */
  61380. animated: boolean;
  61381. /**
  61382. * Creates a new instance of @see GrainPostProcess
  61383. * @param name The name of the effect.
  61384. * @param options The required width/height ratio to downsize to before computing the render pass.
  61385. * @param camera The camera to apply the render pass to.
  61386. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61387. * @param engine The engine which the post process will be applied. (default: current engine)
  61388. * @param reusable If the post process can be reused on the same frame. (default: false)
  61389. * @param textureType Type of textures used when performing the post process. (default: 0)
  61390. * @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)
  61391. */
  61392. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61393. }
  61394. }
  61395. declare module BABYLON {
  61396. /** @hidden */
  61397. export var highlightsPixelShader: {
  61398. name: string;
  61399. shader: string;
  61400. };
  61401. }
  61402. declare module BABYLON {
  61403. /**
  61404. * Extracts highlights from the image
  61405. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61406. */
  61407. export class HighlightsPostProcess extends PostProcess {
  61408. /**
  61409. * Extracts highlights from the image
  61410. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61411. * @param name The name of the effect.
  61412. * @param options The required width/height ratio to downsize to before computing the render pass.
  61413. * @param camera The camera to apply the render pass to.
  61414. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61415. * @param engine The engine which the post process will be applied. (default: current engine)
  61416. * @param reusable If the post process can be reused on the same frame. (default: false)
  61417. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  61418. */
  61419. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61420. }
  61421. }
  61422. declare module BABYLON {
  61423. /** @hidden */
  61424. export var mrtFragmentDeclaration: {
  61425. name: string;
  61426. shader: string;
  61427. };
  61428. }
  61429. declare module BABYLON {
  61430. /** @hidden */
  61431. export var geometryPixelShader: {
  61432. name: string;
  61433. shader: string;
  61434. };
  61435. }
  61436. declare module BABYLON {
  61437. /** @hidden */
  61438. export var geometryVertexShader: {
  61439. name: string;
  61440. shader: string;
  61441. };
  61442. }
  61443. declare module BABYLON {
  61444. /** @hidden */
  61445. interface ISavedTransformationMatrix {
  61446. world: Matrix;
  61447. viewProjection: Matrix;
  61448. }
  61449. /**
  61450. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  61451. */
  61452. export class GeometryBufferRenderer {
  61453. /**
  61454. * Constant used to retrieve the position texture index in the G-Buffer textures array
  61455. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  61456. */
  61457. static readonly POSITION_TEXTURE_TYPE: number;
  61458. /**
  61459. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  61460. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  61461. */
  61462. static readonly VELOCITY_TEXTURE_TYPE: number;
  61463. /**
  61464. * Dictionary used to store the previous transformation matrices of each rendered mesh
  61465. * in order to compute objects velocities when enableVelocity is set to "true"
  61466. * @hidden
  61467. */
  61468. _previousTransformationMatrices: {
  61469. [index: number]: ISavedTransformationMatrix;
  61470. };
  61471. /**
  61472. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  61473. * in order to compute objects velocities when enableVelocity is set to "true"
  61474. * @hidden
  61475. */
  61476. _previousBonesTransformationMatrices: {
  61477. [index: number]: Float32Array;
  61478. };
  61479. /**
  61480. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  61481. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  61482. */
  61483. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  61484. private _scene;
  61485. private _multiRenderTarget;
  61486. private _ratio;
  61487. private _enablePosition;
  61488. private _enableVelocity;
  61489. private _positionIndex;
  61490. private _velocityIndex;
  61491. protected _effect: Effect;
  61492. protected _cachedDefines: string;
  61493. /**
  61494. * Set the render list (meshes to be rendered) used in the G buffer.
  61495. */
  61496. renderList: Mesh[];
  61497. /**
  61498. * Gets wether or not G buffer are supported by the running hardware.
  61499. * This requires draw buffer supports
  61500. */
  61501. readonly isSupported: boolean;
  61502. /**
  61503. * Returns the index of the given texture type in the G-Buffer textures array
  61504. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  61505. * @returns the index of the given texture type in the G-Buffer textures array
  61506. */
  61507. getTextureIndex(textureType: number): number;
  61508. /**
  61509. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  61510. */
  61511. /**
  61512. * Sets whether or not objects positions are enabled for the G buffer.
  61513. */
  61514. enablePosition: boolean;
  61515. /**
  61516. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  61517. */
  61518. /**
  61519. * Sets wether or not objects velocities are enabled for the G buffer.
  61520. */
  61521. enableVelocity: boolean;
  61522. /**
  61523. * Gets the scene associated with the buffer.
  61524. */
  61525. readonly scene: Scene;
  61526. /**
  61527. * Gets the ratio used by the buffer during its creation.
  61528. * How big is the buffer related to the main canvas.
  61529. */
  61530. readonly ratio: number;
  61531. /** @hidden */
  61532. static _SceneComponentInitialization: (scene: Scene) => void;
  61533. /**
  61534. * Creates a new G Buffer for the scene
  61535. * @param scene The scene the buffer belongs to
  61536. * @param ratio How big is the buffer related to the main canvas.
  61537. */
  61538. constructor(scene: Scene, ratio?: number);
  61539. /**
  61540. * Checks wether everything is ready to render a submesh to the G buffer.
  61541. * @param subMesh the submesh to check readiness for
  61542. * @param useInstances is the mesh drawn using instance or not
  61543. * @returns true if ready otherwise false
  61544. */
  61545. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61546. /**
  61547. * Gets the current underlying G Buffer.
  61548. * @returns the buffer
  61549. */
  61550. getGBuffer(): MultiRenderTarget;
  61551. /**
  61552. * Gets the number of samples used to render the buffer (anti aliasing).
  61553. */
  61554. /**
  61555. * Sets the number of samples used to render the buffer (anti aliasing).
  61556. */
  61557. samples: number;
  61558. /**
  61559. * Disposes the renderer and frees up associated resources.
  61560. */
  61561. dispose(): void;
  61562. protected _createRenderTargets(): void;
  61563. private _copyBonesTransformationMatrices;
  61564. }
  61565. }
  61566. declare module BABYLON {
  61567. interface Scene {
  61568. /** @hidden (Backing field) */
  61569. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61570. /**
  61571. * Gets or Sets the current geometry buffer associated to the scene.
  61572. */
  61573. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61574. /**
  61575. * Enables a GeometryBufferRender and associates it with the scene
  61576. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  61577. * @returns the GeometryBufferRenderer
  61578. */
  61579. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  61580. /**
  61581. * Disables the GeometryBufferRender associated with the scene
  61582. */
  61583. disableGeometryBufferRenderer(): void;
  61584. }
  61585. /**
  61586. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  61587. * in several rendering techniques.
  61588. */
  61589. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  61590. /**
  61591. * The component name helpful to identify the component in the list of scene components.
  61592. */
  61593. readonly name: string;
  61594. /**
  61595. * The scene the component belongs to.
  61596. */
  61597. scene: Scene;
  61598. /**
  61599. * Creates a new instance of the component for the given scene
  61600. * @param scene Defines the scene to register the component in
  61601. */
  61602. constructor(scene: Scene);
  61603. /**
  61604. * Registers the component in a given scene
  61605. */
  61606. register(): void;
  61607. /**
  61608. * Rebuilds the elements related to this component in case of
  61609. * context lost for instance.
  61610. */
  61611. rebuild(): void;
  61612. /**
  61613. * Disposes the component and the associated ressources
  61614. */
  61615. dispose(): void;
  61616. private _gatherRenderTargets;
  61617. }
  61618. }
  61619. declare module BABYLON {
  61620. /** @hidden */
  61621. export var motionBlurPixelShader: {
  61622. name: string;
  61623. shader: string;
  61624. };
  61625. }
  61626. declare module BABYLON {
  61627. /**
  61628. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  61629. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  61630. * As an example, all you have to do is to create the post-process:
  61631. * var mb = new BABYLON.MotionBlurPostProcess(
  61632. * 'mb', // The name of the effect.
  61633. * scene, // The scene containing the objects to blur according to their velocity.
  61634. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  61635. * camera // The camera to apply the render pass to.
  61636. * );
  61637. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  61638. */
  61639. export class MotionBlurPostProcess extends PostProcess {
  61640. /**
  61641. * Defines how much the image is blurred by the movement. Default value is equal to 1
  61642. */
  61643. motionStrength: number;
  61644. /**
  61645. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  61646. */
  61647. /**
  61648. * Sets the number of iterations to be used for motion blur quality
  61649. */
  61650. motionBlurSamples: number;
  61651. private _motionBlurSamples;
  61652. private _geometryBufferRenderer;
  61653. /**
  61654. * Creates a new instance MotionBlurPostProcess
  61655. * @param name The name of the effect.
  61656. * @param scene The scene containing the objects to blur according to their velocity.
  61657. * @param options The required width/height ratio to downsize to before computing the render pass.
  61658. * @param camera The camera to apply the render pass to.
  61659. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61660. * @param engine The engine which the post process will be applied. (default: current engine)
  61661. * @param reusable If the post process can be reused on the same frame. (default: false)
  61662. * @param textureType Type of textures used when performing the post process. (default: 0)
  61663. * @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)
  61664. */
  61665. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61666. /**
  61667. * Excludes the given skinned mesh from computing bones velocities.
  61668. * 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.
  61669. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  61670. */
  61671. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61672. /**
  61673. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  61674. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  61675. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  61676. */
  61677. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61678. /**
  61679. * Disposes the post process.
  61680. * @param camera The camera to dispose the post process on.
  61681. */
  61682. dispose(camera?: Camera): void;
  61683. }
  61684. }
  61685. declare module BABYLON {
  61686. /** @hidden */
  61687. export var refractionPixelShader: {
  61688. name: string;
  61689. shader: string;
  61690. };
  61691. }
  61692. declare module BABYLON {
  61693. /**
  61694. * Post process which applies a refractin texture
  61695. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61696. */
  61697. export class RefractionPostProcess extends PostProcess {
  61698. /** the base color of the refraction (used to taint the rendering) */
  61699. color: Color3;
  61700. /** simulated refraction depth */
  61701. depth: number;
  61702. /** the coefficient of the base color (0 to remove base color tainting) */
  61703. colorLevel: number;
  61704. private _refTexture;
  61705. private _ownRefractionTexture;
  61706. /**
  61707. * Gets or sets the refraction texture
  61708. * Please note that you are responsible for disposing the texture if you set it manually
  61709. */
  61710. refractionTexture: Texture;
  61711. /**
  61712. * Initializes the RefractionPostProcess
  61713. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61714. * @param name The name of the effect.
  61715. * @param refractionTextureUrl Url of the refraction texture to use
  61716. * @param color the base color of the refraction (used to taint the rendering)
  61717. * @param depth simulated refraction depth
  61718. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  61719. * @param camera The camera to apply the render pass to.
  61720. * @param options The required width/height ratio to downsize to before computing the render pass.
  61721. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61722. * @param engine The engine which the post process will be applied. (default: current engine)
  61723. * @param reusable If the post process can be reused on the same frame. (default: false)
  61724. */
  61725. constructor(name: string, refractionTextureUrl: string,
  61726. /** the base color of the refraction (used to taint the rendering) */
  61727. color: Color3,
  61728. /** simulated refraction depth */
  61729. depth: number,
  61730. /** the coefficient of the base color (0 to remove base color tainting) */
  61731. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61732. /**
  61733. * Disposes of the post process
  61734. * @param camera Camera to dispose post process on
  61735. */
  61736. dispose(camera: Camera): void;
  61737. }
  61738. }
  61739. declare module BABYLON {
  61740. /** @hidden */
  61741. export var sharpenPixelShader: {
  61742. name: string;
  61743. shader: string;
  61744. };
  61745. }
  61746. declare module BABYLON {
  61747. /**
  61748. * The SharpenPostProcess applies a sharpen kernel to every pixel
  61749. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61750. */
  61751. export class SharpenPostProcess extends PostProcess {
  61752. /**
  61753. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  61754. */
  61755. colorAmount: number;
  61756. /**
  61757. * How much sharpness should be applied (default: 0.3)
  61758. */
  61759. edgeAmount: number;
  61760. /**
  61761. * Creates a new instance ConvolutionPostProcess
  61762. * @param name The name of the effect.
  61763. * @param options The required width/height ratio to downsize to before computing the render pass.
  61764. * @param camera The camera to apply the render pass to.
  61765. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61766. * @param engine The engine which the post process will be applied. (default: current engine)
  61767. * @param reusable If the post process can be reused on the same frame. (default: false)
  61768. * @param textureType Type of textures used when performing the post process. (default: 0)
  61769. * @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)
  61770. */
  61771. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61772. }
  61773. }
  61774. declare module BABYLON {
  61775. /**
  61776. * PostProcessRenderPipeline
  61777. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61778. */
  61779. export class PostProcessRenderPipeline {
  61780. private engine;
  61781. private _renderEffects;
  61782. private _renderEffectsForIsolatedPass;
  61783. /**
  61784. * List of inspectable custom properties (used by the Inspector)
  61785. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  61786. */
  61787. inspectableCustomProperties: IInspectable[];
  61788. /**
  61789. * @hidden
  61790. */
  61791. protected _cameras: Camera[];
  61792. /** @hidden */
  61793. _name: string;
  61794. /**
  61795. * Gets pipeline name
  61796. */
  61797. readonly name: string;
  61798. /** Gets the list of attached cameras */
  61799. readonly cameras: Camera[];
  61800. /**
  61801. * Initializes a PostProcessRenderPipeline
  61802. * @param engine engine to add the pipeline to
  61803. * @param name name of the pipeline
  61804. */
  61805. constructor(engine: Engine, name: string);
  61806. /**
  61807. * Gets the class name
  61808. * @returns "PostProcessRenderPipeline"
  61809. */
  61810. getClassName(): string;
  61811. /**
  61812. * If all the render effects in the pipeline are supported
  61813. */
  61814. readonly isSupported: boolean;
  61815. /**
  61816. * Adds an effect to the pipeline
  61817. * @param renderEffect the effect to add
  61818. */
  61819. addEffect(renderEffect: PostProcessRenderEffect): void;
  61820. /** @hidden */
  61821. _rebuild(): void;
  61822. /** @hidden */
  61823. _enableEffect(renderEffectName: string, cameras: Camera): void;
  61824. /** @hidden */
  61825. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  61826. /** @hidden */
  61827. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  61828. /** @hidden */
  61829. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  61830. /** @hidden */
  61831. _attachCameras(cameras: Camera, unique: boolean): void;
  61832. /** @hidden */
  61833. _attachCameras(cameras: Camera[], unique: boolean): void;
  61834. /** @hidden */
  61835. _detachCameras(cameras: Camera): void;
  61836. /** @hidden */
  61837. _detachCameras(cameras: Nullable<Camera[]>): void;
  61838. /** @hidden */
  61839. _update(): void;
  61840. /** @hidden */
  61841. _reset(): void;
  61842. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  61843. /**
  61844. * Disposes of the pipeline
  61845. */
  61846. dispose(): void;
  61847. }
  61848. }
  61849. declare module BABYLON {
  61850. /**
  61851. * PostProcessRenderPipelineManager class
  61852. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61853. */
  61854. export class PostProcessRenderPipelineManager {
  61855. private _renderPipelines;
  61856. /**
  61857. * Initializes a PostProcessRenderPipelineManager
  61858. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61859. */
  61860. constructor();
  61861. /**
  61862. * Gets the list of supported render pipelines
  61863. */
  61864. readonly supportedPipelines: PostProcessRenderPipeline[];
  61865. /**
  61866. * Adds a pipeline to the manager
  61867. * @param renderPipeline The pipeline to add
  61868. */
  61869. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  61870. /**
  61871. * Attaches a camera to the pipeline
  61872. * @param renderPipelineName The name of the pipeline to attach to
  61873. * @param cameras the camera to attach
  61874. * @param unique if the camera can be attached multiple times to the pipeline
  61875. */
  61876. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  61877. /**
  61878. * Detaches a camera from the pipeline
  61879. * @param renderPipelineName The name of the pipeline to detach from
  61880. * @param cameras the camera to detach
  61881. */
  61882. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  61883. /**
  61884. * Enables an effect by name on a pipeline
  61885. * @param renderPipelineName the name of the pipeline to enable the effect in
  61886. * @param renderEffectName the name of the effect to enable
  61887. * @param cameras the cameras that the effect should be enabled on
  61888. */
  61889. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61890. /**
  61891. * Disables an effect by name on a pipeline
  61892. * @param renderPipelineName the name of the pipeline to disable the effect in
  61893. * @param renderEffectName the name of the effect to disable
  61894. * @param cameras the cameras that the effect should be disabled on
  61895. */
  61896. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61897. /**
  61898. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  61899. */
  61900. update(): void;
  61901. /** @hidden */
  61902. _rebuild(): void;
  61903. /**
  61904. * Disposes of the manager and pipelines
  61905. */
  61906. dispose(): void;
  61907. }
  61908. }
  61909. declare module BABYLON {
  61910. interface Scene {
  61911. /** @hidden (Backing field) */
  61912. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  61913. /**
  61914. * Gets the postprocess render pipeline manager
  61915. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61916. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61917. */
  61918. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  61919. }
  61920. /**
  61921. * Defines the Render Pipeline scene component responsible to rendering pipelines
  61922. */
  61923. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  61924. /**
  61925. * The component name helpfull to identify the component in the list of scene components.
  61926. */
  61927. readonly name: string;
  61928. /**
  61929. * The scene the component belongs to.
  61930. */
  61931. scene: Scene;
  61932. /**
  61933. * Creates a new instance of the component for the given scene
  61934. * @param scene Defines the scene to register the component in
  61935. */
  61936. constructor(scene: Scene);
  61937. /**
  61938. * Registers the component in a given scene
  61939. */
  61940. register(): void;
  61941. /**
  61942. * Rebuilds the elements related to this component in case of
  61943. * context lost for instance.
  61944. */
  61945. rebuild(): void;
  61946. /**
  61947. * Disposes the component and the associated ressources
  61948. */
  61949. dispose(): void;
  61950. private _gatherRenderTargets;
  61951. }
  61952. }
  61953. declare module BABYLON {
  61954. /**
  61955. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  61956. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61957. */
  61958. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61959. private _scene;
  61960. private _camerasToBeAttached;
  61961. /**
  61962. * ID of the sharpen post process,
  61963. */
  61964. private readonly SharpenPostProcessId;
  61965. /**
  61966. * @ignore
  61967. * ID of the image processing post process;
  61968. */
  61969. readonly ImageProcessingPostProcessId: string;
  61970. /**
  61971. * @ignore
  61972. * ID of the Fast Approximate Anti-Aliasing post process;
  61973. */
  61974. readonly FxaaPostProcessId: string;
  61975. /**
  61976. * ID of the chromatic aberration post process,
  61977. */
  61978. private readonly ChromaticAberrationPostProcessId;
  61979. /**
  61980. * ID of the grain post process
  61981. */
  61982. private readonly GrainPostProcessId;
  61983. /**
  61984. * Sharpen post process which will apply a sharpen convolution to enhance edges
  61985. */
  61986. sharpen: SharpenPostProcess;
  61987. private _sharpenEffect;
  61988. private bloom;
  61989. /**
  61990. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  61991. */
  61992. depthOfField: DepthOfFieldEffect;
  61993. /**
  61994. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61995. */
  61996. fxaa: FxaaPostProcess;
  61997. /**
  61998. * Image post processing pass used to perform operations such as tone mapping or color grading.
  61999. */
  62000. imageProcessing: ImageProcessingPostProcess;
  62001. /**
  62002. * Chromatic aberration post process which will shift rgb colors in the image
  62003. */
  62004. chromaticAberration: ChromaticAberrationPostProcess;
  62005. private _chromaticAberrationEffect;
  62006. /**
  62007. * Grain post process which add noise to the image
  62008. */
  62009. grain: GrainPostProcess;
  62010. private _grainEffect;
  62011. /**
  62012. * Glow post process which adds a glow to emissive areas of the image
  62013. */
  62014. private _glowLayer;
  62015. /**
  62016. * Animations which can be used to tweak settings over a period of time
  62017. */
  62018. animations: Animation[];
  62019. private _imageProcessingConfigurationObserver;
  62020. private _sharpenEnabled;
  62021. private _bloomEnabled;
  62022. private _depthOfFieldEnabled;
  62023. private _depthOfFieldBlurLevel;
  62024. private _fxaaEnabled;
  62025. private _imageProcessingEnabled;
  62026. private _defaultPipelineTextureType;
  62027. private _bloomScale;
  62028. private _chromaticAberrationEnabled;
  62029. private _grainEnabled;
  62030. private _buildAllowed;
  62031. /**
  62032. * Gets active scene
  62033. */
  62034. readonly scene: Scene;
  62035. /**
  62036. * Enable or disable the sharpen process from the pipeline
  62037. */
  62038. sharpenEnabled: boolean;
  62039. private _resizeObserver;
  62040. private _hardwareScaleLevel;
  62041. private _bloomKernel;
  62042. /**
  62043. * Specifies the size of the bloom blur kernel, relative to the final output size
  62044. */
  62045. bloomKernel: number;
  62046. /**
  62047. * Specifies the weight of the bloom in the final rendering
  62048. */
  62049. private _bloomWeight;
  62050. /**
  62051. * Specifies the luma threshold for the area that will be blurred by the bloom
  62052. */
  62053. private _bloomThreshold;
  62054. private _hdr;
  62055. /**
  62056. * The strength of the bloom.
  62057. */
  62058. bloomWeight: number;
  62059. /**
  62060. * The strength of the bloom.
  62061. */
  62062. bloomThreshold: number;
  62063. /**
  62064. * The scale of the bloom, lower value will provide better performance.
  62065. */
  62066. bloomScale: number;
  62067. /**
  62068. * Enable or disable the bloom from the pipeline
  62069. */
  62070. bloomEnabled: boolean;
  62071. private _rebuildBloom;
  62072. /**
  62073. * If the depth of field is enabled.
  62074. */
  62075. depthOfFieldEnabled: boolean;
  62076. /**
  62077. * Blur level of the depth of field effect. (Higher blur will effect performance)
  62078. */
  62079. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  62080. /**
  62081. * If the anti aliasing is enabled.
  62082. */
  62083. fxaaEnabled: boolean;
  62084. private _samples;
  62085. /**
  62086. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62087. */
  62088. samples: number;
  62089. /**
  62090. * If image processing is enabled.
  62091. */
  62092. imageProcessingEnabled: boolean;
  62093. /**
  62094. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  62095. */
  62096. glowLayerEnabled: boolean;
  62097. /**
  62098. * Gets the glow layer (or null if not defined)
  62099. */
  62100. readonly glowLayer: Nullable<GlowLayer>;
  62101. /**
  62102. * Enable or disable the chromaticAberration process from the pipeline
  62103. */
  62104. chromaticAberrationEnabled: boolean;
  62105. /**
  62106. * Enable or disable the grain process from the pipeline
  62107. */
  62108. grainEnabled: boolean;
  62109. /**
  62110. * @constructor
  62111. * @param name - The rendering pipeline name (default: "")
  62112. * @param hdr - If high dynamic range textures should be used (default: true)
  62113. * @param scene - The scene linked to this pipeline (default: the last created scene)
  62114. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  62115. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  62116. */
  62117. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  62118. /**
  62119. * Get the class name
  62120. * @returns "DefaultRenderingPipeline"
  62121. */
  62122. getClassName(): string;
  62123. /**
  62124. * Force the compilation of the entire pipeline.
  62125. */
  62126. prepare(): void;
  62127. private _hasCleared;
  62128. private _prevPostProcess;
  62129. private _prevPrevPostProcess;
  62130. private _setAutoClearAndTextureSharing;
  62131. private _depthOfFieldSceneObserver;
  62132. private _buildPipeline;
  62133. private _disposePostProcesses;
  62134. /**
  62135. * Adds a camera to the pipeline
  62136. * @param camera the camera to be added
  62137. */
  62138. addCamera(camera: Camera): void;
  62139. /**
  62140. * Removes a camera from the pipeline
  62141. * @param camera the camera to remove
  62142. */
  62143. removeCamera(camera: Camera): void;
  62144. /**
  62145. * Dispose of the pipeline and stop all post processes
  62146. */
  62147. dispose(): void;
  62148. /**
  62149. * Serialize the rendering pipeline (Used when exporting)
  62150. * @returns the serialized object
  62151. */
  62152. serialize(): any;
  62153. /**
  62154. * Parse the serialized pipeline
  62155. * @param source Source pipeline.
  62156. * @param scene The scene to load the pipeline to.
  62157. * @param rootUrl The URL of the serialized pipeline.
  62158. * @returns An instantiated pipeline from the serialized object.
  62159. */
  62160. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  62161. }
  62162. }
  62163. declare module BABYLON {
  62164. /** @hidden */
  62165. export var lensHighlightsPixelShader: {
  62166. name: string;
  62167. shader: string;
  62168. };
  62169. }
  62170. declare module BABYLON {
  62171. /** @hidden */
  62172. export var depthOfFieldPixelShader: {
  62173. name: string;
  62174. shader: string;
  62175. };
  62176. }
  62177. declare module BABYLON {
  62178. /**
  62179. * BABYLON.JS Chromatic Aberration GLSL Shader
  62180. * Author: Olivier Guyot
  62181. * Separates very slightly R, G and B colors on the edges of the screen
  62182. * Inspired by Francois Tarlier & Martins Upitis
  62183. */
  62184. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  62185. /**
  62186. * @ignore
  62187. * The chromatic aberration PostProcess id in the pipeline
  62188. */
  62189. LensChromaticAberrationEffect: string;
  62190. /**
  62191. * @ignore
  62192. * The highlights enhancing PostProcess id in the pipeline
  62193. */
  62194. HighlightsEnhancingEffect: string;
  62195. /**
  62196. * @ignore
  62197. * The depth-of-field PostProcess id in the pipeline
  62198. */
  62199. LensDepthOfFieldEffect: string;
  62200. private _scene;
  62201. private _depthTexture;
  62202. private _grainTexture;
  62203. private _chromaticAberrationPostProcess;
  62204. private _highlightsPostProcess;
  62205. private _depthOfFieldPostProcess;
  62206. private _edgeBlur;
  62207. private _grainAmount;
  62208. private _chromaticAberration;
  62209. private _distortion;
  62210. private _highlightsGain;
  62211. private _highlightsThreshold;
  62212. private _dofDistance;
  62213. private _dofAperture;
  62214. private _dofDarken;
  62215. private _dofPentagon;
  62216. private _blurNoise;
  62217. /**
  62218. * @constructor
  62219. *
  62220. * Effect parameters are as follow:
  62221. * {
  62222. * chromatic_aberration: number; // from 0 to x (1 for realism)
  62223. * edge_blur: number; // from 0 to x (1 for realism)
  62224. * distortion: number; // from 0 to x (1 for realism)
  62225. * grain_amount: number; // from 0 to 1
  62226. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  62227. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  62228. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  62229. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  62230. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  62231. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  62232. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  62233. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  62234. * }
  62235. * Note: if an effect parameter is unset, effect is disabled
  62236. *
  62237. * @param name The rendering pipeline name
  62238. * @param parameters - An object containing all parameters (see above)
  62239. * @param scene The scene linked to this pipeline
  62240. * @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)
  62241. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62242. */
  62243. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  62244. /**
  62245. * Get the class name
  62246. * @returns "LensRenderingPipeline"
  62247. */
  62248. getClassName(): string;
  62249. /**
  62250. * Gets associated scene
  62251. */
  62252. readonly scene: Scene;
  62253. /**
  62254. * Gets or sets the edge blur
  62255. */
  62256. edgeBlur: number;
  62257. /**
  62258. * Gets or sets the grain amount
  62259. */
  62260. grainAmount: number;
  62261. /**
  62262. * Gets or sets the chromatic aberration amount
  62263. */
  62264. chromaticAberration: number;
  62265. /**
  62266. * Gets or sets the depth of field aperture
  62267. */
  62268. dofAperture: number;
  62269. /**
  62270. * Gets or sets the edge distortion
  62271. */
  62272. edgeDistortion: number;
  62273. /**
  62274. * Gets or sets the depth of field distortion
  62275. */
  62276. dofDistortion: number;
  62277. /**
  62278. * Gets or sets the darken out of focus amount
  62279. */
  62280. darkenOutOfFocus: number;
  62281. /**
  62282. * Gets or sets a boolean indicating if blur noise is enabled
  62283. */
  62284. blurNoise: boolean;
  62285. /**
  62286. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  62287. */
  62288. pentagonBokeh: boolean;
  62289. /**
  62290. * Gets or sets the highlight grain amount
  62291. */
  62292. highlightsGain: number;
  62293. /**
  62294. * Gets or sets the highlight threshold
  62295. */
  62296. highlightsThreshold: number;
  62297. /**
  62298. * Sets the amount of blur at the edges
  62299. * @param amount blur amount
  62300. */
  62301. setEdgeBlur(amount: number): void;
  62302. /**
  62303. * Sets edge blur to 0
  62304. */
  62305. disableEdgeBlur(): void;
  62306. /**
  62307. * Sets the amout of grain
  62308. * @param amount Amount of grain
  62309. */
  62310. setGrainAmount(amount: number): void;
  62311. /**
  62312. * Set grain amount to 0
  62313. */
  62314. disableGrain(): void;
  62315. /**
  62316. * Sets the chromatic aberration amount
  62317. * @param amount amount of chromatic aberration
  62318. */
  62319. setChromaticAberration(amount: number): void;
  62320. /**
  62321. * Sets chromatic aberration amount to 0
  62322. */
  62323. disableChromaticAberration(): void;
  62324. /**
  62325. * Sets the EdgeDistortion amount
  62326. * @param amount amount of EdgeDistortion
  62327. */
  62328. setEdgeDistortion(amount: number): void;
  62329. /**
  62330. * Sets edge distortion to 0
  62331. */
  62332. disableEdgeDistortion(): void;
  62333. /**
  62334. * Sets the FocusDistance amount
  62335. * @param amount amount of FocusDistance
  62336. */
  62337. setFocusDistance(amount: number): void;
  62338. /**
  62339. * Disables depth of field
  62340. */
  62341. disableDepthOfField(): void;
  62342. /**
  62343. * Sets the Aperture amount
  62344. * @param amount amount of Aperture
  62345. */
  62346. setAperture(amount: number): void;
  62347. /**
  62348. * Sets the DarkenOutOfFocus amount
  62349. * @param amount amount of DarkenOutOfFocus
  62350. */
  62351. setDarkenOutOfFocus(amount: number): void;
  62352. private _pentagonBokehIsEnabled;
  62353. /**
  62354. * Creates a pentagon bokeh effect
  62355. */
  62356. enablePentagonBokeh(): void;
  62357. /**
  62358. * Disables the pentagon bokeh effect
  62359. */
  62360. disablePentagonBokeh(): void;
  62361. /**
  62362. * Enables noise blur
  62363. */
  62364. enableNoiseBlur(): void;
  62365. /**
  62366. * Disables noise blur
  62367. */
  62368. disableNoiseBlur(): void;
  62369. /**
  62370. * Sets the HighlightsGain amount
  62371. * @param amount amount of HighlightsGain
  62372. */
  62373. setHighlightsGain(amount: number): void;
  62374. /**
  62375. * Sets the HighlightsThreshold amount
  62376. * @param amount amount of HighlightsThreshold
  62377. */
  62378. setHighlightsThreshold(amount: number): void;
  62379. /**
  62380. * Disables highlights
  62381. */
  62382. disableHighlights(): void;
  62383. /**
  62384. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  62385. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  62386. */
  62387. dispose(disableDepthRender?: boolean): void;
  62388. private _createChromaticAberrationPostProcess;
  62389. private _createHighlightsPostProcess;
  62390. private _createDepthOfFieldPostProcess;
  62391. private _createGrainTexture;
  62392. }
  62393. }
  62394. declare module BABYLON {
  62395. /** @hidden */
  62396. export var ssao2PixelShader: {
  62397. name: string;
  62398. shader: string;
  62399. };
  62400. }
  62401. declare module BABYLON {
  62402. /** @hidden */
  62403. export var ssaoCombinePixelShader: {
  62404. name: string;
  62405. shader: string;
  62406. };
  62407. }
  62408. declare module BABYLON {
  62409. /**
  62410. * Render pipeline to produce ssao effect
  62411. */
  62412. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  62413. /**
  62414. * @ignore
  62415. * The PassPostProcess id in the pipeline that contains the original scene color
  62416. */
  62417. SSAOOriginalSceneColorEffect: string;
  62418. /**
  62419. * @ignore
  62420. * The SSAO PostProcess id in the pipeline
  62421. */
  62422. SSAORenderEffect: string;
  62423. /**
  62424. * @ignore
  62425. * The horizontal blur PostProcess id in the pipeline
  62426. */
  62427. SSAOBlurHRenderEffect: string;
  62428. /**
  62429. * @ignore
  62430. * The vertical blur PostProcess id in the pipeline
  62431. */
  62432. SSAOBlurVRenderEffect: string;
  62433. /**
  62434. * @ignore
  62435. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62436. */
  62437. SSAOCombineRenderEffect: string;
  62438. /**
  62439. * The output strength of the SSAO post-process. Default value is 1.0.
  62440. */
  62441. totalStrength: number;
  62442. /**
  62443. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  62444. */
  62445. maxZ: number;
  62446. /**
  62447. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  62448. */
  62449. minZAspect: number;
  62450. private _samples;
  62451. /**
  62452. * Number of samples used for the SSAO calculations. Default value is 8
  62453. */
  62454. samples: number;
  62455. private _textureSamples;
  62456. /**
  62457. * Number of samples to use for antialiasing
  62458. */
  62459. textureSamples: number;
  62460. /**
  62461. * Ratio object used for SSAO ratio and blur ratio
  62462. */
  62463. private _ratio;
  62464. /**
  62465. * Dynamically generated sphere sampler.
  62466. */
  62467. private _sampleSphere;
  62468. /**
  62469. * Blur filter offsets
  62470. */
  62471. private _samplerOffsets;
  62472. private _expensiveBlur;
  62473. /**
  62474. * If bilateral blur should be used
  62475. */
  62476. expensiveBlur: boolean;
  62477. /**
  62478. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  62479. */
  62480. radius: number;
  62481. /**
  62482. * The base color of the SSAO post-process
  62483. * The final result is "base + ssao" between [0, 1]
  62484. */
  62485. base: number;
  62486. /**
  62487. * Support test.
  62488. */
  62489. static readonly IsSupported: boolean;
  62490. private _scene;
  62491. private _depthTexture;
  62492. private _normalTexture;
  62493. private _randomTexture;
  62494. private _originalColorPostProcess;
  62495. private _ssaoPostProcess;
  62496. private _blurHPostProcess;
  62497. private _blurVPostProcess;
  62498. private _ssaoCombinePostProcess;
  62499. /**
  62500. * Gets active scene
  62501. */
  62502. readonly scene: Scene;
  62503. /**
  62504. * @constructor
  62505. * @param name The rendering pipeline name
  62506. * @param scene The scene linked to this pipeline
  62507. * @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 }
  62508. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62509. */
  62510. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62511. /**
  62512. * Get the class name
  62513. * @returns "SSAO2RenderingPipeline"
  62514. */
  62515. getClassName(): string;
  62516. /**
  62517. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62518. */
  62519. dispose(disableGeometryBufferRenderer?: boolean): void;
  62520. private _createBlurPostProcess;
  62521. /** @hidden */
  62522. _rebuild(): void;
  62523. private _bits;
  62524. private _radicalInverse_VdC;
  62525. private _hammersley;
  62526. private _hemisphereSample_uniform;
  62527. private _generateHemisphere;
  62528. private _createSSAOPostProcess;
  62529. private _createSSAOCombinePostProcess;
  62530. private _createRandomTexture;
  62531. /**
  62532. * Serialize the rendering pipeline (Used when exporting)
  62533. * @returns the serialized object
  62534. */
  62535. serialize(): any;
  62536. /**
  62537. * Parse the serialized pipeline
  62538. * @param source Source pipeline.
  62539. * @param scene The scene to load the pipeline to.
  62540. * @param rootUrl The URL of the serialized pipeline.
  62541. * @returns An instantiated pipeline from the serialized object.
  62542. */
  62543. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  62544. }
  62545. }
  62546. declare module BABYLON {
  62547. /** @hidden */
  62548. export var ssaoPixelShader: {
  62549. name: string;
  62550. shader: string;
  62551. };
  62552. }
  62553. declare module BABYLON {
  62554. /**
  62555. * Render pipeline to produce ssao effect
  62556. */
  62557. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  62558. /**
  62559. * @ignore
  62560. * The PassPostProcess id in the pipeline that contains the original scene color
  62561. */
  62562. SSAOOriginalSceneColorEffect: string;
  62563. /**
  62564. * @ignore
  62565. * The SSAO PostProcess id in the pipeline
  62566. */
  62567. SSAORenderEffect: string;
  62568. /**
  62569. * @ignore
  62570. * The horizontal blur PostProcess id in the pipeline
  62571. */
  62572. SSAOBlurHRenderEffect: string;
  62573. /**
  62574. * @ignore
  62575. * The vertical blur PostProcess id in the pipeline
  62576. */
  62577. SSAOBlurVRenderEffect: string;
  62578. /**
  62579. * @ignore
  62580. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62581. */
  62582. SSAOCombineRenderEffect: string;
  62583. /**
  62584. * The output strength of the SSAO post-process. Default value is 1.0.
  62585. */
  62586. totalStrength: number;
  62587. /**
  62588. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  62589. */
  62590. radius: number;
  62591. /**
  62592. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  62593. * Must not be equal to fallOff and superior to fallOff.
  62594. * Default value is 0.0075
  62595. */
  62596. area: number;
  62597. /**
  62598. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  62599. * Must not be equal to area and inferior to area.
  62600. * Default value is 0.000001
  62601. */
  62602. fallOff: number;
  62603. /**
  62604. * The base color of the SSAO post-process
  62605. * The final result is "base + ssao" between [0, 1]
  62606. */
  62607. base: number;
  62608. private _scene;
  62609. private _depthTexture;
  62610. private _randomTexture;
  62611. private _originalColorPostProcess;
  62612. private _ssaoPostProcess;
  62613. private _blurHPostProcess;
  62614. private _blurVPostProcess;
  62615. private _ssaoCombinePostProcess;
  62616. private _firstUpdate;
  62617. /**
  62618. * Gets active scene
  62619. */
  62620. readonly scene: Scene;
  62621. /**
  62622. * @constructor
  62623. * @param name - The rendering pipeline name
  62624. * @param scene - The scene linked to this pipeline
  62625. * @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 }
  62626. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  62627. */
  62628. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62629. /**
  62630. * Get the class name
  62631. * @returns "SSAORenderingPipeline"
  62632. */
  62633. getClassName(): string;
  62634. /**
  62635. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62636. */
  62637. dispose(disableDepthRender?: boolean): void;
  62638. private _createBlurPostProcess;
  62639. /** @hidden */
  62640. _rebuild(): void;
  62641. private _createSSAOPostProcess;
  62642. private _createSSAOCombinePostProcess;
  62643. private _createRandomTexture;
  62644. }
  62645. }
  62646. declare module BABYLON {
  62647. /** @hidden */
  62648. export var standardPixelShader: {
  62649. name: string;
  62650. shader: string;
  62651. };
  62652. }
  62653. declare module BABYLON {
  62654. /**
  62655. * Standard rendering pipeline
  62656. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62657. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  62658. */
  62659. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62660. /**
  62661. * Public members
  62662. */
  62663. /**
  62664. * Post-process which contains the original scene color before the pipeline applies all the effects
  62665. */
  62666. originalPostProcess: Nullable<PostProcess>;
  62667. /**
  62668. * Post-process used to down scale an image x4
  62669. */
  62670. downSampleX4PostProcess: Nullable<PostProcess>;
  62671. /**
  62672. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  62673. */
  62674. brightPassPostProcess: Nullable<PostProcess>;
  62675. /**
  62676. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  62677. */
  62678. blurHPostProcesses: PostProcess[];
  62679. /**
  62680. * Post-process array storing all the vertical blur post-processes used by the pipeline
  62681. */
  62682. blurVPostProcesses: PostProcess[];
  62683. /**
  62684. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  62685. */
  62686. textureAdderPostProcess: Nullable<PostProcess>;
  62687. /**
  62688. * Post-process used to create volumetric lighting effect
  62689. */
  62690. volumetricLightPostProcess: Nullable<PostProcess>;
  62691. /**
  62692. * Post-process used to smooth the previous volumetric light post-process on the X axis
  62693. */
  62694. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  62695. /**
  62696. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  62697. */
  62698. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  62699. /**
  62700. * Post-process used to merge the volumetric light effect and the real scene color
  62701. */
  62702. volumetricLightMergePostProces: Nullable<PostProcess>;
  62703. /**
  62704. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  62705. */
  62706. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  62707. /**
  62708. * Base post-process used to calculate the average luminance of the final image for HDR
  62709. */
  62710. luminancePostProcess: Nullable<PostProcess>;
  62711. /**
  62712. * Post-processes used to create down sample post-processes in order to get
  62713. * the average luminance of the final image for HDR
  62714. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  62715. */
  62716. luminanceDownSamplePostProcesses: PostProcess[];
  62717. /**
  62718. * Post-process used to create a HDR effect (light adaptation)
  62719. */
  62720. hdrPostProcess: Nullable<PostProcess>;
  62721. /**
  62722. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  62723. */
  62724. textureAdderFinalPostProcess: Nullable<PostProcess>;
  62725. /**
  62726. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  62727. */
  62728. lensFlareFinalPostProcess: Nullable<PostProcess>;
  62729. /**
  62730. * Post-process used to merge the final HDR post-process and the real scene color
  62731. */
  62732. hdrFinalPostProcess: Nullable<PostProcess>;
  62733. /**
  62734. * Post-process used to create a lens flare effect
  62735. */
  62736. lensFlarePostProcess: Nullable<PostProcess>;
  62737. /**
  62738. * Post-process that merges the result of the lens flare post-process and the real scene color
  62739. */
  62740. lensFlareComposePostProcess: Nullable<PostProcess>;
  62741. /**
  62742. * Post-process used to create a motion blur effect
  62743. */
  62744. motionBlurPostProcess: Nullable<PostProcess>;
  62745. /**
  62746. * Post-process used to create a depth of field effect
  62747. */
  62748. depthOfFieldPostProcess: Nullable<PostProcess>;
  62749. /**
  62750. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62751. */
  62752. fxaaPostProcess: Nullable<FxaaPostProcess>;
  62753. /**
  62754. * Represents the brightness threshold in order to configure the illuminated surfaces
  62755. */
  62756. brightThreshold: number;
  62757. /**
  62758. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  62759. */
  62760. blurWidth: number;
  62761. /**
  62762. * Sets if the blur for highlighted surfaces must be only horizontal
  62763. */
  62764. horizontalBlur: boolean;
  62765. /**
  62766. * Gets the overall exposure used by the pipeline
  62767. */
  62768. /**
  62769. * Sets the overall exposure used by the pipeline
  62770. */
  62771. exposure: number;
  62772. /**
  62773. * Texture used typically to simulate "dirty" on camera lens
  62774. */
  62775. lensTexture: Nullable<Texture>;
  62776. /**
  62777. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  62778. */
  62779. volumetricLightCoefficient: number;
  62780. /**
  62781. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  62782. */
  62783. volumetricLightPower: number;
  62784. /**
  62785. * Used the set the blur intensity to smooth the volumetric lights
  62786. */
  62787. volumetricLightBlurScale: number;
  62788. /**
  62789. * Light (spot or directional) used to generate the volumetric lights rays
  62790. * The source light must have a shadow generate so the pipeline can get its
  62791. * depth map
  62792. */
  62793. sourceLight: Nullable<SpotLight | DirectionalLight>;
  62794. /**
  62795. * For eye adaptation, represents the minimum luminance the eye can see
  62796. */
  62797. hdrMinimumLuminance: number;
  62798. /**
  62799. * For eye adaptation, represents the decrease luminance speed
  62800. */
  62801. hdrDecreaseRate: number;
  62802. /**
  62803. * For eye adaptation, represents the increase luminance speed
  62804. */
  62805. hdrIncreaseRate: number;
  62806. /**
  62807. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  62808. */
  62809. /**
  62810. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  62811. */
  62812. hdrAutoExposure: boolean;
  62813. /**
  62814. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  62815. */
  62816. lensColorTexture: Nullable<Texture>;
  62817. /**
  62818. * The overall strengh for the lens flare effect
  62819. */
  62820. lensFlareStrength: number;
  62821. /**
  62822. * Dispersion coefficient for lens flare ghosts
  62823. */
  62824. lensFlareGhostDispersal: number;
  62825. /**
  62826. * Main lens flare halo width
  62827. */
  62828. lensFlareHaloWidth: number;
  62829. /**
  62830. * Based on the lens distortion effect, defines how much the lens flare result
  62831. * is distorted
  62832. */
  62833. lensFlareDistortionStrength: number;
  62834. /**
  62835. * Configures the blur intensity used for for lens flare (halo)
  62836. */
  62837. lensFlareBlurWidth: number;
  62838. /**
  62839. * Lens star texture must be used to simulate rays on the flares and is available
  62840. * in the documentation
  62841. */
  62842. lensStarTexture: Nullable<Texture>;
  62843. /**
  62844. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  62845. * flare effect by taking account of the dirt texture
  62846. */
  62847. lensFlareDirtTexture: Nullable<Texture>;
  62848. /**
  62849. * Represents the focal length for the depth of field effect
  62850. */
  62851. depthOfFieldDistance: number;
  62852. /**
  62853. * Represents the blur intensity for the blurred part of the depth of field effect
  62854. */
  62855. depthOfFieldBlurWidth: number;
  62856. /**
  62857. * Gets how much the image is blurred by the movement while using the motion blur post-process
  62858. */
  62859. /**
  62860. * Sets how much the image is blurred by the movement while using the motion blur post-process
  62861. */
  62862. motionStrength: number;
  62863. /**
  62864. * Gets wether or not the motion blur post-process is object based or screen based.
  62865. */
  62866. /**
  62867. * Sets wether or not the motion blur post-process should be object based or screen based
  62868. */
  62869. objectBasedMotionBlur: boolean;
  62870. /**
  62871. * List of animations for the pipeline (IAnimatable implementation)
  62872. */
  62873. animations: Animation[];
  62874. /**
  62875. * Private members
  62876. */
  62877. private _scene;
  62878. private _currentDepthOfFieldSource;
  62879. private _basePostProcess;
  62880. private _fixedExposure;
  62881. private _currentExposure;
  62882. private _hdrAutoExposure;
  62883. private _hdrCurrentLuminance;
  62884. private _motionStrength;
  62885. private _isObjectBasedMotionBlur;
  62886. private _floatTextureType;
  62887. private _camerasToBeAttached;
  62888. private _ratio;
  62889. private _bloomEnabled;
  62890. private _depthOfFieldEnabled;
  62891. private _vlsEnabled;
  62892. private _lensFlareEnabled;
  62893. private _hdrEnabled;
  62894. private _motionBlurEnabled;
  62895. private _fxaaEnabled;
  62896. private _motionBlurSamples;
  62897. private _volumetricLightStepsCount;
  62898. private _samples;
  62899. /**
  62900. * @ignore
  62901. * Specifies if the bloom pipeline is enabled
  62902. */
  62903. BloomEnabled: boolean;
  62904. /**
  62905. * @ignore
  62906. * Specifies if the depth of field pipeline is enabed
  62907. */
  62908. DepthOfFieldEnabled: boolean;
  62909. /**
  62910. * @ignore
  62911. * Specifies if the lens flare pipeline is enabed
  62912. */
  62913. LensFlareEnabled: boolean;
  62914. /**
  62915. * @ignore
  62916. * Specifies if the HDR pipeline is enabled
  62917. */
  62918. HDREnabled: boolean;
  62919. /**
  62920. * @ignore
  62921. * Specifies if the volumetric lights scattering effect is enabled
  62922. */
  62923. VLSEnabled: boolean;
  62924. /**
  62925. * @ignore
  62926. * Specifies if the motion blur effect is enabled
  62927. */
  62928. MotionBlurEnabled: boolean;
  62929. /**
  62930. * Specifies if anti-aliasing is enabled
  62931. */
  62932. fxaaEnabled: boolean;
  62933. /**
  62934. * Specifies the number of steps used to calculate the volumetric lights
  62935. * Typically in interval [50, 200]
  62936. */
  62937. volumetricLightStepsCount: number;
  62938. /**
  62939. * Specifies the number of samples used for the motion blur effect
  62940. * Typically in interval [16, 64]
  62941. */
  62942. motionBlurSamples: number;
  62943. /**
  62944. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62945. */
  62946. samples: number;
  62947. /**
  62948. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62949. * @constructor
  62950. * @param name The rendering pipeline name
  62951. * @param scene The scene linked to this pipeline
  62952. * @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)
  62953. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  62954. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62955. */
  62956. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  62957. private _buildPipeline;
  62958. private _createDownSampleX4PostProcess;
  62959. private _createBrightPassPostProcess;
  62960. private _createBlurPostProcesses;
  62961. private _createTextureAdderPostProcess;
  62962. private _createVolumetricLightPostProcess;
  62963. private _createLuminancePostProcesses;
  62964. private _createHdrPostProcess;
  62965. private _createLensFlarePostProcess;
  62966. private _createDepthOfFieldPostProcess;
  62967. private _createMotionBlurPostProcess;
  62968. private _getDepthTexture;
  62969. private _disposePostProcesses;
  62970. /**
  62971. * Dispose of the pipeline and stop all post processes
  62972. */
  62973. dispose(): void;
  62974. /**
  62975. * Serialize the rendering pipeline (Used when exporting)
  62976. * @returns the serialized object
  62977. */
  62978. serialize(): any;
  62979. /**
  62980. * Parse the serialized pipeline
  62981. * @param source Source pipeline.
  62982. * @param scene The scene to load the pipeline to.
  62983. * @param rootUrl The URL of the serialized pipeline.
  62984. * @returns An instantiated pipeline from the serialized object.
  62985. */
  62986. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  62987. /**
  62988. * Luminance steps
  62989. */
  62990. static LuminanceSteps: number;
  62991. }
  62992. }
  62993. declare module BABYLON {
  62994. /** @hidden */
  62995. export var tonemapPixelShader: {
  62996. name: string;
  62997. shader: string;
  62998. };
  62999. }
  63000. declare module BABYLON {
  63001. /** Defines operator used for tonemapping */
  63002. export enum TonemappingOperator {
  63003. /** Hable */
  63004. Hable = 0,
  63005. /** Reinhard */
  63006. Reinhard = 1,
  63007. /** HejiDawson */
  63008. HejiDawson = 2,
  63009. /** Photographic */
  63010. Photographic = 3
  63011. }
  63012. /**
  63013. * Defines a post process to apply tone mapping
  63014. */
  63015. export class TonemapPostProcess extends PostProcess {
  63016. private _operator;
  63017. /** Defines the required exposure adjustement */
  63018. exposureAdjustment: number;
  63019. /**
  63020. * Creates a new TonemapPostProcess
  63021. * @param name defines the name of the postprocess
  63022. * @param _operator defines the operator to use
  63023. * @param exposureAdjustment defines the required exposure adjustement
  63024. * @param camera defines the camera to use (can be null)
  63025. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  63026. * @param engine defines the hosting engine (can be ignore if camera is set)
  63027. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63028. */
  63029. constructor(name: string, _operator: TonemappingOperator,
  63030. /** Defines the required exposure adjustement */
  63031. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  63032. }
  63033. }
  63034. declare module BABYLON {
  63035. /** @hidden */
  63036. export var depthVertexShader: {
  63037. name: string;
  63038. shader: string;
  63039. };
  63040. }
  63041. declare module BABYLON {
  63042. /** @hidden */
  63043. export var volumetricLightScatteringPixelShader: {
  63044. name: string;
  63045. shader: string;
  63046. };
  63047. }
  63048. declare module BABYLON {
  63049. /** @hidden */
  63050. export var volumetricLightScatteringPassVertexShader: {
  63051. name: string;
  63052. shader: string;
  63053. };
  63054. }
  63055. declare module BABYLON {
  63056. /** @hidden */
  63057. export var volumetricLightScatteringPassPixelShader: {
  63058. name: string;
  63059. shader: string;
  63060. };
  63061. }
  63062. declare module BABYLON {
  63063. /**
  63064. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  63065. */
  63066. export class VolumetricLightScatteringPostProcess extends PostProcess {
  63067. private _volumetricLightScatteringPass;
  63068. private _volumetricLightScatteringRTT;
  63069. private _viewPort;
  63070. private _screenCoordinates;
  63071. private _cachedDefines;
  63072. /**
  63073. * If not undefined, the mesh position is computed from the attached node position
  63074. */
  63075. attachedNode: {
  63076. position: Vector3;
  63077. };
  63078. /**
  63079. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  63080. */
  63081. customMeshPosition: Vector3;
  63082. /**
  63083. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  63084. */
  63085. useCustomMeshPosition: boolean;
  63086. /**
  63087. * If the post-process should inverse the light scattering direction
  63088. */
  63089. invert: boolean;
  63090. /**
  63091. * The internal mesh used by the post-process
  63092. */
  63093. mesh: Mesh;
  63094. /**
  63095. * @hidden
  63096. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  63097. */
  63098. useDiffuseColor: boolean;
  63099. /**
  63100. * Array containing the excluded meshes not rendered in the internal pass
  63101. */
  63102. excludedMeshes: AbstractMesh[];
  63103. /**
  63104. * Controls the overall intensity of the post-process
  63105. */
  63106. exposure: number;
  63107. /**
  63108. * Dissipates each sample's contribution in range [0, 1]
  63109. */
  63110. decay: number;
  63111. /**
  63112. * Controls the overall intensity of each sample
  63113. */
  63114. weight: number;
  63115. /**
  63116. * Controls the density of each sample
  63117. */
  63118. density: number;
  63119. /**
  63120. * @constructor
  63121. * @param name The post-process name
  63122. * @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)
  63123. * @param camera The camera that the post-process will be attached to
  63124. * @param mesh The mesh used to create the light scattering
  63125. * @param samples The post-process quality, default 100
  63126. * @param samplingModeThe post-process filtering mode
  63127. * @param engine The babylon engine
  63128. * @param reusable If the post-process is reusable
  63129. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  63130. */
  63131. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  63132. /**
  63133. * Returns the string "VolumetricLightScatteringPostProcess"
  63134. * @returns "VolumetricLightScatteringPostProcess"
  63135. */
  63136. getClassName(): string;
  63137. private _isReady;
  63138. /**
  63139. * Sets the new light position for light scattering effect
  63140. * @param position The new custom light position
  63141. */
  63142. setCustomMeshPosition(position: Vector3): void;
  63143. /**
  63144. * Returns the light position for light scattering effect
  63145. * @return Vector3 The custom light position
  63146. */
  63147. getCustomMeshPosition(): Vector3;
  63148. /**
  63149. * Disposes the internal assets and detaches the post-process from the camera
  63150. */
  63151. dispose(camera: Camera): void;
  63152. /**
  63153. * Returns the render target texture used by the post-process
  63154. * @return the render target texture used by the post-process
  63155. */
  63156. getPass(): RenderTargetTexture;
  63157. private _meshExcluded;
  63158. private _createPass;
  63159. private _updateMeshScreenCoordinates;
  63160. /**
  63161. * Creates a default mesh for the Volumeric Light Scattering post-process
  63162. * @param name The mesh name
  63163. * @param scene The scene where to create the mesh
  63164. * @return the default mesh
  63165. */
  63166. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  63167. }
  63168. }
  63169. declare module BABYLON {
  63170. interface Scene {
  63171. /** @hidden (Backing field) */
  63172. _boundingBoxRenderer: BoundingBoxRenderer;
  63173. /** @hidden (Backing field) */
  63174. _forceShowBoundingBoxes: boolean;
  63175. /**
  63176. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  63177. */
  63178. forceShowBoundingBoxes: boolean;
  63179. /**
  63180. * Gets the bounding box renderer associated with the scene
  63181. * @returns a BoundingBoxRenderer
  63182. */
  63183. getBoundingBoxRenderer(): BoundingBoxRenderer;
  63184. }
  63185. interface AbstractMesh {
  63186. /** @hidden (Backing field) */
  63187. _showBoundingBox: boolean;
  63188. /**
  63189. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  63190. */
  63191. showBoundingBox: boolean;
  63192. }
  63193. /**
  63194. * Component responsible of rendering the bounding box of the meshes in a scene.
  63195. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  63196. */
  63197. export class BoundingBoxRenderer implements ISceneComponent {
  63198. /**
  63199. * The component name helpfull to identify the component in the list of scene components.
  63200. */
  63201. readonly name: string;
  63202. /**
  63203. * The scene the component belongs to.
  63204. */
  63205. scene: Scene;
  63206. /**
  63207. * Color of the bounding box lines placed in front of an object
  63208. */
  63209. frontColor: Color3;
  63210. /**
  63211. * Color of the bounding box lines placed behind an object
  63212. */
  63213. backColor: Color3;
  63214. /**
  63215. * Defines if the renderer should show the back lines or not
  63216. */
  63217. showBackLines: boolean;
  63218. /**
  63219. * @hidden
  63220. */
  63221. renderList: SmartArray<BoundingBox>;
  63222. private _colorShader;
  63223. private _vertexBuffers;
  63224. private _indexBuffer;
  63225. private _fillIndexBuffer;
  63226. private _fillIndexData;
  63227. /**
  63228. * Instantiates a new bounding box renderer in a scene.
  63229. * @param scene the scene the renderer renders in
  63230. */
  63231. constructor(scene: Scene);
  63232. /**
  63233. * Registers the component in a given scene
  63234. */
  63235. register(): void;
  63236. private _evaluateSubMesh;
  63237. private _activeMesh;
  63238. private _prepareRessources;
  63239. private _createIndexBuffer;
  63240. /**
  63241. * Rebuilds the elements related to this component in case of
  63242. * context lost for instance.
  63243. */
  63244. rebuild(): void;
  63245. /**
  63246. * @hidden
  63247. */
  63248. reset(): void;
  63249. /**
  63250. * Render the bounding boxes of a specific rendering group
  63251. * @param renderingGroupId defines the rendering group to render
  63252. */
  63253. render(renderingGroupId: number): void;
  63254. /**
  63255. * In case of occlusion queries, we can render the occlusion bounding box through this method
  63256. * @param mesh Define the mesh to render the occlusion bounding box for
  63257. */
  63258. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  63259. /**
  63260. * Dispose and release the resources attached to this renderer.
  63261. */
  63262. dispose(): void;
  63263. }
  63264. }
  63265. declare module BABYLON {
  63266. /** @hidden */
  63267. export var depthPixelShader: {
  63268. name: string;
  63269. shader: string;
  63270. };
  63271. }
  63272. declare module BABYLON {
  63273. /**
  63274. * This represents a depth renderer in Babylon.
  63275. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63276. */
  63277. export class DepthRenderer {
  63278. private _scene;
  63279. private _depthMap;
  63280. private _effect;
  63281. private readonly _storeNonLinearDepth;
  63282. private readonly _clearColor;
  63283. /** Get if the depth renderer is using packed depth or not */
  63284. readonly isPacked: boolean;
  63285. private _cachedDefines;
  63286. private _camera;
  63287. /**
  63288. * Specifiess that the depth renderer will only be used within
  63289. * the camera it is created for.
  63290. * This can help forcing its rendering during the camera processing.
  63291. */
  63292. useOnlyInActiveCamera: boolean;
  63293. /** @hidden */
  63294. static _SceneComponentInitialization: (scene: Scene) => void;
  63295. /**
  63296. * Instantiates a depth renderer
  63297. * @param scene The scene the renderer belongs to
  63298. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63299. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63300. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63301. */
  63302. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63303. /**
  63304. * Creates the depth rendering effect and checks if the effect is ready.
  63305. * @param subMesh The submesh to be used to render the depth map of
  63306. * @param useInstances If multiple world instances should be used
  63307. * @returns if the depth renderer is ready to render the depth map
  63308. */
  63309. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63310. /**
  63311. * Gets the texture which the depth map will be written to.
  63312. * @returns The depth map texture
  63313. */
  63314. getDepthMap(): RenderTargetTexture;
  63315. /**
  63316. * Disposes of the depth renderer.
  63317. */
  63318. dispose(): void;
  63319. }
  63320. }
  63321. declare module BABYLON {
  63322. interface Scene {
  63323. /** @hidden (Backing field) */
  63324. _depthRenderer: {
  63325. [id: string]: DepthRenderer;
  63326. };
  63327. /**
  63328. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  63329. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  63330. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63331. * @returns the created depth renderer
  63332. */
  63333. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  63334. /**
  63335. * Disables a depth renderer for a given camera
  63336. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  63337. */
  63338. disableDepthRenderer(camera?: Nullable<Camera>): void;
  63339. }
  63340. /**
  63341. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  63342. * in several rendering techniques.
  63343. */
  63344. export class DepthRendererSceneComponent implements ISceneComponent {
  63345. /**
  63346. * The component name helpfull to identify the component in the list of scene components.
  63347. */
  63348. readonly name: string;
  63349. /**
  63350. * The scene the component belongs to.
  63351. */
  63352. scene: Scene;
  63353. /**
  63354. * Creates a new instance of the component for the given scene
  63355. * @param scene Defines the scene to register the component in
  63356. */
  63357. constructor(scene: Scene);
  63358. /**
  63359. * Registers the component in a given scene
  63360. */
  63361. register(): void;
  63362. /**
  63363. * Rebuilds the elements related to this component in case of
  63364. * context lost for instance.
  63365. */
  63366. rebuild(): void;
  63367. /**
  63368. * Disposes the component and the associated ressources
  63369. */
  63370. dispose(): void;
  63371. private _gatherRenderTargets;
  63372. private _gatherActiveCameraRenderTargets;
  63373. }
  63374. }
  63375. declare module BABYLON {
  63376. /** @hidden */
  63377. export var outlinePixelShader: {
  63378. name: string;
  63379. shader: string;
  63380. };
  63381. }
  63382. declare module BABYLON {
  63383. /** @hidden */
  63384. export var outlineVertexShader: {
  63385. name: string;
  63386. shader: string;
  63387. };
  63388. }
  63389. declare module BABYLON {
  63390. interface Scene {
  63391. /** @hidden */
  63392. _outlineRenderer: OutlineRenderer;
  63393. /**
  63394. * Gets the outline renderer associated with the scene
  63395. * @returns a OutlineRenderer
  63396. */
  63397. getOutlineRenderer(): OutlineRenderer;
  63398. }
  63399. interface AbstractMesh {
  63400. /** @hidden (Backing field) */
  63401. _renderOutline: boolean;
  63402. /**
  63403. * Gets or sets a boolean indicating if the outline must be rendered as well
  63404. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  63405. */
  63406. renderOutline: boolean;
  63407. /** @hidden (Backing field) */
  63408. _renderOverlay: boolean;
  63409. /**
  63410. * Gets or sets a boolean indicating if the overlay must be rendered as well
  63411. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  63412. */
  63413. renderOverlay: boolean;
  63414. }
  63415. /**
  63416. * This class is responsible to draw bothe outline/overlay of meshes.
  63417. * It should not be used directly but through the available method on mesh.
  63418. */
  63419. export class OutlineRenderer implements ISceneComponent {
  63420. /**
  63421. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  63422. */
  63423. private static _StencilReference;
  63424. /**
  63425. * The name of the component. Each component must have a unique name.
  63426. */
  63427. name: string;
  63428. /**
  63429. * The scene the component belongs to.
  63430. */
  63431. scene: Scene;
  63432. /**
  63433. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  63434. */
  63435. zOffset: number;
  63436. private _engine;
  63437. private _effect;
  63438. private _cachedDefines;
  63439. private _savedDepthWrite;
  63440. /**
  63441. * Instantiates a new outline renderer. (There could be only one per scene).
  63442. * @param scene Defines the scene it belongs to
  63443. */
  63444. constructor(scene: Scene);
  63445. /**
  63446. * Register the component to one instance of a scene.
  63447. */
  63448. register(): void;
  63449. /**
  63450. * Rebuilds the elements related to this component in case of
  63451. * context lost for instance.
  63452. */
  63453. rebuild(): void;
  63454. /**
  63455. * Disposes the component and the associated ressources.
  63456. */
  63457. dispose(): void;
  63458. /**
  63459. * Renders the outline in the canvas.
  63460. * @param subMesh Defines the sumesh to render
  63461. * @param batch Defines the batch of meshes in case of instances
  63462. * @param useOverlay Defines if the rendering is for the overlay or the outline
  63463. */
  63464. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  63465. /**
  63466. * Returns whether or not the outline renderer is ready for a given submesh.
  63467. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  63468. * @param subMesh Defines the submesh to check readyness for
  63469. * @param useInstances Defines wheter wee are trying to render instances or not
  63470. * @returns true if ready otherwise false
  63471. */
  63472. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63473. private _beforeRenderingMesh;
  63474. private _afterRenderingMesh;
  63475. }
  63476. }
  63477. declare module BABYLON {
  63478. /**
  63479. * Class used to manage multiple sprites of different sizes on the same spritesheet
  63480. * @see http://doc.babylonjs.com/babylon101/sprites
  63481. */
  63482. export class SpritePackedManager extends SpriteManager {
  63483. /** defines the packed manager's name */
  63484. name: string;
  63485. /**
  63486. * Creates a new sprite manager from a packed sprite sheet
  63487. * @param name defines the manager's name
  63488. * @param imgUrl defines the sprite sheet url
  63489. * @param capacity defines the maximum allowed number of sprites
  63490. * @param scene defines the hosting scene
  63491. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  63492. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  63493. * @param samplingMode defines the smapling mode to use with spritesheet
  63494. * @param fromPacked set to true; do not alter
  63495. */
  63496. constructor(
  63497. /** defines the packed manager's name */
  63498. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  63499. }
  63500. }
  63501. declare module BABYLON {
  63502. /**
  63503. * Defines the list of states available for a task inside a AssetsManager
  63504. */
  63505. export enum AssetTaskState {
  63506. /**
  63507. * Initialization
  63508. */
  63509. INIT = 0,
  63510. /**
  63511. * Running
  63512. */
  63513. RUNNING = 1,
  63514. /**
  63515. * Done
  63516. */
  63517. DONE = 2,
  63518. /**
  63519. * Error
  63520. */
  63521. ERROR = 3
  63522. }
  63523. /**
  63524. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  63525. */
  63526. export abstract class AbstractAssetTask {
  63527. /**
  63528. * Task name
  63529. */ name: string;
  63530. /**
  63531. * Callback called when the task is successful
  63532. */
  63533. onSuccess: (task: any) => void;
  63534. /**
  63535. * Callback called when the task is not successful
  63536. */
  63537. onError: (task: any, message?: string, exception?: any) => void;
  63538. /**
  63539. * Creates a new AssetsManager
  63540. * @param name defines the name of the task
  63541. */
  63542. constructor(
  63543. /**
  63544. * Task name
  63545. */ name: string);
  63546. private _isCompleted;
  63547. private _taskState;
  63548. private _errorObject;
  63549. /**
  63550. * Get if the task is completed
  63551. */
  63552. readonly isCompleted: boolean;
  63553. /**
  63554. * Gets the current state of the task
  63555. */
  63556. readonly taskState: AssetTaskState;
  63557. /**
  63558. * Gets the current error object (if task is in error)
  63559. */
  63560. readonly errorObject: {
  63561. message?: string;
  63562. exception?: any;
  63563. };
  63564. /**
  63565. * Internal only
  63566. * @hidden
  63567. */
  63568. _setErrorObject(message?: string, exception?: any): void;
  63569. /**
  63570. * Execute the current task
  63571. * @param scene defines the scene where you want your assets to be loaded
  63572. * @param onSuccess is a callback called when the task is successfully executed
  63573. * @param onError is a callback called if an error occurs
  63574. */
  63575. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63576. /**
  63577. * Execute the current task
  63578. * @param scene defines the scene where you want your assets to be loaded
  63579. * @param onSuccess is a callback called when the task is successfully executed
  63580. * @param onError is a callback called if an error occurs
  63581. */
  63582. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63583. /**
  63584. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  63585. * This can be used with failed tasks that have the reason for failure fixed.
  63586. */
  63587. reset(): void;
  63588. private onErrorCallback;
  63589. private onDoneCallback;
  63590. }
  63591. /**
  63592. * Define the interface used by progress events raised during assets loading
  63593. */
  63594. export interface IAssetsProgressEvent {
  63595. /**
  63596. * Defines the number of remaining tasks to process
  63597. */
  63598. remainingCount: number;
  63599. /**
  63600. * Defines the total number of tasks
  63601. */
  63602. totalCount: number;
  63603. /**
  63604. * Defines the task that was just processed
  63605. */
  63606. task: AbstractAssetTask;
  63607. }
  63608. /**
  63609. * Class used to share progress information about assets loading
  63610. */
  63611. export class AssetsProgressEvent implements IAssetsProgressEvent {
  63612. /**
  63613. * Defines the number of remaining tasks to process
  63614. */
  63615. remainingCount: number;
  63616. /**
  63617. * Defines the total number of tasks
  63618. */
  63619. totalCount: number;
  63620. /**
  63621. * Defines the task that was just processed
  63622. */
  63623. task: AbstractAssetTask;
  63624. /**
  63625. * Creates a AssetsProgressEvent
  63626. * @param remainingCount defines the number of remaining tasks to process
  63627. * @param totalCount defines the total number of tasks
  63628. * @param task defines the task that was just processed
  63629. */
  63630. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  63631. }
  63632. /**
  63633. * Define a task used by AssetsManager to load meshes
  63634. */
  63635. export class MeshAssetTask extends AbstractAssetTask {
  63636. /**
  63637. * Defines the name of the task
  63638. */
  63639. name: string;
  63640. /**
  63641. * Defines the list of mesh's names you want to load
  63642. */
  63643. meshesNames: any;
  63644. /**
  63645. * Defines the root url to use as a base to load your meshes and associated resources
  63646. */
  63647. rootUrl: string;
  63648. /**
  63649. * Defines the filename of the scene to load from
  63650. */
  63651. sceneFilename: string;
  63652. /**
  63653. * Gets the list of loaded meshes
  63654. */
  63655. loadedMeshes: Array<AbstractMesh>;
  63656. /**
  63657. * Gets the list of loaded particle systems
  63658. */
  63659. loadedParticleSystems: Array<IParticleSystem>;
  63660. /**
  63661. * Gets the list of loaded skeletons
  63662. */
  63663. loadedSkeletons: Array<Skeleton>;
  63664. /**
  63665. * Gets the list of loaded animation groups
  63666. */
  63667. loadedAnimationGroups: Array<AnimationGroup>;
  63668. /**
  63669. * Callback called when the task is successful
  63670. */
  63671. onSuccess: (task: MeshAssetTask) => void;
  63672. /**
  63673. * Callback called when the task is successful
  63674. */
  63675. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  63676. /**
  63677. * Creates a new MeshAssetTask
  63678. * @param name defines the name of the task
  63679. * @param meshesNames defines the list of mesh's names you want to load
  63680. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  63681. * @param sceneFilename defines the filename of the scene to load from
  63682. */
  63683. constructor(
  63684. /**
  63685. * Defines the name of the task
  63686. */
  63687. name: string,
  63688. /**
  63689. * Defines the list of mesh's names you want to load
  63690. */
  63691. meshesNames: any,
  63692. /**
  63693. * Defines the root url to use as a base to load your meshes and associated resources
  63694. */
  63695. rootUrl: string,
  63696. /**
  63697. * Defines the filename of the scene to load from
  63698. */
  63699. sceneFilename: string);
  63700. /**
  63701. * Execute the current task
  63702. * @param scene defines the scene where you want your assets to be loaded
  63703. * @param onSuccess is a callback called when the task is successfully executed
  63704. * @param onError is a callback called if an error occurs
  63705. */
  63706. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63707. }
  63708. /**
  63709. * Define a task used by AssetsManager to load text content
  63710. */
  63711. export class TextFileAssetTask extends AbstractAssetTask {
  63712. /**
  63713. * Defines the name of the task
  63714. */
  63715. name: string;
  63716. /**
  63717. * Defines the location of the file to load
  63718. */
  63719. url: string;
  63720. /**
  63721. * Gets the loaded text string
  63722. */
  63723. text: string;
  63724. /**
  63725. * Callback called when the task is successful
  63726. */
  63727. onSuccess: (task: TextFileAssetTask) => void;
  63728. /**
  63729. * Callback called when the task is successful
  63730. */
  63731. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  63732. /**
  63733. * Creates a new TextFileAssetTask object
  63734. * @param name defines the name of the task
  63735. * @param url defines the location of the file to load
  63736. */
  63737. constructor(
  63738. /**
  63739. * Defines the name of the task
  63740. */
  63741. name: string,
  63742. /**
  63743. * Defines the location of the file to load
  63744. */
  63745. url: string);
  63746. /**
  63747. * Execute the current task
  63748. * @param scene defines the scene where you want your assets to be loaded
  63749. * @param onSuccess is a callback called when the task is successfully executed
  63750. * @param onError is a callback called if an error occurs
  63751. */
  63752. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63753. }
  63754. /**
  63755. * Define a task used by AssetsManager to load binary data
  63756. */
  63757. export class BinaryFileAssetTask extends AbstractAssetTask {
  63758. /**
  63759. * Defines the name of the task
  63760. */
  63761. name: string;
  63762. /**
  63763. * Defines the location of the file to load
  63764. */
  63765. url: string;
  63766. /**
  63767. * Gets the lodaded data (as an array buffer)
  63768. */
  63769. data: ArrayBuffer;
  63770. /**
  63771. * Callback called when the task is successful
  63772. */
  63773. onSuccess: (task: BinaryFileAssetTask) => void;
  63774. /**
  63775. * Callback called when the task is successful
  63776. */
  63777. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  63778. /**
  63779. * Creates a new BinaryFileAssetTask object
  63780. * @param name defines the name of the new task
  63781. * @param url defines the location of the file to load
  63782. */
  63783. constructor(
  63784. /**
  63785. * Defines the name of the task
  63786. */
  63787. name: string,
  63788. /**
  63789. * Defines the location of the file to load
  63790. */
  63791. url: string);
  63792. /**
  63793. * Execute the current task
  63794. * @param scene defines the scene where you want your assets to be loaded
  63795. * @param onSuccess is a callback called when the task is successfully executed
  63796. * @param onError is a callback called if an error occurs
  63797. */
  63798. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63799. }
  63800. /**
  63801. * Define a task used by AssetsManager to load images
  63802. */
  63803. export class ImageAssetTask extends AbstractAssetTask {
  63804. /**
  63805. * Defines the name of the task
  63806. */
  63807. name: string;
  63808. /**
  63809. * Defines the location of the image to load
  63810. */
  63811. url: string;
  63812. /**
  63813. * Gets the loaded images
  63814. */
  63815. image: HTMLImageElement;
  63816. /**
  63817. * Callback called when the task is successful
  63818. */
  63819. onSuccess: (task: ImageAssetTask) => void;
  63820. /**
  63821. * Callback called when the task is successful
  63822. */
  63823. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  63824. /**
  63825. * Creates a new ImageAssetTask
  63826. * @param name defines the name of the task
  63827. * @param url defines the location of the image to load
  63828. */
  63829. constructor(
  63830. /**
  63831. * Defines the name of the task
  63832. */
  63833. name: string,
  63834. /**
  63835. * Defines the location of the image to load
  63836. */
  63837. url: string);
  63838. /**
  63839. * Execute the current task
  63840. * @param scene defines the scene where you want your assets to be loaded
  63841. * @param onSuccess is a callback called when the task is successfully executed
  63842. * @param onError is a callback called if an error occurs
  63843. */
  63844. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63845. }
  63846. /**
  63847. * Defines the interface used by texture loading tasks
  63848. */
  63849. export interface ITextureAssetTask<TEX extends BaseTexture> {
  63850. /**
  63851. * Gets the loaded texture
  63852. */
  63853. texture: TEX;
  63854. }
  63855. /**
  63856. * Define a task used by AssetsManager to load 2D textures
  63857. */
  63858. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  63859. /**
  63860. * Defines the name of the task
  63861. */
  63862. name: string;
  63863. /**
  63864. * Defines the location of the file to load
  63865. */
  63866. url: string;
  63867. /**
  63868. * Defines if mipmap should not be generated (default is false)
  63869. */
  63870. noMipmap?: boolean | undefined;
  63871. /**
  63872. * Defines if texture must be inverted on Y axis (default is false)
  63873. */
  63874. invertY?: boolean | undefined;
  63875. /**
  63876. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63877. */
  63878. samplingMode: number;
  63879. /**
  63880. * Gets the loaded texture
  63881. */
  63882. texture: Texture;
  63883. /**
  63884. * Callback called when the task is successful
  63885. */
  63886. onSuccess: (task: TextureAssetTask) => void;
  63887. /**
  63888. * Callback called when the task is successful
  63889. */
  63890. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  63891. /**
  63892. * Creates a new TextureAssetTask object
  63893. * @param name defines the name of the task
  63894. * @param url defines the location of the file to load
  63895. * @param noMipmap defines if mipmap should not be generated (default is false)
  63896. * @param invertY defines if texture must be inverted on Y axis (default is false)
  63897. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63898. */
  63899. constructor(
  63900. /**
  63901. * Defines the name of the task
  63902. */
  63903. name: string,
  63904. /**
  63905. * Defines the location of the file to load
  63906. */
  63907. url: string,
  63908. /**
  63909. * Defines if mipmap should not be generated (default is false)
  63910. */
  63911. noMipmap?: boolean | undefined,
  63912. /**
  63913. * Defines if texture must be inverted on Y axis (default is false)
  63914. */
  63915. invertY?: boolean | undefined,
  63916. /**
  63917. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63918. */
  63919. samplingMode?: number);
  63920. /**
  63921. * Execute the current task
  63922. * @param scene defines the scene where you want your assets to be loaded
  63923. * @param onSuccess is a callback called when the task is successfully executed
  63924. * @param onError is a callback called if an error occurs
  63925. */
  63926. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63927. }
  63928. /**
  63929. * Define a task used by AssetsManager to load cube textures
  63930. */
  63931. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  63932. /**
  63933. * Defines the name of the task
  63934. */
  63935. name: string;
  63936. /**
  63937. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63938. */
  63939. url: string;
  63940. /**
  63941. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63942. */
  63943. extensions?: string[] | undefined;
  63944. /**
  63945. * Defines if mipmaps should not be generated (default is false)
  63946. */
  63947. noMipmap?: boolean | undefined;
  63948. /**
  63949. * Defines the explicit list of files (undefined by default)
  63950. */
  63951. files?: string[] | undefined;
  63952. /**
  63953. * Gets the loaded texture
  63954. */
  63955. texture: CubeTexture;
  63956. /**
  63957. * Callback called when the task is successful
  63958. */
  63959. onSuccess: (task: CubeTextureAssetTask) => void;
  63960. /**
  63961. * Callback called when the task is successful
  63962. */
  63963. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  63964. /**
  63965. * Creates a new CubeTextureAssetTask
  63966. * @param name defines the name of the task
  63967. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63968. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63969. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63970. * @param files defines the explicit list of files (undefined by default)
  63971. */
  63972. constructor(
  63973. /**
  63974. * Defines the name of the task
  63975. */
  63976. name: string,
  63977. /**
  63978. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63979. */
  63980. url: string,
  63981. /**
  63982. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63983. */
  63984. extensions?: string[] | undefined,
  63985. /**
  63986. * Defines if mipmaps should not be generated (default is false)
  63987. */
  63988. noMipmap?: boolean | undefined,
  63989. /**
  63990. * Defines the explicit list of files (undefined by default)
  63991. */
  63992. files?: string[] | undefined);
  63993. /**
  63994. * Execute the current task
  63995. * @param scene defines the scene where you want your assets to be loaded
  63996. * @param onSuccess is a callback called when the task is successfully executed
  63997. * @param onError is a callback called if an error occurs
  63998. */
  63999. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64000. }
  64001. /**
  64002. * Define a task used by AssetsManager to load HDR cube textures
  64003. */
  64004. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  64005. /**
  64006. * Defines the name of the task
  64007. */
  64008. name: string;
  64009. /**
  64010. * Defines the location of the file to load
  64011. */
  64012. url: string;
  64013. /**
  64014. * Defines the desired size (the more it increases the longer the generation will be)
  64015. */
  64016. size: number;
  64017. /**
  64018. * Defines if mipmaps should not be generated (default is false)
  64019. */
  64020. noMipmap: boolean;
  64021. /**
  64022. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64023. */
  64024. generateHarmonics: boolean;
  64025. /**
  64026. * 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)
  64027. */
  64028. gammaSpace: boolean;
  64029. /**
  64030. * Internal Use Only
  64031. */
  64032. reserved: boolean;
  64033. /**
  64034. * Gets the loaded texture
  64035. */
  64036. texture: HDRCubeTexture;
  64037. /**
  64038. * Callback called when the task is successful
  64039. */
  64040. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  64041. /**
  64042. * Callback called when the task is successful
  64043. */
  64044. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  64045. /**
  64046. * Creates a new HDRCubeTextureAssetTask object
  64047. * @param name defines the name of the task
  64048. * @param url defines the location of the file to load
  64049. * @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.
  64050. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64051. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64052. * @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)
  64053. * @param reserved Internal use only
  64054. */
  64055. constructor(
  64056. /**
  64057. * Defines the name of the task
  64058. */
  64059. name: string,
  64060. /**
  64061. * Defines the location of the file to load
  64062. */
  64063. url: string,
  64064. /**
  64065. * Defines the desired size (the more it increases the longer the generation will be)
  64066. */
  64067. size: number,
  64068. /**
  64069. * Defines if mipmaps should not be generated (default is false)
  64070. */
  64071. noMipmap?: boolean,
  64072. /**
  64073. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64074. */
  64075. generateHarmonics?: boolean,
  64076. /**
  64077. * 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)
  64078. */
  64079. gammaSpace?: boolean,
  64080. /**
  64081. * Internal Use Only
  64082. */
  64083. reserved?: boolean);
  64084. /**
  64085. * Execute the current task
  64086. * @param scene defines the scene where you want your assets to be loaded
  64087. * @param onSuccess is a callback called when the task is successfully executed
  64088. * @param onError is a callback called if an error occurs
  64089. */
  64090. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64091. }
  64092. /**
  64093. * Define a task used by AssetsManager to load Equirectangular cube textures
  64094. */
  64095. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  64096. /**
  64097. * Defines the name of the task
  64098. */
  64099. name: string;
  64100. /**
  64101. * Defines the location of the file to load
  64102. */
  64103. url: string;
  64104. /**
  64105. * Defines the desired size (the more it increases the longer the generation will be)
  64106. */
  64107. size: number;
  64108. /**
  64109. * Defines if mipmaps should not be generated (default is false)
  64110. */
  64111. noMipmap: boolean;
  64112. /**
  64113. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64114. * but the standard material would require them in Gamma space) (default is true)
  64115. */
  64116. gammaSpace: boolean;
  64117. /**
  64118. * Gets the loaded texture
  64119. */
  64120. texture: EquiRectangularCubeTexture;
  64121. /**
  64122. * Callback called when the task is successful
  64123. */
  64124. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  64125. /**
  64126. * Callback called when the task is successful
  64127. */
  64128. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  64129. /**
  64130. * Creates a new EquiRectangularCubeTextureAssetTask object
  64131. * @param name defines the name of the task
  64132. * @param url defines the location of the file to load
  64133. * @param size defines the desired size (the more it increases the longer the generation will be)
  64134. * If the size is omitted this implies you are using a preprocessed cubemap.
  64135. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64136. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  64137. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  64138. * (default is true)
  64139. */
  64140. constructor(
  64141. /**
  64142. * Defines the name of the task
  64143. */
  64144. name: string,
  64145. /**
  64146. * Defines the location of the file to load
  64147. */
  64148. url: string,
  64149. /**
  64150. * Defines the desired size (the more it increases the longer the generation will be)
  64151. */
  64152. size: number,
  64153. /**
  64154. * Defines if mipmaps should not be generated (default is false)
  64155. */
  64156. noMipmap?: boolean,
  64157. /**
  64158. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64159. * but the standard material would require them in Gamma space) (default is true)
  64160. */
  64161. gammaSpace?: boolean);
  64162. /**
  64163. * Execute the current task
  64164. * @param scene defines the scene where you want your assets to be loaded
  64165. * @param onSuccess is a callback called when the task is successfully executed
  64166. * @param onError is a callback called if an error occurs
  64167. */
  64168. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64169. }
  64170. /**
  64171. * This class can be used to easily import assets into a scene
  64172. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  64173. */
  64174. export class AssetsManager {
  64175. private _scene;
  64176. private _isLoading;
  64177. protected _tasks: AbstractAssetTask[];
  64178. protected _waitingTasksCount: number;
  64179. protected _totalTasksCount: number;
  64180. /**
  64181. * Callback called when all tasks are processed
  64182. */
  64183. onFinish: (tasks: AbstractAssetTask[]) => void;
  64184. /**
  64185. * Callback called when a task is successful
  64186. */
  64187. onTaskSuccess: (task: AbstractAssetTask) => void;
  64188. /**
  64189. * Callback called when a task had an error
  64190. */
  64191. onTaskError: (task: AbstractAssetTask) => void;
  64192. /**
  64193. * Callback called when a task is done (whatever the result is)
  64194. */
  64195. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  64196. /**
  64197. * Observable called when all tasks are processed
  64198. */
  64199. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  64200. /**
  64201. * Observable called when a task had an error
  64202. */
  64203. onTaskErrorObservable: Observable<AbstractAssetTask>;
  64204. /**
  64205. * Observable called when all tasks were executed
  64206. */
  64207. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  64208. /**
  64209. * Observable called when a task is done (whatever the result is)
  64210. */
  64211. onProgressObservable: Observable<IAssetsProgressEvent>;
  64212. /**
  64213. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  64214. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  64215. */
  64216. useDefaultLoadingScreen: boolean;
  64217. /**
  64218. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  64219. * when all assets have been downloaded.
  64220. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  64221. */
  64222. autoHideLoadingUI: boolean;
  64223. /**
  64224. * Creates a new AssetsManager
  64225. * @param scene defines the scene to work on
  64226. */
  64227. constructor(scene: Scene);
  64228. /**
  64229. * Add a MeshAssetTask to the list of active tasks
  64230. * @param taskName defines the name of the new task
  64231. * @param meshesNames defines the name of meshes to load
  64232. * @param rootUrl defines the root url to use to locate files
  64233. * @param sceneFilename defines the filename of the scene file
  64234. * @returns a new MeshAssetTask object
  64235. */
  64236. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  64237. /**
  64238. * Add a TextFileAssetTask to the list of active tasks
  64239. * @param taskName defines the name of the new task
  64240. * @param url defines the url of the file to load
  64241. * @returns a new TextFileAssetTask object
  64242. */
  64243. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  64244. /**
  64245. * Add a BinaryFileAssetTask to the list of active tasks
  64246. * @param taskName defines the name of the new task
  64247. * @param url defines the url of the file to load
  64248. * @returns a new BinaryFileAssetTask object
  64249. */
  64250. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  64251. /**
  64252. * Add a ImageAssetTask to the list of active tasks
  64253. * @param taskName defines the name of the new task
  64254. * @param url defines the url of the file to load
  64255. * @returns a new ImageAssetTask object
  64256. */
  64257. addImageTask(taskName: string, url: string): ImageAssetTask;
  64258. /**
  64259. * Add a TextureAssetTask to the list of active tasks
  64260. * @param taskName defines the name of the new task
  64261. * @param url defines the url of the file to load
  64262. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64263. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  64264. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64265. * @returns a new TextureAssetTask object
  64266. */
  64267. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  64268. /**
  64269. * Add a CubeTextureAssetTask to the list of active tasks
  64270. * @param taskName defines the name of the new task
  64271. * @param url defines the url of the file to load
  64272. * @param extensions defines the extension to use to load the cube map (can be null)
  64273. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64274. * @param files defines the list of files to load (can be null)
  64275. * @returns a new CubeTextureAssetTask object
  64276. */
  64277. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  64278. /**
  64279. *
  64280. * Add a HDRCubeTextureAssetTask to the list of active tasks
  64281. * @param taskName defines the name of the new task
  64282. * @param url defines the url of the file to load
  64283. * @param size defines the size you want for the cubemap (can be null)
  64284. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64285. * @param generateHarmonics defines if you want to automatically generate (true by default)
  64286. * @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)
  64287. * @param reserved Internal use only
  64288. * @returns a new HDRCubeTextureAssetTask object
  64289. */
  64290. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  64291. /**
  64292. *
  64293. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  64294. * @param taskName defines the name of the new task
  64295. * @param url defines the url of the file to load
  64296. * @param size defines the size you want for the cubemap (can be null)
  64297. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64298. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64299. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64300. * @returns a new EquiRectangularCubeTextureAssetTask object
  64301. */
  64302. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  64303. /**
  64304. * Remove a task from the assets manager.
  64305. * @param task the task to remove
  64306. */
  64307. removeTask(task: AbstractAssetTask): void;
  64308. private _decreaseWaitingTasksCount;
  64309. private _runTask;
  64310. /**
  64311. * Reset the AssetsManager and remove all tasks
  64312. * @return the current instance of the AssetsManager
  64313. */
  64314. reset(): AssetsManager;
  64315. /**
  64316. * Start the loading process
  64317. * @return the current instance of the AssetsManager
  64318. */
  64319. load(): AssetsManager;
  64320. /**
  64321. * Start the loading process as an async operation
  64322. * @return a promise returning the list of failed tasks
  64323. */
  64324. loadAsync(): Promise<void>;
  64325. }
  64326. }
  64327. declare module BABYLON {
  64328. /**
  64329. * Wrapper class for promise with external resolve and reject.
  64330. */
  64331. export class Deferred<T> {
  64332. /**
  64333. * The promise associated with this deferred object.
  64334. */
  64335. readonly promise: Promise<T>;
  64336. private _resolve;
  64337. private _reject;
  64338. /**
  64339. * The resolve method of the promise associated with this deferred object.
  64340. */
  64341. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  64342. /**
  64343. * The reject method of the promise associated with this deferred object.
  64344. */
  64345. readonly reject: (reason?: any) => void;
  64346. /**
  64347. * Constructor for this deferred object.
  64348. */
  64349. constructor();
  64350. }
  64351. }
  64352. declare module BABYLON {
  64353. /**
  64354. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  64355. */
  64356. export class MeshExploder {
  64357. private _centerMesh;
  64358. private _meshes;
  64359. private _meshesOrigins;
  64360. private _toCenterVectors;
  64361. private _scaledDirection;
  64362. private _newPosition;
  64363. private _centerPosition;
  64364. /**
  64365. * Explodes meshes from a center mesh.
  64366. * @param meshes The meshes to explode.
  64367. * @param centerMesh The mesh to be center of explosion.
  64368. */
  64369. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  64370. private _setCenterMesh;
  64371. /**
  64372. * Get class name
  64373. * @returns "MeshExploder"
  64374. */
  64375. getClassName(): string;
  64376. /**
  64377. * "Exploded meshes"
  64378. * @returns Array of meshes with the centerMesh at index 0.
  64379. */
  64380. getMeshes(): Array<Mesh>;
  64381. /**
  64382. * Explodes meshes giving a specific direction
  64383. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  64384. */
  64385. explode(direction?: number): void;
  64386. }
  64387. }
  64388. declare module BABYLON {
  64389. /**
  64390. * Class used to help managing file picking and drag'n'drop
  64391. */
  64392. export class FilesInput {
  64393. /**
  64394. * List of files ready to be loaded
  64395. */
  64396. static readonly FilesToLoad: {
  64397. [key: string]: File;
  64398. };
  64399. /**
  64400. * Callback called when a file is processed
  64401. */
  64402. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  64403. private _engine;
  64404. private _currentScene;
  64405. private _sceneLoadedCallback;
  64406. private _progressCallback;
  64407. private _additionalRenderLoopLogicCallback;
  64408. private _textureLoadingCallback;
  64409. private _startingProcessingFilesCallback;
  64410. private _onReloadCallback;
  64411. private _errorCallback;
  64412. private _elementToMonitor;
  64413. private _sceneFileToLoad;
  64414. private _filesToLoad;
  64415. /**
  64416. * Creates a new FilesInput
  64417. * @param engine defines the rendering engine
  64418. * @param scene defines the hosting scene
  64419. * @param sceneLoadedCallback callback called when scene is loaded
  64420. * @param progressCallback callback called to track progress
  64421. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  64422. * @param textureLoadingCallback callback called when a texture is loading
  64423. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  64424. * @param onReloadCallback callback called when a reload is requested
  64425. * @param errorCallback callback call if an error occurs
  64426. */
  64427. 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);
  64428. private _dragEnterHandler;
  64429. private _dragOverHandler;
  64430. private _dropHandler;
  64431. /**
  64432. * Calls this function to listen to drag'n'drop events on a specific DOM element
  64433. * @param elementToMonitor defines the DOM element to track
  64434. */
  64435. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  64436. /**
  64437. * Release all associated resources
  64438. */
  64439. dispose(): void;
  64440. private renderFunction;
  64441. private drag;
  64442. private drop;
  64443. private _traverseFolder;
  64444. private _processFiles;
  64445. /**
  64446. * Load files from a drop event
  64447. * @param event defines the drop event to use as source
  64448. */
  64449. loadFiles(event: any): void;
  64450. private _processReload;
  64451. /**
  64452. * Reload the current scene from the loaded files
  64453. */
  64454. reload(): void;
  64455. }
  64456. }
  64457. declare module BABYLON {
  64458. /**
  64459. * Defines the root class used to create scene optimization to use with SceneOptimizer
  64460. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64461. */
  64462. export class SceneOptimization {
  64463. /**
  64464. * Defines the priority of this optimization (0 by default which means first in the list)
  64465. */
  64466. priority: number;
  64467. /**
  64468. * Gets a string describing the action executed by the current optimization
  64469. * @returns description string
  64470. */
  64471. getDescription(): string;
  64472. /**
  64473. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64474. * @param scene defines the current scene where to apply this optimization
  64475. * @param optimizer defines the current optimizer
  64476. * @returns true if everything that can be done was applied
  64477. */
  64478. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64479. /**
  64480. * Creates the SceneOptimization object
  64481. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64482. * @param desc defines the description associated with the optimization
  64483. */
  64484. constructor(
  64485. /**
  64486. * Defines the priority of this optimization (0 by default which means first in the list)
  64487. */
  64488. priority?: number);
  64489. }
  64490. /**
  64491. * Defines an optimization used to reduce the size of render target textures
  64492. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64493. */
  64494. export class TextureOptimization extends SceneOptimization {
  64495. /**
  64496. * Defines the priority of this optimization (0 by default which means first in the list)
  64497. */
  64498. priority: number;
  64499. /**
  64500. * 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
  64501. */
  64502. maximumSize: number;
  64503. /**
  64504. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64505. */
  64506. step: number;
  64507. /**
  64508. * Gets a string describing the action executed by the current optimization
  64509. * @returns description string
  64510. */
  64511. getDescription(): string;
  64512. /**
  64513. * Creates the TextureOptimization object
  64514. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64515. * @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
  64516. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64517. */
  64518. constructor(
  64519. /**
  64520. * Defines the priority of this optimization (0 by default which means first in the list)
  64521. */
  64522. priority?: number,
  64523. /**
  64524. * 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
  64525. */
  64526. maximumSize?: number,
  64527. /**
  64528. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64529. */
  64530. step?: number);
  64531. /**
  64532. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64533. * @param scene defines the current scene where to apply this optimization
  64534. * @param optimizer defines the current optimizer
  64535. * @returns true if everything that can be done was applied
  64536. */
  64537. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64538. }
  64539. /**
  64540. * Defines an optimization used to increase or decrease the rendering resolution
  64541. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64542. */
  64543. export class HardwareScalingOptimization extends SceneOptimization {
  64544. /**
  64545. * Defines the priority of this optimization (0 by default which means first in the list)
  64546. */
  64547. priority: number;
  64548. /**
  64549. * Defines the maximum scale to use (2 by default)
  64550. */
  64551. maximumScale: number;
  64552. /**
  64553. * Defines the step to use between two passes (0.5 by default)
  64554. */
  64555. step: number;
  64556. private _currentScale;
  64557. private _directionOffset;
  64558. /**
  64559. * Gets a string describing the action executed by the current optimization
  64560. * @return description string
  64561. */
  64562. getDescription(): string;
  64563. /**
  64564. * Creates the HardwareScalingOptimization object
  64565. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64566. * @param maximumScale defines the maximum scale to use (2 by default)
  64567. * @param step defines the step to use between two passes (0.5 by default)
  64568. */
  64569. constructor(
  64570. /**
  64571. * Defines the priority of this optimization (0 by default which means first in the list)
  64572. */
  64573. priority?: number,
  64574. /**
  64575. * Defines the maximum scale to use (2 by default)
  64576. */
  64577. maximumScale?: number,
  64578. /**
  64579. * Defines the step to use between two passes (0.5 by default)
  64580. */
  64581. step?: number);
  64582. /**
  64583. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64584. * @param scene defines the current scene where to apply this optimization
  64585. * @param optimizer defines the current optimizer
  64586. * @returns true if everything that can be done was applied
  64587. */
  64588. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64589. }
  64590. /**
  64591. * Defines an optimization used to remove shadows
  64592. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64593. */
  64594. export class ShadowsOptimization extends SceneOptimization {
  64595. /**
  64596. * Gets a string describing the action executed by the current optimization
  64597. * @return description string
  64598. */
  64599. getDescription(): string;
  64600. /**
  64601. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64602. * @param scene defines the current scene where to apply this optimization
  64603. * @param optimizer defines the current optimizer
  64604. * @returns true if everything that can be done was applied
  64605. */
  64606. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64607. }
  64608. /**
  64609. * Defines an optimization used to turn post-processes off
  64610. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64611. */
  64612. export class PostProcessesOptimization extends SceneOptimization {
  64613. /**
  64614. * Gets a string describing the action executed by the current optimization
  64615. * @return description string
  64616. */
  64617. getDescription(): string;
  64618. /**
  64619. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64620. * @param scene defines the current scene where to apply this optimization
  64621. * @param optimizer defines the current optimizer
  64622. * @returns true if everything that can be done was applied
  64623. */
  64624. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64625. }
  64626. /**
  64627. * Defines an optimization used to turn lens flares off
  64628. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64629. */
  64630. export class LensFlaresOptimization extends SceneOptimization {
  64631. /**
  64632. * Gets a string describing the action executed by the current optimization
  64633. * @return description string
  64634. */
  64635. getDescription(): string;
  64636. /**
  64637. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64638. * @param scene defines the current scene where to apply this optimization
  64639. * @param optimizer defines the current optimizer
  64640. * @returns true if everything that can be done was applied
  64641. */
  64642. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64643. }
  64644. /**
  64645. * Defines an optimization based on user defined callback.
  64646. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64647. */
  64648. export class CustomOptimization extends SceneOptimization {
  64649. /**
  64650. * Callback called to apply the custom optimization.
  64651. */
  64652. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  64653. /**
  64654. * Callback called to get custom description
  64655. */
  64656. onGetDescription: () => string;
  64657. /**
  64658. * Gets a string describing the action executed by the current optimization
  64659. * @returns description string
  64660. */
  64661. getDescription(): string;
  64662. /**
  64663. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64664. * @param scene defines the current scene where to apply this optimization
  64665. * @param optimizer defines the current optimizer
  64666. * @returns true if everything that can be done was applied
  64667. */
  64668. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64669. }
  64670. /**
  64671. * Defines an optimization used to turn particles off
  64672. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64673. */
  64674. export class ParticlesOptimization extends SceneOptimization {
  64675. /**
  64676. * Gets a string describing the action executed by the current optimization
  64677. * @return description string
  64678. */
  64679. getDescription(): string;
  64680. /**
  64681. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64682. * @param scene defines the current scene where to apply this optimization
  64683. * @param optimizer defines the current optimizer
  64684. * @returns true if everything that can be done was applied
  64685. */
  64686. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64687. }
  64688. /**
  64689. * Defines an optimization used to turn render targets off
  64690. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64691. */
  64692. export class RenderTargetsOptimization extends SceneOptimization {
  64693. /**
  64694. * Gets a string describing the action executed by the current optimization
  64695. * @return description string
  64696. */
  64697. getDescription(): string;
  64698. /**
  64699. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64700. * @param scene defines the current scene where to apply this optimization
  64701. * @param optimizer defines the current optimizer
  64702. * @returns true if everything that can be done was applied
  64703. */
  64704. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64705. }
  64706. /**
  64707. * Defines an optimization used to merge meshes with compatible materials
  64708. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64709. */
  64710. export class MergeMeshesOptimization extends SceneOptimization {
  64711. private static _UpdateSelectionTree;
  64712. /**
  64713. * Gets or sets a boolean which defines if optimization octree has to be updated
  64714. */
  64715. /**
  64716. * Gets or sets a boolean which defines if optimization octree has to be updated
  64717. */
  64718. static UpdateSelectionTree: boolean;
  64719. /**
  64720. * Gets a string describing the action executed by the current optimization
  64721. * @return description string
  64722. */
  64723. getDescription(): string;
  64724. private _canBeMerged;
  64725. /**
  64726. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64727. * @param scene defines the current scene where to apply this optimization
  64728. * @param optimizer defines the current optimizer
  64729. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  64730. * @returns true if everything that can be done was applied
  64731. */
  64732. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  64733. }
  64734. /**
  64735. * Defines a list of options used by SceneOptimizer
  64736. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64737. */
  64738. export class SceneOptimizerOptions {
  64739. /**
  64740. * Defines the target frame rate to reach (60 by default)
  64741. */
  64742. targetFrameRate: number;
  64743. /**
  64744. * Defines the interval between two checkes (2000ms by default)
  64745. */
  64746. trackerDuration: number;
  64747. /**
  64748. * Gets the list of optimizations to apply
  64749. */
  64750. optimizations: SceneOptimization[];
  64751. /**
  64752. * Creates a new list of options used by SceneOptimizer
  64753. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  64754. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  64755. */
  64756. constructor(
  64757. /**
  64758. * Defines the target frame rate to reach (60 by default)
  64759. */
  64760. targetFrameRate?: number,
  64761. /**
  64762. * Defines the interval between two checkes (2000ms by default)
  64763. */
  64764. trackerDuration?: number);
  64765. /**
  64766. * Add a new optimization
  64767. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  64768. * @returns the current SceneOptimizerOptions
  64769. */
  64770. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  64771. /**
  64772. * Add a new custom optimization
  64773. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  64774. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  64775. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64776. * @returns the current SceneOptimizerOptions
  64777. */
  64778. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  64779. /**
  64780. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  64781. * @param targetFrameRate defines the target frame rate (60 by default)
  64782. * @returns a SceneOptimizerOptions object
  64783. */
  64784. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64785. /**
  64786. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  64787. * @param targetFrameRate defines the target frame rate (60 by default)
  64788. * @returns a SceneOptimizerOptions object
  64789. */
  64790. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64791. /**
  64792. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  64793. * @param targetFrameRate defines the target frame rate (60 by default)
  64794. * @returns a SceneOptimizerOptions object
  64795. */
  64796. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64797. }
  64798. /**
  64799. * Class used to run optimizations in order to reach a target frame rate
  64800. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64801. */
  64802. export class SceneOptimizer implements IDisposable {
  64803. private _isRunning;
  64804. private _options;
  64805. private _scene;
  64806. private _currentPriorityLevel;
  64807. private _targetFrameRate;
  64808. private _trackerDuration;
  64809. private _currentFrameRate;
  64810. private _sceneDisposeObserver;
  64811. private _improvementMode;
  64812. /**
  64813. * Defines an observable called when the optimizer reaches the target frame rate
  64814. */
  64815. onSuccessObservable: Observable<SceneOptimizer>;
  64816. /**
  64817. * Defines an observable called when the optimizer enables an optimization
  64818. */
  64819. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  64820. /**
  64821. * Defines an observable called when the optimizer is not able to reach the target frame rate
  64822. */
  64823. onFailureObservable: Observable<SceneOptimizer>;
  64824. /**
  64825. * Gets a boolean indicating if the optimizer is in improvement mode
  64826. */
  64827. readonly isInImprovementMode: boolean;
  64828. /**
  64829. * Gets the current priority level (0 at start)
  64830. */
  64831. readonly currentPriorityLevel: number;
  64832. /**
  64833. * Gets the current frame rate checked by the SceneOptimizer
  64834. */
  64835. readonly currentFrameRate: number;
  64836. /**
  64837. * Gets or sets the current target frame rate (60 by default)
  64838. */
  64839. /**
  64840. * Gets or sets the current target frame rate (60 by default)
  64841. */
  64842. targetFrameRate: number;
  64843. /**
  64844. * Gets or sets the current interval between two checks (every 2000ms by default)
  64845. */
  64846. /**
  64847. * Gets or sets the current interval between two checks (every 2000ms by default)
  64848. */
  64849. trackerDuration: number;
  64850. /**
  64851. * Gets the list of active optimizations
  64852. */
  64853. readonly optimizations: SceneOptimization[];
  64854. /**
  64855. * Creates a new SceneOptimizer
  64856. * @param scene defines the scene to work on
  64857. * @param options defines the options to use with the SceneOptimizer
  64858. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  64859. * @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)
  64860. */
  64861. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  64862. /**
  64863. * Stops the current optimizer
  64864. */
  64865. stop(): void;
  64866. /**
  64867. * Reset the optimizer to initial step (current priority level = 0)
  64868. */
  64869. reset(): void;
  64870. /**
  64871. * Start the optimizer. By default it will try to reach a specific framerate
  64872. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  64873. */
  64874. start(): void;
  64875. private _checkCurrentState;
  64876. /**
  64877. * Release all resources
  64878. */
  64879. dispose(): void;
  64880. /**
  64881. * Helper function to create a SceneOptimizer with one single line of code
  64882. * @param scene defines the scene to work on
  64883. * @param options defines the options to use with the SceneOptimizer
  64884. * @param onSuccess defines a callback to call on success
  64885. * @param onFailure defines a callback to call on failure
  64886. * @returns the new SceneOptimizer object
  64887. */
  64888. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  64889. }
  64890. }
  64891. declare module BABYLON {
  64892. /**
  64893. * Class used to serialize a scene into a string
  64894. */
  64895. export class SceneSerializer {
  64896. /**
  64897. * Clear cache used by a previous serialization
  64898. */
  64899. static ClearCache(): void;
  64900. /**
  64901. * Serialize a scene into a JSON compatible object
  64902. * @param scene defines the scene to serialize
  64903. * @returns a JSON compatible object
  64904. */
  64905. static Serialize(scene: Scene): any;
  64906. /**
  64907. * Serialize a mesh into a JSON compatible object
  64908. * @param toSerialize defines the mesh to serialize
  64909. * @param withParents defines if parents must be serialized as well
  64910. * @param withChildren defines if children must be serialized as well
  64911. * @returns a JSON compatible object
  64912. */
  64913. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  64914. }
  64915. }
  64916. declare module BABYLON {
  64917. /**
  64918. * Class used to host texture specific utilities
  64919. */
  64920. export class TextureTools {
  64921. /**
  64922. * Uses the GPU to create a copy texture rescaled at a given size
  64923. * @param texture Texture to copy from
  64924. * @param width defines the desired width
  64925. * @param height defines the desired height
  64926. * @param useBilinearMode defines if bilinear mode has to be used
  64927. * @return the generated texture
  64928. */
  64929. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  64930. }
  64931. }
  64932. declare module BABYLON {
  64933. /**
  64934. * This represents the different options available for the video capture.
  64935. */
  64936. export interface VideoRecorderOptions {
  64937. /** Defines the mime type of the video. */
  64938. mimeType: string;
  64939. /** Defines the FPS the video should be recorded at. */
  64940. fps: number;
  64941. /** Defines the chunk size for the recording data. */
  64942. recordChunckSize: number;
  64943. /** The audio tracks to attach to the recording. */
  64944. audioTracks?: MediaStreamTrack[];
  64945. }
  64946. /**
  64947. * This can help with recording videos from BabylonJS.
  64948. * This is based on the available WebRTC functionalities of the browser.
  64949. *
  64950. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  64951. */
  64952. export class VideoRecorder {
  64953. private static readonly _defaultOptions;
  64954. /**
  64955. * Returns whether or not the VideoRecorder is available in your browser.
  64956. * @param engine Defines the Babylon Engine.
  64957. * @returns true if supported otherwise false.
  64958. */
  64959. static IsSupported(engine: Engine): boolean;
  64960. private readonly _options;
  64961. private _canvas;
  64962. private _mediaRecorder;
  64963. private _recordedChunks;
  64964. private _fileName;
  64965. private _resolve;
  64966. private _reject;
  64967. /**
  64968. * True when a recording is already in progress.
  64969. */
  64970. readonly isRecording: boolean;
  64971. /**
  64972. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  64973. * @param engine Defines the BabylonJS Engine you wish to record.
  64974. * @param options Defines options that can be used to customize the capture.
  64975. */
  64976. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  64977. /**
  64978. * Stops the current recording before the default capture timeout passed in the startRecording function.
  64979. */
  64980. stopRecording(): void;
  64981. /**
  64982. * Starts recording the canvas for a max duration specified in parameters.
  64983. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  64984. * If null no automatic download will start and you can rely on the promise to get the data back.
  64985. * @param maxDuration Defines the maximum recording time in seconds.
  64986. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  64987. * @return A promise callback at the end of the recording with the video data in Blob.
  64988. */
  64989. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  64990. /**
  64991. * Releases internal resources used during the recording.
  64992. */
  64993. dispose(): void;
  64994. private _handleDataAvailable;
  64995. private _handleError;
  64996. private _handleStop;
  64997. }
  64998. }
  64999. declare module BABYLON {
  65000. /**
  65001. * Class containing a set of static utilities functions for screenshots
  65002. */
  65003. export class ScreenshotTools {
  65004. /**
  65005. * Captures a screenshot of the current rendering
  65006. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65007. * @param engine defines the rendering engine
  65008. * @param camera defines the source camera
  65009. * @param size This parameter can be set to a single number or to an object with the
  65010. * following (optional) properties: precision, width, height. If a single number is passed,
  65011. * it will be used for both width and height. If an object is passed, the screenshot size
  65012. * will be derived from the parameters. The precision property is a multiplier allowing
  65013. * rendering at a higher or lower resolution
  65014. * @param successCallback defines the callback receives a single parameter which contains the
  65015. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65016. * src parameter of an <img> to display it
  65017. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65018. * Check your browser for supported MIME types
  65019. */
  65020. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  65021. /**
  65022. * Captures a screenshot of the current rendering
  65023. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65024. * @param engine defines the rendering engine
  65025. * @param camera defines the source camera
  65026. * @param size This parameter can be set to a single number or to an object with the
  65027. * following (optional) properties: precision, width, height. If a single number is passed,
  65028. * it will be used for both width and height. If an object is passed, the screenshot size
  65029. * will be derived from the parameters. The precision property is a multiplier allowing
  65030. * rendering at a higher or lower resolution
  65031. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65032. * Check your browser for supported MIME types
  65033. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65034. * to the src parameter of an <img> to display it
  65035. */
  65036. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  65037. /**
  65038. * Generates an image screenshot from the specified camera.
  65039. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65040. * @param engine The engine to use for rendering
  65041. * @param camera The camera to use for rendering
  65042. * @param size This parameter can be set to a single number or to an object with the
  65043. * following (optional) properties: precision, width, height. If a single number is passed,
  65044. * it will be used for both width and height. If an object is passed, the screenshot size
  65045. * will be derived from the parameters. The precision property is a multiplier allowing
  65046. * rendering at a higher or lower resolution
  65047. * @param successCallback The callback receives a single parameter which contains the
  65048. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65049. * src parameter of an <img> to display it
  65050. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65051. * Check your browser for supported MIME types
  65052. * @param samples Texture samples (default: 1)
  65053. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65054. * @param fileName A name for for the downloaded file.
  65055. */
  65056. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  65057. /**
  65058. * Generates an image screenshot from the specified camera.
  65059. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65060. * @param engine The engine to use for rendering
  65061. * @param camera The camera to use for rendering
  65062. * @param size This parameter can be set to a single number or to an object with the
  65063. * following (optional) properties: precision, width, height. If a single number is passed,
  65064. * it will be used for both width and height. If an object is passed, the screenshot size
  65065. * will be derived from the parameters. The precision property is a multiplier allowing
  65066. * rendering at a higher or lower resolution
  65067. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65068. * Check your browser for supported MIME types
  65069. * @param samples Texture samples (default: 1)
  65070. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65071. * @param fileName A name for for the downloaded file.
  65072. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65073. * to the src parameter of an <img> to display it
  65074. */
  65075. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  65076. /**
  65077. * Gets height and width for screenshot size
  65078. * @private
  65079. */
  65080. private static _getScreenshotSize;
  65081. }
  65082. }
  65083. declare module BABYLON {
  65084. /**
  65085. * Interface for a data buffer
  65086. */
  65087. export interface IDataBuffer {
  65088. /**
  65089. * Reads bytes from the data buffer.
  65090. * @param byteOffset The byte offset to read
  65091. * @param byteLength The byte length to read
  65092. * @returns A promise that resolves when the bytes are read
  65093. */
  65094. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  65095. /**
  65096. * The byte length of the buffer.
  65097. */
  65098. readonly byteLength: number;
  65099. }
  65100. /**
  65101. * Utility class for reading from a data buffer
  65102. */
  65103. export class DataReader {
  65104. /**
  65105. * The data buffer associated with this data reader.
  65106. */
  65107. readonly buffer: IDataBuffer;
  65108. /**
  65109. * The current byte offset from the beginning of the data buffer.
  65110. */
  65111. byteOffset: number;
  65112. private _dataView;
  65113. private _dataByteOffset;
  65114. /**
  65115. * Constructor
  65116. * @param buffer The buffer to read
  65117. */
  65118. constructor(buffer: IDataBuffer);
  65119. /**
  65120. * Loads the given byte length.
  65121. * @param byteLength The byte length to load
  65122. * @returns A promise that resolves when the load is complete
  65123. */
  65124. loadAsync(byteLength: number): Promise<void>;
  65125. /**
  65126. * Read a unsigned 32-bit integer from the currently loaded data range.
  65127. * @returns The 32-bit integer read
  65128. */
  65129. readUint32(): number;
  65130. /**
  65131. * Read a byte array from the currently loaded data range.
  65132. * @param byteLength The byte length to read
  65133. * @returns The byte array read
  65134. */
  65135. readUint8Array(byteLength: number): Uint8Array;
  65136. /**
  65137. * Read a string from the currently loaded data range.
  65138. * @param byteLength The byte length to read
  65139. * @returns The string read
  65140. */
  65141. readString(byteLength: number): string;
  65142. /**
  65143. * Skips the given byte length the currently loaded data range.
  65144. * @param byteLength The byte length to skip
  65145. */
  65146. skipBytes(byteLength: number): void;
  65147. }
  65148. }
  65149. declare module BABYLON {
  65150. /**
  65151. * A cursor which tracks a point on a path
  65152. */
  65153. export class PathCursor {
  65154. private path;
  65155. /**
  65156. * Stores path cursor callbacks for when an onchange event is triggered
  65157. */
  65158. private _onchange;
  65159. /**
  65160. * The value of the path cursor
  65161. */
  65162. value: number;
  65163. /**
  65164. * The animation array of the path cursor
  65165. */
  65166. animations: Animation[];
  65167. /**
  65168. * Initializes the path cursor
  65169. * @param path The path to track
  65170. */
  65171. constructor(path: Path2);
  65172. /**
  65173. * Gets the cursor point on the path
  65174. * @returns A point on the path cursor at the cursor location
  65175. */
  65176. getPoint(): Vector3;
  65177. /**
  65178. * Moves the cursor ahead by the step amount
  65179. * @param step The amount to move the cursor forward
  65180. * @returns This path cursor
  65181. */
  65182. moveAhead(step?: number): PathCursor;
  65183. /**
  65184. * Moves the cursor behind by the step amount
  65185. * @param step The amount to move the cursor back
  65186. * @returns This path cursor
  65187. */
  65188. moveBack(step?: number): PathCursor;
  65189. /**
  65190. * Moves the cursor by the step amount
  65191. * If the step amount is greater than one, an exception is thrown
  65192. * @param step The amount to move the cursor
  65193. * @returns This path cursor
  65194. */
  65195. move(step: number): PathCursor;
  65196. /**
  65197. * Ensures that the value is limited between zero and one
  65198. * @returns This path cursor
  65199. */
  65200. private ensureLimits;
  65201. /**
  65202. * Runs onchange callbacks on change (used by the animation engine)
  65203. * @returns This path cursor
  65204. */
  65205. private raiseOnChange;
  65206. /**
  65207. * Executes a function on change
  65208. * @param f A path cursor onchange callback
  65209. * @returns This path cursor
  65210. */
  65211. onchange(f: (cursor: PathCursor) => void): PathCursor;
  65212. }
  65213. }
  65214. declare module BABYLON {
  65215. /** @hidden */
  65216. export var blurPixelShader: {
  65217. name: string;
  65218. shader: string;
  65219. };
  65220. }
  65221. declare module BABYLON {
  65222. /** @hidden */
  65223. export var pointCloudVertexDeclaration: {
  65224. name: string;
  65225. shader: string;
  65226. };
  65227. }
  65228. // Mixins
  65229. interface Window {
  65230. mozIndexedDB: IDBFactory;
  65231. webkitIndexedDB: IDBFactory;
  65232. msIndexedDB: IDBFactory;
  65233. webkitURL: typeof URL;
  65234. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  65235. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  65236. WebGLRenderingContext: WebGLRenderingContext;
  65237. MSGesture: MSGesture;
  65238. CANNON: any;
  65239. AudioContext: AudioContext;
  65240. webkitAudioContext: AudioContext;
  65241. PointerEvent: any;
  65242. Math: Math;
  65243. Uint8Array: Uint8ArrayConstructor;
  65244. Float32Array: Float32ArrayConstructor;
  65245. mozURL: typeof URL;
  65246. msURL: typeof URL;
  65247. VRFrameData: any; // WebVR, from specs 1.1
  65248. DracoDecoderModule: any;
  65249. setImmediate(handler: (...args: any[]) => void): number;
  65250. }
  65251. interface HTMLCanvasElement {
  65252. requestPointerLock(): void;
  65253. msRequestPointerLock?(): void;
  65254. mozRequestPointerLock?(): void;
  65255. webkitRequestPointerLock?(): void;
  65256. /** Track wether a record is in progress */
  65257. isRecording: boolean;
  65258. /** Capture Stream method defined by some browsers */
  65259. captureStream(fps?: number): MediaStream;
  65260. }
  65261. interface CanvasRenderingContext2D {
  65262. msImageSmoothingEnabled: boolean;
  65263. }
  65264. interface MouseEvent {
  65265. mozMovementX: number;
  65266. mozMovementY: number;
  65267. webkitMovementX: number;
  65268. webkitMovementY: number;
  65269. msMovementX: number;
  65270. msMovementY: number;
  65271. }
  65272. interface Navigator {
  65273. mozGetVRDevices: (any: any) => any;
  65274. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  65275. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  65276. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  65277. webkitGetGamepads(): Gamepad[];
  65278. msGetGamepads(): Gamepad[];
  65279. webkitGamepads(): Gamepad[];
  65280. }
  65281. interface HTMLVideoElement {
  65282. mozSrcObject: any;
  65283. }
  65284. interface Math {
  65285. fround(x: number): number;
  65286. imul(a: number, b: number): number;
  65287. }
  65288. interface WebGLRenderingContext {
  65289. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  65290. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  65291. vertexAttribDivisor(index: number, divisor: number): void;
  65292. createVertexArray(): any;
  65293. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  65294. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  65295. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  65296. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  65297. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  65298. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  65299. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  65300. // Queries
  65301. createQuery(): WebGLQuery;
  65302. deleteQuery(query: WebGLQuery): void;
  65303. beginQuery(target: number, query: WebGLQuery): void;
  65304. endQuery(target: number): void;
  65305. getQueryParameter(query: WebGLQuery, pname: number): any;
  65306. getQuery(target: number, pname: number): any;
  65307. MAX_SAMPLES: number;
  65308. RGBA8: number;
  65309. READ_FRAMEBUFFER: number;
  65310. DRAW_FRAMEBUFFER: number;
  65311. UNIFORM_BUFFER: number;
  65312. HALF_FLOAT_OES: number;
  65313. RGBA16F: number;
  65314. RGBA32F: number;
  65315. R32F: number;
  65316. RG32F: number;
  65317. RGB32F: number;
  65318. R16F: number;
  65319. RG16F: number;
  65320. RGB16F: number;
  65321. RED: number;
  65322. RG: number;
  65323. R8: number;
  65324. RG8: number;
  65325. UNSIGNED_INT_24_8: number;
  65326. DEPTH24_STENCIL8: number;
  65327. MIN: number;
  65328. MAX: number;
  65329. /* Multiple Render Targets */
  65330. drawBuffers(buffers: number[]): void;
  65331. readBuffer(src: number): void;
  65332. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  65333. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  65334. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  65335. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  65336. // Occlusion Query
  65337. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  65338. ANY_SAMPLES_PASSED: number;
  65339. QUERY_RESULT_AVAILABLE: number;
  65340. QUERY_RESULT: number;
  65341. }
  65342. interface WebGLProgram {
  65343. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  65344. }
  65345. interface EXT_disjoint_timer_query {
  65346. QUERY_COUNTER_BITS_EXT: number;
  65347. TIME_ELAPSED_EXT: number;
  65348. TIMESTAMP_EXT: number;
  65349. GPU_DISJOINT_EXT: number;
  65350. QUERY_RESULT_EXT: number;
  65351. QUERY_RESULT_AVAILABLE_EXT: number;
  65352. queryCounterEXT(query: WebGLQuery, target: number): void;
  65353. createQueryEXT(): WebGLQuery;
  65354. beginQueryEXT(target: number, query: WebGLQuery): void;
  65355. endQueryEXT(target: number): void;
  65356. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  65357. deleteQueryEXT(query: WebGLQuery): void;
  65358. }
  65359. interface WebGLUniformLocation {
  65360. _currentState: any;
  65361. }
  65362. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  65363. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  65364. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  65365. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  65366. interface WebGLRenderingContext {
  65367. readonly RASTERIZER_DISCARD: number;
  65368. readonly DEPTH_COMPONENT24: number;
  65369. readonly TEXTURE_3D: number;
  65370. readonly TEXTURE_2D_ARRAY: number;
  65371. readonly TEXTURE_COMPARE_FUNC: number;
  65372. readonly TEXTURE_COMPARE_MODE: number;
  65373. readonly COMPARE_REF_TO_TEXTURE: number;
  65374. readonly TEXTURE_WRAP_R: number;
  65375. readonly HALF_FLOAT: number;
  65376. readonly RGB8: number;
  65377. readonly RED_INTEGER: number;
  65378. readonly RG_INTEGER: number;
  65379. readonly RGB_INTEGER: number;
  65380. readonly RGBA_INTEGER: number;
  65381. readonly R8_SNORM: number;
  65382. readonly RG8_SNORM: number;
  65383. readonly RGB8_SNORM: number;
  65384. readonly RGBA8_SNORM: number;
  65385. readonly R8I: number;
  65386. readonly RG8I: number;
  65387. readonly RGB8I: number;
  65388. readonly RGBA8I: number;
  65389. readonly R8UI: number;
  65390. readonly RG8UI: number;
  65391. readonly RGB8UI: number;
  65392. readonly RGBA8UI: number;
  65393. readonly R16I: number;
  65394. readonly RG16I: number;
  65395. readonly RGB16I: number;
  65396. readonly RGBA16I: number;
  65397. readonly R16UI: number;
  65398. readonly RG16UI: number;
  65399. readonly RGB16UI: number;
  65400. readonly RGBA16UI: number;
  65401. readonly R32I: number;
  65402. readonly RG32I: number;
  65403. readonly RGB32I: number;
  65404. readonly RGBA32I: number;
  65405. readonly R32UI: number;
  65406. readonly RG32UI: number;
  65407. readonly RGB32UI: number;
  65408. readonly RGBA32UI: number;
  65409. readonly RGB10_A2UI: number;
  65410. readonly R11F_G11F_B10F: number;
  65411. readonly RGB9_E5: number;
  65412. readonly RGB10_A2: number;
  65413. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  65414. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  65415. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  65416. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  65417. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  65418. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  65419. 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;
  65420. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  65421. readonly TRANSFORM_FEEDBACK: number;
  65422. readonly INTERLEAVED_ATTRIBS: number;
  65423. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  65424. createTransformFeedback(): WebGLTransformFeedback;
  65425. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  65426. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  65427. beginTransformFeedback(primitiveMode: number): void;
  65428. endTransformFeedback(): void;
  65429. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  65430. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  65431. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  65432. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  65433. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  65434. }
  65435. interface ImageBitmap {
  65436. readonly width: number;
  65437. readonly height: number;
  65438. close(): void;
  65439. }
  65440. interface WebGLQuery extends WebGLObject {
  65441. }
  65442. declare var WebGLQuery: {
  65443. prototype: WebGLQuery;
  65444. new(): WebGLQuery;
  65445. };
  65446. interface WebGLSampler extends WebGLObject {
  65447. }
  65448. declare var WebGLSampler: {
  65449. prototype: WebGLSampler;
  65450. new(): WebGLSampler;
  65451. };
  65452. interface WebGLSync extends WebGLObject {
  65453. }
  65454. declare var WebGLSync: {
  65455. prototype: WebGLSync;
  65456. new(): WebGLSync;
  65457. };
  65458. interface WebGLTransformFeedback extends WebGLObject {
  65459. }
  65460. declare var WebGLTransformFeedback: {
  65461. prototype: WebGLTransformFeedback;
  65462. new(): WebGLTransformFeedback;
  65463. };
  65464. interface WebGLVertexArrayObject extends WebGLObject {
  65465. }
  65466. declare var WebGLVertexArrayObject: {
  65467. prototype: WebGLVertexArrayObject;
  65468. new(): WebGLVertexArrayObject;
  65469. };
  65470. // Type definitions for WebVR API
  65471. // Project: https://w3c.github.io/webvr/
  65472. // Definitions by: six a <https://github.com/lostfictions>
  65473. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  65474. interface VRDisplay extends EventTarget {
  65475. /**
  65476. * Dictionary of capabilities describing the VRDisplay.
  65477. */
  65478. readonly capabilities: VRDisplayCapabilities;
  65479. /**
  65480. * z-depth defining the far plane of the eye view frustum
  65481. * enables mapping of values in the render target depth
  65482. * attachment to scene coordinates. Initially set to 10000.0.
  65483. */
  65484. depthFar: number;
  65485. /**
  65486. * z-depth defining the near plane of the eye view frustum
  65487. * enables mapping of values in the render target depth
  65488. * attachment to scene coordinates. Initially set to 0.01.
  65489. */
  65490. depthNear: number;
  65491. /**
  65492. * An identifier for this distinct VRDisplay. Used as an
  65493. * association point in the Gamepad API.
  65494. */
  65495. readonly displayId: number;
  65496. /**
  65497. * A display name, a user-readable name identifying it.
  65498. */
  65499. readonly displayName: string;
  65500. readonly isConnected: boolean;
  65501. readonly isPresenting: boolean;
  65502. /**
  65503. * If this VRDisplay supports room-scale experiences, the optional
  65504. * stage attribute contains details on the room-scale parameters.
  65505. */
  65506. readonly stageParameters: VRStageParameters | null;
  65507. /**
  65508. * Passing the value returned by `requestAnimationFrame` to
  65509. * `cancelAnimationFrame` will unregister the callback.
  65510. * @param handle Define the hanle of the request to cancel
  65511. */
  65512. cancelAnimationFrame(handle: number): void;
  65513. /**
  65514. * Stops presenting to the VRDisplay.
  65515. * @returns a promise to know when it stopped
  65516. */
  65517. exitPresent(): Promise<void>;
  65518. /**
  65519. * Return the current VREyeParameters for the given eye.
  65520. * @param whichEye Define the eye we want the parameter for
  65521. * @returns the eye parameters
  65522. */
  65523. getEyeParameters(whichEye: string): VREyeParameters;
  65524. /**
  65525. * Populates the passed VRFrameData with the information required to render
  65526. * the current frame.
  65527. * @param frameData Define the data structure to populate
  65528. * @returns true if ok otherwise false
  65529. */
  65530. getFrameData(frameData: VRFrameData): boolean;
  65531. /**
  65532. * Get the layers currently being presented.
  65533. * @returns the list of VR layers
  65534. */
  65535. getLayers(): VRLayer[];
  65536. /**
  65537. * Return a VRPose containing the future predicted pose of the VRDisplay
  65538. * when the current frame will be presented. The value returned will not
  65539. * change until JavaScript has returned control to the browser.
  65540. *
  65541. * The VRPose will contain the position, orientation, velocity,
  65542. * and acceleration of each of these properties.
  65543. * @returns the pose object
  65544. */
  65545. getPose(): VRPose;
  65546. /**
  65547. * Return the current instantaneous pose of the VRDisplay, with no
  65548. * prediction applied.
  65549. * @returns the current instantaneous pose
  65550. */
  65551. getImmediatePose(): VRPose;
  65552. /**
  65553. * The callback passed to `requestAnimationFrame` will be called
  65554. * any time a new frame should be rendered. When the VRDisplay is
  65555. * presenting the callback will be called at the native refresh
  65556. * rate of the HMD. When not presenting this function acts
  65557. * identically to how window.requestAnimationFrame acts. Content should
  65558. * make no assumptions of frame rate or vsync behavior as the HMD runs
  65559. * asynchronously from other displays and at differing refresh rates.
  65560. * @param callback Define the eaction to run next frame
  65561. * @returns the request handle it
  65562. */
  65563. requestAnimationFrame(callback: FrameRequestCallback): number;
  65564. /**
  65565. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  65566. * Repeat calls while already presenting will update the VRLayers being displayed.
  65567. * @param layers Define the list of layer to present
  65568. * @returns a promise to know when the request has been fulfilled
  65569. */
  65570. requestPresent(layers: VRLayer[]): Promise<void>;
  65571. /**
  65572. * Reset the pose for this display, treating its current position and
  65573. * orientation as the "origin/zero" values. VRPose.position,
  65574. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  65575. * updated when calling resetPose(). This should be called in only
  65576. * sitting-space experiences.
  65577. */
  65578. resetPose(): void;
  65579. /**
  65580. * The VRLayer provided to the VRDisplay will be captured and presented
  65581. * in the HMD. Calling this function has the same effect on the source
  65582. * canvas as any other operation that uses its source image, and canvases
  65583. * created without preserveDrawingBuffer set to true will be cleared.
  65584. * @param pose Define the pose to submit
  65585. */
  65586. submitFrame(pose?: VRPose): void;
  65587. }
  65588. declare var VRDisplay: {
  65589. prototype: VRDisplay;
  65590. new(): VRDisplay;
  65591. };
  65592. interface VRLayer {
  65593. leftBounds?: number[] | Float32Array | null;
  65594. rightBounds?: number[] | Float32Array | null;
  65595. source?: HTMLCanvasElement | null;
  65596. }
  65597. interface VRDisplayCapabilities {
  65598. readonly canPresent: boolean;
  65599. readonly hasExternalDisplay: boolean;
  65600. readonly hasOrientation: boolean;
  65601. readonly hasPosition: boolean;
  65602. readonly maxLayers: number;
  65603. }
  65604. interface VREyeParameters {
  65605. /** @deprecated */
  65606. readonly fieldOfView: VRFieldOfView;
  65607. readonly offset: Float32Array;
  65608. readonly renderHeight: number;
  65609. readonly renderWidth: number;
  65610. }
  65611. interface VRFieldOfView {
  65612. readonly downDegrees: number;
  65613. readonly leftDegrees: number;
  65614. readonly rightDegrees: number;
  65615. readonly upDegrees: number;
  65616. }
  65617. interface VRFrameData {
  65618. readonly leftProjectionMatrix: Float32Array;
  65619. readonly leftViewMatrix: Float32Array;
  65620. readonly pose: VRPose;
  65621. readonly rightProjectionMatrix: Float32Array;
  65622. readonly rightViewMatrix: Float32Array;
  65623. readonly timestamp: number;
  65624. }
  65625. interface VRPose {
  65626. readonly angularAcceleration: Float32Array | null;
  65627. readonly angularVelocity: Float32Array | null;
  65628. readonly linearAcceleration: Float32Array | null;
  65629. readonly linearVelocity: Float32Array | null;
  65630. readonly orientation: Float32Array | null;
  65631. readonly position: Float32Array | null;
  65632. readonly timestamp: number;
  65633. }
  65634. interface VRStageParameters {
  65635. sittingToStandingTransform?: Float32Array;
  65636. sizeX?: number;
  65637. sizeY?: number;
  65638. }
  65639. interface Navigator {
  65640. getVRDisplays(): Promise<VRDisplay[]>;
  65641. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  65642. }
  65643. interface Window {
  65644. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  65645. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  65646. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  65647. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  65648. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  65649. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  65650. }
  65651. interface Gamepad {
  65652. readonly displayId: number;
  65653. }
  65654. type XRSessionMode =
  65655. | "inline"
  65656. | "immersive-vr"
  65657. | "immersive-ar";
  65658. type XRReferenceSpaceType =
  65659. | "viewer"
  65660. | "local"
  65661. | "local-floor"
  65662. | "bounded-floor"
  65663. | "unbounded";
  65664. type XREnvironmentBlendMode =
  65665. | "opaque"
  65666. | "additive"
  65667. | "alpha-blend";
  65668. type XRVisibilityState =
  65669. | "visible"
  65670. | "visible-blurred"
  65671. | "hidden";
  65672. type XRHandedness =
  65673. | "none"
  65674. | "left"
  65675. | "right";
  65676. type XRTargetRayMode =
  65677. | "gaze"
  65678. | "tracked-pointer"
  65679. | "screen";
  65680. type XREye =
  65681. | "none"
  65682. | "left"
  65683. | "right";
  65684. interface XRSpace extends EventTarget {
  65685. }
  65686. interface XRRenderState {
  65687. depthNear?: number;
  65688. depthFar?: number;
  65689. inlineVerticalFieldOfView?: number;
  65690. baseLayer?: XRWebGLLayer;
  65691. }
  65692. interface XRInputSource {
  65693. handedness: XRHandedness;
  65694. targetRayMode: XRTargetRayMode;
  65695. targetRaySpace: XRSpace;
  65696. gripSpace: XRSpace | undefined;
  65697. gamepad: Gamepad | undefined;
  65698. profiles: Array<string>;
  65699. }
  65700. interface XRSession {
  65701. addEventListener: Function;
  65702. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  65703. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  65704. requestAnimationFrame: Function;
  65705. end(): Promise<void>;
  65706. renderState: XRRenderState;
  65707. inputSources: Array<XRInputSource>;
  65708. }
  65709. interface XRReferenceSpace extends XRSpace {
  65710. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  65711. onreset: any;
  65712. }
  65713. interface XRFrame {
  65714. session: XRSession;
  65715. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  65716. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  65717. }
  65718. interface XRViewerPose extends XRPose {
  65719. views: Array<XRView>;
  65720. }
  65721. interface XRPose {
  65722. transform: XRRigidTransform;
  65723. emulatedPosition: boolean;
  65724. }
  65725. interface XRWebGLLayerOptions {
  65726. antialias ?: boolean;
  65727. depth ?: boolean;
  65728. stencil ?: boolean;
  65729. alpha ?: boolean;
  65730. multiview ?: boolean;
  65731. framebufferScaleFactor ?: number;
  65732. }
  65733. declare var XRWebGLLayer: {
  65734. prototype: XRWebGLLayer;
  65735. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  65736. };
  65737. interface XRWebGLLayer {
  65738. framebuffer: WebGLFramebuffer;
  65739. framebufferWidth: number;
  65740. framebufferHeight: number;
  65741. getViewport: Function;
  65742. }
  65743. interface XRRigidTransform {
  65744. position: DOMPointReadOnly;
  65745. orientation: DOMPointReadOnly;
  65746. matrix: Float32Array;
  65747. inverse: XRRigidTransform;
  65748. }
  65749. interface XRView {
  65750. eye: XREye;
  65751. projectionMatrix: Float32Array;
  65752. transform: XRRigidTransform;
  65753. }
  65754. interface XRInputSourceChangeEvent {
  65755. session: XRSession;
  65756. removed: Array<XRInputSource>;
  65757. added: Array<XRInputSource>;
  65758. }
  65759. /**
  65760. * @ignore
  65761. */
  65762. declare module BABYLON.GLTF2.Exporter {
  65763. }
  65764. /**
  65765. * @ignore
  65766. */
  65767. declare module BABYLON.GLTF1 {
  65768. }
  65769. declare module BABYLON.GUI {
  65770. /**
  65771. * Class used to specific a value and its associated unit
  65772. */
  65773. export class ValueAndUnit {
  65774. /** defines the unit to store */
  65775. unit: number;
  65776. /** defines a boolean indicating if the value can be negative */
  65777. negativeValueAllowed: boolean;
  65778. private _value;
  65779. private _originalUnit;
  65780. /**
  65781. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  65782. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  65783. */
  65784. ignoreAdaptiveScaling: boolean;
  65785. /**
  65786. * Creates a new ValueAndUnit
  65787. * @param value defines the value to store
  65788. * @param unit defines the unit to store
  65789. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  65790. */
  65791. constructor(value: number,
  65792. /** defines the unit to store */
  65793. unit?: number,
  65794. /** defines a boolean indicating if the value can be negative */
  65795. negativeValueAllowed?: boolean);
  65796. /** Gets a boolean indicating if the value is a percentage */
  65797. readonly isPercentage: boolean;
  65798. /** Gets a boolean indicating if the value is store as pixel */
  65799. readonly isPixel: boolean;
  65800. /** Gets direct internal value */
  65801. readonly internalValue: number;
  65802. /**
  65803. * Gets value as pixel
  65804. * @param host defines the root host
  65805. * @param refValue defines the reference value for percentages
  65806. * @returns the value as pixel
  65807. */
  65808. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  65809. /**
  65810. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  65811. * @param value defines the value to store
  65812. * @param unit defines the unit to store
  65813. * @returns the current ValueAndUnit
  65814. */
  65815. updateInPlace(value: number, unit?: number): ValueAndUnit;
  65816. /**
  65817. * Gets the value accordingly to its unit
  65818. * @param host defines the root host
  65819. * @returns the value
  65820. */
  65821. getValue(host: AdvancedDynamicTexture): number;
  65822. /**
  65823. * Gets a string representation of the value
  65824. * @param host defines the root host
  65825. * @param decimals defines an optional number of decimals to display
  65826. * @returns a string
  65827. */
  65828. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  65829. /**
  65830. * Store a value parsed from a string
  65831. * @param source defines the source string
  65832. * @returns true if the value was successfully parsed
  65833. */
  65834. fromString(source: string | number): boolean;
  65835. private static _Regex;
  65836. private static _UNITMODE_PERCENTAGE;
  65837. private static _UNITMODE_PIXEL;
  65838. /** UNITMODE_PERCENTAGE */
  65839. static readonly UNITMODE_PERCENTAGE: number;
  65840. /** UNITMODE_PIXEL */
  65841. static readonly UNITMODE_PIXEL: number;
  65842. }
  65843. }
  65844. declare module BABYLON.GUI {
  65845. /**
  65846. * Define a style used by control to automatically setup properties based on a template.
  65847. * Only support font related properties so far
  65848. */
  65849. export class Style implements BABYLON.IDisposable {
  65850. private _fontFamily;
  65851. private _fontStyle;
  65852. private _fontWeight;
  65853. /** @hidden */
  65854. _host: AdvancedDynamicTexture;
  65855. /** @hidden */
  65856. _fontSize: ValueAndUnit;
  65857. /**
  65858. * BABYLON.Observable raised when the style values are changed
  65859. */
  65860. onChangedObservable: BABYLON.Observable<Style>;
  65861. /**
  65862. * Creates a new style object
  65863. * @param host defines the AdvancedDynamicTexture which hosts this style
  65864. */
  65865. constructor(host: AdvancedDynamicTexture);
  65866. /**
  65867. * Gets or sets the font size
  65868. */
  65869. fontSize: string | number;
  65870. /**
  65871. * Gets or sets the font family
  65872. */
  65873. fontFamily: string;
  65874. /**
  65875. * Gets or sets the font style
  65876. */
  65877. fontStyle: string;
  65878. /** Gets or sets font weight */
  65879. fontWeight: string;
  65880. /** Dispose all associated resources */
  65881. dispose(): void;
  65882. }
  65883. }
  65884. declare module BABYLON.GUI {
  65885. /**
  65886. * Class used to transport BABYLON.Vector2 information for pointer events
  65887. */
  65888. export class Vector2WithInfo extends BABYLON.Vector2 {
  65889. /** defines the current mouse button index */
  65890. buttonIndex: number;
  65891. /**
  65892. * Creates a new Vector2WithInfo
  65893. * @param source defines the vector2 data to transport
  65894. * @param buttonIndex defines the current mouse button index
  65895. */
  65896. constructor(source: BABYLON.Vector2,
  65897. /** defines the current mouse button index */
  65898. buttonIndex?: number);
  65899. }
  65900. /** Class used to provide 2D matrix features */
  65901. export class Matrix2D {
  65902. /** Gets the internal array of 6 floats used to store matrix data */
  65903. m: Float32Array;
  65904. /**
  65905. * Creates a new matrix
  65906. * @param m00 defines value for (0, 0)
  65907. * @param m01 defines value for (0, 1)
  65908. * @param m10 defines value for (1, 0)
  65909. * @param m11 defines value for (1, 1)
  65910. * @param m20 defines value for (2, 0)
  65911. * @param m21 defines value for (2, 1)
  65912. */
  65913. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  65914. /**
  65915. * Fills the matrix from direct values
  65916. * @param m00 defines value for (0, 0)
  65917. * @param m01 defines value for (0, 1)
  65918. * @param m10 defines value for (1, 0)
  65919. * @param m11 defines value for (1, 1)
  65920. * @param m20 defines value for (2, 0)
  65921. * @param m21 defines value for (2, 1)
  65922. * @returns the current modified matrix
  65923. */
  65924. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  65925. /**
  65926. * Gets matrix determinant
  65927. * @returns the determinant
  65928. */
  65929. determinant(): number;
  65930. /**
  65931. * Inverses the matrix and stores it in a target matrix
  65932. * @param result defines the target matrix
  65933. * @returns the current matrix
  65934. */
  65935. invertToRef(result: Matrix2D): Matrix2D;
  65936. /**
  65937. * Multiplies the current matrix with another one
  65938. * @param other defines the second operand
  65939. * @param result defines the target matrix
  65940. * @returns the current matrix
  65941. */
  65942. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  65943. /**
  65944. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  65945. * @param x defines the x coordinate to transform
  65946. * @param y defines the x coordinate to transform
  65947. * @param result defines the target vector2
  65948. * @returns the current matrix
  65949. */
  65950. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  65951. /**
  65952. * Creates an identity matrix
  65953. * @returns a new matrix
  65954. */
  65955. static Identity(): Matrix2D;
  65956. /**
  65957. * Creates a translation matrix and stores it in a target matrix
  65958. * @param x defines the x coordinate of the translation
  65959. * @param y defines the y coordinate of the translation
  65960. * @param result defines the target matrix
  65961. */
  65962. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  65963. /**
  65964. * Creates a scaling matrix and stores it in a target matrix
  65965. * @param x defines the x coordinate of the scaling
  65966. * @param y defines the y coordinate of the scaling
  65967. * @param result defines the target matrix
  65968. */
  65969. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  65970. /**
  65971. * Creates a rotation matrix and stores it in a target matrix
  65972. * @param angle defines the rotation angle
  65973. * @param result defines the target matrix
  65974. */
  65975. static RotationToRef(angle: number, result: Matrix2D): void;
  65976. private static _TempPreTranslationMatrix;
  65977. private static _TempPostTranslationMatrix;
  65978. private static _TempRotationMatrix;
  65979. private static _TempScalingMatrix;
  65980. private static _TempCompose0;
  65981. private static _TempCompose1;
  65982. private static _TempCompose2;
  65983. /**
  65984. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  65985. * @param tx defines the x coordinate of the translation
  65986. * @param ty defines the y coordinate of the translation
  65987. * @param angle defines the rotation angle
  65988. * @param scaleX defines the x coordinate of the scaling
  65989. * @param scaleY defines the y coordinate of the scaling
  65990. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  65991. * @param result defines the target matrix
  65992. */
  65993. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  65994. }
  65995. }
  65996. declare module BABYLON.GUI {
  65997. /**
  65998. * Class used to store 2D control sizes
  65999. */
  66000. export class Measure {
  66001. /** defines left coordinate */
  66002. left: number;
  66003. /** defines top coordinate */
  66004. top: number;
  66005. /** defines width dimension */
  66006. width: number;
  66007. /** defines height dimension */
  66008. height: number;
  66009. /**
  66010. * Creates a new measure
  66011. * @param left defines left coordinate
  66012. * @param top defines top coordinate
  66013. * @param width defines width dimension
  66014. * @param height defines height dimension
  66015. */
  66016. constructor(
  66017. /** defines left coordinate */
  66018. left: number,
  66019. /** defines top coordinate */
  66020. top: number,
  66021. /** defines width dimension */
  66022. width: number,
  66023. /** defines height dimension */
  66024. height: number);
  66025. /**
  66026. * Copy from another measure
  66027. * @param other defines the other measure to copy from
  66028. */
  66029. copyFrom(other: Measure): void;
  66030. /**
  66031. * Copy from a group of 4 floats
  66032. * @param left defines left coordinate
  66033. * @param top defines top coordinate
  66034. * @param width defines width dimension
  66035. * @param height defines height dimension
  66036. */
  66037. copyFromFloats(left: number, top: number, width: number, height: number): void;
  66038. /**
  66039. * Computes the axis aligned bounding box measure for two given measures
  66040. * @param a Input measure
  66041. * @param b Input measure
  66042. * @param result the resulting bounding measure
  66043. */
  66044. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  66045. /**
  66046. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  66047. * @param transform the matrix to transform the measure before computing the AABB
  66048. * @param result the resulting AABB
  66049. */
  66050. transformToRef(transform: Matrix2D, result: Measure): void;
  66051. /**
  66052. * Check equality between this measure and another one
  66053. * @param other defines the other measures
  66054. * @returns true if both measures are equals
  66055. */
  66056. isEqualsTo(other: Measure): boolean;
  66057. /**
  66058. * Creates an empty measure
  66059. * @returns a new measure
  66060. */
  66061. static Empty(): Measure;
  66062. }
  66063. }
  66064. declare module BABYLON.GUI {
  66065. /**
  66066. * Interface used to define a control that can receive focus
  66067. */
  66068. export interface IFocusableControl {
  66069. /**
  66070. * Function called when the control receives the focus
  66071. */
  66072. onFocus(): void;
  66073. /**
  66074. * Function called when the control loses the focus
  66075. */
  66076. onBlur(): void;
  66077. /**
  66078. * Function called to let the control handle keyboard events
  66079. * @param evt defines the current keyboard event
  66080. */
  66081. processKeyboard(evt: KeyboardEvent): void;
  66082. /**
  66083. * Function called to get the list of controls that should not steal the focus from this control
  66084. * @returns an array of controls
  66085. */
  66086. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  66087. }
  66088. /**
  66089. * Class used to create texture to support 2D GUI elements
  66090. * @see http://doc.babylonjs.com/how_to/gui
  66091. */
  66092. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  66093. private _isDirty;
  66094. private _renderObserver;
  66095. private _resizeObserver;
  66096. private _preKeyboardObserver;
  66097. private _pointerMoveObserver;
  66098. private _pointerObserver;
  66099. private _canvasPointerOutObserver;
  66100. private _background;
  66101. /** @hidden */
  66102. _rootContainer: Container;
  66103. /** @hidden */
  66104. _lastPickedControl: Control;
  66105. /** @hidden */
  66106. _lastControlOver: {
  66107. [pointerId: number]: Control;
  66108. };
  66109. /** @hidden */
  66110. _lastControlDown: {
  66111. [pointerId: number]: Control;
  66112. };
  66113. /** @hidden */
  66114. _capturingControl: {
  66115. [pointerId: number]: Control;
  66116. };
  66117. /** @hidden */
  66118. _shouldBlockPointer: boolean;
  66119. /** @hidden */
  66120. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  66121. /** @hidden */
  66122. _linkedControls: Control[];
  66123. private _isFullscreen;
  66124. private _fullscreenViewport;
  66125. private _idealWidth;
  66126. private _idealHeight;
  66127. private _useSmallestIdeal;
  66128. private _renderAtIdealSize;
  66129. private _focusedControl;
  66130. private _blockNextFocusCheck;
  66131. private _renderScale;
  66132. private _rootElement;
  66133. private _cursorChanged;
  66134. /**
  66135. * Define type to string to ensure compatibility across browsers
  66136. * Safari doesn't support DataTransfer constructor
  66137. */
  66138. private _clipboardData;
  66139. /**
  66140. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  66141. */
  66142. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  66143. /**
  66144. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  66145. */
  66146. onControlPickedObservable: BABYLON.Observable<Control>;
  66147. /**
  66148. * BABYLON.Observable event triggered before layout is evaluated
  66149. */
  66150. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  66151. /**
  66152. * BABYLON.Observable event triggered after the layout was evaluated
  66153. */
  66154. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  66155. /**
  66156. * BABYLON.Observable event triggered before the texture is rendered
  66157. */
  66158. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  66159. /**
  66160. * BABYLON.Observable event triggered after the texture was rendered
  66161. */
  66162. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  66163. /**
  66164. * Gets or sets a boolean defining if alpha is stored as premultiplied
  66165. */
  66166. premulAlpha: boolean;
  66167. /**
  66168. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  66169. * Useful when you want more antialiasing
  66170. */
  66171. renderScale: number;
  66172. /** Gets or sets the background color */
  66173. background: string;
  66174. /**
  66175. * Gets or sets the ideal width used to design controls.
  66176. * The GUI will then rescale everything accordingly
  66177. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  66178. */
  66179. idealWidth: number;
  66180. /**
  66181. * Gets or sets the ideal height used to design controls.
  66182. * The GUI will then rescale everything accordingly
  66183. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  66184. */
  66185. idealHeight: number;
  66186. /**
  66187. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  66188. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  66189. */
  66190. useSmallestIdeal: boolean;
  66191. /**
  66192. * Gets or sets a boolean indicating if adaptive scaling must be used
  66193. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  66194. */
  66195. renderAtIdealSize: boolean;
  66196. /**
  66197. * Gets the underlying layer used to render the texture when in fullscreen mode
  66198. */
  66199. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  66200. /**
  66201. * Gets the root container control
  66202. */
  66203. readonly rootContainer: Container;
  66204. /**
  66205. * Returns an array containing the root container.
  66206. * This is mostly used to let the Inspector introspects the ADT
  66207. * @returns an array containing the rootContainer
  66208. */
  66209. getChildren(): Array<Container>;
  66210. /**
  66211. * Will return all controls that are inside this texture
  66212. * @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
  66213. * @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
  66214. * @return all child controls
  66215. */
  66216. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  66217. /**
  66218. * Gets or sets the current focused control
  66219. */
  66220. focusedControl: BABYLON.Nullable<IFocusableControl>;
  66221. /**
  66222. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  66223. */
  66224. isForeground: boolean;
  66225. /**
  66226. * Gets or set information about clipboardData
  66227. */
  66228. clipboardData: string;
  66229. /**
  66230. * Creates a new AdvancedDynamicTexture
  66231. * @param name defines the name of the texture
  66232. * @param width defines the width of the texture
  66233. * @param height defines the height of the texture
  66234. * @param scene defines the hosting scene
  66235. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  66236. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  66237. */
  66238. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  66239. /**
  66240. * Get the current class name of the texture useful for serialization or dynamic coding.
  66241. * @returns "AdvancedDynamicTexture"
  66242. */
  66243. getClassName(): string;
  66244. /**
  66245. * Function used to execute a function on all controls
  66246. * @param func defines the function to execute
  66247. * @param container defines the container where controls belong. If null the root container will be used
  66248. */
  66249. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  66250. private _useInvalidateRectOptimization;
  66251. /**
  66252. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  66253. */
  66254. useInvalidateRectOptimization: boolean;
  66255. private _invalidatedRectangle;
  66256. /**
  66257. * Invalidates a rectangle area on the gui texture
  66258. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  66259. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  66260. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  66261. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  66262. */
  66263. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  66264. /**
  66265. * Marks the texture as dirty forcing a complete update
  66266. */
  66267. markAsDirty(): void;
  66268. /**
  66269. * Helper function used to create a new style
  66270. * @returns a new style
  66271. * @see http://doc.babylonjs.com/how_to/gui#styles
  66272. */
  66273. createStyle(): Style;
  66274. /**
  66275. * Adds a new control to the root container
  66276. * @param control defines the control to add
  66277. * @returns the current texture
  66278. */
  66279. addControl(control: Control): AdvancedDynamicTexture;
  66280. /**
  66281. * Removes a control from the root container
  66282. * @param control defines the control to remove
  66283. * @returns the current texture
  66284. */
  66285. removeControl(control: Control): AdvancedDynamicTexture;
  66286. /**
  66287. * Release all resources
  66288. */
  66289. dispose(): void;
  66290. private _onResize;
  66291. /** @hidden */
  66292. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  66293. /**
  66294. * Get screen coordinates for a vector3
  66295. * @param position defines the position to project
  66296. * @param worldMatrix defines the world matrix to use
  66297. * @returns the projected position
  66298. */
  66299. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  66300. private _checkUpdate;
  66301. private _clearMeasure;
  66302. private _render;
  66303. /** @hidden */
  66304. _changeCursor(cursor: string): void;
  66305. /** @hidden */
  66306. _registerLastControlDown(control: Control, pointerId: number): void;
  66307. private _doPicking;
  66308. /** @hidden */
  66309. _cleanControlAfterRemovalFromList(list: {
  66310. [pointerId: number]: Control;
  66311. }, control: Control): void;
  66312. /** @hidden */
  66313. _cleanControlAfterRemoval(control: Control): void;
  66314. /** Attach to all scene events required to support pointer events */
  66315. attach(): void;
  66316. /** @hidden */
  66317. private onClipboardCopy;
  66318. /** @hidden */
  66319. private onClipboardCut;
  66320. /** @hidden */
  66321. private onClipboardPaste;
  66322. /**
  66323. * Register the clipboard Events onto the canvas
  66324. */
  66325. registerClipboardEvents(): void;
  66326. /**
  66327. * Unregister the clipboard Events from the canvas
  66328. */
  66329. unRegisterClipboardEvents(): void;
  66330. /**
  66331. * Connect the texture to a hosting mesh to enable interactions
  66332. * @param mesh defines the mesh to attach to
  66333. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  66334. */
  66335. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  66336. /**
  66337. * Move the focus to a specific control
  66338. * @param control defines the control which will receive the focus
  66339. */
  66340. moveFocusToControl(control: IFocusableControl): void;
  66341. private _manageFocus;
  66342. private _attachToOnPointerOut;
  66343. /**
  66344. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  66345. * @param mesh defines the mesh which will receive the texture
  66346. * @param width defines the texture width (1024 by default)
  66347. * @param height defines the texture height (1024 by default)
  66348. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  66349. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  66350. * @returns a new AdvancedDynamicTexture
  66351. */
  66352. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  66353. /**
  66354. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  66355. * In this mode the texture will rely on a layer for its rendering.
  66356. * This allows it to be treated like any other layer.
  66357. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  66358. * LayerMask is set through advancedTexture.layer.layerMask
  66359. * @param name defines name for the texture
  66360. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  66361. * @param scene defines the hsoting scene
  66362. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  66363. * @returns a new AdvancedDynamicTexture
  66364. */
  66365. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  66366. }
  66367. }
  66368. declare module BABYLON.GUI {
  66369. /**
  66370. * Root class used for all 2D controls
  66371. * @see http://doc.babylonjs.com/how_to/gui#controls
  66372. */
  66373. export class Control {
  66374. /** defines the name of the control */
  66375. name?: string | undefined;
  66376. /**
  66377. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  66378. */
  66379. static AllowAlphaInheritance: boolean;
  66380. private _alpha;
  66381. private _alphaSet;
  66382. private _zIndex;
  66383. /** @hidden */
  66384. _host: AdvancedDynamicTexture;
  66385. /** Gets or sets the control parent */
  66386. parent: BABYLON.Nullable<Container>;
  66387. /** @hidden */
  66388. _currentMeasure: Measure;
  66389. private _fontFamily;
  66390. private _fontStyle;
  66391. private _fontWeight;
  66392. private _fontSize;
  66393. private _font;
  66394. /** @hidden */
  66395. _width: ValueAndUnit;
  66396. /** @hidden */
  66397. _height: ValueAndUnit;
  66398. /** @hidden */
  66399. protected _fontOffset: {
  66400. ascent: number;
  66401. height: number;
  66402. descent: number;
  66403. };
  66404. private _color;
  66405. private _style;
  66406. private _styleObserver;
  66407. /** @hidden */
  66408. protected _horizontalAlignment: number;
  66409. /** @hidden */
  66410. protected _verticalAlignment: number;
  66411. /** @hidden */
  66412. protected _isDirty: boolean;
  66413. /** @hidden */
  66414. protected _wasDirty: boolean;
  66415. /** @hidden */
  66416. _tempParentMeasure: Measure;
  66417. /** @hidden */
  66418. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  66419. /** @hidden */
  66420. protected _cachedParentMeasure: Measure;
  66421. private _paddingLeft;
  66422. private _paddingRight;
  66423. private _paddingTop;
  66424. private _paddingBottom;
  66425. /** @hidden */
  66426. _left: ValueAndUnit;
  66427. /** @hidden */
  66428. _top: ValueAndUnit;
  66429. private _scaleX;
  66430. private _scaleY;
  66431. private _rotation;
  66432. private _transformCenterX;
  66433. private _transformCenterY;
  66434. /** @hidden */
  66435. _transformMatrix: Matrix2D;
  66436. /** @hidden */
  66437. protected _invertTransformMatrix: Matrix2D;
  66438. /** @hidden */
  66439. protected _transformedPosition: BABYLON.Vector2;
  66440. private _isMatrixDirty;
  66441. private _cachedOffsetX;
  66442. private _cachedOffsetY;
  66443. private _isVisible;
  66444. private _isHighlighted;
  66445. /** @hidden */
  66446. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66447. private _fontSet;
  66448. private _dummyVector2;
  66449. private _downCount;
  66450. private _enterCount;
  66451. private _doNotRender;
  66452. private _downPointerIds;
  66453. protected _isEnabled: boolean;
  66454. protected _disabledColor: string;
  66455. /** @hidden */
  66456. protected _rebuildLayout: boolean;
  66457. /** @hidden */
  66458. _isClipped: boolean;
  66459. /** @hidden */
  66460. _automaticSize: boolean;
  66461. /** @hidden */
  66462. _tag: any;
  66463. /**
  66464. * 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
  66465. */
  66466. uniqueId: number;
  66467. /**
  66468. * Gets or sets an object used to store user defined information for the node
  66469. */
  66470. metadata: any;
  66471. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  66472. isHitTestVisible: boolean;
  66473. /** Gets or sets a boolean indicating if the control can block pointer events */
  66474. isPointerBlocker: boolean;
  66475. /** Gets or sets a boolean indicating if the control can be focusable */
  66476. isFocusInvisible: boolean;
  66477. /**
  66478. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  66479. * 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
  66480. */
  66481. clipChildren: boolean;
  66482. /**
  66483. * Gets or sets a boolean indicating that control content must be clipped
  66484. * 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
  66485. */
  66486. clipContent: boolean;
  66487. /**
  66488. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  66489. */
  66490. useBitmapCache: boolean;
  66491. private _cacheData;
  66492. private _shadowOffsetX;
  66493. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  66494. shadowOffsetX: number;
  66495. private _shadowOffsetY;
  66496. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  66497. shadowOffsetY: number;
  66498. private _shadowBlur;
  66499. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  66500. shadowBlur: number;
  66501. private _shadowColor;
  66502. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  66503. shadowColor: string;
  66504. /** Gets or sets the cursor to use when the control is hovered */
  66505. hoverCursor: string;
  66506. /** @hidden */
  66507. protected _linkOffsetX: ValueAndUnit;
  66508. /** @hidden */
  66509. protected _linkOffsetY: ValueAndUnit;
  66510. /** Gets the control type name */
  66511. readonly typeName: string;
  66512. /**
  66513. * Get the current class name of the control.
  66514. * @returns current class name
  66515. */
  66516. getClassName(): string;
  66517. /**
  66518. * An event triggered when the pointer move over the control.
  66519. */
  66520. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  66521. /**
  66522. * An event triggered when the pointer move out of the control.
  66523. */
  66524. onPointerOutObservable: BABYLON.Observable<Control>;
  66525. /**
  66526. * An event triggered when the pointer taps the control
  66527. */
  66528. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  66529. /**
  66530. * An event triggered when pointer up
  66531. */
  66532. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  66533. /**
  66534. * An event triggered when a control is clicked on
  66535. */
  66536. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  66537. /**
  66538. * An event triggered when pointer enters the control
  66539. */
  66540. onPointerEnterObservable: BABYLON.Observable<Control>;
  66541. /**
  66542. * An event triggered when the control is marked as dirty
  66543. */
  66544. onDirtyObservable: BABYLON.Observable<Control>;
  66545. /**
  66546. * An event triggered before drawing the control
  66547. */
  66548. onBeforeDrawObservable: BABYLON.Observable<Control>;
  66549. /**
  66550. * An event triggered after the control was drawn
  66551. */
  66552. onAfterDrawObservable: BABYLON.Observable<Control>;
  66553. /**
  66554. * Get the hosting AdvancedDynamicTexture
  66555. */
  66556. readonly host: AdvancedDynamicTexture;
  66557. /** Gets or set information about font offsets (used to render and align text) */
  66558. fontOffset: {
  66559. ascent: number;
  66560. height: number;
  66561. descent: number;
  66562. };
  66563. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  66564. alpha: number;
  66565. /**
  66566. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  66567. */
  66568. isHighlighted: boolean;
  66569. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  66570. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  66571. */
  66572. scaleX: number;
  66573. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  66574. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  66575. */
  66576. scaleY: number;
  66577. /** Gets or sets the rotation angle (0 by default)
  66578. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  66579. */
  66580. rotation: number;
  66581. /** Gets or sets the transformation center on Y axis (0 by default)
  66582. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  66583. */
  66584. transformCenterY: number;
  66585. /** Gets or sets the transformation center on X axis (0 by default)
  66586. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  66587. */
  66588. transformCenterX: number;
  66589. /**
  66590. * Gets or sets the horizontal alignment
  66591. * @see http://doc.babylonjs.com/how_to/gui#alignments
  66592. */
  66593. horizontalAlignment: number;
  66594. /**
  66595. * Gets or sets the vertical alignment
  66596. * @see http://doc.babylonjs.com/how_to/gui#alignments
  66597. */
  66598. verticalAlignment: number;
  66599. /**
  66600. * Gets or sets control width
  66601. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66602. */
  66603. width: string | number;
  66604. /**
  66605. * Gets or sets the control width in pixel
  66606. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66607. */
  66608. widthInPixels: number;
  66609. /**
  66610. * Gets or sets control height
  66611. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66612. */
  66613. height: string | number;
  66614. /**
  66615. * Gets or sets control height in pixel
  66616. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66617. */
  66618. heightInPixels: number;
  66619. /** Gets or set font family */
  66620. fontFamily: string;
  66621. /** Gets or sets font style */
  66622. fontStyle: string;
  66623. /** Gets or sets font weight */
  66624. fontWeight: string;
  66625. /**
  66626. * Gets or sets style
  66627. * @see http://doc.babylonjs.com/how_to/gui#styles
  66628. */
  66629. style: BABYLON.Nullable<Style>;
  66630. /** @hidden */
  66631. readonly _isFontSizeInPercentage: boolean;
  66632. /** Gets or sets font size in pixels */
  66633. fontSizeInPixels: number;
  66634. /** Gets or sets font size */
  66635. fontSize: string | number;
  66636. /** Gets or sets foreground color */
  66637. color: string;
  66638. /** Gets or sets z index which is used to reorder controls on the z axis */
  66639. zIndex: number;
  66640. /** Gets or sets a boolean indicating if the control can be rendered */
  66641. notRenderable: boolean;
  66642. /** Gets or sets a boolean indicating if the control is visible */
  66643. isVisible: boolean;
  66644. /** Gets a boolean indicating that the control needs to update its rendering */
  66645. readonly isDirty: boolean;
  66646. /**
  66647. * Gets the current linked mesh (or null if none)
  66648. */
  66649. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66650. /**
  66651. * Gets or sets a value indicating the padding to use on the left of the control
  66652. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66653. */
  66654. paddingLeft: string | number;
  66655. /**
  66656. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  66657. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66658. */
  66659. paddingLeftInPixels: number;
  66660. /**
  66661. * Gets or sets a value indicating the padding to use on the right of the control
  66662. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66663. */
  66664. paddingRight: string | number;
  66665. /**
  66666. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  66667. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66668. */
  66669. paddingRightInPixels: number;
  66670. /**
  66671. * Gets or sets a value indicating the padding to use on the top of the control
  66672. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66673. */
  66674. paddingTop: string | number;
  66675. /**
  66676. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  66677. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66678. */
  66679. paddingTopInPixels: number;
  66680. /**
  66681. * Gets or sets a value indicating the padding to use on the bottom of the control
  66682. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66683. */
  66684. paddingBottom: string | number;
  66685. /**
  66686. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  66687. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66688. */
  66689. paddingBottomInPixels: number;
  66690. /**
  66691. * Gets or sets a value indicating the left coordinate of the control
  66692. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66693. */
  66694. left: string | number;
  66695. /**
  66696. * Gets or sets a value indicating the left coordinate in pixels of the control
  66697. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66698. */
  66699. leftInPixels: number;
  66700. /**
  66701. * Gets or sets a value indicating the top coordinate of the control
  66702. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66703. */
  66704. top: string | number;
  66705. /**
  66706. * Gets or sets a value indicating the top coordinate in pixels of the control
  66707. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66708. */
  66709. topInPixels: number;
  66710. /**
  66711. * Gets or sets a value indicating the offset on X axis to the linked mesh
  66712. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  66713. */
  66714. linkOffsetX: string | number;
  66715. /**
  66716. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  66717. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  66718. */
  66719. linkOffsetXInPixels: number;
  66720. /**
  66721. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  66722. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  66723. */
  66724. linkOffsetY: string | number;
  66725. /**
  66726. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  66727. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  66728. */
  66729. linkOffsetYInPixels: number;
  66730. /** Gets the center coordinate on X axis */
  66731. readonly centerX: number;
  66732. /** Gets the center coordinate on Y axis */
  66733. readonly centerY: number;
  66734. /** Gets or sets if control is Enabled*/
  66735. isEnabled: boolean;
  66736. /** Gets or sets background color of control if it's disabled*/
  66737. disabledColor: string;
  66738. /**
  66739. * Creates a new control
  66740. * @param name defines the name of the control
  66741. */
  66742. constructor(
  66743. /** defines the name of the control */
  66744. name?: string | undefined);
  66745. /** @hidden */
  66746. protected _getTypeName(): string;
  66747. /**
  66748. * Gets the first ascendant in the hierarchy of the given type
  66749. * @param className defines the required type
  66750. * @returns the ascendant or null if not found
  66751. */
  66752. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  66753. /** @hidden */
  66754. _resetFontCache(): void;
  66755. /**
  66756. * Determines if a container is an ascendant of the current control
  66757. * @param container defines the container to look for
  66758. * @returns true if the container is one of the ascendant of the control
  66759. */
  66760. isAscendant(container: Control): boolean;
  66761. /**
  66762. * Gets coordinates in local control space
  66763. * @param globalCoordinates defines the coordinates to transform
  66764. * @returns the new coordinates in local space
  66765. */
  66766. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  66767. /**
  66768. * Gets coordinates in local control space
  66769. * @param globalCoordinates defines the coordinates to transform
  66770. * @param result defines the target vector2 where to store the result
  66771. * @returns the current control
  66772. */
  66773. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  66774. /**
  66775. * Gets coordinates in parent local control space
  66776. * @param globalCoordinates defines the coordinates to transform
  66777. * @returns the new coordinates in parent local space
  66778. */
  66779. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  66780. /**
  66781. * Move the current control to a vector3 position projected onto the screen.
  66782. * @param position defines the target position
  66783. * @param scene defines the hosting scene
  66784. */
  66785. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  66786. /**
  66787. * Will store all controls that have this control as ascendant in a given array
  66788. * @param results defines the array where to store the descendants
  66789. * @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
  66790. * @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
  66791. */
  66792. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  66793. /**
  66794. * Will return all controls that have this control as ascendant
  66795. * @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
  66796. * @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
  66797. * @return all child controls
  66798. */
  66799. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  66800. /**
  66801. * Link current control with a target mesh
  66802. * @param mesh defines the mesh to link with
  66803. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  66804. */
  66805. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  66806. /** @hidden */
  66807. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  66808. /** @hidden */
  66809. _offsetLeft(offset: number): void;
  66810. /** @hidden */
  66811. _offsetTop(offset: number): void;
  66812. /** @hidden */
  66813. _markMatrixAsDirty(): void;
  66814. /** @hidden */
  66815. _flagDescendantsAsMatrixDirty(): void;
  66816. /** @hidden */
  66817. _intersectsRect(rect: Measure): boolean;
  66818. /** @hidden */
  66819. protected invalidateRect(): void;
  66820. /** @hidden */
  66821. _markAsDirty(force?: boolean): void;
  66822. /** @hidden */
  66823. _markAllAsDirty(): void;
  66824. /** @hidden */
  66825. _link(host: AdvancedDynamicTexture): void;
  66826. /** @hidden */
  66827. protected _transform(context?: CanvasRenderingContext2D): void;
  66828. /** @hidden */
  66829. _renderHighlight(context: CanvasRenderingContext2D): void;
  66830. /** @hidden */
  66831. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  66832. /** @hidden */
  66833. protected _applyStates(context: CanvasRenderingContext2D): void;
  66834. /** @hidden */
  66835. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  66836. /** @hidden */
  66837. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66838. protected _evaluateClippingState(parentMeasure: Measure): void;
  66839. /** @hidden */
  66840. _measure(): void;
  66841. /** @hidden */
  66842. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66843. /** @hidden */
  66844. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66845. /** @hidden */
  66846. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66847. /** @hidden */
  66848. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  66849. private static _ClipMeasure;
  66850. private _tmpMeasureA;
  66851. private _clip;
  66852. /** @hidden */
  66853. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  66854. /** @hidden */
  66855. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  66856. /**
  66857. * Tests if a given coordinates belong to the current control
  66858. * @param x defines x coordinate to test
  66859. * @param y defines y coordinate to test
  66860. * @returns true if the coordinates are inside the control
  66861. */
  66862. contains(x: number, y: number): boolean;
  66863. /** @hidden */
  66864. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  66865. /** @hidden */
  66866. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66867. /** @hidden */
  66868. _onPointerEnter(target: Control): boolean;
  66869. /** @hidden */
  66870. _onPointerOut(target: Control, force?: boolean): void;
  66871. /** @hidden */
  66872. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66873. /** @hidden */
  66874. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66875. /** @hidden */
  66876. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  66877. /** @hidden */
  66878. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  66879. private _prepareFont;
  66880. /** Releases associated resources */
  66881. dispose(): void;
  66882. private static _HORIZONTAL_ALIGNMENT_LEFT;
  66883. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  66884. private static _HORIZONTAL_ALIGNMENT_CENTER;
  66885. private static _VERTICAL_ALIGNMENT_TOP;
  66886. private static _VERTICAL_ALIGNMENT_BOTTOM;
  66887. private static _VERTICAL_ALIGNMENT_CENTER;
  66888. /** HORIZONTAL_ALIGNMENT_LEFT */
  66889. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  66890. /** HORIZONTAL_ALIGNMENT_RIGHT */
  66891. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  66892. /** HORIZONTAL_ALIGNMENT_CENTER */
  66893. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  66894. /** VERTICAL_ALIGNMENT_TOP */
  66895. static readonly VERTICAL_ALIGNMENT_TOP: number;
  66896. /** VERTICAL_ALIGNMENT_BOTTOM */
  66897. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  66898. /** VERTICAL_ALIGNMENT_CENTER */
  66899. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  66900. private static _FontHeightSizes;
  66901. /** @hidden */
  66902. static _GetFontOffset(font: string): {
  66903. ascent: number;
  66904. height: number;
  66905. descent: number;
  66906. };
  66907. /**
  66908. * Creates a stack panel that can be used to render headers
  66909. * @param control defines the control to associate with the header
  66910. * @param text defines the text of the header
  66911. * @param size defines the size of the header
  66912. * @param options defines options used to configure the header
  66913. * @returns a new StackPanel
  66914. * @ignore
  66915. * @hidden
  66916. */
  66917. static AddHeader: (control: Control, text: string, size: string | number, options: {
  66918. isHorizontal: boolean;
  66919. controlFirst: boolean;
  66920. }) => any;
  66921. /** @hidden */
  66922. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  66923. }
  66924. }
  66925. declare module BABYLON.GUI {
  66926. /**
  66927. * Root class for 2D containers
  66928. * @see http://doc.babylonjs.com/how_to/gui#containers
  66929. */
  66930. export class Container extends Control {
  66931. name?: string | undefined;
  66932. /** @hidden */
  66933. protected _children: Control[];
  66934. /** @hidden */
  66935. protected _measureForChildren: Measure;
  66936. /** @hidden */
  66937. protected _background: string;
  66938. /** @hidden */
  66939. protected _adaptWidthToChildren: boolean;
  66940. /** @hidden */
  66941. protected _adaptHeightToChildren: boolean;
  66942. /**
  66943. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  66944. */
  66945. logLayoutCycleErrors: boolean;
  66946. /**
  66947. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  66948. */
  66949. maxLayoutCycle: number;
  66950. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  66951. adaptHeightToChildren: boolean;
  66952. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  66953. adaptWidthToChildren: boolean;
  66954. /** Gets or sets background color */
  66955. background: string;
  66956. /** Gets the list of children */
  66957. readonly children: Control[];
  66958. /**
  66959. * Creates a new Container
  66960. * @param name defines the name of the container
  66961. */
  66962. constructor(name?: string | undefined);
  66963. protected _getTypeName(): string;
  66964. _flagDescendantsAsMatrixDirty(): void;
  66965. /**
  66966. * Gets a child using its name
  66967. * @param name defines the child name to look for
  66968. * @returns the child control if found
  66969. */
  66970. getChildByName(name: string): BABYLON.Nullable<Control>;
  66971. /**
  66972. * Gets a child using its type and its name
  66973. * @param name defines the child name to look for
  66974. * @param type defines the child type to look for
  66975. * @returns the child control if found
  66976. */
  66977. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  66978. /**
  66979. * Search for a specific control in children
  66980. * @param control defines the control to look for
  66981. * @returns true if the control is in child list
  66982. */
  66983. containsControl(control: Control): boolean;
  66984. /**
  66985. * Adds a new control to the current container
  66986. * @param control defines the control to add
  66987. * @returns the current container
  66988. */
  66989. addControl(control: BABYLON.Nullable<Control>): Container;
  66990. /**
  66991. * Removes all controls from the current container
  66992. * @returns the current container
  66993. */
  66994. clearControls(): Container;
  66995. /**
  66996. * Removes a control from the current container
  66997. * @param control defines the control to remove
  66998. * @returns the current container
  66999. */
  67000. removeControl(control: Control): Container;
  67001. /** @hidden */
  67002. _reOrderControl(control: Control): void;
  67003. /** @hidden */
  67004. _offsetLeft(offset: number): void;
  67005. /** @hidden */
  67006. _offsetTop(offset: number): void;
  67007. /** @hidden */
  67008. _markAllAsDirty(): void;
  67009. /** @hidden */
  67010. protected _localDraw(context: CanvasRenderingContext2D): void;
  67011. /** @hidden */
  67012. _link(host: AdvancedDynamicTexture): void;
  67013. /** @hidden */
  67014. protected _beforeLayout(): void;
  67015. /** @hidden */
  67016. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67017. /** @hidden */
  67018. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  67019. protected _postMeasure(): void;
  67020. /** @hidden */
  67021. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  67022. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  67023. /** @hidden */
  67024. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  67025. /** @hidden */
  67026. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67027. /** Releases associated resources */
  67028. dispose(): void;
  67029. }
  67030. }
  67031. declare module BABYLON.GUI {
  67032. /** Class used to create rectangle container */
  67033. export class Rectangle extends Container {
  67034. name?: string | undefined;
  67035. private _thickness;
  67036. private _cornerRadius;
  67037. /** Gets or sets border thickness */
  67038. thickness: number;
  67039. /** Gets or sets the corner radius angle */
  67040. cornerRadius: number;
  67041. /**
  67042. * Creates a new Rectangle
  67043. * @param name defines the control name
  67044. */
  67045. constructor(name?: string | undefined);
  67046. protected _getTypeName(): string;
  67047. protected _localDraw(context: CanvasRenderingContext2D): void;
  67048. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67049. private _drawRoundedRect;
  67050. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  67051. }
  67052. }
  67053. declare module BABYLON.GUI {
  67054. /**
  67055. * Enum that determines the text-wrapping mode to use.
  67056. */
  67057. export enum TextWrapping {
  67058. /**
  67059. * Clip the text when it's larger than Control.width; this is the default mode.
  67060. */
  67061. Clip = 0,
  67062. /**
  67063. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  67064. */
  67065. WordWrap = 1,
  67066. /**
  67067. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  67068. */
  67069. Ellipsis = 2
  67070. }
  67071. /**
  67072. * Class used to create text block control
  67073. */
  67074. export class TextBlock extends Control {
  67075. /**
  67076. * Defines the name of the control
  67077. */
  67078. name?: string | undefined;
  67079. private _text;
  67080. private _textWrapping;
  67081. private _textHorizontalAlignment;
  67082. private _textVerticalAlignment;
  67083. private _lines;
  67084. private _resizeToFit;
  67085. private _lineSpacing;
  67086. private _outlineWidth;
  67087. private _outlineColor;
  67088. /**
  67089. * An event triggered after the text is changed
  67090. */
  67091. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  67092. /**
  67093. * An event triggered after the text was broken up into lines
  67094. */
  67095. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  67096. /**
  67097. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  67098. */
  67099. readonly lines: any[];
  67100. /**
  67101. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  67102. */
  67103. /**
  67104. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  67105. */
  67106. resizeToFit: boolean;
  67107. /**
  67108. * Gets or sets a boolean indicating if text must be wrapped
  67109. */
  67110. /**
  67111. * Gets or sets a boolean indicating if text must be wrapped
  67112. */
  67113. textWrapping: TextWrapping | boolean;
  67114. /**
  67115. * Gets or sets text to display
  67116. */
  67117. /**
  67118. * Gets or sets text to display
  67119. */
  67120. text: string;
  67121. /**
  67122. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  67123. */
  67124. /**
  67125. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  67126. */
  67127. textHorizontalAlignment: number;
  67128. /**
  67129. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  67130. */
  67131. /**
  67132. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  67133. */
  67134. textVerticalAlignment: number;
  67135. /**
  67136. * Gets or sets line spacing value
  67137. */
  67138. /**
  67139. * Gets or sets line spacing value
  67140. */
  67141. lineSpacing: string | number;
  67142. /**
  67143. * Gets or sets outlineWidth of the text to display
  67144. */
  67145. /**
  67146. * Gets or sets outlineWidth of the text to display
  67147. */
  67148. outlineWidth: number;
  67149. /**
  67150. * Gets or sets outlineColor of the text to display
  67151. */
  67152. /**
  67153. * Gets or sets outlineColor of the text to display
  67154. */
  67155. outlineColor: string;
  67156. /**
  67157. * Creates a new TextBlock object
  67158. * @param name defines the name of the control
  67159. * @param text defines the text to display (emptry string by default)
  67160. */
  67161. constructor(
  67162. /**
  67163. * Defines the name of the control
  67164. */
  67165. name?: string | undefined, text?: string);
  67166. protected _getTypeName(): string;
  67167. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67168. private _drawText;
  67169. /** @hidden */
  67170. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  67171. protected _applyStates(context: CanvasRenderingContext2D): void;
  67172. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  67173. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  67174. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  67175. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  67176. protected _renderLines(context: CanvasRenderingContext2D): void;
  67177. /**
  67178. * Given a width constraint applied on the text block, find the expected height
  67179. * @returns expected height
  67180. */
  67181. computeExpectedHeight(): number;
  67182. dispose(): void;
  67183. }
  67184. }
  67185. declare module BABYLON.GUI {
  67186. /**
  67187. * Class used to create 2D images
  67188. */
  67189. export class Image extends Control {
  67190. name?: string | undefined;
  67191. private _workingCanvas;
  67192. private _domImage;
  67193. private _imageWidth;
  67194. private _imageHeight;
  67195. private _loaded;
  67196. private _stretch;
  67197. private _source;
  67198. private _autoScale;
  67199. private _sourceLeft;
  67200. private _sourceTop;
  67201. private _sourceWidth;
  67202. private _sourceHeight;
  67203. private _cellWidth;
  67204. private _cellHeight;
  67205. private _cellId;
  67206. private _populateNinePatchSlicesFromImage;
  67207. private _sliceLeft;
  67208. private _sliceRight;
  67209. private _sliceTop;
  67210. private _sliceBottom;
  67211. private _detectPointerOnOpaqueOnly;
  67212. /**
  67213. * BABYLON.Observable notified when the content is loaded
  67214. */
  67215. onImageLoadedObservable: BABYLON.Observable<Image>;
  67216. /**
  67217. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  67218. */
  67219. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  67220. /**
  67221. * Gets a boolean indicating that the content is loaded
  67222. */
  67223. readonly isLoaded: boolean;
  67224. /**
  67225. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  67226. */
  67227. populateNinePatchSlicesFromImage: boolean;
  67228. /**
  67229. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  67230. * Beware using this as this will comsume more memory as the image has to be stored twice
  67231. */
  67232. detectPointerOnOpaqueOnly: boolean;
  67233. /**
  67234. * Gets or sets the left value for slicing (9-patch)
  67235. */
  67236. sliceLeft: number;
  67237. /**
  67238. * Gets or sets the right value for slicing (9-patch)
  67239. */
  67240. sliceRight: number;
  67241. /**
  67242. * Gets or sets the top value for slicing (9-patch)
  67243. */
  67244. sliceTop: number;
  67245. /**
  67246. * Gets or sets the bottom value for slicing (9-patch)
  67247. */
  67248. sliceBottom: number;
  67249. /**
  67250. * Gets or sets the left coordinate in the source image
  67251. */
  67252. sourceLeft: number;
  67253. /**
  67254. * Gets or sets the top coordinate in the source image
  67255. */
  67256. sourceTop: number;
  67257. /**
  67258. * Gets or sets the width to capture in the source image
  67259. */
  67260. sourceWidth: number;
  67261. /**
  67262. * Gets or sets the height to capture in the source image
  67263. */
  67264. sourceHeight: number;
  67265. /**
  67266. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  67267. * @see http://doc.babylonjs.com/how_to/gui#image
  67268. */
  67269. autoScale: boolean;
  67270. /** Gets or sets the streching mode used by the image */
  67271. stretch: number;
  67272. /** @hidden */
  67273. _rotate90(n: number): Image;
  67274. /**
  67275. * Gets or sets the internal DOM image used to render the control
  67276. */
  67277. domImage: HTMLImageElement;
  67278. private _onImageLoaded;
  67279. private _extractNinePatchSliceDataFromImage;
  67280. /**
  67281. * Gets or sets image source url
  67282. */
  67283. source: BABYLON.Nullable<string>;
  67284. /**
  67285. * Checks for svg document with icon id present
  67286. */
  67287. private _svgCheck;
  67288. /**
  67289. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  67290. * given external svg file and icon id
  67291. */
  67292. private _getSVGAttribs;
  67293. /**
  67294. * Gets or sets the cell width to use when animation sheet is enabled
  67295. * @see http://doc.babylonjs.com/how_to/gui#image
  67296. */
  67297. cellWidth: number;
  67298. /**
  67299. * Gets or sets the cell height to use when animation sheet is enabled
  67300. * @see http://doc.babylonjs.com/how_to/gui#image
  67301. */
  67302. cellHeight: number;
  67303. /**
  67304. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  67305. * @see http://doc.babylonjs.com/how_to/gui#image
  67306. */
  67307. cellId: number;
  67308. /**
  67309. * Creates a new Image
  67310. * @param name defines the control name
  67311. * @param url defines the image url
  67312. */
  67313. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  67314. /**
  67315. * Tests if a given coordinates belong to the current control
  67316. * @param x defines x coordinate to test
  67317. * @param y defines y coordinate to test
  67318. * @returns true if the coordinates are inside the control
  67319. */
  67320. contains(x: number, y: number): boolean;
  67321. protected _getTypeName(): string;
  67322. /** Force the control to synchronize with its content */
  67323. synchronizeSizeWithContent(): void;
  67324. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67325. private _prepareWorkingCanvasForOpaqueDetection;
  67326. private _drawImage;
  67327. _draw(context: CanvasRenderingContext2D): void;
  67328. private _renderCornerPatch;
  67329. private _renderNinePatch;
  67330. dispose(): void;
  67331. /** STRETCH_NONE */
  67332. static readonly STRETCH_NONE: number;
  67333. /** STRETCH_FILL */
  67334. static readonly STRETCH_FILL: number;
  67335. /** STRETCH_UNIFORM */
  67336. static readonly STRETCH_UNIFORM: number;
  67337. /** STRETCH_EXTEND */
  67338. static readonly STRETCH_EXTEND: number;
  67339. /** NINE_PATCH */
  67340. static readonly STRETCH_NINE_PATCH: number;
  67341. }
  67342. }
  67343. declare module BABYLON.GUI {
  67344. /**
  67345. * Class used to create 2D buttons
  67346. */
  67347. export class Button extends Rectangle {
  67348. name?: string | undefined;
  67349. /**
  67350. * Function called to generate a pointer enter animation
  67351. */
  67352. pointerEnterAnimation: () => void;
  67353. /**
  67354. * Function called to generate a pointer out animation
  67355. */
  67356. pointerOutAnimation: () => void;
  67357. /**
  67358. * Function called to generate a pointer down animation
  67359. */
  67360. pointerDownAnimation: () => void;
  67361. /**
  67362. * Function called to generate a pointer up animation
  67363. */
  67364. pointerUpAnimation: () => void;
  67365. /**
  67366. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  67367. */
  67368. delegatePickingToChildren: boolean;
  67369. private _image;
  67370. /**
  67371. * Returns the image part of the button (if any)
  67372. */
  67373. readonly image: BABYLON.Nullable<Image>;
  67374. private _textBlock;
  67375. /**
  67376. * Returns the image part of the button (if any)
  67377. */
  67378. readonly textBlock: BABYLON.Nullable<TextBlock>;
  67379. /**
  67380. * Creates a new Button
  67381. * @param name defines the name of the button
  67382. */
  67383. constructor(name?: string | undefined);
  67384. protected _getTypeName(): string;
  67385. /** @hidden */
  67386. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  67387. /** @hidden */
  67388. _onPointerEnter(target: Control): boolean;
  67389. /** @hidden */
  67390. _onPointerOut(target: Control, force?: boolean): void;
  67391. /** @hidden */
  67392. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67393. /** @hidden */
  67394. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67395. /**
  67396. * Creates a new button made with an image and a text
  67397. * @param name defines the name of the button
  67398. * @param text defines the text of the button
  67399. * @param imageUrl defines the url of the image
  67400. * @returns a new Button
  67401. */
  67402. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  67403. /**
  67404. * Creates a new button made with an image
  67405. * @param name defines the name of the button
  67406. * @param imageUrl defines the url of the image
  67407. * @returns a new Button
  67408. */
  67409. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  67410. /**
  67411. * Creates a new button made with a text
  67412. * @param name defines the name of the button
  67413. * @param text defines the text of the button
  67414. * @returns a new Button
  67415. */
  67416. static CreateSimpleButton(name: string, text: string): Button;
  67417. /**
  67418. * Creates a new button made with an image and a centered text
  67419. * @param name defines the name of the button
  67420. * @param text defines the text of the button
  67421. * @param imageUrl defines the url of the image
  67422. * @returns a new Button
  67423. */
  67424. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  67425. }
  67426. }
  67427. declare module BABYLON.GUI {
  67428. /**
  67429. * Class used to create a 2D stack panel container
  67430. */
  67431. export class StackPanel extends Container {
  67432. name?: string | undefined;
  67433. private _isVertical;
  67434. private _manualWidth;
  67435. private _manualHeight;
  67436. private _doNotTrackManualChanges;
  67437. /**
  67438. * Gets or sets a boolean indicating that layou warnings should be ignored
  67439. */
  67440. ignoreLayoutWarnings: boolean;
  67441. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  67442. isVertical: boolean;
  67443. /**
  67444. * Gets or sets panel width.
  67445. * This value should not be set when in horizontal mode as it will be computed automatically
  67446. */
  67447. width: string | number;
  67448. /**
  67449. * Gets or sets panel height.
  67450. * This value should not be set when in vertical mode as it will be computed automatically
  67451. */
  67452. height: string | number;
  67453. /**
  67454. * Creates a new StackPanel
  67455. * @param name defines control name
  67456. */
  67457. constructor(name?: string | undefined);
  67458. protected _getTypeName(): string;
  67459. /** @hidden */
  67460. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67461. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67462. protected _postMeasure(): void;
  67463. }
  67464. }
  67465. declare module BABYLON.GUI {
  67466. /**
  67467. * Class used to represent a 2D checkbox
  67468. */
  67469. export class Checkbox extends Control {
  67470. name?: string | undefined;
  67471. private _isChecked;
  67472. private _background;
  67473. private _checkSizeRatio;
  67474. private _thickness;
  67475. /** Gets or sets border thickness */
  67476. thickness: number;
  67477. /**
  67478. * BABYLON.Observable raised when isChecked property changes
  67479. */
  67480. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  67481. /** Gets or sets a value indicating the ratio between overall size and check size */
  67482. checkSizeRatio: number;
  67483. /** Gets or sets background color */
  67484. background: string;
  67485. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  67486. isChecked: boolean;
  67487. /**
  67488. * Creates a new CheckBox
  67489. * @param name defines the control name
  67490. */
  67491. constructor(name?: string | undefined);
  67492. protected _getTypeName(): string;
  67493. /** @hidden */
  67494. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  67495. /** @hidden */
  67496. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67497. /**
  67498. * Utility function to easily create a checkbox with a header
  67499. * @param title defines the label to use for the header
  67500. * @param onValueChanged defines the callback to call when value changes
  67501. * @returns a StackPanel containing the checkbox and a textBlock
  67502. */
  67503. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  67504. }
  67505. }
  67506. declare module BABYLON.GUI {
  67507. /**
  67508. * Class used to store key control properties
  67509. */
  67510. export class KeyPropertySet {
  67511. /** Width */
  67512. width?: string;
  67513. /** Height */
  67514. height?: string;
  67515. /** Left padding */
  67516. paddingLeft?: string;
  67517. /** Right padding */
  67518. paddingRight?: string;
  67519. /** Top padding */
  67520. paddingTop?: string;
  67521. /** Bottom padding */
  67522. paddingBottom?: string;
  67523. /** Foreground color */
  67524. color?: string;
  67525. /** Background color */
  67526. background?: string;
  67527. }
  67528. /**
  67529. * Class used to create virtual keyboard
  67530. */
  67531. export class VirtualKeyboard extends StackPanel {
  67532. /** BABYLON.Observable raised when a key is pressed */
  67533. onKeyPressObservable: BABYLON.Observable<string>;
  67534. /** Gets or sets default key button width */
  67535. defaultButtonWidth: string;
  67536. /** Gets or sets default key button height */
  67537. defaultButtonHeight: string;
  67538. /** Gets or sets default key button left padding */
  67539. defaultButtonPaddingLeft: string;
  67540. /** Gets or sets default key button right padding */
  67541. defaultButtonPaddingRight: string;
  67542. /** Gets or sets default key button top padding */
  67543. defaultButtonPaddingTop: string;
  67544. /** Gets or sets default key button bottom padding */
  67545. defaultButtonPaddingBottom: string;
  67546. /** Gets or sets default key button foreground color */
  67547. defaultButtonColor: string;
  67548. /** Gets or sets default key button background color */
  67549. defaultButtonBackground: string;
  67550. /** Gets or sets shift button foreground color */
  67551. shiftButtonColor: string;
  67552. /** Gets or sets shift button thickness*/
  67553. selectedShiftThickness: number;
  67554. /** Gets shift key state */
  67555. shiftState: number;
  67556. protected _getTypeName(): string;
  67557. private _createKey;
  67558. /**
  67559. * Adds a new row of keys
  67560. * @param keys defines the list of keys to add
  67561. * @param propertySets defines the associated property sets
  67562. */
  67563. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  67564. /**
  67565. * Set the shift key to a specific state
  67566. * @param shiftState defines the new shift state
  67567. */
  67568. applyShiftState(shiftState: number): void;
  67569. private _currentlyConnectedInputText;
  67570. private _connectedInputTexts;
  67571. private _onKeyPressObserver;
  67572. /** Gets the input text control currently attached to the keyboard */
  67573. readonly connectedInputText: BABYLON.Nullable<InputText>;
  67574. /**
  67575. * Connects the keyboard with an input text control
  67576. *
  67577. * @param input defines the target control
  67578. */
  67579. connect(input: InputText): void;
  67580. /**
  67581. * Disconnects the keyboard from connected InputText controls
  67582. *
  67583. * @param input optionally defines a target control, otherwise all are disconnected
  67584. */
  67585. disconnect(input?: InputText): void;
  67586. private _removeConnectedInputObservables;
  67587. /**
  67588. * Release all resources
  67589. */
  67590. dispose(): void;
  67591. /**
  67592. * Creates a new keyboard using a default layout
  67593. *
  67594. * @param name defines control name
  67595. * @returns a new VirtualKeyboard
  67596. */
  67597. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  67598. }
  67599. }
  67600. declare module BABYLON.GUI {
  67601. /**
  67602. * Class used to create input text control
  67603. */
  67604. export class InputText extends Control implements IFocusableControl {
  67605. name?: string | undefined;
  67606. private _text;
  67607. private _placeholderText;
  67608. private _background;
  67609. private _focusedBackground;
  67610. private _focusedColor;
  67611. private _placeholderColor;
  67612. private _thickness;
  67613. private _margin;
  67614. private _autoStretchWidth;
  67615. private _maxWidth;
  67616. private _isFocused;
  67617. private _blinkTimeout;
  67618. private _blinkIsEven;
  67619. private _cursorOffset;
  67620. private _scrollLeft;
  67621. private _textWidth;
  67622. private _clickedCoordinate;
  67623. private _deadKey;
  67624. private _addKey;
  67625. private _currentKey;
  67626. private _isTextHighlightOn;
  67627. private _textHighlightColor;
  67628. private _highligherOpacity;
  67629. private _highlightedText;
  67630. private _startHighlightIndex;
  67631. private _endHighlightIndex;
  67632. private _cursorIndex;
  67633. private _onFocusSelectAll;
  67634. private _isPointerDown;
  67635. private _onClipboardObserver;
  67636. private _onPointerDblTapObserver;
  67637. /** @hidden */
  67638. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  67639. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  67640. promptMessage: string;
  67641. /** Force disable prompt on mobile device */
  67642. disableMobilePrompt: boolean;
  67643. /** BABYLON.Observable raised when the text changes */
  67644. onTextChangedObservable: BABYLON.Observable<InputText>;
  67645. /** BABYLON.Observable raised just before an entered character is to be added */
  67646. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  67647. /** BABYLON.Observable raised when the control gets the focus */
  67648. onFocusObservable: BABYLON.Observable<InputText>;
  67649. /** BABYLON.Observable raised when the control loses the focus */
  67650. onBlurObservable: BABYLON.Observable<InputText>;
  67651. /**Observable raised when the text is highlighted */
  67652. onTextHighlightObservable: BABYLON.Observable<InputText>;
  67653. /**Observable raised when copy event is triggered */
  67654. onTextCopyObservable: BABYLON.Observable<InputText>;
  67655. /** BABYLON.Observable raised when cut event is triggered */
  67656. onTextCutObservable: BABYLON.Observable<InputText>;
  67657. /** BABYLON.Observable raised when paste event is triggered */
  67658. onTextPasteObservable: BABYLON.Observable<InputText>;
  67659. /** BABYLON.Observable raised when a key event was processed */
  67660. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  67661. /** Gets or sets the maximum width allowed by the control */
  67662. maxWidth: string | number;
  67663. /** Gets the maximum width allowed by the control in pixels */
  67664. readonly maxWidthInPixels: number;
  67665. /** Gets or sets the text highlighter transparency; default: 0.4 */
  67666. highligherOpacity: number;
  67667. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  67668. onFocusSelectAll: boolean;
  67669. /** Gets or sets the text hightlight color */
  67670. textHighlightColor: string;
  67671. /** Gets or sets control margin */
  67672. margin: string;
  67673. /** Gets control margin in pixels */
  67674. readonly marginInPixels: number;
  67675. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  67676. autoStretchWidth: boolean;
  67677. /** Gets or sets border thickness */
  67678. thickness: number;
  67679. /** Gets or sets the background color when focused */
  67680. focusedBackground: string;
  67681. /** Gets or sets the background color when focused */
  67682. focusedColor: string;
  67683. /** Gets or sets the background color */
  67684. background: string;
  67685. /** Gets or sets the placeholder color */
  67686. placeholderColor: string;
  67687. /** Gets or sets the text displayed when the control is empty */
  67688. placeholderText: string;
  67689. /** Gets or sets the dead key flag */
  67690. deadKey: boolean;
  67691. /** Gets or sets the highlight text */
  67692. highlightedText: string;
  67693. /** Gets or sets if the current key should be added */
  67694. addKey: boolean;
  67695. /** Gets or sets the value of the current key being entered */
  67696. currentKey: string;
  67697. /** Gets or sets the text displayed in the control */
  67698. text: string;
  67699. /** Gets or sets control width */
  67700. width: string | number;
  67701. /**
  67702. * Creates a new InputText
  67703. * @param name defines the control name
  67704. * @param text defines the text of the control
  67705. */
  67706. constructor(name?: string | undefined, text?: string);
  67707. /** @hidden */
  67708. onBlur(): void;
  67709. /** @hidden */
  67710. onFocus(): void;
  67711. protected _getTypeName(): string;
  67712. /**
  67713. * Function called to get the list of controls that should not steal the focus from this control
  67714. * @returns an array of controls
  67715. */
  67716. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  67717. /** @hidden */
  67718. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  67719. /** @hidden */
  67720. private _updateValueFromCursorIndex;
  67721. /** @hidden */
  67722. private _processDblClick;
  67723. /** @hidden */
  67724. private _selectAllText;
  67725. /**
  67726. * Handles the keyboard event
  67727. * @param evt Defines the KeyboardEvent
  67728. */
  67729. processKeyboard(evt: KeyboardEvent): void;
  67730. /** @hidden */
  67731. private _onCopyText;
  67732. /** @hidden */
  67733. private _onCutText;
  67734. /** @hidden */
  67735. private _onPasteText;
  67736. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  67737. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67738. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  67739. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67740. protected _beforeRenderText(text: string): string;
  67741. dispose(): void;
  67742. }
  67743. }
  67744. declare module BABYLON.GUI {
  67745. /**
  67746. * Class used to create a 2D grid container
  67747. */
  67748. export class Grid extends Container {
  67749. name?: string | undefined;
  67750. private _rowDefinitions;
  67751. private _columnDefinitions;
  67752. private _cells;
  67753. private _childControls;
  67754. /**
  67755. * Gets the number of columns
  67756. */
  67757. readonly columnCount: number;
  67758. /**
  67759. * Gets the number of rows
  67760. */
  67761. readonly rowCount: number;
  67762. /** Gets the list of children */
  67763. readonly children: Control[];
  67764. /** Gets the list of cells (e.g. the containers) */
  67765. readonly cells: {
  67766. [key: string]: Container;
  67767. };
  67768. /**
  67769. * Gets the definition of a specific row
  67770. * @param index defines the index of the row
  67771. * @returns the row definition
  67772. */
  67773. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  67774. /**
  67775. * Gets the definition of a specific column
  67776. * @param index defines the index of the column
  67777. * @returns the column definition
  67778. */
  67779. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  67780. /**
  67781. * Adds a new row to the grid
  67782. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  67783. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  67784. * @returns the current grid
  67785. */
  67786. addRowDefinition(height: number, isPixel?: boolean): Grid;
  67787. /**
  67788. * Adds a new column to the grid
  67789. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  67790. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  67791. * @returns the current grid
  67792. */
  67793. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  67794. /**
  67795. * Update a row definition
  67796. * @param index defines the index of the row to update
  67797. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  67798. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  67799. * @returns the current grid
  67800. */
  67801. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  67802. /**
  67803. * Update a column definition
  67804. * @param index defines the index of the column to update
  67805. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  67806. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  67807. * @returns the current grid
  67808. */
  67809. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  67810. /**
  67811. * Gets the list of children stored in a specific cell
  67812. * @param row defines the row to check
  67813. * @param column defines the column to check
  67814. * @returns the list of controls
  67815. */
  67816. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  67817. /**
  67818. * Gets a string representing the child cell info (row x column)
  67819. * @param child defines the control to get info from
  67820. * @returns a string containing the child cell info (row x column)
  67821. */
  67822. getChildCellInfo(child: Control): string;
  67823. private _removeCell;
  67824. private _offsetCell;
  67825. /**
  67826. * Remove a column definition at specified index
  67827. * @param index defines the index of the column to remove
  67828. * @returns the current grid
  67829. */
  67830. removeColumnDefinition(index: number): Grid;
  67831. /**
  67832. * Remove a row definition at specified index
  67833. * @param index defines the index of the row to remove
  67834. * @returns the current grid
  67835. */
  67836. removeRowDefinition(index: number): Grid;
  67837. /**
  67838. * Adds a new control to the current grid
  67839. * @param control defines the control to add
  67840. * @param row defines the row where to add the control (0 by default)
  67841. * @param column defines the column where to add the control (0 by default)
  67842. * @returns the current grid
  67843. */
  67844. addControl(control: Control, row?: number, column?: number): Grid;
  67845. /**
  67846. * Removes a control from the current container
  67847. * @param control defines the control to remove
  67848. * @returns the current container
  67849. */
  67850. removeControl(control: Control): Container;
  67851. /**
  67852. * Creates a new Grid
  67853. * @param name defines control name
  67854. */
  67855. constructor(name?: string | undefined);
  67856. protected _getTypeName(): string;
  67857. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  67858. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67859. _flagDescendantsAsMatrixDirty(): void;
  67860. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  67861. /** Releases associated resources */
  67862. dispose(): void;
  67863. }
  67864. }
  67865. declare module BABYLON.GUI {
  67866. /** Class used to create color pickers */
  67867. export class ColorPicker extends Control {
  67868. name?: string | undefined;
  67869. private static _Epsilon;
  67870. private _colorWheelCanvas;
  67871. private _value;
  67872. private _tmpColor;
  67873. private _pointerStartedOnSquare;
  67874. private _pointerStartedOnWheel;
  67875. private _squareLeft;
  67876. private _squareTop;
  67877. private _squareSize;
  67878. private _h;
  67879. private _s;
  67880. private _v;
  67881. private _lastPointerDownID;
  67882. /**
  67883. * BABYLON.Observable raised when the value changes
  67884. */
  67885. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  67886. /** Gets or sets the color of the color picker */
  67887. value: BABYLON.Color3;
  67888. /**
  67889. * Gets or sets control width
  67890. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67891. */
  67892. width: string | number;
  67893. /**
  67894. * Gets or sets control height
  67895. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67896. */
  67897. /** Gets or sets control height */
  67898. height: string | number;
  67899. /** Gets or sets control size */
  67900. size: string | number;
  67901. /**
  67902. * Creates a new ColorPicker
  67903. * @param name defines the control name
  67904. */
  67905. constructor(name?: string | undefined);
  67906. protected _getTypeName(): string;
  67907. /** @hidden */
  67908. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67909. private _updateSquareProps;
  67910. private _drawGradientSquare;
  67911. private _drawCircle;
  67912. private _createColorWheelCanvas;
  67913. /** @hidden */
  67914. _draw(context: CanvasRenderingContext2D): void;
  67915. private _pointerIsDown;
  67916. private _updateValueFromPointer;
  67917. private _isPointOnSquare;
  67918. private _isPointOnWheel;
  67919. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67920. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  67921. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67922. /**
  67923. * This function expands the color picker by creating a color picker dialog with manual
  67924. * color value input and the ability to save colors into an array to be used later in
  67925. * subsequent launches of the dialogue.
  67926. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  67927. * @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.
  67928. * @returns picked color as a hex string and the saved colors array as hex strings.
  67929. */
  67930. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  67931. pickerWidth?: string;
  67932. pickerHeight?: string;
  67933. headerHeight?: string;
  67934. lastColor?: string;
  67935. swatchLimit?: number;
  67936. numSwatchesPerLine?: number;
  67937. savedColors?: Array<string>;
  67938. }): Promise<{
  67939. savedColors?: string[];
  67940. pickedColor: string;
  67941. }>;
  67942. }
  67943. }
  67944. declare module BABYLON.GUI {
  67945. /** Class used to create 2D ellipse containers */
  67946. export class Ellipse extends Container {
  67947. name?: string | undefined;
  67948. private _thickness;
  67949. /** Gets or sets border thickness */
  67950. thickness: number;
  67951. /**
  67952. * Creates a new Ellipse
  67953. * @param name defines the control name
  67954. */
  67955. constructor(name?: string | undefined);
  67956. protected _getTypeName(): string;
  67957. protected _localDraw(context: CanvasRenderingContext2D): void;
  67958. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67959. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  67960. }
  67961. }
  67962. declare module BABYLON.GUI {
  67963. /**
  67964. * Class used to create a password control
  67965. */
  67966. export class InputPassword extends InputText {
  67967. protected _beforeRenderText(text: string): string;
  67968. }
  67969. }
  67970. declare module BABYLON.GUI {
  67971. /** Class used to render 2D lines */
  67972. export class Line extends Control {
  67973. name?: string | undefined;
  67974. private _lineWidth;
  67975. private _x1;
  67976. private _y1;
  67977. private _x2;
  67978. private _y2;
  67979. private _dash;
  67980. private _connectedControl;
  67981. private _connectedControlDirtyObserver;
  67982. /** Gets or sets the dash pattern */
  67983. dash: Array<number>;
  67984. /** Gets or sets the control connected with the line end */
  67985. connectedControl: Control;
  67986. /** Gets or sets start coordinates on X axis */
  67987. x1: string | number;
  67988. /** Gets or sets start coordinates on Y axis */
  67989. y1: string | number;
  67990. /** Gets or sets end coordinates on X axis */
  67991. x2: string | number;
  67992. /** Gets or sets end coordinates on Y axis */
  67993. y2: string | number;
  67994. /** Gets or sets line width */
  67995. lineWidth: number;
  67996. /** Gets or sets horizontal alignment */
  67997. horizontalAlignment: number;
  67998. /** Gets or sets vertical alignment */
  67999. verticalAlignment: number;
  68000. private readonly _effectiveX2;
  68001. private readonly _effectiveY2;
  68002. /**
  68003. * Creates a new Line
  68004. * @param name defines the control name
  68005. */
  68006. constructor(name?: string | undefined);
  68007. protected _getTypeName(): string;
  68008. _draw(context: CanvasRenderingContext2D): void;
  68009. _measure(): void;
  68010. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68011. /**
  68012. * Move one end of the line given 3D cartesian coordinates.
  68013. * @param position Targeted world position
  68014. * @param scene BABYLON.Scene
  68015. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  68016. */
  68017. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  68018. /**
  68019. * Move one end of the line to a position in screen absolute space.
  68020. * @param projectedPosition Position in screen absolute space (X, Y)
  68021. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  68022. */
  68023. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  68024. }
  68025. }
  68026. declare module BABYLON.GUI {
  68027. /**
  68028. * Class used to store a point for a MultiLine object.
  68029. * The point can be pure 2D coordinates, a mesh or a control
  68030. */
  68031. export class MultiLinePoint {
  68032. private _multiLine;
  68033. private _x;
  68034. private _y;
  68035. private _control;
  68036. private _mesh;
  68037. private _controlObserver;
  68038. private _meshObserver;
  68039. /** @hidden */
  68040. _point: BABYLON.Vector2;
  68041. /**
  68042. * Creates a new MultiLinePoint
  68043. * @param multiLine defines the source MultiLine object
  68044. */
  68045. constructor(multiLine: MultiLine);
  68046. /** Gets or sets x coordinate */
  68047. x: string | number;
  68048. /** Gets or sets y coordinate */
  68049. y: string | number;
  68050. /** Gets or sets the control associated with this point */
  68051. control: BABYLON.Nullable<Control>;
  68052. /** Gets or sets the mesh associated with this point */
  68053. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  68054. /** Resets links */
  68055. resetLinks(): void;
  68056. /**
  68057. * Gets a translation vector
  68058. * @returns the translation vector
  68059. */
  68060. translate(): BABYLON.Vector2;
  68061. private _translatePoint;
  68062. /** Release associated resources */
  68063. dispose(): void;
  68064. }
  68065. }
  68066. declare module BABYLON.GUI {
  68067. /**
  68068. * Class used to create multi line control
  68069. */
  68070. export class MultiLine extends Control {
  68071. name?: string | undefined;
  68072. private _lineWidth;
  68073. private _dash;
  68074. private _points;
  68075. private _minX;
  68076. private _minY;
  68077. private _maxX;
  68078. private _maxY;
  68079. /**
  68080. * Creates a new MultiLine
  68081. * @param name defines the control name
  68082. */
  68083. constructor(name?: string | undefined);
  68084. /** Gets or sets dash pattern */
  68085. dash: Array<number>;
  68086. /**
  68087. * Gets point stored at specified index
  68088. * @param index defines the index to look for
  68089. * @returns the requested point if found
  68090. */
  68091. getAt(index: number): MultiLinePoint;
  68092. /** Function called when a point is updated */
  68093. onPointUpdate: () => void;
  68094. /**
  68095. * Adds new points to the point collection
  68096. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  68097. * @returns the list of created MultiLinePoint
  68098. */
  68099. add(...items: (AbstractMesh | Control | {
  68100. x: string | number;
  68101. y: string | number;
  68102. })[]): MultiLinePoint[];
  68103. /**
  68104. * Adds a new point to the point collection
  68105. * @param item defines the item (mesh, control or 2d coordiantes) to add
  68106. * @returns the created MultiLinePoint
  68107. */
  68108. push(item?: (AbstractMesh | Control | {
  68109. x: string | number;
  68110. y: string | number;
  68111. })): MultiLinePoint;
  68112. /**
  68113. * Remove a specific value or point from the active point collection
  68114. * @param value defines the value or point to remove
  68115. */
  68116. remove(value: number | MultiLinePoint): void;
  68117. /**
  68118. * Resets this object to initial state (no point)
  68119. */
  68120. reset(): void;
  68121. /**
  68122. * Resets all links
  68123. */
  68124. resetLinks(): void;
  68125. /** Gets or sets line width */
  68126. lineWidth: number;
  68127. horizontalAlignment: number;
  68128. verticalAlignment: number;
  68129. protected _getTypeName(): string;
  68130. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68131. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68132. _measure(): void;
  68133. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68134. dispose(): void;
  68135. }
  68136. }
  68137. declare module BABYLON.GUI {
  68138. /**
  68139. * Class used to create radio button controls
  68140. */
  68141. export class RadioButton extends Control {
  68142. name?: string | undefined;
  68143. private _isChecked;
  68144. private _background;
  68145. private _checkSizeRatio;
  68146. private _thickness;
  68147. /** Gets or sets border thickness */
  68148. thickness: number;
  68149. /** Gets or sets group name */
  68150. group: string;
  68151. /** BABYLON.Observable raised when isChecked is changed */
  68152. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  68153. /** Gets or sets a value indicating the ratio between overall size and check size */
  68154. checkSizeRatio: number;
  68155. /** Gets or sets background color */
  68156. background: string;
  68157. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  68158. isChecked: boolean;
  68159. /**
  68160. * Creates a new RadioButton
  68161. * @param name defines the control name
  68162. */
  68163. constructor(name?: string | undefined);
  68164. protected _getTypeName(): string;
  68165. _draw(context: CanvasRenderingContext2D): void;
  68166. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68167. /**
  68168. * Utility function to easily create a radio button with a header
  68169. * @param title defines the label to use for the header
  68170. * @param group defines the group to use for the radio button
  68171. * @param isChecked defines the initial state of the radio button
  68172. * @param onValueChanged defines the callback to call when value changes
  68173. * @returns a StackPanel containing the radio button and a textBlock
  68174. */
  68175. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  68176. }
  68177. }
  68178. declare module BABYLON.GUI {
  68179. /**
  68180. * Class used to create slider controls
  68181. */
  68182. export class BaseSlider extends Control {
  68183. name?: string | undefined;
  68184. protected _thumbWidth: ValueAndUnit;
  68185. private _minimum;
  68186. private _maximum;
  68187. private _value;
  68188. private _isVertical;
  68189. protected _barOffset: ValueAndUnit;
  68190. private _isThumbClamped;
  68191. protected _displayThumb: boolean;
  68192. private _step;
  68193. private _lastPointerDownID;
  68194. protected _effectiveBarOffset: number;
  68195. protected _renderLeft: number;
  68196. protected _renderTop: number;
  68197. protected _renderWidth: number;
  68198. protected _renderHeight: number;
  68199. protected _backgroundBoxLength: number;
  68200. protected _backgroundBoxThickness: number;
  68201. protected _effectiveThumbThickness: number;
  68202. /** BABYLON.Observable raised when the sldier value changes */
  68203. onValueChangedObservable: BABYLON.Observable<number>;
  68204. /** Gets or sets a boolean indicating if the thumb must be rendered */
  68205. displayThumb: boolean;
  68206. /** Gets or sets a step to apply to values (0 by default) */
  68207. step: number;
  68208. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  68209. barOffset: string | number;
  68210. /** Gets main bar offset in pixels*/
  68211. readonly barOffsetInPixels: number;
  68212. /** Gets or sets thumb width */
  68213. thumbWidth: string | number;
  68214. /** Gets thumb width in pixels */
  68215. readonly thumbWidthInPixels: number;
  68216. /** Gets or sets minimum value */
  68217. minimum: number;
  68218. /** Gets or sets maximum value */
  68219. maximum: number;
  68220. /** Gets or sets current value */
  68221. value: number;
  68222. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  68223. isVertical: boolean;
  68224. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  68225. isThumbClamped: boolean;
  68226. /**
  68227. * Creates a new BaseSlider
  68228. * @param name defines the control name
  68229. */
  68230. constructor(name?: string | undefined);
  68231. protected _getTypeName(): string;
  68232. protected _getThumbPosition(): number;
  68233. protected _getThumbThickness(type: string): number;
  68234. protected _prepareRenderingData(type: string): void;
  68235. private _pointerIsDown;
  68236. /** @hidden */
  68237. protected _updateValueFromPointer(x: number, y: number): void;
  68238. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68239. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  68240. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  68241. }
  68242. }
  68243. declare module BABYLON.GUI {
  68244. /**
  68245. * Class used to create slider controls
  68246. */
  68247. export class Slider extends BaseSlider {
  68248. name?: string | undefined;
  68249. private _background;
  68250. private _borderColor;
  68251. private _isThumbCircle;
  68252. protected _displayValueBar: boolean;
  68253. /** Gets or sets a boolean indicating if the value bar must be rendered */
  68254. displayValueBar: boolean;
  68255. /** Gets or sets border color */
  68256. borderColor: string;
  68257. /** Gets or sets background color */
  68258. background: string;
  68259. /** Gets or sets a boolean indicating if the thumb should be round or square */
  68260. isThumbCircle: boolean;
  68261. /**
  68262. * Creates a new Slider
  68263. * @param name defines the control name
  68264. */
  68265. constructor(name?: string | undefined);
  68266. protected _getTypeName(): string;
  68267. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68268. }
  68269. }
  68270. declare module BABYLON.GUI {
  68271. /** Class used to create a RadioGroup
  68272. * which contains groups of radio buttons
  68273. */
  68274. export class SelectorGroup {
  68275. /** name of SelectorGroup */
  68276. name: string;
  68277. private _groupPanel;
  68278. private _selectors;
  68279. private _groupHeader;
  68280. /**
  68281. * Creates a new SelectorGroup
  68282. * @param name of group, used as a group heading
  68283. */
  68284. constructor(
  68285. /** name of SelectorGroup */
  68286. name: string);
  68287. /** Gets the groupPanel of the SelectorGroup */
  68288. readonly groupPanel: StackPanel;
  68289. /** Gets the selectors array */
  68290. readonly selectors: StackPanel[];
  68291. /** Gets and sets the group header */
  68292. header: string;
  68293. /** @hidden */
  68294. private _addGroupHeader;
  68295. /** @hidden*/
  68296. _getSelector(selectorNb: number): StackPanel | undefined;
  68297. /** Removes the selector at the given position
  68298. * @param selectorNb the position of the selector within the group
  68299. */
  68300. removeSelector(selectorNb: number): void;
  68301. }
  68302. /** Class used to create a CheckboxGroup
  68303. * which contains groups of checkbox buttons
  68304. */
  68305. export class CheckboxGroup extends SelectorGroup {
  68306. /** Adds a checkbox as a control
  68307. * @param text is the label for the selector
  68308. * @param func is the function called when the Selector is checked
  68309. * @param checked is true when Selector is checked
  68310. */
  68311. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  68312. /** @hidden */
  68313. _setSelectorLabel(selectorNb: number, label: string): void;
  68314. /** @hidden */
  68315. _setSelectorLabelColor(selectorNb: number, color: string): void;
  68316. /** @hidden */
  68317. _setSelectorButtonColor(selectorNb: number, color: string): void;
  68318. /** @hidden */
  68319. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  68320. }
  68321. /** Class used to create a RadioGroup
  68322. * which contains groups of radio buttons
  68323. */
  68324. export class RadioGroup extends SelectorGroup {
  68325. private _selectNb;
  68326. /** Adds a radio button as a control
  68327. * @param label is the label for the selector
  68328. * @param func is the function called when the Selector is checked
  68329. * @param checked is true when Selector is checked
  68330. */
  68331. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  68332. /** @hidden */
  68333. _setSelectorLabel(selectorNb: number, label: string): void;
  68334. /** @hidden */
  68335. _setSelectorLabelColor(selectorNb: number, color: string): void;
  68336. /** @hidden */
  68337. _setSelectorButtonColor(selectorNb: number, color: string): void;
  68338. /** @hidden */
  68339. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  68340. }
  68341. /** Class used to create a SliderGroup
  68342. * which contains groups of slider buttons
  68343. */
  68344. export class SliderGroup extends SelectorGroup {
  68345. /**
  68346. * Adds a slider to the SelectorGroup
  68347. * @param label is the label for the SliderBar
  68348. * @param func is the function called when the Slider moves
  68349. * @param unit is a string describing the units used, eg degrees or metres
  68350. * @param min is the minimum value for the Slider
  68351. * @param max is the maximum value for the Slider
  68352. * @param value is the start value for the Slider between min and max
  68353. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  68354. */
  68355. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  68356. /** @hidden */
  68357. _setSelectorLabel(selectorNb: number, label: string): void;
  68358. /** @hidden */
  68359. _setSelectorLabelColor(selectorNb: number, color: string): void;
  68360. /** @hidden */
  68361. _setSelectorButtonColor(selectorNb: number, color: string): void;
  68362. /** @hidden */
  68363. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  68364. }
  68365. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  68366. * @see http://doc.babylonjs.com/how_to/selector
  68367. */
  68368. export class SelectionPanel extends Rectangle {
  68369. /** name of SelectionPanel */
  68370. name: string;
  68371. /** an array of SelectionGroups */
  68372. groups: SelectorGroup[];
  68373. private _panel;
  68374. private _buttonColor;
  68375. private _buttonBackground;
  68376. private _headerColor;
  68377. private _barColor;
  68378. private _barHeight;
  68379. private _spacerHeight;
  68380. private _labelColor;
  68381. private _groups;
  68382. private _bars;
  68383. /**
  68384. * Creates a new SelectionPanel
  68385. * @param name of SelectionPanel
  68386. * @param groups is an array of SelectionGroups
  68387. */
  68388. constructor(
  68389. /** name of SelectionPanel */
  68390. name: string,
  68391. /** an array of SelectionGroups */
  68392. groups?: SelectorGroup[]);
  68393. protected _getTypeName(): string;
  68394. /** Gets or sets the headerColor */
  68395. headerColor: string;
  68396. private _setHeaderColor;
  68397. /** Gets or sets the button color */
  68398. buttonColor: string;
  68399. private _setbuttonColor;
  68400. /** Gets or sets the label color */
  68401. labelColor: string;
  68402. private _setLabelColor;
  68403. /** Gets or sets the button background */
  68404. buttonBackground: string;
  68405. private _setButtonBackground;
  68406. /** Gets or sets the color of separator bar */
  68407. barColor: string;
  68408. private _setBarColor;
  68409. /** Gets or sets the height of separator bar */
  68410. barHeight: string;
  68411. private _setBarHeight;
  68412. /** Gets or sets the height of spacers*/
  68413. spacerHeight: string;
  68414. private _setSpacerHeight;
  68415. /** Adds a bar between groups */
  68416. private _addSpacer;
  68417. /** Add a group to the selection panel
  68418. * @param group is the selector group to add
  68419. */
  68420. addGroup(group: SelectorGroup): void;
  68421. /** Remove the group from the given position
  68422. * @param groupNb is the position of the group in the list
  68423. */
  68424. removeGroup(groupNb: number): void;
  68425. /** Change a group header label
  68426. * @param label is the new group header label
  68427. * @param groupNb is the number of the group to relabel
  68428. * */
  68429. setHeaderName(label: string, groupNb: number): void;
  68430. /** Change selector label to the one given
  68431. * @param label is the new selector label
  68432. * @param groupNb is the number of the groupcontaining the selector
  68433. * @param selectorNb is the number of the selector within a group to relabel
  68434. * */
  68435. relabel(label: string, groupNb: number, selectorNb: number): void;
  68436. /** For a given group position remove the selector at the given position
  68437. * @param groupNb is the number of the group to remove the selector from
  68438. * @param selectorNb is the number of the selector within the group
  68439. */
  68440. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  68441. /** For a given group position of correct type add a checkbox button
  68442. * @param groupNb is the number of the group to remove the selector from
  68443. * @param label is the label for the selector
  68444. * @param func is the function called when the Selector is checked
  68445. * @param checked is true when Selector is checked
  68446. */
  68447. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  68448. /** For a given group position of correct type add a radio button
  68449. * @param groupNb is the number of the group to remove the selector from
  68450. * @param label is the label for the selector
  68451. * @param func is the function called when the Selector is checked
  68452. * @param checked is true when Selector is checked
  68453. */
  68454. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  68455. /**
  68456. * For a given slider group add a slider
  68457. * @param groupNb is the number of the group to add the slider to
  68458. * @param label is the label for the Slider
  68459. * @param func is the function called when the Slider moves
  68460. * @param unit is a string describing the units used, eg degrees or metres
  68461. * @param min is the minimum value for the Slider
  68462. * @param max is the maximum value for the Slider
  68463. * @param value is the start value for the Slider between min and max
  68464. * @param onVal is the function used to format the value displayed, eg radians to degrees
  68465. */
  68466. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  68467. }
  68468. }
  68469. declare module BABYLON.GUI {
  68470. /**
  68471. * Class used to hold a the container for ScrollViewer
  68472. * @hidden
  68473. */
  68474. export class _ScrollViewerWindow extends Container {
  68475. parentClientWidth: number;
  68476. parentClientHeight: number;
  68477. /**
  68478. * Creates a new ScrollViewerWindow
  68479. * @param name of ScrollViewerWindow
  68480. */
  68481. constructor(name?: string);
  68482. protected _getTypeName(): string;
  68483. /** @hidden */
  68484. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68485. protected _postMeasure(): void;
  68486. }
  68487. }
  68488. declare module BABYLON.GUI {
  68489. /**
  68490. * Class used to create slider controls
  68491. */
  68492. export class ScrollBar extends BaseSlider {
  68493. name?: string | undefined;
  68494. private _background;
  68495. private _borderColor;
  68496. private _tempMeasure;
  68497. /** Gets or sets border color */
  68498. borderColor: string;
  68499. /** Gets or sets background color */
  68500. background: string;
  68501. /**
  68502. * Creates a new Slider
  68503. * @param name defines the control name
  68504. */
  68505. constructor(name?: string | undefined);
  68506. protected _getTypeName(): string;
  68507. protected _getThumbThickness(): number;
  68508. _draw(context: CanvasRenderingContext2D): void;
  68509. private _first;
  68510. private _originX;
  68511. private _originY;
  68512. /** @hidden */
  68513. protected _updateValueFromPointer(x: number, y: number): void;
  68514. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68515. }
  68516. }
  68517. declare module BABYLON.GUI {
  68518. /**
  68519. * Class used to create slider controls
  68520. */
  68521. export class ImageScrollBar extends BaseSlider {
  68522. name?: string | undefined;
  68523. private _backgroundBaseImage;
  68524. private _backgroundImage;
  68525. private _thumbImage;
  68526. private _thumbBaseImage;
  68527. private _thumbLength;
  68528. private _thumbHeight;
  68529. private _barImageHeight;
  68530. private _tempMeasure;
  68531. /**
  68532. * Gets or sets the image used to render the background for horizontal bar
  68533. */
  68534. backgroundImage: Image;
  68535. /**
  68536. * Gets or sets the image used to render the thumb
  68537. */
  68538. thumbImage: Image;
  68539. /**
  68540. * Gets or sets the length of the thumb
  68541. */
  68542. thumbLength: number;
  68543. /**
  68544. * Gets or sets the height of the thumb
  68545. */
  68546. thumbHeight: number;
  68547. /**
  68548. * Gets or sets the height of the bar image
  68549. */
  68550. barImageHeight: number;
  68551. /**
  68552. * Creates a new ImageScrollBar
  68553. * @param name defines the control name
  68554. */
  68555. constructor(name?: string | undefined);
  68556. protected _getTypeName(): string;
  68557. protected _getThumbThickness(): number;
  68558. _draw(context: CanvasRenderingContext2D): void;
  68559. private _first;
  68560. private _originX;
  68561. private _originY;
  68562. /** @hidden */
  68563. protected _updateValueFromPointer(x: number, y: number): void;
  68564. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68565. }
  68566. }
  68567. declare module BABYLON.GUI {
  68568. /**
  68569. * Class used to hold a viewer window and sliders in a grid
  68570. */
  68571. export class ScrollViewer extends Rectangle {
  68572. private _grid;
  68573. private _horizontalBarSpace;
  68574. private _verticalBarSpace;
  68575. private _dragSpace;
  68576. private _horizontalBar;
  68577. private _verticalBar;
  68578. private _barColor;
  68579. private _barBackground;
  68580. private _barImage;
  68581. private _barBackgroundImage;
  68582. private _barSize;
  68583. private _endLeft;
  68584. private _endTop;
  68585. private _window;
  68586. private _pointerIsOver;
  68587. private _wheelPrecision;
  68588. private _onPointerObserver;
  68589. private _clientWidth;
  68590. private _clientHeight;
  68591. private _useImageBar;
  68592. private _thumbLength;
  68593. private _thumbHeight;
  68594. private _barImageHeight;
  68595. /**
  68596. * Gets the horizontal scrollbar
  68597. */
  68598. readonly horizontalBar: ScrollBar | ImageScrollBar;
  68599. /**
  68600. * Gets the vertical scrollbar
  68601. */
  68602. readonly verticalBar: ScrollBar | ImageScrollBar;
  68603. /**
  68604. * Adds a new control to the current container
  68605. * @param control defines the control to add
  68606. * @returns the current container
  68607. */
  68608. addControl(control: BABYLON.Nullable<Control>): Container;
  68609. /**
  68610. * Removes a control from the current container
  68611. * @param control defines the control to remove
  68612. * @returns the current container
  68613. */
  68614. removeControl(control: Control): Container;
  68615. /** Gets the list of children */
  68616. readonly children: Control[];
  68617. _flagDescendantsAsMatrixDirty(): void;
  68618. /**
  68619. * Creates a new ScrollViewer
  68620. * @param name of ScrollViewer
  68621. */
  68622. constructor(name?: string, isImageBased?: boolean);
  68623. /** Reset the scroll viewer window to initial size */
  68624. resetWindow(): void;
  68625. protected _getTypeName(): string;
  68626. private _buildClientSizes;
  68627. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68628. protected _postMeasure(): void;
  68629. /**
  68630. * Gets or sets the mouse wheel precision
  68631. * from 0 to 1 with a default value of 0.05
  68632. * */
  68633. wheelPrecision: number;
  68634. /** Gets or sets the scroll bar container background color */
  68635. scrollBackground: string;
  68636. /** Gets or sets the bar color */
  68637. barColor: string;
  68638. /** Gets or sets the bar image */
  68639. thumbImage: Image;
  68640. /** Gets or sets the size of the bar */
  68641. barSize: number;
  68642. /** Gets or sets the length of the thumb */
  68643. thumbLength: number;
  68644. /** Gets or sets the height of the thumb */
  68645. thumbHeight: number;
  68646. /** Gets or sets the height of the bar image */
  68647. barImageHeight: number;
  68648. /** Gets or sets the bar background */
  68649. barBackground: string;
  68650. /** Gets or sets the bar background image */
  68651. barImage: Image;
  68652. /** @hidden */
  68653. private _updateScroller;
  68654. _link(host: AdvancedDynamicTexture): void;
  68655. /** @hidden */
  68656. private _addBar;
  68657. /** @hidden */
  68658. private _attachWheel;
  68659. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  68660. /** Releases associated resources */
  68661. dispose(): void;
  68662. }
  68663. }
  68664. declare module BABYLON.GUI {
  68665. /** Class used to render a grid */
  68666. export class DisplayGrid extends Control {
  68667. name?: string | undefined;
  68668. private _cellWidth;
  68669. private _cellHeight;
  68670. private _minorLineTickness;
  68671. private _minorLineColor;
  68672. private _majorLineTickness;
  68673. private _majorLineColor;
  68674. private _majorLineFrequency;
  68675. private _background;
  68676. private _displayMajorLines;
  68677. private _displayMinorLines;
  68678. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  68679. displayMinorLines: boolean;
  68680. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  68681. displayMajorLines: boolean;
  68682. /** Gets or sets background color (Black by default) */
  68683. background: string;
  68684. /** Gets or sets the width of each cell (20 by default) */
  68685. cellWidth: number;
  68686. /** Gets or sets the height of each cell (20 by default) */
  68687. cellHeight: number;
  68688. /** Gets or sets the tickness of minor lines (1 by default) */
  68689. minorLineTickness: number;
  68690. /** Gets or sets the color of minor lines (DarkGray by default) */
  68691. minorLineColor: string;
  68692. /** Gets or sets the tickness of major lines (2 by default) */
  68693. majorLineTickness: number;
  68694. /** Gets or sets the color of major lines (White by default) */
  68695. majorLineColor: string;
  68696. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  68697. majorLineFrequency: number;
  68698. /**
  68699. * Creates a new GridDisplayRectangle
  68700. * @param name defines the control name
  68701. */
  68702. constructor(name?: string | undefined);
  68703. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68704. protected _getTypeName(): string;
  68705. }
  68706. }
  68707. declare module BABYLON.GUI {
  68708. /**
  68709. * Class used to create slider controls based on images
  68710. */
  68711. export class ImageBasedSlider extends BaseSlider {
  68712. name?: string | undefined;
  68713. private _backgroundImage;
  68714. private _thumbImage;
  68715. private _valueBarImage;
  68716. private _tempMeasure;
  68717. displayThumb: boolean;
  68718. /**
  68719. * Gets or sets the image used to render the background
  68720. */
  68721. backgroundImage: Image;
  68722. /**
  68723. * Gets or sets the image used to render the value bar
  68724. */
  68725. valueBarImage: Image;
  68726. /**
  68727. * Gets or sets the image used to render the thumb
  68728. */
  68729. thumbImage: Image;
  68730. /**
  68731. * Creates a new ImageBasedSlider
  68732. * @param name defines the control name
  68733. */
  68734. constructor(name?: string | undefined);
  68735. protected _getTypeName(): string;
  68736. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68737. }
  68738. }
  68739. declare module BABYLON.GUI {
  68740. /**
  68741. * Forcing an export so that this code will execute
  68742. * @hidden
  68743. */
  68744. const name = "Statics";
  68745. }
  68746. declare module BABYLON.GUI {
  68747. /**
  68748. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  68749. */
  68750. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  68751. /**
  68752. * Define the instrumented AdvancedDynamicTexture.
  68753. */
  68754. texture: AdvancedDynamicTexture;
  68755. private _captureRenderTime;
  68756. private _renderTime;
  68757. private _captureLayoutTime;
  68758. private _layoutTime;
  68759. private _onBeginRenderObserver;
  68760. private _onEndRenderObserver;
  68761. private _onBeginLayoutObserver;
  68762. private _onEndLayoutObserver;
  68763. /**
  68764. * Gets the perf counter used to capture render time
  68765. */
  68766. readonly renderTimeCounter: BABYLON.PerfCounter;
  68767. /**
  68768. * Gets the perf counter used to capture layout time
  68769. */
  68770. readonly layoutTimeCounter: BABYLON.PerfCounter;
  68771. /**
  68772. * Enable or disable the render time capture
  68773. */
  68774. captureRenderTime: boolean;
  68775. /**
  68776. * Enable or disable the layout time capture
  68777. */
  68778. captureLayoutTime: boolean;
  68779. /**
  68780. * Instantiates a new advanced dynamic texture instrumentation.
  68781. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  68782. * @param texture Defines the AdvancedDynamicTexture to instrument
  68783. */
  68784. constructor(
  68785. /**
  68786. * Define the instrumented AdvancedDynamicTexture.
  68787. */
  68788. texture: AdvancedDynamicTexture);
  68789. /**
  68790. * Dispose and release associated resources.
  68791. */
  68792. dispose(): void;
  68793. }
  68794. }
  68795. declare module BABYLON.GUI {
  68796. /**
  68797. * Class used to load GUI via XML.
  68798. */
  68799. export class XmlLoader {
  68800. private _nodes;
  68801. private _nodeTypes;
  68802. private _isLoaded;
  68803. private _objectAttributes;
  68804. private _parentClass;
  68805. /**
  68806. * Create a new xml loader
  68807. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  68808. */
  68809. constructor(parentClass?: null);
  68810. private _getChainElement;
  68811. private _getClassAttribute;
  68812. private _createGuiElement;
  68813. private _parseGrid;
  68814. private _parseElement;
  68815. private _prepareSourceElement;
  68816. private _parseElementsFromSource;
  68817. private _parseXml;
  68818. /**
  68819. * Gets if the loading has finished.
  68820. * @returns whether the loading has finished or not
  68821. */
  68822. isLoaded(): boolean;
  68823. /**
  68824. * Gets a loaded node / control by id.
  68825. * @param id the Controls id set in the xml
  68826. * @returns element of type Control
  68827. */
  68828. getNodeById(id: string): any;
  68829. /**
  68830. * Gets all loaded nodes / controls
  68831. * @returns Array of controls
  68832. */
  68833. getNodes(): any;
  68834. /**
  68835. * Initiates the xml layout loading
  68836. * @param xmlFile defines the xml layout to load
  68837. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  68838. * @param callback defines the callback called on layout load.
  68839. */
  68840. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  68841. }
  68842. }
  68843. declare module BABYLON.GUI {
  68844. /**
  68845. * Class used to create containers for controls
  68846. */
  68847. export class Container3D extends Control3D {
  68848. private _blockLayout;
  68849. /**
  68850. * Gets the list of child controls
  68851. */
  68852. protected _children: Control3D[];
  68853. /**
  68854. * Gets the list of child controls
  68855. */
  68856. readonly children: Array<Control3D>;
  68857. /**
  68858. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  68859. * This is helpful to optimize layout operation when adding multiple children in a row
  68860. */
  68861. blockLayout: boolean;
  68862. /**
  68863. * Creates a new container
  68864. * @param name defines the container name
  68865. */
  68866. constructor(name?: string);
  68867. /**
  68868. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  68869. * @returns the current container
  68870. */
  68871. updateLayout(): Container3D;
  68872. /**
  68873. * Gets a boolean indicating if the given control is in the children of this control
  68874. * @param control defines the control to check
  68875. * @returns true if the control is in the child list
  68876. */
  68877. containsControl(control: Control3D): boolean;
  68878. /**
  68879. * Adds a control to the children of this control
  68880. * @param control defines the control to add
  68881. * @returns the current container
  68882. */
  68883. addControl(control: Control3D): Container3D;
  68884. /**
  68885. * This function will be called everytime a new control is added
  68886. */
  68887. protected _arrangeChildren(): void;
  68888. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  68889. /**
  68890. * Removes a control from the children of this control
  68891. * @param control defines the control to remove
  68892. * @returns the current container
  68893. */
  68894. removeControl(control: Control3D): Container3D;
  68895. protected _getTypeName(): string;
  68896. /**
  68897. * Releases all associated resources
  68898. */
  68899. dispose(): void;
  68900. /** Control rotation will remain unchanged */
  68901. static readonly UNSET_ORIENTATION: number;
  68902. /** Control will rotate to make it look at sphere central axis */
  68903. static readonly FACEORIGIN_ORIENTATION: number;
  68904. /** Control will rotate to make it look back at sphere central axis */
  68905. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  68906. /** Control will rotate to look at z axis (0, 0, 1) */
  68907. static readonly FACEFORWARD_ORIENTATION: number;
  68908. /** Control will rotate to look at negative z axis (0, 0, -1) */
  68909. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  68910. }
  68911. }
  68912. declare module BABYLON.GUI {
  68913. /**
  68914. * Class used to manage 3D user interface
  68915. * @see http://doc.babylonjs.com/how_to/gui3d
  68916. */
  68917. export class GUI3DManager implements BABYLON.IDisposable {
  68918. private _scene;
  68919. private _sceneDisposeObserver;
  68920. private _utilityLayer;
  68921. private _rootContainer;
  68922. private _pointerObserver;
  68923. private _pointerOutObserver;
  68924. /** @hidden */
  68925. _lastPickedControl: Control3D;
  68926. /** @hidden */
  68927. _lastControlOver: {
  68928. [pointerId: number]: Control3D;
  68929. };
  68930. /** @hidden */
  68931. _lastControlDown: {
  68932. [pointerId: number]: Control3D;
  68933. };
  68934. /**
  68935. * BABYLON.Observable raised when the point picked by the pointer events changed
  68936. */
  68937. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  68938. /** @hidden */
  68939. _sharedMaterials: {
  68940. [key: string]: BABYLON.Material;
  68941. };
  68942. /** Gets the hosting scene */
  68943. readonly scene: BABYLON.Scene;
  68944. /** Gets associated utility layer */
  68945. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  68946. /**
  68947. * Creates a new GUI3DManager
  68948. * @param scene
  68949. */
  68950. constructor(scene?: BABYLON.Scene);
  68951. private _handlePointerOut;
  68952. private _doPicking;
  68953. /**
  68954. * Gets the root container
  68955. */
  68956. readonly rootContainer: Container3D;
  68957. /**
  68958. * Gets a boolean indicating if the given control is in the root child list
  68959. * @param control defines the control to check
  68960. * @returns true if the control is in the root child list
  68961. */
  68962. containsControl(control: Control3D): boolean;
  68963. /**
  68964. * Adds a control to the root child list
  68965. * @param control defines the control to add
  68966. * @returns the current manager
  68967. */
  68968. addControl(control: Control3D): GUI3DManager;
  68969. /**
  68970. * Removes a control from the root child list
  68971. * @param control defines the control to remove
  68972. * @returns the current container
  68973. */
  68974. removeControl(control: Control3D): GUI3DManager;
  68975. /**
  68976. * Releases all associated resources
  68977. */
  68978. dispose(): void;
  68979. }
  68980. }
  68981. declare module BABYLON.GUI {
  68982. /**
  68983. * Class used to transport BABYLON.Vector3 information for pointer events
  68984. */
  68985. export class Vector3WithInfo extends BABYLON.Vector3 {
  68986. /** defines the current mouse button index */
  68987. buttonIndex: number;
  68988. /**
  68989. * Creates a new Vector3WithInfo
  68990. * @param source defines the vector3 data to transport
  68991. * @param buttonIndex defines the current mouse button index
  68992. */
  68993. constructor(source: BABYLON.Vector3,
  68994. /** defines the current mouse button index */
  68995. buttonIndex?: number);
  68996. }
  68997. }
  68998. declare module BABYLON.GUI {
  68999. /**
  69000. * Class used as base class for controls
  69001. */
  69002. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  69003. /** Defines the control name */
  69004. name?: string | undefined;
  69005. /** @hidden */
  69006. _host: GUI3DManager;
  69007. private _node;
  69008. private _downCount;
  69009. private _enterCount;
  69010. private _downPointerIds;
  69011. private _isVisible;
  69012. /** Gets or sets the control position in world space */
  69013. position: BABYLON.Vector3;
  69014. /** Gets or sets the control scaling in world space */
  69015. scaling: BABYLON.Vector3;
  69016. /** Callback used to start pointer enter animation */
  69017. pointerEnterAnimation: () => void;
  69018. /** Callback used to start pointer out animation */
  69019. pointerOutAnimation: () => void;
  69020. /** Callback used to start pointer down animation */
  69021. pointerDownAnimation: () => void;
  69022. /** Callback used to start pointer up animation */
  69023. pointerUpAnimation: () => void;
  69024. /**
  69025. * An event triggered when the pointer move over the control
  69026. */
  69027. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  69028. /**
  69029. * An event triggered when the pointer move out of the control
  69030. */
  69031. onPointerOutObservable: BABYLON.Observable<Control3D>;
  69032. /**
  69033. * An event triggered when the pointer taps the control
  69034. */
  69035. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  69036. /**
  69037. * An event triggered when pointer is up
  69038. */
  69039. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  69040. /**
  69041. * An event triggered when a control is clicked on (with a mouse)
  69042. */
  69043. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  69044. /**
  69045. * An event triggered when pointer enters the control
  69046. */
  69047. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  69048. /**
  69049. * Gets or sets the parent container
  69050. */
  69051. parent: BABYLON.Nullable<Container3D>;
  69052. private _behaviors;
  69053. /**
  69054. * Gets the list of attached behaviors
  69055. * @see http://doc.babylonjs.com/features/behaviour
  69056. */
  69057. readonly behaviors: BABYLON.Behavior<Control3D>[];
  69058. /**
  69059. * Attach a behavior to the control
  69060. * @see http://doc.babylonjs.com/features/behaviour
  69061. * @param behavior defines the behavior to attach
  69062. * @returns the current control
  69063. */
  69064. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  69065. /**
  69066. * Remove an attached behavior
  69067. * @see http://doc.babylonjs.com/features/behaviour
  69068. * @param behavior defines the behavior to attach
  69069. * @returns the current control
  69070. */
  69071. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  69072. /**
  69073. * Gets an attached behavior by name
  69074. * @param name defines the name of the behavior to look for
  69075. * @see http://doc.babylonjs.com/features/behaviour
  69076. * @returns null if behavior was not found else the requested behavior
  69077. */
  69078. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  69079. /** Gets or sets a boolean indicating if the control is visible */
  69080. isVisible: boolean;
  69081. /**
  69082. * Creates a new control
  69083. * @param name defines the control name
  69084. */
  69085. constructor(
  69086. /** Defines the control name */
  69087. name?: string | undefined);
  69088. /**
  69089. * Gets a string representing the class name
  69090. */
  69091. readonly typeName: string;
  69092. /**
  69093. * Get the current class name of the control.
  69094. * @returns current class name
  69095. */
  69096. getClassName(): string;
  69097. protected _getTypeName(): string;
  69098. /**
  69099. * Gets the transform node used by this control
  69100. */
  69101. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  69102. /**
  69103. * Gets the mesh used to render this control
  69104. */
  69105. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  69106. /**
  69107. * Link the control as child of the given node
  69108. * @param node defines the node to link to. Use null to unlink the control
  69109. * @returns the current control
  69110. */
  69111. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  69112. /** @hidden **/
  69113. _prepareNode(scene: BABYLON.Scene): void;
  69114. /**
  69115. * Node creation.
  69116. * Can be overriden by children
  69117. * @param scene defines the scene where the node must be attached
  69118. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  69119. */
  69120. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  69121. /**
  69122. * Affect a material to the given mesh
  69123. * @param mesh defines the mesh which will represent the control
  69124. */
  69125. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  69126. /** @hidden */
  69127. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  69128. /** @hidden */
  69129. _onPointerEnter(target: Control3D): boolean;
  69130. /** @hidden */
  69131. _onPointerOut(target: Control3D): void;
  69132. /** @hidden */
  69133. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  69134. /** @hidden */
  69135. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  69136. /** @hidden */
  69137. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  69138. /** @hidden */
  69139. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  69140. /** @hidden */
  69141. _disposeNode(): void;
  69142. /**
  69143. * Releases all associated resources
  69144. */
  69145. dispose(): void;
  69146. }
  69147. }
  69148. declare module BABYLON.GUI {
  69149. /**
  69150. * Class used as a root to all buttons
  69151. */
  69152. export class AbstractButton3D extends Control3D {
  69153. /**
  69154. * Creates a new button
  69155. * @param name defines the control name
  69156. */
  69157. constructor(name?: string);
  69158. protected _getTypeName(): string;
  69159. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  69160. }
  69161. }
  69162. declare module BABYLON.GUI {
  69163. /**
  69164. * Class used to create a button in 3D
  69165. */
  69166. export class Button3D extends AbstractButton3D {
  69167. /** @hidden */
  69168. protected _currentMaterial: BABYLON.Material;
  69169. private _facadeTexture;
  69170. private _content;
  69171. private _contentResolution;
  69172. private _contentScaleRatio;
  69173. /**
  69174. * Gets or sets the texture resolution used to render content (512 by default)
  69175. */
  69176. contentResolution: BABYLON.int;
  69177. /**
  69178. * Gets or sets the texture scale ratio used to render content (2 by default)
  69179. */
  69180. contentScaleRatio: number;
  69181. protected _disposeFacadeTexture(): void;
  69182. protected _resetContent(): void;
  69183. /**
  69184. * Creates a new button
  69185. * @param name defines the control name
  69186. */
  69187. constructor(name?: string);
  69188. /**
  69189. * Gets or sets the GUI 2D content used to display the button's facade
  69190. */
  69191. content: Control;
  69192. /**
  69193. * Apply the facade texture (created from the content property).
  69194. * This function can be overloaded by child classes
  69195. * @param facadeTexture defines the AdvancedDynamicTexture to use
  69196. */
  69197. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  69198. protected _getTypeName(): string;
  69199. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  69200. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  69201. /**
  69202. * Releases all associated resources
  69203. */
  69204. dispose(): void;
  69205. }
  69206. }
  69207. declare module BABYLON.GUI {
  69208. /**
  69209. * Abstract class used to create a container panel deployed on the surface of a volume
  69210. */
  69211. export abstract class VolumeBasedPanel extends Container3D {
  69212. private _columns;
  69213. private _rows;
  69214. private _rowThenColum;
  69215. private _orientation;
  69216. protected _cellWidth: number;
  69217. protected _cellHeight: number;
  69218. /**
  69219. * Gets or sets the distance between elements
  69220. */
  69221. margin: number;
  69222. /**
  69223. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  69224. * | Value | Type | Description |
  69225. * | ----- | ----------------------------------- | ----------- |
  69226. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  69227. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  69228. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  69229. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  69230. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  69231. */
  69232. orientation: number;
  69233. /**
  69234. * Gets or sets the number of columns requested (10 by default).
  69235. * The panel will automatically compute the number of rows based on number of child controls.
  69236. */
  69237. columns: BABYLON.int;
  69238. /**
  69239. * Gets or sets a the number of rows requested.
  69240. * The panel will automatically compute the number of columns based on number of child controls.
  69241. */
  69242. rows: BABYLON.int;
  69243. /**
  69244. * Creates new VolumeBasedPanel
  69245. */
  69246. constructor();
  69247. protected _arrangeChildren(): void;
  69248. /** Child classes must implement this function to provide correct control positioning */
  69249. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  69250. /** Child classes can implement this function to provide additional processing */
  69251. protected _finalProcessing(): void;
  69252. }
  69253. }
  69254. declare module BABYLON.GUI {
  69255. /**
  69256. * Class used to create a container panel deployed on the surface of a cylinder
  69257. */
  69258. export class CylinderPanel extends VolumeBasedPanel {
  69259. private _radius;
  69260. /**
  69261. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  69262. */
  69263. radius: BABYLON.float;
  69264. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  69265. private _cylindricalMapping;
  69266. }
  69267. }
  69268. declare module BABYLON.GUI {
  69269. /** @hidden */
  69270. export var fluentVertexShader: {
  69271. name: string;
  69272. shader: string;
  69273. };
  69274. }
  69275. declare module BABYLON.GUI {
  69276. /** @hidden */
  69277. export var fluentPixelShader: {
  69278. name: string;
  69279. shader: string;
  69280. };
  69281. }
  69282. declare module BABYLON.GUI {
  69283. /** @hidden */
  69284. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  69285. INNERGLOW: boolean;
  69286. BORDER: boolean;
  69287. HOVERLIGHT: boolean;
  69288. TEXTURE: boolean;
  69289. constructor();
  69290. }
  69291. /**
  69292. * Class used to render controls with fluent desgin
  69293. */
  69294. export class FluentMaterial extends BABYLON.PushMaterial {
  69295. /**
  69296. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  69297. */
  69298. innerGlowColorIntensity: number;
  69299. /**
  69300. * Gets or sets the inner glow color (white by default)
  69301. */
  69302. innerGlowColor: BABYLON.Color3;
  69303. /**
  69304. * Gets or sets alpha value (default is 1.0)
  69305. */
  69306. alpha: number;
  69307. /**
  69308. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  69309. */
  69310. albedoColor: BABYLON.Color3;
  69311. /**
  69312. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  69313. */
  69314. renderBorders: boolean;
  69315. /**
  69316. * Gets or sets border width (default is 0.5)
  69317. */
  69318. borderWidth: number;
  69319. /**
  69320. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  69321. */
  69322. edgeSmoothingValue: number;
  69323. /**
  69324. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  69325. */
  69326. borderMinValue: number;
  69327. /**
  69328. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  69329. */
  69330. renderHoverLight: boolean;
  69331. /**
  69332. * Gets or sets the radius used to render the hover light (default is 1.0)
  69333. */
  69334. hoverRadius: number;
  69335. /**
  69336. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  69337. */
  69338. hoverColor: BABYLON.Color4;
  69339. /**
  69340. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  69341. */
  69342. hoverPosition: BABYLON.Vector3;
  69343. private _albedoTexture;
  69344. /** Gets or sets the texture to use for albedo color */
  69345. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69346. /**
  69347. * Creates a new Fluent material
  69348. * @param name defines the name of the material
  69349. * @param scene defines the hosting scene
  69350. */
  69351. constructor(name: string, scene: BABYLON.Scene);
  69352. needAlphaBlending(): boolean;
  69353. needAlphaTesting(): boolean;
  69354. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69355. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69356. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69357. getActiveTextures(): BABYLON.BaseTexture[];
  69358. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69359. dispose(forceDisposeEffect?: boolean): void;
  69360. clone(name: string): FluentMaterial;
  69361. serialize(): any;
  69362. getClassName(): string;
  69363. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  69364. }
  69365. }
  69366. declare module BABYLON.GUI {
  69367. /**
  69368. * Class used to create a holographic button in 3D
  69369. */
  69370. export class HolographicButton extends Button3D {
  69371. private _backPlate;
  69372. private _textPlate;
  69373. private _frontPlate;
  69374. private _text;
  69375. private _imageUrl;
  69376. private _shareMaterials;
  69377. private _frontMaterial;
  69378. private _backMaterial;
  69379. private _plateMaterial;
  69380. private _pickedPointObserver;
  69381. private _tooltipFade;
  69382. private _tooltipTextBlock;
  69383. private _tooltipTexture;
  69384. private _tooltipMesh;
  69385. private _tooltipHoverObserver;
  69386. private _tooltipOutObserver;
  69387. private _disposeTooltip;
  69388. /**
  69389. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  69390. */
  69391. tooltipText: BABYLON.Nullable<string>;
  69392. /**
  69393. * Gets or sets text for the button
  69394. */
  69395. text: string;
  69396. /**
  69397. * Gets or sets the image url for the button
  69398. */
  69399. imageUrl: string;
  69400. /**
  69401. * Gets the back material used by this button
  69402. */
  69403. readonly backMaterial: FluentMaterial;
  69404. /**
  69405. * Gets the front material used by this button
  69406. */
  69407. readonly frontMaterial: FluentMaterial;
  69408. /**
  69409. * Gets the plate material used by this button
  69410. */
  69411. readonly plateMaterial: BABYLON.StandardMaterial;
  69412. /**
  69413. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  69414. */
  69415. readonly shareMaterials: boolean;
  69416. /**
  69417. * Creates a new button
  69418. * @param name defines the control name
  69419. */
  69420. constructor(name?: string, shareMaterials?: boolean);
  69421. protected _getTypeName(): string;
  69422. private _rebuildContent;
  69423. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  69424. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  69425. private _createBackMaterial;
  69426. private _createFrontMaterial;
  69427. private _createPlateMaterial;
  69428. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  69429. /**
  69430. * Releases all associated resources
  69431. */
  69432. dispose(): void;
  69433. }
  69434. }
  69435. declare module BABYLON.GUI {
  69436. /**
  69437. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  69438. */
  69439. export class MeshButton3D extends Button3D {
  69440. /** @hidden */
  69441. protected _currentMesh: BABYLON.Mesh;
  69442. /**
  69443. * Creates a new 3D button based on a mesh
  69444. * @param mesh mesh to become a 3D button
  69445. * @param name defines the control name
  69446. */
  69447. constructor(mesh: BABYLON.Mesh, name?: string);
  69448. protected _getTypeName(): string;
  69449. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  69450. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  69451. }
  69452. }
  69453. declare module BABYLON.GUI {
  69454. /**
  69455. * Class used to create a container panel deployed on the surface of a plane
  69456. */
  69457. export class PlanePanel extends VolumeBasedPanel {
  69458. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  69459. }
  69460. }
  69461. declare module BABYLON.GUI {
  69462. /**
  69463. * Class used to create a container panel where items get randomized planar mapping
  69464. */
  69465. export class ScatterPanel extends VolumeBasedPanel {
  69466. private _iteration;
  69467. /**
  69468. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  69469. */
  69470. iteration: BABYLON.float;
  69471. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  69472. private _scatterMapping;
  69473. protected _finalProcessing(): void;
  69474. }
  69475. }
  69476. declare module BABYLON.GUI {
  69477. /**
  69478. * Class used to create a container panel deployed on the surface of a sphere
  69479. */
  69480. export class SpherePanel extends VolumeBasedPanel {
  69481. private _radius;
  69482. /**
  69483. * Gets or sets the radius of the sphere where to project controls (5 by default)
  69484. */
  69485. radius: BABYLON.float;
  69486. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  69487. private _sphericalMapping;
  69488. }
  69489. }
  69490. declare module BABYLON.GUI {
  69491. /**
  69492. * Class used to create a stack panel in 3D on XY plane
  69493. */
  69494. export class StackPanel3D extends Container3D {
  69495. private _isVertical;
  69496. /**
  69497. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  69498. */
  69499. isVertical: boolean;
  69500. /**
  69501. * Gets or sets the distance between elements
  69502. */
  69503. margin: number;
  69504. /**
  69505. * Creates new StackPanel
  69506. * @param isVertical
  69507. */
  69508. constructor(isVertical?: boolean);
  69509. protected _arrangeChildren(): void;
  69510. }
  69511. }
  69512. declare module BABYLON {
  69513. /**
  69514. * Mode that determines the coordinate system to use.
  69515. */
  69516. export enum GLTFLoaderCoordinateSystemMode {
  69517. /**
  69518. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  69519. */
  69520. AUTO = 0,
  69521. /**
  69522. * Sets the useRightHandedSystem flag on the scene.
  69523. */
  69524. FORCE_RIGHT_HANDED = 1
  69525. }
  69526. /**
  69527. * Mode that determines what animations will start.
  69528. */
  69529. export enum GLTFLoaderAnimationStartMode {
  69530. /**
  69531. * No animation will start.
  69532. */
  69533. NONE = 0,
  69534. /**
  69535. * The first animation will start.
  69536. */
  69537. FIRST = 1,
  69538. /**
  69539. * All animations will start.
  69540. */
  69541. ALL = 2
  69542. }
  69543. /**
  69544. * Interface that contains the data for the glTF asset.
  69545. */
  69546. export interface IGLTFLoaderData {
  69547. /**
  69548. * The object that represents the glTF JSON.
  69549. */
  69550. json: Object;
  69551. /**
  69552. * The BIN chunk of a binary glTF.
  69553. */
  69554. bin: Nullable<IDataBuffer>;
  69555. }
  69556. /**
  69557. * Interface for extending the loader.
  69558. */
  69559. export interface IGLTFLoaderExtension {
  69560. /**
  69561. * The name of this extension.
  69562. */
  69563. readonly name: string;
  69564. /**
  69565. * Defines whether this extension is enabled.
  69566. */
  69567. enabled: boolean;
  69568. /**
  69569. * Defines the order of this extension.
  69570. * The loader sorts the extensions using these values when loading.
  69571. */
  69572. order?: number;
  69573. }
  69574. /**
  69575. * Loader state.
  69576. */
  69577. export enum GLTFLoaderState {
  69578. /**
  69579. * The asset is loading.
  69580. */
  69581. LOADING = 0,
  69582. /**
  69583. * The asset is ready for rendering.
  69584. */
  69585. READY = 1,
  69586. /**
  69587. * The asset is completely loaded.
  69588. */
  69589. COMPLETE = 2
  69590. }
  69591. /** @hidden */
  69592. export interface IGLTFLoader extends IDisposable {
  69593. readonly state: Nullable<GLTFLoaderState>;
  69594. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  69595. meshes: AbstractMesh[];
  69596. particleSystems: IParticleSystem[];
  69597. skeletons: Skeleton[];
  69598. animationGroups: AnimationGroup[];
  69599. }>;
  69600. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  69601. }
  69602. /**
  69603. * File loader for loading glTF files into a scene.
  69604. */
  69605. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  69606. /** @hidden */
  69607. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  69608. /** @hidden */
  69609. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  69610. /**
  69611. * Raised when the asset has been parsed
  69612. */
  69613. onParsedObservable: Observable<IGLTFLoaderData>;
  69614. private _onParsedObserver;
  69615. /**
  69616. * Raised when the asset has been parsed
  69617. */
  69618. onParsed: (loaderData: IGLTFLoaderData) => void;
  69619. /**
  69620. * 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.
  69621. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  69622. * Defaults to true.
  69623. * @hidden
  69624. */
  69625. static IncrementalLoading: boolean;
  69626. /**
  69627. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  69628. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  69629. * @hidden
  69630. */
  69631. static HomogeneousCoordinates: boolean;
  69632. /**
  69633. * The coordinate system mode. Defaults to AUTO.
  69634. */
  69635. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  69636. /**
  69637. * The animation start mode. Defaults to FIRST.
  69638. */
  69639. animationStartMode: GLTFLoaderAnimationStartMode;
  69640. /**
  69641. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  69642. */
  69643. compileMaterials: boolean;
  69644. /**
  69645. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  69646. */
  69647. useClipPlane: boolean;
  69648. /**
  69649. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  69650. */
  69651. compileShadowGenerators: boolean;
  69652. /**
  69653. * Defines if the Alpha blended materials are only applied as coverage.
  69654. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  69655. * If true, no extra effects are applied to transparent pixels.
  69656. */
  69657. transparencyAsCoverage: boolean;
  69658. /**
  69659. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  69660. * Enabling will disable offline support and glTF validator.
  69661. * Defaults to false.
  69662. */
  69663. useRangeRequests: boolean;
  69664. /**
  69665. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  69666. */
  69667. createInstances: boolean;
  69668. /**
  69669. * Function called before loading a url referenced by the asset.
  69670. */
  69671. preprocessUrlAsync: (url: string) => Promise<string>;
  69672. /**
  69673. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  69674. */
  69675. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  69676. private _onMeshLoadedObserver;
  69677. /**
  69678. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  69679. */
  69680. onMeshLoaded: (mesh: AbstractMesh) => void;
  69681. /**
  69682. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  69683. */
  69684. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  69685. private _onTextureLoadedObserver;
  69686. /**
  69687. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  69688. */
  69689. onTextureLoaded: (texture: BaseTexture) => void;
  69690. /**
  69691. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  69692. */
  69693. readonly onMaterialLoadedObservable: Observable<Material>;
  69694. private _onMaterialLoadedObserver;
  69695. /**
  69696. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  69697. */
  69698. onMaterialLoaded: (material: Material) => void;
  69699. /**
  69700. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  69701. */
  69702. readonly onCameraLoadedObservable: Observable<Camera>;
  69703. private _onCameraLoadedObserver;
  69704. /**
  69705. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  69706. */
  69707. onCameraLoaded: (camera: Camera) => void;
  69708. /**
  69709. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  69710. * For assets with LODs, raised when all of the LODs are complete.
  69711. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  69712. */
  69713. readonly onCompleteObservable: Observable<void>;
  69714. private _onCompleteObserver;
  69715. /**
  69716. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  69717. * For assets with LODs, raised when all of the LODs are complete.
  69718. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  69719. */
  69720. onComplete: () => void;
  69721. /**
  69722. * Observable raised when an error occurs.
  69723. */
  69724. readonly onErrorObservable: Observable<any>;
  69725. private _onErrorObserver;
  69726. /**
  69727. * Callback raised when an error occurs.
  69728. */
  69729. onError: (reason: any) => void;
  69730. /**
  69731. * Observable raised after the loader is disposed.
  69732. */
  69733. readonly onDisposeObservable: Observable<void>;
  69734. private _onDisposeObserver;
  69735. /**
  69736. * Callback raised after the loader is disposed.
  69737. */
  69738. onDispose: () => void;
  69739. /**
  69740. * Observable raised after a loader extension is created.
  69741. * Set additional options for a loader extension in this event.
  69742. */
  69743. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  69744. private _onExtensionLoadedObserver;
  69745. /**
  69746. * Callback raised after a loader extension is created.
  69747. */
  69748. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  69749. /**
  69750. * Defines if the loader logging is enabled.
  69751. */
  69752. loggingEnabled: boolean;
  69753. /**
  69754. * Defines if the loader should capture performance counters.
  69755. */
  69756. capturePerformanceCounters: boolean;
  69757. /**
  69758. * Defines if the loader should validate the asset.
  69759. */
  69760. validate: boolean;
  69761. /**
  69762. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  69763. */
  69764. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  69765. private _onValidatedObserver;
  69766. /**
  69767. * Callback raised after a loader extension is created.
  69768. */
  69769. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  69770. private _loader;
  69771. /**
  69772. * Name of the loader ("gltf")
  69773. */
  69774. name: string;
  69775. /** @hidden */
  69776. extensions: ISceneLoaderPluginExtensions;
  69777. /**
  69778. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  69779. */
  69780. dispose(): void;
  69781. /** @hidden */
  69782. _clear(): void;
  69783. /** @hidden */
  69784. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  69785. /** @hidden */
  69786. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  69787. /** @hidden */
  69788. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  69789. meshes: AbstractMesh[];
  69790. particleSystems: IParticleSystem[];
  69791. skeletons: Skeleton[];
  69792. animationGroups: AnimationGroup[];
  69793. }>;
  69794. /** @hidden */
  69795. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  69796. /** @hidden */
  69797. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  69798. /** @hidden */
  69799. canDirectLoad(data: string): boolean;
  69800. /** @hidden */
  69801. directLoad(scene: Scene, data: string): any;
  69802. /**
  69803. * The callback that allows custom handling of the root url based on the response url.
  69804. * @param rootUrl the original root url
  69805. * @param responseURL the response url if available
  69806. * @returns the new root url
  69807. */
  69808. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  69809. /** @hidden */
  69810. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  69811. /**
  69812. * The loader state or null if the loader is not active.
  69813. */
  69814. readonly loaderState: Nullable<GLTFLoaderState>;
  69815. /**
  69816. * Returns a promise that resolves when the asset is completely loaded.
  69817. * @returns a promise that resolves when the asset is completely loaded.
  69818. */
  69819. whenCompleteAsync(): Promise<void>;
  69820. private _validateAsync;
  69821. private _getLoader;
  69822. private _parseJson;
  69823. private _unpackBinaryAsync;
  69824. private _unpackBinaryV1Async;
  69825. private _unpackBinaryV2Async;
  69826. private static _parseVersion;
  69827. private static _compareVersion;
  69828. private static readonly _logSpaces;
  69829. private _logIndentLevel;
  69830. private _loggingEnabled;
  69831. /** @hidden */
  69832. _log: (message: string) => void;
  69833. /** @hidden */
  69834. _logOpen(message: string): void;
  69835. /** @hidden */
  69836. _logClose(): void;
  69837. private _logEnabled;
  69838. private _logDisabled;
  69839. private _capturePerformanceCounters;
  69840. /** @hidden */
  69841. _startPerformanceCounter: (counterName: string) => void;
  69842. /** @hidden */
  69843. _endPerformanceCounter: (counterName: string) => void;
  69844. private _startPerformanceCounterEnabled;
  69845. private _startPerformanceCounterDisabled;
  69846. private _endPerformanceCounterEnabled;
  69847. private _endPerformanceCounterDisabled;
  69848. }
  69849. }
  69850. declare module BABYLON.GLTF1 {
  69851. /**
  69852. * Enums
  69853. * @hidden
  69854. */
  69855. export enum EComponentType {
  69856. BYTE = 5120,
  69857. UNSIGNED_BYTE = 5121,
  69858. SHORT = 5122,
  69859. UNSIGNED_SHORT = 5123,
  69860. FLOAT = 5126
  69861. }
  69862. /** @hidden */
  69863. export enum EShaderType {
  69864. FRAGMENT = 35632,
  69865. VERTEX = 35633
  69866. }
  69867. /** @hidden */
  69868. export enum EParameterType {
  69869. BYTE = 5120,
  69870. UNSIGNED_BYTE = 5121,
  69871. SHORT = 5122,
  69872. UNSIGNED_SHORT = 5123,
  69873. INT = 5124,
  69874. UNSIGNED_INT = 5125,
  69875. FLOAT = 5126,
  69876. FLOAT_VEC2 = 35664,
  69877. FLOAT_VEC3 = 35665,
  69878. FLOAT_VEC4 = 35666,
  69879. INT_VEC2 = 35667,
  69880. INT_VEC3 = 35668,
  69881. INT_VEC4 = 35669,
  69882. BOOL = 35670,
  69883. BOOL_VEC2 = 35671,
  69884. BOOL_VEC3 = 35672,
  69885. BOOL_VEC4 = 35673,
  69886. FLOAT_MAT2 = 35674,
  69887. FLOAT_MAT3 = 35675,
  69888. FLOAT_MAT4 = 35676,
  69889. SAMPLER_2D = 35678
  69890. }
  69891. /** @hidden */
  69892. export enum ETextureWrapMode {
  69893. CLAMP_TO_EDGE = 33071,
  69894. MIRRORED_REPEAT = 33648,
  69895. REPEAT = 10497
  69896. }
  69897. /** @hidden */
  69898. export enum ETextureFilterType {
  69899. NEAREST = 9728,
  69900. LINEAR = 9728,
  69901. NEAREST_MIPMAP_NEAREST = 9984,
  69902. LINEAR_MIPMAP_NEAREST = 9985,
  69903. NEAREST_MIPMAP_LINEAR = 9986,
  69904. LINEAR_MIPMAP_LINEAR = 9987
  69905. }
  69906. /** @hidden */
  69907. export enum ETextureFormat {
  69908. ALPHA = 6406,
  69909. RGB = 6407,
  69910. RGBA = 6408,
  69911. LUMINANCE = 6409,
  69912. LUMINANCE_ALPHA = 6410
  69913. }
  69914. /** @hidden */
  69915. export enum ECullingType {
  69916. FRONT = 1028,
  69917. BACK = 1029,
  69918. FRONT_AND_BACK = 1032
  69919. }
  69920. /** @hidden */
  69921. export enum EBlendingFunction {
  69922. ZERO = 0,
  69923. ONE = 1,
  69924. SRC_COLOR = 768,
  69925. ONE_MINUS_SRC_COLOR = 769,
  69926. DST_COLOR = 774,
  69927. ONE_MINUS_DST_COLOR = 775,
  69928. SRC_ALPHA = 770,
  69929. ONE_MINUS_SRC_ALPHA = 771,
  69930. DST_ALPHA = 772,
  69931. ONE_MINUS_DST_ALPHA = 773,
  69932. CONSTANT_COLOR = 32769,
  69933. ONE_MINUS_CONSTANT_COLOR = 32770,
  69934. CONSTANT_ALPHA = 32771,
  69935. ONE_MINUS_CONSTANT_ALPHA = 32772,
  69936. SRC_ALPHA_SATURATE = 776
  69937. }
  69938. /** @hidden */
  69939. export interface IGLTFProperty {
  69940. extensions?: {
  69941. [key: string]: any;
  69942. };
  69943. extras?: Object;
  69944. }
  69945. /** @hidden */
  69946. export interface IGLTFChildRootProperty extends IGLTFProperty {
  69947. name?: string;
  69948. }
  69949. /** @hidden */
  69950. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  69951. bufferView: string;
  69952. byteOffset: number;
  69953. byteStride: number;
  69954. count: number;
  69955. type: string;
  69956. componentType: EComponentType;
  69957. max?: number[];
  69958. min?: number[];
  69959. name?: string;
  69960. }
  69961. /** @hidden */
  69962. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  69963. buffer: string;
  69964. byteOffset: number;
  69965. byteLength: number;
  69966. byteStride: number;
  69967. target?: number;
  69968. }
  69969. /** @hidden */
  69970. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  69971. uri: string;
  69972. byteLength?: number;
  69973. type?: string;
  69974. }
  69975. /** @hidden */
  69976. export interface IGLTFShader extends IGLTFChildRootProperty {
  69977. uri: string;
  69978. type: EShaderType;
  69979. }
  69980. /** @hidden */
  69981. export interface IGLTFProgram extends IGLTFChildRootProperty {
  69982. attributes: string[];
  69983. fragmentShader: string;
  69984. vertexShader: string;
  69985. }
  69986. /** @hidden */
  69987. export interface IGLTFTechniqueParameter {
  69988. type: number;
  69989. count?: number;
  69990. semantic?: string;
  69991. node?: string;
  69992. value?: number | boolean | string | Array<any>;
  69993. source?: string;
  69994. babylonValue?: any;
  69995. }
  69996. /** @hidden */
  69997. export interface IGLTFTechniqueCommonProfile {
  69998. lightingModel: string;
  69999. texcoordBindings: Object;
  70000. parameters?: Array<any>;
  70001. }
  70002. /** @hidden */
  70003. export interface IGLTFTechniqueStatesFunctions {
  70004. blendColor?: number[];
  70005. blendEquationSeparate?: number[];
  70006. blendFuncSeparate?: number[];
  70007. colorMask: boolean[];
  70008. cullFace: number[];
  70009. }
  70010. /** @hidden */
  70011. export interface IGLTFTechniqueStates {
  70012. enable: number[];
  70013. functions: IGLTFTechniqueStatesFunctions;
  70014. }
  70015. /** @hidden */
  70016. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  70017. parameters: {
  70018. [key: string]: IGLTFTechniqueParameter;
  70019. };
  70020. program: string;
  70021. attributes: {
  70022. [key: string]: string;
  70023. };
  70024. uniforms: {
  70025. [key: string]: string;
  70026. };
  70027. states: IGLTFTechniqueStates;
  70028. }
  70029. /** @hidden */
  70030. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  70031. technique?: string;
  70032. values: string[];
  70033. }
  70034. /** @hidden */
  70035. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  70036. attributes: {
  70037. [key: string]: string;
  70038. };
  70039. indices: string;
  70040. material: string;
  70041. mode?: number;
  70042. }
  70043. /** @hidden */
  70044. export interface IGLTFMesh extends IGLTFChildRootProperty {
  70045. primitives: IGLTFMeshPrimitive[];
  70046. }
  70047. /** @hidden */
  70048. export interface IGLTFImage extends IGLTFChildRootProperty {
  70049. uri: string;
  70050. }
  70051. /** @hidden */
  70052. export interface IGLTFSampler extends IGLTFChildRootProperty {
  70053. magFilter?: number;
  70054. minFilter?: number;
  70055. wrapS?: number;
  70056. wrapT?: number;
  70057. }
  70058. /** @hidden */
  70059. export interface IGLTFTexture extends IGLTFChildRootProperty {
  70060. sampler: string;
  70061. source: string;
  70062. format?: ETextureFormat;
  70063. internalFormat?: ETextureFormat;
  70064. target?: number;
  70065. type?: number;
  70066. babylonTexture?: Texture;
  70067. }
  70068. /** @hidden */
  70069. export interface IGLTFAmbienLight {
  70070. color?: number[];
  70071. }
  70072. /** @hidden */
  70073. export interface IGLTFDirectionalLight {
  70074. color?: number[];
  70075. }
  70076. /** @hidden */
  70077. export interface IGLTFPointLight {
  70078. color?: number[];
  70079. constantAttenuation?: number;
  70080. linearAttenuation?: number;
  70081. quadraticAttenuation?: number;
  70082. }
  70083. /** @hidden */
  70084. export interface IGLTFSpotLight {
  70085. color?: number[];
  70086. constantAttenuation?: number;
  70087. fallOfAngle?: number;
  70088. fallOffExponent?: number;
  70089. linearAttenuation?: number;
  70090. quadraticAttenuation?: number;
  70091. }
  70092. /** @hidden */
  70093. export interface IGLTFLight extends IGLTFChildRootProperty {
  70094. type: string;
  70095. }
  70096. /** @hidden */
  70097. export interface IGLTFCameraOrthographic {
  70098. xmag: number;
  70099. ymag: number;
  70100. zfar: number;
  70101. znear: number;
  70102. }
  70103. /** @hidden */
  70104. export interface IGLTFCameraPerspective {
  70105. aspectRatio: number;
  70106. yfov: number;
  70107. zfar: number;
  70108. znear: number;
  70109. }
  70110. /** @hidden */
  70111. export interface IGLTFCamera extends IGLTFChildRootProperty {
  70112. type: string;
  70113. }
  70114. /** @hidden */
  70115. export interface IGLTFAnimationChannelTarget {
  70116. id: string;
  70117. path: string;
  70118. }
  70119. /** @hidden */
  70120. export interface IGLTFAnimationChannel {
  70121. sampler: string;
  70122. target: IGLTFAnimationChannelTarget;
  70123. }
  70124. /** @hidden */
  70125. export interface IGLTFAnimationSampler {
  70126. input: string;
  70127. output: string;
  70128. interpolation?: string;
  70129. }
  70130. /** @hidden */
  70131. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  70132. channels?: IGLTFAnimationChannel[];
  70133. parameters?: {
  70134. [key: string]: string;
  70135. };
  70136. samplers?: {
  70137. [key: string]: IGLTFAnimationSampler;
  70138. };
  70139. }
  70140. /** @hidden */
  70141. export interface IGLTFNodeInstanceSkin {
  70142. skeletons: string[];
  70143. skin: string;
  70144. meshes: string[];
  70145. }
  70146. /** @hidden */
  70147. export interface IGLTFSkins extends IGLTFChildRootProperty {
  70148. bindShapeMatrix: number[];
  70149. inverseBindMatrices: string;
  70150. jointNames: string[];
  70151. babylonSkeleton?: Skeleton;
  70152. }
  70153. /** @hidden */
  70154. export interface IGLTFNode extends IGLTFChildRootProperty {
  70155. camera?: string;
  70156. children: string[];
  70157. skin?: string;
  70158. jointName?: string;
  70159. light?: string;
  70160. matrix: number[];
  70161. mesh?: string;
  70162. meshes?: string[];
  70163. rotation?: number[];
  70164. scale?: number[];
  70165. translation?: number[];
  70166. babylonNode?: Node;
  70167. }
  70168. /** @hidden */
  70169. export interface IGLTFScene extends IGLTFChildRootProperty {
  70170. nodes: string[];
  70171. }
  70172. /** @hidden */
  70173. export interface IGLTFRuntime {
  70174. extensions: {
  70175. [key: string]: any;
  70176. };
  70177. accessors: {
  70178. [key: string]: IGLTFAccessor;
  70179. };
  70180. buffers: {
  70181. [key: string]: IGLTFBuffer;
  70182. };
  70183. bufferViews: {
  70184. [key: string]: IGLTFBufferView;
  70185. };
  70186. meshes: {
  70187. [key: string]: IGLTFMesh;
  70188. };
  70189. lights: {
  70190. [key: string]: IGLTFLight;
  70191. };
  70192. cameras: {
  70193. [key: string]: IGLTFCamera;
  70194. };
  70195. nodes: {
  70196. [key: string]: IGLTFNode;
  70197. };
  70198. images: {
  70199. [key: string]: IGLTFImage;
  70200. };
  70201. textures: {
  70202. [key: string]: IGLTFTexture;
  70203. };
  70204. shaders: {
  70205. [key: string]: IGLTFShader;
  70206. };
  70207. programs: {
  70208. [key: string]: IGLTFProgram;
  70209. };
  70210. samplers: {
  70211. [key: string]: IGLTFSampler;
  70212. };
  70213. techniques: {
  70214. [key: string]: IGLTFTechnique;
  70215. };
  70216. materials: {
  70217. [key: string]: IGLTFMaterial;
  70218. };
  70219. animations: {
  70220. [key: string]: IGLTFAnimation;
  70221. };
  70222. skins: {
  70223. [key: string]: IGLTFSkins;
  70224. };
  70225. currentScene?: Object;
  70226. scenes: {
  70227. [key: string]: IGLTFScene;
  70228. };
  70229. extensionsUsed: string[];
  70230. extensionsRequired?: string[];
  70231. buffersCount: number;
  70232. shaderscount: number;
  70233. scene: Scene;
  70234. rootUrl: string;
  70235. loadedBufferCount: number;
  70236. loadedBufferViews: {
  70237. [name: string]: ArrayBufferView;
  70238. };
  70239. loadedShaderCount: number;
  70240. importOnlyMeshes: boolean;
  70241. importMeshesNames?: string[];
  70242. dummyNodes: Node[];
  70243. }
  70244. /** @hidden */
  70245. export interface INodeToRoot {
  70246. bone: Bone;
  70247. node: IGLTFNode;
  70248. id: string;
  70249. }
  70250. /** @hidden */
  70251. export interface IJointNode {
  70252. node: IGLTFNode;
  70253. id: string;
  70254. }
  70255. }
  70256. declare module BABYLON.GLTF1 {
  70257. /**
  70258. * Utils functions for GLTF
  70259. * @hidden
  70260. */
  70261. export class GLTFUtils {
  70262. /**
  70263. * Sets the given "parameter" matrix
  70264. * @param scene: the Scene object
  70265. * @param source: the source node where to pick the matrix
  70266. * @param parameter: the GLTF technique parameter
  70267. * @param uniformName: the name of the shader's uniform
  70268. * @param shaderMaterial: the shader material
  70269. */
  70270. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  70271. /**
  70272. * Sets the given "parameter" matrix
  70273. * @param shaderMaterial: the shader material
  70274. * @param uniform: the name of the shader's uniform
  70275. * @param value: the value of the uniform
  70276. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  70277. */
  70278. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  70279. /**
  70280. * Returns the wrap mode of the texture
  70281. * @param mode: the mode value
  70282. */
  70283. static GetWrapMode(mode: number): number;
  70284. /**
  70285. * Returns the byte stride giving an accessor
  70286. * @param accessor: the GLTF accessor objet
  70287. */
  70288. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  70289. /**
  70290. * Returns the texture filter mode giving a mode value
  70291. * @param mode: the filter mode value
  70292. */
  70293. static GetTextureFilterMode(mode: number): ETextureFilterType;
  70294. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  70295. /**
  70296. * Returns a buffer from its accessor
  70297. * @param gltfRuntime: the GLTF runtime
  70298. * @param accessor: the GLTF accessor
  70299. */
  70300. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  70301. /**
  70302. * Decodes a buffer view into a string
  70303. * @param view: the buffer view
  70304. */
  70305. static DecodeBufferToText(view: ArrayBufferView): string;
  70306. /**
  70307. * Returns the default material of gltf. Related to
  70308. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  70309. * @param scene: the Babylon.js scene
  70310. */
  70311. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  70312. private static _DefaultMaterial;
  70313. }
  70314. }
  70315. declare module BABYLON.GLTF1 {
  70316. /**
  70317. * Implementation of the base glTF spec
  70318. * @hidden
  70319. */
  70320. export class GLTFLoaderBase {
  70321. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  70322. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  70323. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  70324. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  70325. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  70326. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  70327. }
  70328. /**
  70329. * glTF V1 Loader
  70330. * @hidden
  70331. */
  70332. export class GLTFLoader implements IGLTFLoader {
  70333. static Extensions: {
  70334. [name: string]: GLTFLoaderExtension;
  70335. };
  70336. static RegisterExtension(extension: GLTFLoaderExtension): void;
  70337. state: Nullable<GLTFLoaderState>;
  70338. dispose(): void;
  70339. private _importMeshAsync;
  70340. /**
  70341. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  70342. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  70343. * @param scene the scene the meshes should be added to
  70344. * @param data gltf data containing information of the meshes in a loaded file
  70345. * @param rootUrl root url to load from
  70346. * @param onProgress event that fires when loading progress has occured
  70347. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  70348. */
  70349. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  70350. meshes: AbstractMesh[];
  70351. particleSystems: IParticleSystem[];
  70352. skeletons: Skeleton[];
  70353. animationGroups: AnimationGroup[];
  70354. }>;
  70355. private _loadAsync;
  70356. /**
  70357. * Imports all objects from a loaded gltf file and adds them to the scene
  70358. * @param scene the scene the objects should be added to
  70359. * @param data gltf data containing information of the meshes in a loaded file
  70360. * @param rootUrl root url to load from
  70361. * @param onProgress event that fires when loading progress has occured
  70362. * @returns a promise which completes when objects have been loaded to the scene
  70363. */
  70364. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  70365. private _loadShadersAsync;
  70366. private _loadBuffersAsync;
  70367. private _createNodes;
  70368. }
  70369. /** @hidden */
  70370. export abstract class GLTFLoaderExtension {
  70371. private _name;
  70372. constructor(name: string);
  70373. readonly name: string;
  70374. /**
  70375. * Defines an override for loading the runtime
  70376. * Return true to stop further extensions from loading the runtime
  70377. */
  70378. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  70379. /**
  70380. * Defines an onverride for creating gltf runtime
  70381. * Return true to stop further extensions from creating the runtime
  70382. */
  70383. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  70384. /**
  70385. * Defines an override for loading buffers
  70386. * Return true to stop further extensions from loading this buffer
  70387. */
  70388. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  70389. /**
  70390. * Defines an override for loading texture buffers
  70391. * Return true to stop further extensions from loading this texture data
  70392. */
  70393. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  70394. /**
  70395. * Defines an override for creating textures
  70396. * Return true to stop further extensions from loading this texture
  70397. */
  70398. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  70399. /**
  70400. * Defines an override for loading shader strings
  70401. * Return true to stop further extensions from loading this shader data
  70402. */
  70403. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  70404. /**
  70405. * Defines an override for loading materials
  70406. * Return true to stop further extensions from loading this material
  70407. */
  70408. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  70409. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  70410. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  70411. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  70412. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  70413. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  70414. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  70415. private static LoadTextureBufferAsync;
  70416. private static CreateTextureAsync;
  70417. private static ApplyExtensions;
  70418. }
  70419. }
  70420. declare module BABYLON.GLTF1 {
  70421. /** @hidden */
  70422. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  70423. private _bin;
  70424. constructor();
  70425. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  70426. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  70427. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  70428. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  70429. }
  70430. }
  70431. declare module BABYLON.GLTF1 {
  70432. /** @hidden */
  70433. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  70434. constructor();
  70435. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  70436. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  70437. private _loadTexture;
  70438. }
  70439. }
  70440. declare module BABYLON.GLTF2.Loader {
  70441. /**
  70442. * Loader interface with an index field.
  70443. */
  70444. export interface IArrayItem {
  70445. /**
  70446. * The index of this item in the array.
  70447. */
  70448. index: number;
  70449. }
  70450. /**
  70451. * Loader interface with additional members.
  70452. */
  70453. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  70454. /** @hidden */
  70455. _data?: Promise<ArrayBufferView>;
  70456. /** @hidden */
  70457. _babylonVertexBuffer?: Promise<VertexBuffer>;
  70458. }
  70459. /**
  70460. * Loader interface with additional members.
  70461. */
  70462. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  70463. }
  70464. /** @hidden */
  70465. export interface _IAnimationSamplerData {
  70466. input: Float32Array;
  70467. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  70468. output: Float32Array;
  70469. }
  70470. /**
  70471. * Loader interface with additional members.
  70472. */
  70473. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  70474. /** @hidden */
  70475. _data?: Promise<_IAnimationSamplerData>;
  70476. }
  70477. /**
  70478. * Loader interface with additional members.
  70479. */
  70480. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  70481. channels: IAnimationChannel[];
  70482. samplers: IAnimationSampler[];
  70483. /** @hidden */
  70484. _babylonAnimationGroup?: AnimationGroup;
  70485. }
  70486. /**
  70487. * Loader interface with additional members.
  70488. */
  70489. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  70490. /** @hidden */
  70491. _data?: Promise<ArrayBufferView>;
  70492. }
  70493. /**
  70494. * Loader interface with additional members.
  70495. */
  70496. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  70497. /** @hidden */
  70498. _data?: Promise<ArrayBufferView>;
  70499. /** @hidden */
  70500. _babylonBuffer?: Promise<Buffer>;
  70501. }
  70502. /**
  70503. * Loader interface with additional members.
  70504. */
  70505. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  70506. }
  70507. /**
  70508. * Loader interface with additional members.
  70509. */
  70510. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  70511. /** @hidden */
  70512. _data?: Promise<ArrayBufferView>;
  70513. }
  70514. /**
  70515. * Loader interface with additional members.
  70516. */
  70517. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  70518. }
  70519. /**
  70520. * Loader interface with additional members.
  70521. */
  70522. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  70523. }
  70524. /**
  70525. * Loader interface with additional members.
  70526. */
  70527. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  70528. baseColorTexture?: ITextureInfo;
  70529. metallicRoughnessTexture?: ITextureInfo;
  70530. }
  70531. /**
  70532. * Loader interface with additional members.
  70533. */
  70534. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  70535. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  70536. normalTexture?: IMaterialNormalTextureInfo;
  70537. occlusionTexture?: IMaterialOcclusionTextureInfo;
  70538. emissiveTexture?: ITextureInfo;
  70539. /** @hidden */
  70540. _data?: {
  70541. [babylonDrawMode: number]: {
  70542. babylonMaterial: Material;
  70543. babylonMeshes: AbstractMesh[];
  70544. promise: Promise<void>;
  70545. };
  70546. };
  70547. }
  70548. /**
  70549. * Loader interface with additional members.
  70550. */
  70551. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  70552. primitives: IMeshPrimitive[];
  70553. }
  70554. /**
  70555. * Loader interface with additional members.
  70556. */
  70557. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  70558. /** @hidden */
  70559. _instanceData?: {
  70560. babylonSourceMesh: Mesh;
  70561. promise: Promise<any>;
  70562. };
  70563. }
  70564. /**
  70565. * Loader interface with additional members.
  70566. */
  70567. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  70568. /**
  70569. * The parent glTF node.
  70570. */
  70571. parent?: INode;
  70572. /** @hidden */
  70573. _babylonTransformNode?: TransformNode;
  70574. /** @hidden */
  70575. _primitiveBabylonMeshes?: AbstractMesh[];
  70576. /** @hidden */
  70577. _babylonBones?: Bone[];
  70578. /** @hidden */
  70579. _numMorphTargets?: number;
  70580. }
  70581. /** @hidden */
  70582. export interface _ISamplerData {
  70583. noMipMaps: boolean;
  70584. samplingMode: number;
  70585. wrapU: number;
  70586. wrapV: number;
  70587. }
  70588. /**
  70589. * Loader interface with additional members.
  70590. */
  70591. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  70592. /** @hidden */
  70593. _data?: _ISamplerData;
  70594. }
  70595. /**
  70596. * Loader interface with additional members.
  70597. */
  70598. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  70599. }
  70600. /**
  70601. * Loader interface with additional members.
  70602. */
  70603. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  70604. /** @hidden */
  70605. _data?: {
  70606. babylonSkeleton: Skeleton;
  70607. promise: Promise<void>;
  70608. };
  70609. }
  70610. /**
  70611. * Loader interface with additional members.
  70612. */
  70613. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  70614. }
  70615. /**
  70616. * Loader interface with additional members.
  70617. */
  70618. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  70619. }
  70620. /**
  70621. * Loader interface with additional members.
  70622. */
  70623. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  70624. accessors?: IAccessor[];
  70625. animations?: IAnimation[];
  70626. buffers?: IBuffer[];
  70627. bufferViews?: IBufferView[];
  70628. cameras?: ICamera[];
  70629. images?: IImage[];
  70630. materials?: IMaterial[];
  70631. meshes?: IMesh[];
  70632. nodes?: INode[];
  70633. samplers?: ISampler[];
  70634. scenes?: IScene[];
  70635. skins?: ISkin[];
  70636. textures?: ITexture[];
  70637. }
  70638. }
  70639. declare module BABYLON.GLTF2 {
  70640. /**
  70641. * Interface for a glTF loader extension.
  70642. */
  70643. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  70644. /**
  70645. * Called after the loader state changes to LOADING.
  70646. */
  70647. onLoading?(): void;
  70648. /**
  70649. * Called after the loader state changes to READY.
  70650. */
  70651. onReady?(): void;
  70652. /**
  70653. * Define this method to modify the default behavior when loading scenes.
  70654. * @param context The context when loading the asset
  70655. * @param scene The glTF scene property
  70656. * @returns A promise that resolves when the load is complete or null if not handled
  70657. */
  70658. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  70659. /**
  70660. * Define this method to modify the default behavior when loading nodes.
  70661. * @param context The context when loading the asset
  70662. * @param node The glTF node property
  70663. * @param assign A function called synchronously after parsing the glTF properties
  70664. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  70665. */
  70666. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  70667. /**
  70668. * Define this method to modify the default behavior when loading cameras.
  70669. * @param context The context when loading the asset
  70670. * @param camera The glTF camera property
  70671. * @param assign A function called synchronously after parsing the glTF properties
  70672. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  70673. */
  70674. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  70675. /**
  70676. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  70677. * @param context The context when loading the asset
  70678. * @param primitive The glTF mesh primitive property
  70679. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  70680. */
  70681. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  70682. /**
  70683. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  70684. * @param context The context when loading the asset
  70685. * @param name The mesh name when loading the asset
  70686. * @param node The glTF node when loading the asset
  70687. * @param mesh The glTF mesh when loading the asset
  70688. * @param primitive The glTF mesh primitive property
  70689. * @param assign A function called synchronously after parsing the glTF properties
  70690. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  70691. */
  70692. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  70693. /**
  70694. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  70695. * @param context The context when loading the asset
  70696. * @param material The glTF material property
  70697. * @param assign A function called synchronously after parsing the glTF properties
  70698. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  70699. */
  70700. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  70701. /**
  70702. * Define this method to modify the default behavior when creating materials.
  70703. * @param context The context when loading the asset
  70704. * @param material The glTF material property
  70705. * @param babylonDrawMode The draw mode for the Babylon material
  70706. * @returns The Babylon material or null if not handled
  70707. */
  70708. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  70709. /**
  70710. * Define this method to modify the default behavior when loading material properties.
  70711. * @param context The context when loading the asset
  70712. * @param material The glTF material property
  70713. * @param babylonMaterial The Babylon material
  70714. * @returns A promise that resolves when the load is complete or null if not handled
  70715. */
  70716. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70717. /**
  70718. * Define this method to modify the default behavior when loading texture infos.
  70719. * @param context The context when loading the asset
  70720. * @param textureInfo The glTF texture info property
  70721. * @param assign A function called synchronously after parsing the glTF properties
  70722. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  70723. */
  70724. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  70725. /**
  70726. * Define this method to modify the default behavior when loading animations.
  70727. * @param context The context when loading the asset
  70728. * @param animation The glTF animation property
  70729. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  70730. */
  70731. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  70732. /**
  70733. * @hidden Define this method to modify the default behavior when loading skins.
  70734. * @param context The context when loading the asset
  70735. * @param node The glTF node property
  70736. * @param skin The glTF skin property
  70737. * @returns A promise that resolves when the load is complete or null if not handled
  70738. */
  70739. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  70740. /**
  70741. * @hidden Define this method to modify the default behavior when loading uris.
  70742. * @param context The context when loading the asset
  70743. * @param property The glTF property associated with the uri
  70744. * @param uri The uri to load
  70745. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  70746. */
  70747. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  70748. /**
  70749. * Define this method to modify the default behavior when loading buffer views.
  70750. * @param context The context when loading the asset
  70751. * @param bufferView The glTF buffer view property
  70752. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  70753. */
  70754. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  70755. /**
  70756. * Define this method to modify the default behavior when loading buffers.
  70757. * @param context The context when loading the asset
  70758. * @param buffer The glTF buffer property
  70759. * @param byteOffset The byte offset to load
  70760. * @param byteLength The byte length to load
  70761. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  70762. */
  70763. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  70764. }
  70765. }
  70766. declare module BABYLON.GLTF2 {
  70767. /**
  70768. * Helper class for working with arrays when loading the glTF asset
  70769. */
  70770. export class ArrayItem {
  70771. /**
  70772. * Gets an item from the given array.
  70773. * @param context The context when loading the asset
  70774. * @param array The array to get the item from
  70775. * @param index The index to the array
  70776. * @returns The array item
  70777. */
  70778. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  70779. /**
  70780. * Assign an `index` field to each item of the given array.
  70781. * @param array The array of items
  70782. */
  70783. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  70784. }
  70785. /**
  70786. * The glTF 2.0 loader
  70787. */
  70788. export class GLTFLoader implements IGLTFLoader {
  70789. /** @hidden */
  70790. _completePromises: Promise<any>[];
  70791. private _disposed;
  70792. private _parent;
  70793. private _state;
  70794. private _extensions;
  70795. private _rootUrl;
  70796. private _fileName;
  70797. private _uniqueRootUrl;
  70798. private _gltf;
  70799. private _bin;
  70800. private _babylonScene;
  70801. private _rootBabylonMesh;
  70802. private _defaultBabylonMaterialData;
  70803. private _progressCallback?;
  70804. private _requests;
  70805. private static readonly _DefaultSampler;
  70806. private static _RegisteredExtensions;
  70807. /**
  70808. * Registers a loader extension.
  70809. * @param name The name of the loader extension.
  70810. * @param factory The factory function that creates the loader extension.
  70811. */
  70812. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  70813. /**
  70814. * Unregisters a loader extension.
  70815. * @param name The name of the loader extension.
  70816. * @returns A boolean indicating whether the extension has been unregistered
  70817. */
  70818. static UnregisterExtension(name: string): boolean;
  70819. /**
  70820. * Gets the loader state.
  70821. */
  70822. readonly state: Nullable<GLTFLoaderState>;
  70823. /**
  70824. * The object that represents the glTF JSON.
  70825. */
  70826. readonly gltf: IGLTF;
  70827. /**
  70828. * The BIN chunk of a binary glTF.
  70829. */
  70830. readonly bin: Nullable<IDataBuffer>;
  70831. /**
  70832. * The parent file loader.
  70833. */
  70834. readonly parent: GLTFFileLoader;
  70835. /**
  70836. * The Babylon scene when loading the asset.
  70837. */
  70838. readonly babylonScene: Scene;
  70839. /**
  70840. * The root Babylon mesh when loading the asset.
  70841. */
  70842. readonly rootBabylonMesh: Mesh;
  70843. /** @hidden */
  70844. constructor(parent: GLTFFileLoader);
  70845. /** @hidden */
  70846. dispose(): void;
  70847. /** @hidden */
  70848. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  70849. meshes: AbstractMesh[];
  70850. particleSystems: IParticleSystem[];
  70851. skeletons: Skeleton[];
  70852. animationGroups: AnimationGroup[];
  70853. }>;
  70854. /** @hidden */
  70855. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  70856. private _loadAsync;
  70857. private _loadData;
  70858. private _setupData;
  70859. private _loadExtensions;
  70860. private _checkExtensions;
  70861. private _setState;
  70862. private _createRootNode;
  70863. /**
  70864. * Loads a glTF scene.
  70865. * @param context The context when loading the asset
  70866. * @param scene The glTF scene property
  70867. * @returns A promise that resolves when the load is complete
  70868. */
  70869. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  70870. private _forEachPrimitive;
  70871. private _getMeshes;
  70872. private _getSkeletons;
  70873. private _getAnimationGroups;
  70874. private _startAnimations;
  70875. /**
  70876. * Loads a glTF node.
  70877. * @param context The context when loading the asset
  70878. * @param node The glTF node property
  70879. * @param assign A function called synchronously after parsing the glTF properties
  70880. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  70881. */
  70882. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  70883. private _loadMeshAsync;
  70884. /**
  70885. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  70886. * @param context The context when loading the asset
  70887. * @param name The mesh name when loading the asset
  70888. * @param node The glTF node when loading the asset
  70889. * @param mesh The glTF mesh when loading the asset
  70890. * @param primitive The glTF mesh primitive property
  70891. * @param assign A function called synchronously after parsing the glTF properties
  70892. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  70893. */
  70894. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  70895. private _loadVertexDataAsync;
  70896. private _createMorphTargets;
  70897. private _loadMorphTargetsAsync;
  70898. private _loadMorphTargetVertexDataAsync;
  70899. private static _LoadTransform;
  70900. private _loadSkinAsync;
  70901. private _loadBones;
  70902. private _loadBone;
  70903. private _loadSkinInverseBindMatricesDataAsync;
  70904. private _updateBoneMatrices;
  70905. private _getNodeMatrix;
  70906. /**
  70907. * Loads a glTF camera.
  70908. * @param context The context when loading the asset
  70909. * @param camera The glTF camera property
  70910. * @param assign A function called synchronously after parsing the glTF properties
  70911. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  70912. */
  70913. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  70914. private _loadAnimationsAsync;
  70915. /**
  70916. * Loads a glTF animation.
  70917. * @param context The context when loading the asset
  70918. * @param animation The glTF animation property
  70919. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  70920. */
  70921. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  70922. /**
  70923. * @hidden Loads a glTF animation channel.
  70924. * @param context The context when loading the asset
  70925. * @param animationContext The context of the animation when loading the asset
  70926. * @param animation The glTF animation property
  70927. * @param channel The glTF animation channel property
  70928. * @param babylonAnimationGroup The babylon animation group property
  70929. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  70930. * @returns A void promise when the channel load is complete
  70931. */
  70932. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  70933. private _loadAnimationSamplerAsync;
  70934. private _loadBufferAsync;
  70935. /**
  70936. * Loads a glTF buffer view.
  70937. * @param context The context when loading the asset
  70938. * @param bufferView The glTF buffer view property
  70939. * @returns A promise that resolves with the loaded data when the load is complete
  70940. */
  70941. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  70942. private _loadAccessorAsync;
  70943. private _loadFloatAccessorAsync;
  70944. private _loadIndicesAccessorAsync;
  70945. private _loadVertexBufferViewAsync;
  70946. private _loadVertexAccessorAsync;
  70947. private _loadMaterialMetallicRoughnessPropertiesAsync;
  70948. /** @hidden */
  70949. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  70950. private _createDefaultMaterial;
  70951. /**
  70952. * Creates a Babylon material from a glTF material.
  70953. * @param context The context when loading the asset
  70954. * @param material The glTF material property
  70955. * @param babylonDrawMode The draw mode for the Babylon material
  70956. * @returns The Babylon material
  70957. */
  70958. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  70959. /**
  70960. * Loads properties from a glTF material into a Babylon material.
  70961. * @param context The context when loading the asset
  70962. * @param material The glTF material property
  70963. * @param babylonMaterial The Babylon material
  70964. * @returns A promise that resolves when the load is complete
  70965. */
  70966. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  70967. /**
  70968. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  70969. * @param context The context when loading the asset
  70970. * @param material The glTF material property
  70971. * @param babylonMaterial The Babylon material
  70972. * @returns A promise that resolves when the load is complete
  70973. */
  70974. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  70975. /**
  70976. * Loads the alpha properties from a glTF material into a Babylon material.
  70977. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  70978. * @param context The context when loading the asset
  70979. * @param material The glTF material property
  70980. * @param babylonMaterial The Babylon material
  70981. */
  70982. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  70983. /**
  70984. * Loads a glTF texture info.
  70985. * @param context The context when loading the asset
  70986. * @param textureInfo The glTF texture info property
  70987. * @param assign A function called synchronously after parsing the glTF properties
  70988. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  70989. */
  70990. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  70991. private _loadTextureAsync;
  70992. private _loadSampler;
  70993. /**
  70994. * Loads a glTF image.
  70995. * @param context The context when loading the asset
  70996. * @param image The glTF image property
  70997. * @returns A promise that resolves with the loaded data when the load is complete
  70998. */
  70999. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  71000. /**
  71001. * Loads a glTF uri.
  71002. * @param context The context when loading the asset
  71003. * @param property The glTF property associated with the uri
  71004. * @param uri The base64 or relative uri
  71005. * @returns A promise that resolves with the loaded data when the load is complete
  71006. */
  71007. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  71008. private _onProgress;
  71009. /**
  71010. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  71011. * @param babylonObject the Babylon object with metadata
  71012. * @param pointer the JSON pointer
  71013. */
  71014. static AddPointerMetadata(babylonObject: {
  71015. metadata: any;
  71016. }, pointer: string): void;
  71017. private static _GetTextureWrapMode;
  71018. private static _GetTextureSamplingMode;
  71019. private static _GetTypedArrayConstructor;
  71020. private static _GetTypedArray;
  71021. private static _GetNumComponents;
  71022. private static _ValidateUri;
  71023. private static _GetDrawMode;
  71024. private _compileMaterialsAsync;
  71025. private _compileShadowGeneratorsAsync;
  71026. private _forEachExtensions;
  71027. private _applyExtensions;
  71028. private _extensionsOnLoading;
  71029. private _extensionsOnReady;
  71030. private _extensionsLoadSceneAsync;
  71031. private _extensionsLoadNodeAsync;
  71032. private _extensionsLoadCameraAsync;
  71033. private _extensionsLoadVertexDataAsync;
  71034. private _extensionsLoadMeshPrimitiveAsync;
  71035. private _extensionsLoadMaterialAsync;
  71036. private _extensionsCreateMaterial;
  71037. private _extensionsLoadMaterialPropertiesAsync;
  71038. private _extensionsLoadTextureInfoAsync;
  71039. private _extensionsLoadAnimationAsync;
  71040. private _extensionsLoadSkinAsync;
  71041. private _extensionsLoadUriAsync;
  71042. private _extensionsLoadBufferViewAsync;
  71043. private _extensionsLoadBufferAsync;
  71044. /**
  71045. * Helper method called by a loader extension to load an glTF extension.
  71046. * @param context The context when loading the asset
  71047. * @param property The glTF property to load the extension from
  71048. * @param extensionName The name of the extension to load
  71049. * @param actionAsync The action to run
  71050. * @returns The promise returned by actionAsync or null if the extension does not exist
  71051. */
  71052. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  71053. /**
  71054. * Helper method called by a loader extension to load a glTF extra.
  71055. * @param context The context when loading the asset
  71056. * @param property The glTF property to load the extra from
  71057. * @param extensionName The name of the extension to load
  71058. * @param actionAsync The action to run
  71059. * @returns The promise returned by actionAsync or null if the extra does not exist
  71060. */
  71061. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  71062. /**
  71063. * Checks for presence of an extension.
  71064. * @param name The name of the extension to check
  71065. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  71066. */
  71067. isExtensionUsed(name: string): boolean;
  71068. /**
  71069. * Increments the indentation level and logs a message.
  71070. * @param message The message to log
  71071. */
  71072. logOpen(message: string): void;
  71073. /**
  71074. * Decrements the indentation level.
  71075. */
  71076. logClose(): void;
  71077. /**
  71078. * Logs a message
  71079. * @param message The message to log
  71080. */
  71081. log(message: string): void;
  71082. /**
  71083. * Starts a performance counter.
  71084. * @param counterName The name of the performance counter
  71085. */
  71086. startPerformanceCounter(counterName: string): void;
  71087. /**
  71088. * Ends a performance counter.
  71089. * @param counterName The name of the performance counter
  71090. */
  71091. endPerformanceCounter(counterName: string): void;
  71092. }
  71093. }
  71094. declare module BABYLON.GLTF2.Loader.Extensions {
  71095. /**
  71096. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  71097. */
  71098. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  71099. /**
  71100. * The name of this extension.
  71101. */
  71102. readonly name: string;
  71103. /**
  71104. * Defines whether this extension is enabled.
  71105. */
  71106. enabled: boolean;
  71107. private _loader;
  71108. private _lights?;
  71109. /** @hidden */
  71110. constructor(loader: GLTFLoader);
  71111. /** @hidden */
  71112. dispose(): void;
  71113. /** @hidden */
  71114. onLoading(): void;
  71115. /** @hidden */
  71116. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  71117. private _loadLightAsync;
  71118. }
  71119. }
  71120. declare module BABYLON.GLTF2.Loader.Extensions {
  71121. /**
  71122. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  71123. */
  71124. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  71125. /**
  71126. * The name of this extension.
  71127. */
  71128. readonly name: string;
  71129. /**
  71130. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  71131. */
  71132. dracoCompression?: DracoCompression;
  71133. /**
  71134. * Defines whether this extension is enabled.
  71135. */
  71136. enabled: boolean;
  71137. private _loader;
  71138. /** @hidden */
  71139. constructor(loader: GLTFLoader);
  71140. /** @hidden */
  71141. dispose(): void;
  71142. /** @hidden */
  71143. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  71144. }
  71145. }
  71146. declare module BABYLON.GLTF2.Loader.Extensions {
  71147. /**
  71148. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  71149. */
  71150. export class KHR_lights implements IGLTFLoaderExtension {
  71151. /**
  71152. * The name of this extension.
  71153. */
  71154. readonly name: string;
  71155. /**
  71156. * Defines whether this extension is enabled.
  71157. */
  71158. enabled: boolean;
  71159. private _loader;
  71160. private _lights?;
  71161. /** @hidden */
  71162. constructor(loader: GLTFLoader);
  71163. /** @hidden */
  71164. dispose(): void;
  71165. /** @hidden */
  71166. onLoading(): void;
  71167. /** @hidden */
  71168. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  71169. }
  71170. }
  71171. declare module BABYLON.GLTF2.Loader.Extensions {
  71172. /**
  71173. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  71174. */
  71175. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  71176. /**
  71177. * The name of this extension.
  71178. */
  71179. readonly name: string;
  71180. /**
  71181. * Defines whether this extension is enabled.
  71182. */
  71183. enabled: boolean;
  71184. /**
  71185. * Defines a number that determines the order the extensions are applied.
  71186. */
  71187. order: number;
  71188. private _loader;
  71189. /** @hidden */
  71190. constructor(loader: GLTFLoader);
  71191. /** @hidden */
  71192. dispose(): void;
  71193. /** @hidden */
  71194. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71195. private _loadSpecularGlossinessPropertiesAsync;
  71196. }
  71197. }
  71198. declare module BABYLON.GLTF2.Loader.Extensions {
  71199. /**
  71200. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  71201. */
  71202. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  71203. /**
  71204. * The name of this extension.
  71205. */
  71206. readonly name: string;
  71207. /**
  71208. * Defines whether this extension is enabled.
  71209. */
  71210. enabled: boolean;
  71211. /**
  71212. * Defines a number that determines the order the extensions are applied.
  71213. */
  71214. order: number;
  71215. private _loader;
  71216. /** @hidden */
  71217. constructor(loader: GLTFLoader);
  71218. /** @hidden */
  71219. dispose(): void;
  71220. /** @hidden */
  71221. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71222. private _loadUnlitPropertiesAsync;
  71223. }
  71224. }
  71225. declare module BABYLON.GLTF2.Loader.Extensions {
  71226. /**
  71227. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  71228. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  71229. * !!! Experimental Extension Subject to Changes !!!
  71230. */
  71231. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  71232. /**
  71233. * The name of this extension.
  71234. */
  71235. readonly name: string;
  71236. /**
  71237. * Defines whether this extension is enabled.
  71238. */
  71239. enabled: boolean;
  71240. /**
  71241. * Defines a number that determines the order the extensions are applied.
  71242. */
  71243. order: number;
  71244. private _loader;
  71245. /** @hidden */
  71246. constructor(loader: GLTFLoader);
  71247. /** @hidden */
  71248. dispose(): void;
  71249. /** @hidden */
  71250. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71251. private _loadClearCoatPropertiesAsync;
  71252. }
  71253. }
  71254. declare module BABYLON.GLTF2.Loader.Extensions {
  71255. /**
  71256. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  71257. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  71258. * !!! Experimental Extension Subject to Changes !!!
  71259. */
  71260. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  71261. /**
  71262. * The name of this extension.
  71263. */
  71264. readonly name: string;
  71265. /**
  71266. * Defines whether this extension is enabled.
  71267. */
  71268. enabled: boolean;
  71269. /**
  71270. * Defines a number that determines the order the extensions are applied.
  71271. */
  71272. order: number;
  71273. private _loader;
  71274. /** @hidden */
  71275. constructor(loader: GLTFLoader);
  71276. /** @hidden */
  71277. dispose(): void;
  71278. /** @hidden */
  71279. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71280. private _loadSheenPropertiesAsync;
  71281. }
  71282. }
  71283. declare module BABYLON.GLTF2.Loader.Extensions {
  71284. /**
  71285. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  71286. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  71287. * !!! Experimental Extension Subject to Changes !!!
  71288. */
  71289. export class KHR_materials_specular implements IGLTFLoaderExtension {
  71290. /**
  71291. * The name of this extension.
  71292. */
  71293. readonly name: string;
  71294. /**
  71295. * Defines whether this extension is enabled.
  71296. */
  71297. enabled: boolean;
  71298. /**
  71299. * Defines a number that determines the order the extensions are applied.
  71300. */
  71301. order: number;
  71302. private _loader;
  71303. /** @hidden */
  71304. constructor(loader: GLTFLoader);
  71305. /** @hidden */
  71306. dispose(): void;
  71307. /** @hidden */
  71308. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71309. private _loadSpecularPropertiesAsync;
  71310. }
  71311. }
  71312. declare module BABYLON.GLTF2.Loader.Extensions {
  71313. /**
  71314. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  71315. */
  71316. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  71317. /**
  71318. * The name of this extension.
  71319. */
  71320. readonly name: string;
  71321. /**
  71322. * Defines whether this extension is enabled.
  71323. */
  71324. enabled: boolean;
  71325. /** @hidden */
  71326. constructor(loader: GLTFLoader);
  71327. /** @hidden */
  71328. dispose(): void;
  71329. }
  71330. }
  71331. declare module BABYLON.GLTF2.Loader.Extensions {
  71332. /**
  71333. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  71334. */
  71335. export class KHR_texture_transform implements IGLTFLoaderExtension {
  71336. /**
  71337. * The name of this extension.
  71338. */
  71339. readonly name: string;
  71340. /**
  71341. * Defines whether this extension is enabled.
  71342. */
  71343. enabled: boolean;
  71344. private _loader;
  71345. /** @hidden */
  71346. constructor(loader: GLTFLoader);
  71347. /** @hidden */
  71348. dispose(): void;
  71349. /** @hidden */
  71350. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  71351. }
  71352. }
  71353. declare module BABYLON.GLTF2.Loader.Extensions {
  71354. /**
  71355. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  71356. */
  71357. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  71358. /**
  71359. * The name of this extension.
  71360. */
  71361. readonly name: string;
  71362. /**
  71363. * Defines whether this extension is enabled.
  71364. */
  71365. enabled: boolean;
  71366. private _loader;
  71367. private _clips;
  71368. private _emitters;
  71369. /** @hidden */
  71370. constructor(loader: GLTFLoader);
  71371. /** @hidden */
  71372. dispose(): void;
  71373. /** @hidden */
  71374. onLoading(): void;
  71375. /** @hidden */
  71376. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  71377. /** @hidden */
  71378. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  71379. /** @hidden */
  71380. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  71381. private _loadClipAsync;
  71382. private _loadEmitterAsync;
  71383. private _getEventAction;
  71384. private _loadAnimationEventAsync;
  71385. }
  71386. }
  71387. declare module BABYLON.GLTF2.Loader.Extensions {
  71388. /**
  71389. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  71390. */
  71391. export class MSFT_lod implements IGLTFLoaderExtension {
  71392. /**
  71393. * The name of this extension.
  71394. */
  71395. readonly name: string;
  71396. /**
  71397. * Defines whether this extension is enabled.
  71398. */
  71399. enabled: boolean;
  71400. /**
  71401. * Defines a number that determines the order the extensions are applied.
  71402. */
  71403. order: number;
  71404. /**
  71405. * Maximum number of LODs to load, starting from the lowest LOD.
  71406. */
  71407. maxLODsToLoad: number;
  71408. /**
  71409. * Observable raised when all node LODs of one level are loaded.
  71410. * The event data is the index of the loaded LOD starting from zero.
  71411. * Dispose the loader to cancel the loading of the next level of LODs.
  71412. */
  71413. onNodeLODsLoadedObservable: Observable<number>;
  71414. /**
  71415. * Observable raised when all material LODs of one level are loaded.
  71416. * The event data is the index of the loaded LOD starting from zero.
  71417. * Dispose the loader to cancel the loading of the next level of LODs.
  71418. */
  71419. onMaterialLODsLoadedObservable: Observable<number>;
  71420. private _loader;
  71421. private _nodeIndexLOD;
  71422. private _nodeSignalLODs;
  71423. private _nodePromiseLODs;
  71424. private _materialIndexLOD;
  71425. private _materialSignalLODs;
  71426. private _materialPromiseLODs;
  71427. private _indexLOD;
  71428. private _bufferLODs;
  71429. /** @hidden */
  71430. constructor(loader: GLTFLoader);
  71431. /** @hidden */
  71432. dispose(): void;
  71433. /** @hidden */
  71434. onReady(): void;
  71435. /** @hidden */
  71436. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  71437. /** @hidden */
  71438. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  71439. /** @hidden */
  71440. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  71441. /** @hidden */
  71442. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  71443. private _loadBufferLOD;
  71444. /**
  71445. * Gets an array of LOD properties from lowest to highest.
  71446. */
  71447. private _getLODs;
  71448. private _disposeUnusedMaterials;
  71449. }
  71450. }
  71451. declare module BABYLON.GLTF2.Loader.Extensions {
  71452. /** @hidden */
  71453. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  71454. readonly name: string;
  71455. enabled: boolean;
  71456. private _loader;
  71457. constructor(loader: GLTFLoader);
  71458. dispose(): void;
  71459. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71460. }
  71461. }
  71462. declare module BABYLON.GLTF2.Loader.Extensions {
  71463. /** @hidden */
  71464. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  71465. readonly name: string;
  71466. enabled: boolean;
  71467. private _loader;
  71468. constructor(loader: GLTFLoader);
  71469. dispose(): void;
  71470. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71471. }
  71472. }
  71473. declare module BABYLON.GLTF2.Loader.Extensions {
  71474. /**
  71475. * Store glTF extras (if present) in BJS objects' metadata
  71476. */
  71477. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  71478. /**
  71479. * The name of this extension.
  71480. */
  71481. readonly name: string;
  71482. /**
  71483. * Defines whether this extension is enabled.
  71484. */
  71485. enabled: boolean;
  71486. private _loader;
  71487. private _assignExtras;
  71488. /** @hidden */
  71489. constructor(loader: GLTFLoader);
  71490. /** @hidden */
  71491. dispose(): void;
  71492. /** @hidden */
  71493. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  71494. /** @hidden */
  71495. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  71496. /** @hidden */
  71497. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  71498. }
  71499. }
  71500. declare module BABYLON {
  71501. /**
  71502. * Class reading and parsing the MTL file bundled with the obj file.
  71503. */
  71504. export class MTLFileLoader {
  71505. /**
  71506. * All material loaded from the mtl will be set here
  71507. */
  71508. materials: StandardMaterial[];
  71509. /**
  71510. * This function will read the mtl file and create each material described inside
  71511. * This function could be improve by adding :
  71512. * -some component missing (Ni, Tf...)
  71513. * -including the specific options available
  71514. *
  71515. * @param scene defines the scene the material will be created in
  71516. * @param data defines the mtl data to parse
  71517. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  71518. */
  71519. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  71520. /**
  71521. * Gets the texture for the material.
  71522. *
  71523. * If the material is imported from input file,
  71524. * We sanitize the url to ensure it takes the textre from aside the material.
  71525. *
  71526. * @param rootUrl The root url to load from
  71527. * @param value The value stored in the mtl
  71528. * @return The Texture
  71529. */
  71530. private static _getTexture;
  71531. }
  71532. /**
  71533. * Options for loading OBJ/MTL files
  71534. */
  71535. type MeshLoadOptions = {
  71536. /**
  71537. * Defines if UVs are optimized by default during load.
  71538. */
  71539. OptimizeWithUV: boolean;
  71540. /**
  71541. * Defines custom scaling of UV coordinates of loaded meshes.
  71542. */
  71543. UVScaling: Vector2;
  71544. /**
  71545. * Invert model on y-axis (does a model scaling inversion)
  71546. */
  71547. InvertY: boolean;
  71548. /**
  71549. * Invert Y-Axis of referenced textures on load
  71550. */
  71551. InvertTextureY: boolean;
  71552. /**
  71553. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  71554. */
  71555. ImportVertexColors: boolean;
  71556. /**
  71557. * Compute the normals for the model, even if normals are present in the file.
  71558. */
  71559. ComputeNormals: boolean;
  71560. /**
  71561. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  71562. */
  71563. SkipMaterials: boolean;
  71564. /**
  71565. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  71566. */
  71567. MaterialLoadingFailsSilently: boolean;
  71568. };
  71569. /**
  71570. * OBJ file type loader.
  71571. * This is a babylon scene loader plugin.
  71572. */
  71573. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  71574. /**
  71575. * Defines if UVs are optimized by default during load.
  71576. */
  71577. static OPTIMIZE_WITH_UV: boolean;
  71578. /**
  71579. * Invert model on y-axis (does a model scaling inversion)
  71580. */
  71581. static INVERT_Y: boolean;
  71582. /**
  71583. * Invert Y-Axis of referenced textures on load
  71584. */
  71585. static INVERT_TEXTURE_Y: boolean;
  71586. /**
  71587. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  71588. */
  71589. static IMPORT_VERTEX_COLORS: boolean;
  71590. /**
  71591. * Compute the normals for the model, even if normals are present in the file.
  71592. */
  71593. static COMPUTE_NORMALS: boolean;
  71594. /**
  71595. * Defines custom scaling of UV coordinates of loaded meshes.
  71596. */
  71597. static UV_SCALING: Vector2;
  71598. /**
  71599. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  71600. */
  71601. static SKIP_MATERIALS: boolean;
  71602. /**
  71603. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  71604. *
  71605. * Defaults to true for backwards compatibility.
  71606. */
  71607. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  71608. /**
  71609. * Defines the name of the plugin.
  71610. */
  71611. name: string;
  71612. /**
  71613. * Defines the extension the plugin is able to load.
  71614. */
  71615. extensions: string;
  71616. /** @hidden */
  71617. obj: RegExp;
  71618. /** @hidden */
  71619. group: RegExp;
  71620. /** @hidden */
  71621. mtllib: RegExp;
  71622. /** @hidden */
  71623. usemtl: RegExp;
  71624. /** @hidden */
  71625. smooth: RegExp;
  71626. /** @hidden */
  71627. vertexPattern: RegExp;
  71628. /** @hidden */
  71629. normalPattern: RegExp;
  71630. /** @hidden */
  71631. uvPattern: RegExp;
  71632. /** @hidden */
  71633. facePattern1: RegExp;
  71634. /** @hidden */
  71635. facePattern2: RegExp;
  71636. /** @hidden */
  71637. facePattern3: RegExp;
  71638. /** @hidden */
  71639. facePattern4: RegExp;
  71640. /** @hidden */
  71641. facePattern5: RegExp;
  71642. private _meshLoadOptions;
  71643. /**
  71644. * Creates loader for .OBJ files
  71645. *
  71646. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  71647. */
  71648. constructor(meshLoadOptions?: MeshLoadOptions);
  71649. private static readonly currentMeshLoadOptions;
  71650. /**
  71651. * Calls synchronously the MTL file attached to this obj.
  71652. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  71653. * Without this function materials are not displayed in the first frame (but displayed after).
  71654. * In consequence it is impossible to get material information in your HTML file
  71655. *
  71656. * @param url The URL of the MTL file
  71657. * @param rootUrl
  71658. * @param onSuccess Callback function to be called when the MTL file is loaded
  71659. * @private
  71660. */
  71661. private _loadMTL;
  71662. /**
  71663. * Instantiates a OBJ file loader plugin.
  71664. * @returns the created plugin
  71665. */
  71666. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  71667. /**
  71668. * If the data string can be loaded directly.
  71669. *
  71670. * @param data string containing the file data
  71671. * @returns if the data can be loaded directly
  71672. */
  71673. canDirectLoad(data: string): boolean;
  71674. /**
  71675. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  71676. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  71677. * @param scene the scene the meshes should be added to
  71678. * @param data the OBJ data to load
  71679. * @param rootUrl root url to load from
  71680. * @param onProgress event that fires when loading progress has occured
  71681. * @param fileName Defines the name of the file to load
  71682. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  71683. */
  71684. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  71685. meshes: AbstractMesh[];
  71686. particleSystems: IParticleSystem[];
  71687. skeletons: Skeleton[];
  71688. animationGroups: AnimationGroup[];
  71689. }>;
  71690. /**
  71691. * Imports all objects from the loaded OBJ data and adds them to the scene
  71692. * @param scene the scene the objects should be added to
  71693. * @param data the OBJ data to load
  71694. * @param rootUrl root url to load from
  71695. * @param onProgress event that fires when loading progress has occured
  71696. * @param fileName Defines the name of the file to load
  71697. * @returns a promise which completes when objects have been loaded to the scene
  71698. */
  71699. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  71700. /**
  71701. * Load into an asset container.
  71702. * @param scene The scene to load into
  71703. * @param data The data to import
  71704. * @param rootUrl The root url for scene and resources
  71705. * @param onProgress The callback when the load progresses
  71706. * @param fileName Defines the name of the file to load
  71707. * @returns The loaded asset container
  71708. */
  71709. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  71710. /**
  71711. * Read the OBJ file and create an Array of meshes.
  71712. * Each mesh contains all information given by the OBJ and the MTL file.
  71713. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  71714. *
  71715. * @param meshesNames
  71716. * @param scene Scene The scene where are displayed the data
  71717. * @param data String The content of the obj file
  71718. * @param rootUrl String The path to the folder
  71719. * @returns Array<AbstractMesh>
  71720. * @private
  71721. */
  71722. private _parseSolid;
  71723. }
  71724. }
  71725. declare module BABYLON {
  71726. /**
  71727. * STL file type loader.
  71728. * This is a babylon scene loader plugin.
  71729. */
  71730. export class STLFileLoader implements ISceneLoaderPlugin {
  71731. /** @hidden */
  71732. solidPattern: RegExp;
  71733. /** @hidden */
  71734. facetsPattern: RegExp;
  71735. /** @hidden */
  71736. normalPattern: RegExp;
  71737. /** @hidden */
  71738. vertexPattern: RegExp;
  71739. /**
  71740. * Defines the name of the plugin.
  71741. */
  71742. name: string;
  71743. /**
  71744. * Defines the extensions the stl loader is able to load.
  71745. * force data to come in as an ArrayBuffer
  71746. * we'll convert to string if it looks like it's an ASCII .stl
  71747. */
  71748. extensions: ISceneLoaderPluginExtensions;
  71749. /**
  71750. * Import meshes into a scene.
  71751. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  71752. * @param scene The scene to import into
  71753. * @param data The data to import
  71754. * @param rootUrl The root url for scene and resources
  71755. * @param meshes The meshes array to import into
  71756. * @param particleSystems The particle systems array to import into
  71757. * @param skeletons The skeletons array to import into
  71758. * @param onError The callback when import fails
  71759. * @returns True if successful or false otherwise
  71760. */
  71761. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  71762. /**
  71763. * Load into a scene.
  71764. * @param scene The scene to load into
  71765. * @param data The data to import
  71766. * @param rootUrl The root url for scene and resources
  71767. * @param onError The callback when import fails
  71768. * @returns true if successful or false otherwise
  71769. */
  71770. load(scene: Scene, data: any, rootUrl: string): boolean;
  71771. /**
  71772. * Load into an asset container.
  71773. * @param scene The scene to load into
  71774. * @param data The data to import
  71775. * @param rootUrl The root url for scene and resources
  71776. * @param onError The callback when import fails
  71777. * @returns The loaded asset container
  71778. */
  71779. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  71780. private _isBinary;
  71781. private _parseBinary;
  71782. private _parseASCII;
  71783. }
  71784. }
  71785. declare module BABYLON {
  71786. /**
  71787. * Class for generating OBJ data from a Babylon scene.
  71788. */
  71789. export class OBJExport {
  71790. /**
  71791. * Exports the geometry of a Mesh array in .OBJ file format (text)
  71792. * @param mesh defines the list of meshes to serialize
  71793. * @param materials defines if materials should be exported
  71794. * @param matlibname defines the name of the associated mtl file
  71795. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  71796. * @returns the OBJ content
  71797. */
  71798. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  71799. /**
  71800. * Exports the material(s) of a mesh in .MTL file format (text)
  71801. * @param mesh defines the mesh to extract the material from
  71802. * @returns the mtl content
  71803. */
  71804. static MTL(mesh: Mesh): string;
  71805. }
  71806. }
  71807. declare module BABYLON {
  71808. /** @hidden */
  71809. export var __IGLTFExporterExtension: number;
  71810. /**
  71811. * Interface for extending the exporter
  71812. * @hidden
  71813. */
  71814. export interface IGLTFExporterExtension {
  71815. /**
  71816. * The name of this extension
  71817. */
  71818. readonly name: string;
  71819. /**
  71820. * Defines whether this extension is enabled
  71821. */
  71822. enabled: boolean;
  71823. /**
  71824. * Defines whether this extension is required
  71825. */
  71826. required: boolean;
  71827. }
  71828. }
  71829. declare module BABYLON.GLTF2.Exporter {
  71830. /** @hidden */
  71831. export var __IGLTFExporterExtensionV2: number;
  71832. /**
  71833. * Interface for a glTF exporter extension
  71834. * @hidden
  71835. */
  71836. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  71837. /**
  71838. * Define this method to modify the default behavior before exporting a texture
  71839. * @param context The context when loading the asset
  71840. * @param babylonTexture The Babylon.js texture
  71841. * @param mimeType The mime-type of the generated image
  71842. * @returns A promise that resolves with the exported texture
  71843. */
  71844. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  71845. /**
  71846. * Define this method to get notified when a texture info is created
  71847. * @param context The context when loading the asset
  71848. * @param textureInfo The glTF texture info
  71849. * @param babylonTexture The Babylon.js texture
  71850. */
  71851. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  71852. /**
  71853. * Define this method to modify the default behavior when exporting texture info
  71854. * @param context The context when loading the asset
  71855. * @param meshPrimitive glTF mesh primitive
  71856. * @param babylonSubMesh Babylon submesh
  71857. * @param binaryWriter glTF serializer binary writer instance
  71858. * @returns nullable IMeshPrimitive promise
  71859. */
  71860. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  71861. /**
  71862. * Define this method to modify the default behavior when exporting a node
  71863. * @param context The context when exporting the node
  71864. * @param node glTF node
  71865. * @param babylonNode BabylonJS node
  71866. * @returns nullable INode promise
  71867. */
  71868. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Promise<INode>;
  71869. /**
  71870. * Define this method to modify the default behavior when exporting a material
  71871. * @param material glTF material
  71872. * @param babylonMaterial BabylonJS material
  71873. * @returns nullable IMaterial promise
  71874. */
  71875. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  71876. /**
  71877. * Defint this method to return additional textures to export from a material
  71878. * @param material glTF material
  71879. * @param babylonMaterial BabylonJS material
  71880. * @returns List of textures
  71881. */
  71882. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  71883. /**
  71884. * Called after the exporter state changes to EXPORTING
  71885. */
  71886. onExporting?(): void;
  71887. }
  71888. }
  71889. declare module BABYLON.GLTF2.Exporter {
  71890. /**
  71891. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  71892. * @hidden
  71893. */
  71894. export class _GLTFMaterialExporter {
  71895. /**
  71896. * Represents the dielectric specular values for R, G and B
  71897. */
  71898. private static readonly _DielectricSpecular;
  71899. /**
  71900. * Allows the maximum specular power to be defined for material calculations
  71901. */
  71902. private static readonly _MaxSpecularPower;
  71903. /**
  71904. * Mapping to store textures
  71905. */
  71906. private _textureMap;
  71907. /**
  71908. * Numeric tolerance value
  71909. */
  71910. private static readonly _Epsilon;
  71911. /**
  71912. * Reference to the glTF Exporter
  71913. */
  71914. private _exporter;
  71915. constructor(exporter: _Exporter);
  71916. /**
  71917. * Specifies if two colors are approximately equal in value
  71918. * @param color1 first color to compare to
  71919. * @param color2 second color to compare to
  71920. * @param epsilon threshold value
  71921. */
  71922. private static FuzzyEquals;
  71923. /**
  71924. * Gets the materials from a Babylon scene and converts them to glTF materials
  71925. * @param scene babylonjs scene
  71926. * @param mimeType texture mime type
  71927. * @param images array of images
  71928. * @param textures array of textures
  71929. * @param materials array of materials
  71930. * @param imageData mapping of texture names to base64 textures
  71931. * @param hasTextureCoords specifies if texture coordinates are present on the material
  71932. */
  71933. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  71934. /**
  71935. * Makes a copy of the glTF material without the texture parameters
  71936. * @param originalMaterial original glTF material
  71937. * @returns glTF material without texture parameters
  71938. */
  71939. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  71940. /**
  71941. * Specifies if the material has any texture parameters present
  71942. * @param material glTF Material
  71943. * @returns boolean specifying if texture parameters are present
  71944. */
  71945. _hasTexturesPresent(material: IMaterial): boolean;
  71946. /**
  71947. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  71948. * @param babylonStandardMaterial
  71949. * @returns glTF Metallic Roughness Material representation
  71950. */
  71951. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  71952. /**
  71953. * Computes the metallic factor
  71954. * @param diffuse diffused value
  71955. * @param specular specular value
  71956. * @param oneMinusSpecularStrength one minus the specular strength
  71957. * @returns metallic value
  71958. */
  71959. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  71960. /**
  71961. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  71962. * @param glTFMaterial glTF material
  71963. * @param babylonMaterial Babylon material
  71964. */
  71965. private static _SetAlphaMode;
  71966. /**
  71967. * Converts a Babylon Standard Material to a glTF Material
  71968. * @param babylonStandardMaterial BJS Standard Material
  71969. * @param mimeType mime type to use for the textures
  71970. * @param images array of glTF image interfaces
  71971. * @param textures array of glTF texture interfaces
  71972. * @param materials array of glTF material interfaces
  71973. * @param imageData map of image file name to data
  71974. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  71975. */
  71976. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  71977. private _finishMaterial;
  71978. /**
  71979. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  71980. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  71981. * @param mimeType mime type to use for the textures
  71982. * @param images array of glTF image interfaces
  71983. * @param textures array of glTF texture interfaces
  71984. * @param materials array of glTF material interfaces
  71985. * @param imageData map of image file name to data
  71986. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  71987. */
  71988. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  71989. /**
  71990. * Converts an image typed array buffer to a base64 image
  71991. * @param buffer typed array buffer
  71992. * @param width width of the image
  71993. * @param height height of the image
  71994. * @param mimeType mimetype of the image
  71995. * @returns base64 image string
  71996. */
  71997. private _createBase64FromCanvasAsync;
  71998. /**
  71999. * Generates a white texture based on the specified width and height
  72000. * @param width width of the texture in pixels
  72001. * @param height height of the texture in pixels
  72002. * @param scene babylonjs scene
  72003. * @returns white texture
  72004. */
  72005. private _createWhiteTexture;
  72006. /**
  72007. * 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
  72008. * @param texture1 first texture to resize
  72009. * @param texture2 second texture to resize
  72010. * @param scene babylonjs scene
  72011. * @returns resized textures or null
  72012. */
  72013. private _resizeTexturesToSameDimensions;
  72014. /**
  72015. * Converts an array of pixels to a Float32Array
  72016. * Throws an error if the pixel format is not supported
  72017. * @param pixels - array buffer containing pixel values
  72018. * @returns Float32 of pixels
  72019. */
  72020. private _convertPixelArrayToFloat32;
  72021. /**
  72022. * Convert Specular Glossiness Textures to Metallic Roughness
  72023. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  72024. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  72025. * @param diffuseTexture texture used to store diffuse information
  72026. * @param specularGlossinessTexture texture used to store specular and glossiness information
  72027. * @param factors specular glossiness material factors
  72028. * @param mimeType the mime type to use for the texture
  72029. * @returns pbr metallic roughness interface or null
  72030. */
  72031. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  72032. /**
  72033. * Converts specular glossiness material properties to metallic roughness
  72034. * @param specularGlossiness interface with specular glossiness material properties
  72035. * @returns interface with metallic roughness material properties
  72036. */
  72037. private _convertSpecularGlossinessToMetallicRoughness;
  72038. /**
  72039. * Calculates the surface reflectance, independent of lighting conditions
  72040. * @param color Color source to calculate brightness from
  72041. * @returns number representing the perceived brightness, or zero if color is undefined
  72042. */
  72043. private _getPerceivedBrightness;
  72044. /**
  72045. * Returns the maximum color component value
  72046. * @param color
  72047. * @returns maximum color component value, or zero if color is null or undefined
  72048. */
  72049. private _getMaxComponent;
  72050. /**
  72051. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  72052. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  72053. * @param mimeType mime type to use for the textures
  72054. * @param images array of glTF image interfaces
  72055. * @param textures array of glTF texture interfaces
  72056. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  72057. * @param imageData map of image file name to data
  72058. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  72059. * @returns glTF PBR Metallic Roughness factors
  72060. */
  72061. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  72062. private _getGLTFTextureSampler;
  72063. private _getGLTFTextureWrapMode;
  72064. private _getGLTFTextureWrapModesSampler;
  72065. /**
  72066. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  72067. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  72068. * @param mimeType mime type to use for the textures
  72069. * @param images array of glTF image interfaces
  72070. * @param textures array of glTF texture interfaces
  72071. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  72072. * @param imageData map of image file name to data
  72073. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  72074. * @returns glTF PBR Metallic Roughness factors
  72075. */
  72076. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  72077. /**
  72078. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  72079. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  72080. * @param mimeType mime type to use for the textures
  72081. * @param images array of glTF image interfaces
  72082. * @param textures array of glTF texture interfaces
  72083. * @param materials array of glTF material interfaces
  72084. * @param imageData map of image file name to data
  72085. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  72086. */
  72087. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  72088. private setMetallicRoughnessPbrMaterial;
  72089. private getPixelsFromTexture;
  72090. /**
  72091. * Extracts a texture from a Babylon texture into file data and glTF data
  72092. * @param babylonTexture Babylon texture to extract
  72093. * @param mimeType Mime Type of the babylonTexture
  72094. * @return glTF texture info, or null if the texture format is not supported
  72095. */
  72096. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  72097. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  72098. /**
  72099. * Builds a texture from base64 string
  72100. * @param base64Texture base64 texture string
  72101. * @param baseTextureName Name to use for the texture
  72102. * @param mimeType image mime type for the texture
  72103. * @param images array of images
  72104. * @param textures array of textures
  72105. * @param imageData map of image data
  72106. * @returns glTF texture info, or null if the texture format is not supported
  72107. */
  72108. private _getTextureInfoFromBase64;
  72109. }
  72110. }
  72111. declare module BABYLON {
  72112. /**
  72113. * Class for holding and downloading glTF file data
  72114. */
  72115. export class GLTFData {
  72116. /**
  72117. * Object which contains the file name as the key and its data as the value
  72118. */
  72119. glTFFiles: {
  72120. [fileName: string]: string | Blob;
  72121. };
  72122. /**
  72123. * Initializes the glTF file object
  72124. */
  72125. constructor();
  72126. /**
  72127. * Downloads the glTF data as files based on their names and data
  72128. */
  72129. downloadFiles(): void;
  72130. }
  72131. }
  72132. declare module BABYLON {
  72133. /**
  72134. * Holds a collection of exporter options and parameters
  72135. */
  72136. export interface IExportOptions {
  72137. /**
  72138. * Function which indicates whether a babylon node should be exported or not
  72139. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  72140. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  72141. */
  72142. shouldExportNode?(node: Node): boolean;
  72143. /**
  72144. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  72145. * @param metadata source metadata to read from
  72146. * @returns the data to store to glTF node extras
  72147. */
  72148. metadataSelector?(metadata: any): any;
  72149. /**
  72150. * The sample rate to bake animation curves
  72151. */
  72152. animationSampleRate?: number;
  72153. /**
  72154. * Begin serialization without waiting for the scene to be ready
  72155. */
  72156. exportWithoutWaitingForScene?: boolean;
  72157. }
  72158. /**
  72159. * Class for generating glTF data from a Babylon scene.
  72160. */
  72161. export class GLTF2Export {
  72162. /**
  72163. * Exports the geometry of the scene to .gltf file format asynchronously
  72164. * @param scene Babylon scene with scene hierarchy information
  72165. * @param filePrefix File prefix to use when generating the glTF file
  72166. * @param options Exporter options
  72167. * @returns Returns an object with a .gltf file and associates texture names
  72168. * as keys and their data and paths as values
  72169. */
  72170. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  72171. private static _PreExportAsync;
  72172. private static _PostExportAsync;
  72173. /**
  72174. * Exports the geometry of the scene to .glb file format asychronously
  72175. * @param scene Babylon scene with scene hierarchy information
  72176. * @param filePrefix File prefix to use when generating glb file
  72177. * @param options Exporter options
  72178. * @returns Returns an object with a .glb filename as key and data as value
  72179. */
  72180. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  72181. }
  72182. }
  72183. declare module BABYLON.GLTF2.Exporter {
  72184. /**
  72185. * @hidden
  72186. */
  72187. export class _GLTFUtilities {
  72188. /**
  72189. * Creates a buffer view based on the supplied arguments
  72190. * @param bufferIndex index value of the specified buffer
  72191. * @param byteOffset byte offset value
  72192. * @param byteLength byte length of the bufferView
  72193. * @param byteStride byte distance between conequential elements
  72194. * @param name name of the buffer view
  72195. * @returns bufferView for glTF
  72196. */
  72197. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  72198. /**
  72199. * Creates an accessor based on the supplied arguments
  72200. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  72201. * @param name The name of the accessor
  72202. * @param type The type of the accessor
  72203. * @param componentType The datatype of components in the attribute
  72204. * @param count The number of attributes referenced by this accessor
  72205. * @param byteOffset The offset relative to the start of the bufferView in bytes
  72206. * @param min Minimum value of each component in this attribute
  72207. * @param max Maximum value of each component in this attribute
  72208. * @returns accessor for glTF
  72209. */
  72210. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  72211. /**
  72212. * Calculates the minimum and maximum values of an array of position floats
  72213. * @param positions Positions array of a mesh
  72214. * @param vertexStart Starting vertex offset to calculate min and max values
  72215. * @param vertexCount Number of vertices to check for min and max values
  72216. * @returns min number array and max number array
  72217. */
  72218. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  72219. min: number[];
  72220. max: number[];
  72221. };
  72222. /**
  72223. * Converts a new right-handed Vector3
  72224. * @param vector vector3 array
  72225. * @returns right-handed Vector3
  72226. */
  72227. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  72228. /**
  72229. * Converts a Vector3 to right-handed
  72230. * @param vector Vector3 to convert to right-handed
  72231. */
  72232. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  72233. /**
  72234. * Converts a three element number array to right-handed
  72235. * @param vector number array to convert to right-handed
  72236. */
  72237. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  72238. /**
  72239. * Converts a new right-handed Vector3
  72240. * @param vector vector3 array
  72241. * @returns right-handed Vector3
  72242. */
  72243. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  72244. /**
  72245. * Converts a Vector3 to right-handed
  72246. * @param vector Vector3 to convert to right-handed
  72247. */
  72248. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  72249. /**
  72250. * Converts a three element number array to right-handed
  72251. * @param vector number array to convert to right-handed
  72252. */
  72253. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  72254. /**
  72255. * Converts a Vector4 to right-handed
  72256. * @param vector Vector4 to convert to right-handed
  72257. */
  72258. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  72259. /**
  72260. * Converts a Vector4 to right-handed
  72261. * @param vector Vector4 to convert to right-handed
  72262. */
  72263. static _GetRightHandedArray4FromRef(vector: number[]): void;
  72264. /**
  72265. * Converts a Quaternion to right-handed
  72266. * @param quaternion Source quaternion to convert to right-handed
  72267. */
  72268. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  72269. /**
  72270. * Converts a Quaternion to right-handed
  72271. * @param quaternion Source quaternion to convert to right-handed
  72272. */
  72273. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  72274. static _NormalizeTangentFromRef(tangent: Vector4): void;
  72275. }
  72276. }
  72277. declare module BABYLON.GLTF2.Exporter {
  72278. /**
  72279. * Converts Babylon Scene into glTF 2.0.
  72280. * @hidden
  72281. */
  72282. export class _Exporter {
  72283. /**
  72284. * Stores the glTF to export
  72285. */
  72286. _glTF: IGLTF;
  72287. /**
  72288. * Stores all generated buffer views, which represents views into the main glTF buffer data
  72289. */
  72290. _bufferViews: IBufferView[];
  72291. /**
  72292. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  72293. */
  72294. _accessors: IAccessor[];
  72295. /**
  72296. * Stores all the generated nodes, which contains transform and/or mesh information per node
  72297. */
  72298. private _nodes;
  72299. /**
  72300. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  72301. */
  72302. private _scenes;
  72303. /**
  72304. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  72305. */
  72306. private _meshes;
  72307. /**
  72308. * Stores all the generated material information, which represents the appearance of each primitive
  72309. */
  72310. _materials: IMaterial[];
  72311. _materialMap: {
  72312. [materialID: number]: number;
  72313. };
  72314. /**
  72315. * Stores all the generated texture information, which is referenced by glTF materials
  72316. */
  72317. _textures: ITexture[];
  72318. /**
  72319. * Stores all the generated image information, which is referenced by glTF textures
  72320. */
  72321. _images: IImage[];
  72322. /**
  72323. * Stores all the texture samplers
  72324. */
  72325. _samplers: ISampler[];
  72326. /**
  72327. * Stores all the generated animation samplers, which is referenced by glTF animations
  72328. */
  72329. /**
  72330. * Stores the animations for glTF models
  72331. */
  72332. private _animations;
  72333. /**
  72334. * Stores the total amount of bytes stored in the glTF buffer
  72335. */
  72336. private _totalByteLength;
  72337. /**
  72338. * Stores a reference to the Babylon scene containing the source geometry and material information
  72339. */
  72340. _babylonScene: Scene;
  72341. /**
  72342. * Stores a map of the image data, where the key is the file name and the value
  72343. * is the image data
  72344. */
  72345. _imageData: {
  72346. [fileName: string]: {
  72347. data: Uint8Array;
  72348. mimeType: ImageMimeType;
  72349. };
  72350. };
  72351. /**
  72352. * Stores a map of the unique id of a node to its index in the node array
  72353. */
  72354. private _nodeMap;
  72355. /**
  72356. * Specifies if the Babylon scene should be converted to right-handed on export
  72357. */
  72358. _convertToRightHandedSystem: boolean;
  72359. /**
  72360. * Baked animation sample rate
  72361. */
  72362. private _animationSampleRate;
  72363. private _options;
  72364. private _localEngine;
  72365. _glTFMaterialExporter: _GLTFMaterialExporter;
  72366. private _extensions;
  72367. private static _ExtensionNames;
  72368. private static _ExtensionFactories;
  72369. private _applyExtension;
  72370. private _applyExtensions;
  72371. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  72372. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  72373. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<Nullable<INode>>;
  72374. _extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  72375. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  72376. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  72377. private _forEachExtensions;
  72378. private _extensionsOnExporting;
  72379. /**
  72380. * Load glTF serializer extensions
  72381. */
  72382. private _loadExtensions;
  72383. /**
  72384. * Creates a glTF Exporter instance, which can accept optional exporter options
  72385. * @param babylonScene Babylon scene object
  72386. * @param options Options to modify the behavior of the exporter
  72387. */
  72388. constructor(babylonScene: Scene, options?: IExportOptions);
  72389. dispose(): void;
  72390. /**
  72391. * Registers a glTF exporter extension
  72392. * @param name Name of the extension to export
  72393. * @param factory The factory function that creates the exporter extension
  72394. */
  72395. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  72396. /**
  72397. * Un-registers an exporter extension
  72398. * @param name The name fo the exporter extension
  72399. * @returns A boolean indicating whether the extension has been un-registered
  72400. */
  72401. static UnregisterExtension(name: string): boolean;
  72402. /**
  72403. * Lazy load a local engine with premultiplied alpha set to false
  72404. */
  72405. _getLocalEngine(): Engine;
  72406. private reorderIndicesBasedOnPrimitiveMode;
  72407. /**
  72408. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  72409. * clock-wise during export to glTF
  72410. * @param submesh BabylonJS submesh
  72411. * @param primitiveMode Primitive mode of the mesh
  72412. * @param sideOrientation the winding order of the submesh
  72413. * @param vertexBufferKind The type of vertex attribute
  72414. * @param meshAttributeArray The vertex attribute data
  72415. * @param byteOffset The offset to the binary data
  72416. * @param binaryWriter The binary data for the glTF file
  72417. */
  72418. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  72419. /**
  72420. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  72421. * clock-wise during export to glTF
  72422. * @param submesh BabylonJS submesh
  72423. * @param primitiveMode Primitive mode of the mesh
  72424. * @param sideOrientation the winding order of the submesh
  72425. * @param vertexBufferKind The type of vertex attribute
  72426. * @param meshAttributeArray The vertex attribute data
  72427. * @param byteOffset The offset to the binary data
  72428. * @param binaryWriter The binary data for the glTF file
  72429. */
  72430. private reorderTriangleFillMode;
  72431. /**
  72432. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  72433. * clock-wise during export to glTF
  72434. * @param submesh BabylonJS submesh
  72435. * @param primitiveMode Primitive mode of the mesh
  72436. * @param sideOrientation the winding order of the submesh
  72437. * @param vertexBufferKind The type of vertex attribute
  72438. * @param meshAttributeArray The vertex attribute data
  72439. * @param byteOffset The offset to the binary data
  72440. * @param binaryWriter The binary data for the glTF file
  72441. */
  72442. private reorderTriangleStripDrawMode;
  72443. /**
  72444. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  72445. * clock-wise during export to glTF
  72446. * @param submesh BabylonJS submesh
  72447. * @param primitiveMode Primitive mode of the mesh
  72448. * @param sideOrientation the winding order of the submesh
  72449. * @param vertexBufferKind The type of vertex attribute
  72450. * @param meshAttributeArray The vertex attribute data
  72451. * @param byteOffset The offset to the binary data
  72452. * @param binaryWriter The binary data for the glTF file
  72453. */
  72454. private reorderTriangleFanMode;
  72455. /**
  72456. * Writes the vertex attribute data to binary
  72457. * @param vertices The vertices to write to the binary writer
  72458. * @param byteOffset The offset into the binary writer to overwrite binary data
  72459. * @param vertexAttributeKind The vertex attribute type
  72460. * @param meshAttributeArray The vertex attribute data
  72461. * @param binaryWriter The writer containing the binary data
  72462. */
  72463. private writeVertexAttributeData;
  72464. /**
  72465. * Writes mesh attribute data to a data buffer
  72466. * Returns the bytelength of the data
  72467. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  72468. * @param meshAttributeArray Array containing the attribute data
  72469. * @param binaryWriter The buffer to write the binary data to
  72470. * @param indices Used to specify the order of the vertex data
  72471. */
  72472. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  72473. /**
  72474. * Generates glTF json data
  72475. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  72476. * @param glTFPrefix Text to use when prefixing a glTF file
  72477. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  72478. * @returns json data as string
  72479. */
  72480. private generateJSON;
  72481. /**
  72482. * Generates data for .gltf and .bin files based on the glTF prefix string
  72483. * @param glTFPrefix Text to use when prefixing a glTF file
  72484. * @param dispose Dispose the exporter
  72485. * @returns GLTFData with glTF file data
  72486. */
  72487. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  72488. /**
  72489. * Creates a binary buffer for glTF
  72490. * @returns array buffer for binary data
  72491. */
  72492. private _generateBinaryAsync;
  72493. /**
  72494. * Pads the number to a multiple of 4
  72495. * @param num number to pad
  72496. * @returns padded number
  72497. */
  72498. private _getPadding;
  72499. /**
  72500. * @hidden
  72501. */
  72502. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  72503. /**
  72504. * Sets the TRS for each node
  72505. * @param node glTF Node for storing the transformation data
  72506. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  72507. */
  72508. private setNodeTransformation;
  72509. private getVertexBufferFromMesh;
  72510. /**
  72511. * Creates a bufferview based on the vertices type for the Babylon mesh
  72512. * @param kind Indicates the type of vertices data
  72513. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  72514. * @param binaryWriter The buffer to write the bufferview data to
  72515. */
  72516. private createBufferViewKind;
  72517. /**
  72518. * The primitive mode of the Babylon mesh
  72519. * @param babylonMesh The BabylonJS mesh
  72520. */
  72521. private getMeshPrimitiveMode;
  72522. /**
  72523. * Sets the primitive mode of the glTF mesh primitive
  72524. * @param meshPrimitive glTF mesh primitive
  72525. * @param primitiveMode The primitive mode
  72526. */
  72527. private setPrimitiveMode;
  72528. /**
  72529. * Sets the vertex attribute accessor based of the glTF mesh primitive
  72530. * @param meshPrimitive glTF mesh primitive
  72531. * @param attributeKind vertex attribute
  72532. * @returns boolean specifying if uv coordinates are present
  72533. */
  72534. private setAttributeKind;
  72535. /**
  72536. * Sets data for the primitive attributes of each submesh
  72537. * @param mesh glTF Mesh object to store the primitive attribute information
  72538. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  72539. * @param binaryWriter Buffer to write the attribute data to
  72540. */
  72541. private setPrimitiveAttributesAsync;
  72542. /**
  72543. * Creates a glTF scene based on the array of meshes
  72544. * Returns the the total byte offset
  72545. * @param babylonScene Babylon scene to get the mesh data from
  72546. * @param binaryWriter Buffer to write binary data to
  72547. */
  72548. private createSceneAsync;
  72549. /**
  72550. * Creates a mapping of Node unique id to node index and handles animations
  72551. * @param babylonScene Babylon Scene
  72552. * @param nodes Babylon transform nodes
  72553. * @param binaryWriter Buffer to write binary data to
  72554. * @returns Node mapping of unique id to index
  72555. */
  72556. private createNodeMapAndAnimationsAsync;
  72557. /**
  72558. * Creates a glTF node from a Babylon mesh
  72559. * @param babylonMesh Source Babylon mesh
  72560. * @param binaryWriter Buffer for storing geometry data
  72561. * @returns glTF node
  72562. */
  72563. private createNodeAsync;
  72564. }
  72565. /**
  72566. * @hidden
  72567. *
  72568. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  72569. */
  72570. export class _BinaryWriter {
  72571. /**
  72572. * Array buffer which stores all binary data
  72573. */
  72574. private _arrayBuffer;
  72575. /**
  72576. * View of the array buffer
  72577. */
  72578. private _dataView;
  72579. /**
  72580. * byte offset of data in array buffer
  72581. */
  72582. private _byteOffset;
  72583. /**
  72584. * Initialize binary writer with an initial byte length
  72585. * @param byteLength Initial byte length of the array buffer
  72586. */
  72587. constructor(byteLength: number);
  72588. /**
  72589. * Resize the array buffer to the specified byte length
  72590. * @param byteLength
  72591. */
  72592. private resizeBuffer;
  72593. /**
  72594. * Get an array buffer with the length of the byte offset
  72595. * @returns ArrayBuffer resized to the byte offset
  72596. */
  72597. getArrayBuffer(): ArrayBuffer;
  72598. /**
  72599. * Get the byte offset of the array buffer
  72600. * @returns byte offset
  72601. */
  72602. getByteOffset(): number;
  72603. /**
  72604. * Stores an UInt8 in the array buffer
  72605. * @param entry
  72606. * @param byteOffset If defined, specifies where to set the value as an offset.
  72607. */
  72608. setUInt8(entry: number, byteOffset?: number): void;
  72609. /**
  72610. * Gets an UInt32 in the array buffer
  72611. * @param entry
  72612. * @param byteOffset If defined, specifies where to set the value as an offset.
  72613. */
  72614. getUInt32(byteOffset: number): number;
  72615. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  72616. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  72617. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  72618. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  72619. /**
  72620. * Stores a Float32 in the array buffer
  72621. * @param entry
  72622. */
  72623. setFloat32(entry: number, byteOffset?: number): void;
  72624. /**
  72625. * Stores an UInt32 in the array buffer
  72626. * @param entry
  72627. * @param byteOffset If defined, specifies where to set the value as an offset.
  72628. */
  72629. setUInt32(entry: number, byteOffset?: number): void;
  72630. }
  72631. }
  72632. declare module BABYLON.GLTF2.Exporter {
  72633. /**
  72634. * @hidden
  72635. * Interface to store animation data.
  72636. */
  72637. export interface _IAnimationData {
  72638. /**
  72639. * Keyframe data.
  72640. */
  72641. inputs: number[];
  72642. /**
  72643. * Value data.
  72644. */
  72645. outputs: number[][];
  72646. /**
  72647. * Animation interpolation data.
  72648. */
  72649. samplerInterpolation: AnimationSamplerInterpolation;
  72650. /**
  72651. * Minimum keyframe value.
  72652. */
  72653. inputsMin: number;
  72654. /**
  72655. * Maximum keyframe value.
  72656. */
  72657. inputsMax: number;
  72658. }
  72659. /**
  72660. * @hidden
  72661. */
  72662. export interface _IAnimationInfo {
  72663. /**
  72664. * The target channel for the animation
  72665. */
  72666. animationChannelTargetPath: AnimationChannelTargetPath;
  72667. /**
  72668. * The glTF accessor type for the data.
  72669. */
  72670. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  72671. /**
  72672. * Specifies if quaternions should be used.
  72673. */
  72674. useQuaternion: boolean;
  72675. }
  72676. /**
  72677. * @hidden
  72678. * Utility class for generating glTF animation data from BabylonJS.
  72679. */
  72680. export class _GLTFAnimation {
  72681. /**
  72682. * @ignore
  72683. *
  72684. * Creates glTF channel animation from BabylonJS animation.
  72685. * @param babylonTransformNode - BabylonJS mesh.
  72686. * @param animation - animation.
  72687. * @param animationChannelTargetPath - The target animation channel.
  72688. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  72689. * @param useQuaternion - Specifies if quaternions are used.
  72690. * @returns nullable IAnimationData
  72691. */
  72692. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  72693. private static _DeduceAnimationInfo;
  72694. /**
  72695. * @ignore
  72696. * Create node animations from the transform node animations
  72697. * @param babylonNode
  72698. * @param runtimeGLTFAnimation
  72699. * @param idleGLTFAnimations
  72700. * @param nodeMap
  72701. * @param nodes
  72702. * @param binaryWriter
  72703. * @param bufferViews
  72704. * @param accessors
  72705. * @param convertToRightHandedSystem
  72706. */
  72707. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  72708. [key: number]: number;
  72709. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  72710. /**
  72711. * @ignore
  72712. * Create node animations from the animation groups
  72713. * @param babylonScene
  72714. * @param glTFAnimations
  72715. * @param nodeMap
  72716. * @param nodes
  72717. * @param binaryWriter
  72718. * @param bufferViews
  72719. * @param accessors
  72720. * @param convertToRightHandedSystem
  72721. */
  72722. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  72723. [key: number]: number;
  72724. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  72725. private static AddAnimation;
  72726. /**
  72727. * Create a baked animation
  72728. * @param babylonTransformNode BabylonJS mesh
  72729. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  72730. * @param animationChannelTargetPath animation target channel
  72731. * @param minFrame minimum animation frame
  72732. * @param maxFrame maximum animation frame
  72733. * @param fps frames per second of the animation
  72734. * @param inputs input key frames of the animation
  72735. * @param outputs output key frame data of the animation
  72736. * @param convertToRightHandedSystem converts the values to right-handed
  72737. * @param useQuaternion specifies if quaternions should be used
  72738. */
  72739. private static _CreateBakedAnimation;
  72740. private static _ConvertFactorToVector3OrQuaternion;
  72741. private static _SetInterpolatedValue;
  72742. /**
  72743. * Creates linear animation from the animation key frames
  72744. * @param babylonTransformNode BabylonJS mesh
  72745. * @param animation BabylonJS animation
  72746. * @param animationChannelTargetPath The target animation channel
  72747. * @param frameDelta The difference between the last and first frame of the animation
  72748. * @param inputs Array to store the key frame times
  72749. * @param outputs Array to store the key frame data
  72750. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  72751. * @param useQuaternion Specifies if quaternions are used in the animation
  72752. */
  72753. private static _CreateLinearOrStepAnimation;
  72754. /**
  72755. * Creates cubic spline animation from the animation key frames
  72756. * @param babylonTransformNode BabylonJS mesh
  72757. * @param animation BabylonJS animation
  72758. * @param animationChannelTargetPath The target animation channel
  72759. * @param frameDelta The difference between the last and first frame of the animation
  72760. * @param inputs Array to store the key frame times
  72761. * @param outputs Array to store the key frame data
  72762. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  72763. * @param useQuaternion Specifies if quaternions are used in the animation
  72764. */
  72765. private static _CreateCubicSplineAnimation;
  72766. private static _GetBasePositionRotationOrScale;
  72767. /**
  72768. * Adds a key frame value
  72769. * @param keyFrame
  72770. * @param animation
  72771. * @param outputs
  72772. * @param animationChannelTargetPath
  72773. * @param basePositionRotationOrScale
  72774. * @param convertToRightHandedSystem
  72775. * @param useQuaternion
  72776. */
  72777. private static _AddKeyframeValue;
  72778. /**
  72779. * Determine the interpolation based on the key frames
  72780. * @param keyFrames
  72781. * @param animationChannelTargetPath
  72782. * @param useQuaternion
  72783. */
  72784. private static _DeduceInterpolation;
  72785. /**
  72786. * Adds an input tangent or output tangent to the output data
  72787. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  72788. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  72789. * @param outputs The animation data by keyframe
  72790. * @param animationChannelTargetPath The target animation channel
  72791. * @param interpolation The interpolation type
  72792. * @param keyFrame The key frame with the animation data
  72793. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  72794. * @param useQuaternion Specifies if quaternions are used
  72795. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  72796. */
  72797. private static AddSplineTangent;
  72798. /**
  72799. * Get the minimum and maximum key frames' frame values
  72800. * @param keyFrames animation key frames
  72801. * @returns the minimum and maximum key frame value
  72802. */
  72803. private static calculateMinMaxKeyFrames;
  72804. }
  72805. }
  72806. declare module BABYLON.GLTF2.Exporter {
  72807. /** @hidden */
  72808. export var textureTransformPixelShader: {
  72809. name: string;
  72810. shader: string;
  72811. };
  72812. }
  72813. declare module BABYLON.GLTF2.Exporter.Extensions {
  72814. /**
  72815. * @hidden
  72816. */
  72817. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  72818. private _recordedTextures;
  72819. /** Name of this extension */
  72820. readonly name: string;
  72821. /** Defines whether this extension is enabled */
  72822. enabled: boolean;
  72823. /** Defines whether this extension is required */
  72824. required: boolean;
  72825. /** Reference to the glTF exporter */
  72826. private _exporter;
  72827. constructor(exporter: _Exporter);
  72828. dispose(): void;
  72829. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  72830. /**
  72831. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  72832. * @param babylonTexture
  72833. * @param offset
  72834. * @param rotation
  72835. * @param scale
  72836. * @param scene
  72837. */
  72838. private _textureTransformTextureAsync;
  72839. }
  72840. }
  72841. declare module BABYLON.GLTF2.Exporter.Extensions {
  72842. /**
  72843. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  72844. */
  72845. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  72846. /** The name of this extension. */
  72847. readonly name: string;
  72848. /** Defines whether this extension is enabled. */
  72849. enabled: boolean;
  72850. /** Defines whether this extension is required */
  72851. required: boolean;
  72852. /** Reference to the glTF exporter */
  72853. private _exporter;
  72854. private _lights;
  72855. /** @hidden */
  72856. constructor(exporter: _Exporter);
  72857. /** @hidden */
  72858. dispose(): void;
  72859. /** @hidden */
  72860. onExporting(): void;
  72861. /**
  72862. * Define this method to modify the default behavior when exporting a node
  72863. * @param context The context when exporting the node
  72864. * @param node glTF node
  72865. * @param babylonNode BabylonJS node
  72866. * @returns nullable INode promise
  72867. */
  72868. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<INode>;
  72869. }
  72870. }
  72871. declare module BABYLON.GLTF2.Exporter.Extensions {
  72872. /**
  72873. * @hidden
  72874. */
  72875. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  72876. /** Name of this extension */
  72877. readonly name: string;
  72878. /** Defines whether this extension is enabled */
  72879. enabled: boolean;
  72880. /** Defines whether this extension is required */
  72881. required: boolean;
  72882. /** Reference to the glTF exporter */
  72883. private _exporter;
  72884. private _textureInfo;
  72885. private _exportedTexture;
  72886. private _wasUsed;
  72887. constructor(exporter: _Exporter);
  72888. dispose(): void;
  72889. /** @hidden */
  72890. onExporting(): void;
  72891. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  72892. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  72893. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  72894. }
  72895. }
  72896. declare module BABYLON {
  72897. /**
  72898. * Class for generating STL data from a Babylon scene.
  72899. */
  72900. export class STLExport {
  72901. /**
  72902. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  72903. * @param meshes list defines the mesh to serialize
  72904. * @param download triggers the automatic download of the file.
  72905. * @param fileName changes the downloads fileName.
  72906. * @param binary changes the STL to a binary type.
  72907. * @param isLittleEndian toggle for binary type exporter.
  72908. * @returns the STL as UTF8 string
  72909. */
  72910. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  72911. }
  72912. }
  72913. declare module "babylonjs-gltf2interface" {
  72914. export = BABYLON.GLTF2;
  72915. }
  72916. /**
  72917. * Module for glTF 2.0 Interface
  72918. */
  72919. declare module BABYLON.GLTF2 {
  72920. /**
  72921. * The datatype of the components in the attribute
  72922. */
  72923. const enum AccessorComponentType {
  72924. /**
  72925. * Byte
  72926. */
  72927. BYTE = 5120,
  72928. /**
  72929. * Unsigned Byte
  72930. */
  72931. UNSIGNED_BYTE = 5121,
  72932. /**
  72933. * Short
  72934. */
  72935. SHORT = 5122,
  72936. /**
  72937. * Unsigned Short
  72938. */
  72939. UNSIGNED_SHORT = 5123,
  72940. /**
  72941. * Unsigned Int
  72942. */
  72943. UNSIGNED_INT = 5125,
  72944. /**
  72945. * Float
  72946. */
  72947. FLOAT = 5126,
  72948. }
  72949. /**
  72950. * Specifies if the attirbute is a scalar, vector, or matrix
  72951. */
  72952. const enum AccessorType {
  72953. /**
  72954. * Scalar
  72955. */
  72956. SCALAR = "SCALAR",
  72957. /**
  72958. * Vector2
  72959. */
  72960. VEC2 = "VEC2",
  72961. /**
  72962. * Vector3
  72963. */
  72964. VEC3 = "VEC3",
  72965. /**
  72966. * Vector4
  72967. */
  72968. VEC4 = "VEC4",
  72969. /**
  72970. * Matrix2x2
  72971. */
  72972. MAT2 = "MAT2",
  72973. /**
  72974. * Matrix3x3
  72975. */
  72976. MAT3 = "MAT3",
  72977. /**
  72978. * Matrix4x4
  72979. */
  72980. MAT4 = "MAT4",
  72981. }
  72982. /**
  72983. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  72984. */
  72985. const enum AnimationChannelTargetPath {
  72986. /**
  72987. * Translation
  72988. */
  72989. TRANSLATION = "translation",
  72990. /**
  72991. * Rotation
  72992. */
  72993. ROTATION = "rotation",
  72994. /**
  72995. * Scale
  72996. */
  72997. SCALE = "scale",
  72998. /**
  72999. * Weights
  73000. */
  73001. WEIGHTS = "weights",
  73002. }
  73003. /**
  73004. * Interpolation algorithm
  73005. */
  73006. const enum AnimationSamplerInterpolation {
  73007. /**
  73008. * The animated values are linearly interpolated between keyframes
  73009. */
  73010. LINEAR = "LINEAR",
  73011. /**
  73012. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  73013. */
  73014. STEP = "STEP",
  73015. /**
  73016. * The animation's interpolation is computed using a cubic spline with specified tangents
  73017. */
  73018. CUBICSPLINE = "CUBICSPLINE",
  73019. }
  73020. /**
  73021. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  73022. */
  73023. const enum CameraType {
  73024. /**
  73025. * A perspective camera containing properties to create a perspective projection matrix
  73026. */
  73027. PERSPECTIVE = "perspective",
  73028. /**
  73029. * An orthographic camera containing properties to create an orthographic projection matrix
  73030. */
  73031. ORTHOGRAPHIC = "orthographic",
  73032. }
  73033. /**
  73034. * The mime-type of the image
  73035. */
  73036. const enum ImageMimeType {
  73037. /**
  73038. * JPEG Mime-type
  73039. */
  73040. JPEG = "image/jpeg",
  73041. /**
  73042. * PNG Mime-type
  73043. */
  73044. PNG = "image/png",
  73045. }
  73046. /**
  73047. * The alpha rendering mode of the material
  73048. */
  73049. const enum MaterialAlphaMode {
  73050. /**
  73051. * The alpha value is ignored and the rendered output is fully opaque
  73052. */
  73053. OPAQUE = "OPAQUE",
  73054. /**
  73055. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  73056. */
  73057. MASK = "MASK",
  73058. /**
  73059. * 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)
  73060. */
  73061. BLEND = "BLEND",
  73062. }
  73063. /**
  73064. * The type of the primitives to render
  73065. */
  73066. const enum MeshPrimitiveMode {
  73067. /**
  73068. * Points
  73069. */
  73070. POINTS = 0,
  73071. /**
  73072. * Lines
  73073. */
  73074. LINES = 1,
  73075. /**
  73076. * Line Loop
  73077. */
  73078. LINE_LOOP = 2,
  73079. /**
  73080. * Line Strip
  73081. */
  73082. LINE_STRIP = 3,
  73083. /**
  73084. * Triangles
  73085. */
  73086. TRIANGLES = 4,
  73087. /**
  73088. * Triangle Strip
  73089. */
  73090. TRIANGLE_STRIP = 5,
  73091. /**
  73092. * Triangle Fan
  73093. */
  73094. TRIANGLE_FAN = 6,
  73095. }
  73096. /**
  73097. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  73098. */
  73099. const enum TextureMagFilter {
  73100. /**
  73101. * Nearest
  73102. */
  73103. NEAREST = 9728,
  73104. /**
  73105. * Linear
  73106. */
  73107. LINEAR = 9729,
  73108. }
  73109. /**
  73110. * Minification filter. All valid values correspond to WebGL enums
  73111. */
  73112. const enum TextureMinFilter {
  73113. /**
  73114. * Nearest
  73115. */
  73116. NEAREST = 9728,
  73117. /**
  73118. * Linear
  73119. */
  73120. LINEAR = 9729,
  73121. /**
  73122. * Nearest Mip-Map Nearest
  73123. */
  73124. NEAREST_MIPMAP_NEAREST = 9984,
  73125. /**
  73126. * Linear Mipmap Nearest
  73127. */
  73128. LINEAR_MIPMAP_NEAREST = 9985,
  73129. /**
  73130. * Nearest Mipmap Linear
  73131. */
  73132. NEAREST_MIPMAP_LINEAR = 9986,
  73133. /**
  73134. * Linear Mipmap Linear
  73135. */
  73136. LINEAR_MIPMAP_LINEAR = 9987,
  73137. }
  73138. /**
  73139. * S (U) wrapping mode. All valid values correspond to WebGL enums
  73140. */
  73141. const enum TextureWrapMode {
  73142. /**
  73143. * Clamp to Edge
  73144. */
  73145. CLAMP_TO_EDGE = 33071,
  73146. /**
  73147. * Mirrored Repeat
  73148. */
  73149. MIRRORED_REPEAT = 33648,
  73150. /**
  73151. * Repeat
  73152. */
  73153. REPEAT = 10497,
  73154. }
  73155. /**
  73156. * glTF Property
  73157. */
  73158. interface IProperty {
  73159. /**
  73160. * Dictionary object with extension-specific objects
  73161. */
  73162. extensions?: {
  73163. [key: string]: any;
  73164. };
  73165. /**
  73166. * Application-Specific data
  73167. */
  73168. extras?: any;
  73169. }
  73170. /**
  73171. * glTF Child of Root Property
  73172. */
  73173. interface IChildRootProperty extends IProperty {
  73174. /**
  73175. * The user-defined name of this object
  73176. */
  73177. name?: string;
  73178. }
  73179. /**
  73180. * Indices of those attributes that deviate from their initialization value
  73181. */
  73182. interface IAccessorSparseIndices extends IProperty {
  73183. /**
  73184. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  73185. */
  73186. bufferView: number;
  73187. /**
  73188. * The offset relative to the start of the bufferView in bytes. Must be aligned
  73189. */
  73190. byteOffset?: number;
  73191. /**
  73192. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  73193. */
  73194. componentType: AccessorComponentType;
  73195. }
  73196. /**
  73197. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  73198. */
  73199. interface IAccessorSparseValues extends IProperty {
  73200. /**
  73201. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  73202. */
  73203. bufferView: number;
  73204. /**
  73205. * The offset relative to the start of the bufferView in bytes. Must be aligned
  73206. */
  73207. byteOffset?: number;
  73208. }
  73209. /**
  73210. * Sparse storage of attributes that deviate from their initialization value
  73211. */
  73212. interface IAccessorSparse extends IProperty {
  73213. /**
  73214. * The number of attributes encoded in this sparse accessor
  73215. */
  73216. count: number;
  73217. /**
  73218. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  73219. */
  73220. indices: IAccessorSparseIndices;
  73221. /**
  73222. * 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
  73223. */
  73224. values: IAccessorSparseValues;
  73225. }
  73226. /**
  73227. * 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
  73228. */
  73229. interface IAccessor extends IChildRootProperty {
  73230. /**
  73231. * The index of the bufferview
  73232. */
  73233. bufferView?: number;
  73234. /**
  73235. * The offset relative to the start of the bufferView in bytes
  73236. */
  73237. byteOffset?: number;
  73238. /**
  73239. * The datatype of components in the attribute
  73240. */
  73241. componentType: AccessorComponentType;
  73242. /**
  73243. * Specifies whether integer data values should be normalized
  73244. */
  73245. normalized?: boolean;
  73246. /**
  73247. * The number of attributes referenced by this accessor
  73248. */
  73249. count: number;
  73250. /**
  73251. * Specifies if the attribute is a scalar, vector, or matrix
  73252. */
  73253. type: AccessorType;
  73254. /**
  73255. * Maximum value of each component in this attribute
  73256. */
  73257. max?: number[];
  73258. /**
  73259. * Minimum value of each component in this attribute
  73260. */
  73261. min?: number[];
  73262. /**
  73263. * Sparse storage of attributes that deviate from their initialization value
  73264. */
  73265. sparse?: IAccessorSparse;
  73266. }
  73267. /**
  73268. * Targets an animation's sampler at a node's property
  73269. */
  73270. interface IAnimationChannel extends IProperty {
  73271. /**
  73272. * The index of a sampler in this animation used to compute the value for the target
  73273. */
  73274. sampler: number;
  73275. /**
  73276. * The index of the node and TRS property to target
  73277. */
  73278. target: IAnimationChannelTarget;
  73279. }
  73280. /**
  73281. * The index of the node and TRS property that an animation channel targets
  73282. */
  73283. interface IAnimationChannelTarget extends IProperty {
  73284. /**
  73285. * The index of the node to target
  73286. */
  73287. node: number;
  73288. /**
  73289. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  73290. */
  73291. path: AnimationChannelTargetPath;
  73292. }
  73293. /**
  73294. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  73295. */
  73296. interface IAnimationSampler extends IProperty {
  73297. /**
  73298. * The index of an accessor containing keyframe input values, e.g., time
  73299. */
  73300. input: number;
  73301. /**
  73302. * Interpolation algorithm
  73303. */
  73304. interpolation?: AnimationSamplerInterpolation;
  73305. /**
  73306. * The index of an accessor, containing keyframe output values
  73307. */
  73308. output: number;
  73309. }
  73310. /**
  73311. * A keyframe animation
  73312. */
  73313. interface IAnimation extends IChildRootProperty {
  73314. /**
  73315. * An array of channels, each of which targets an animation's sampler at a node's property
  73316. */
  73317. channels: IAnimationChannel[];
  73318. /**
  73319. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  73320. */
  73321. samplers: IAnimationSampler[];
  73322. }
  73323. /**
  73324. * Metadata about the glTF asset
  73325. */
  73326. interface IAsset extends IChildRootProperty {
  73327. /**
  73328. * A copyright message suitable for display to credit the content creator
  73329. */
  73330. copyright?: string;
  73331. /**
  73332. * Tool that generated this glTF model. Useful for debugging
  73333. */
  73334. generator?: string;
  73335. /**
  73336. * The glTF version that this asset targets
  73337. */
  73338. version: string;
  73339. /**
  73340. * The minimum glTF version that this asset targets
  73341. */
  73342. minVersion?: string;
  73343. }
  73344. /**
  73345. * A buffer points to binary geometry, animation, or skins
  73346. */
  73347. interface IBuffer extends IChildRootProperty {
  73348. /**
  73349. * 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
  73350. */
  73351. uri?: string;
  73352. /**
  73353. * The length of the buffer in bytes
  73354. */
  73355. byteLength: number;
  73356. }
  73357. /**
  73358. * A view into a buffer generally representing a subset of the buffer
  73359. */
  73360. interface IBufferView extends IChildRootProperty {
  73361. /**
  73362. * The index of the buffer
  73363. */
  73364. buffer: number;
  73365. /**
  73366. * The offset into the buffer in bytes
  73367. */
  73368. byteOffset?: number;
  73369. /**
  73370. * The lenth of the bufferView in bytes
  73371. */
  73372. byteLength: number;
  73373. /**
  73374. * The stride, in bytes
  73375. */
  73376. byteStride?: number;
  73377. }
  73378. /**
  73379. * An orthographic camera containing properties to create an orthographic projection matrix
  73380. */
  73381. interface ICameraOrthographic extends IProperty {
  73382. /**
  73383. * The floating-point horizontal magnification of the view. Must not be zero
  73384. */
  73385. xmag: number;
  73386. /**
  73387. * The floating-point vertical magnification of the view. Must not be zero
  73388. */
  73389. ymag: number;
  73390. /**
  73391. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  73392. */
  73393. zfar: number;
  73394. /**
  73395. * The floating-point distance to the near clipping plane
  73396. */
  73397. znear: number;
  73398. }
  73399. /**
  73400. * A perspective camera containing properties to create a perspective projection matrix
  73401. */
  73402. interface ICameraPerspective extends IProperty {
  73403. /**
  73404. * The floating-point aspect ratio of the field of view
  73405. */
  73406. aspectRatio?: number;
  73407. /**
  73408. * The floating-point vertical field of view in radians
  73409. */
  73410. yfov: number;
  73411. /**
  73412. * The floating-point distance to the far clipping plane
  73413. */
  73414. zfar?: number;
  73415. /**
  73416. * The floating-point distance to the near clipping plane
  73417. */
  73418. znear: number;
  73419. }
  73420. /**
  73421. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  73422. */
  73423. interface ICamera extends IChildRootProperty {
  73424. /**
  73425. * An orthographic camera containing properties to create an orthographic projection matrix
  73426. */
  73427. orthographic?: ICameraOrthographic;
  73428. /**
  73429. * A perspective camera containing properties to create a perspective projection matrix
  73430. */
  73431. perspective?: ICameraPerspective;
  73432. /**
  73433. * Specifies if the camera uses a perspective or orthographic projection
  73434. */
  73435. type: CameraType;
  73436. }
  73437. /**
  73438. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  73439. */
  73440. interface IImage extends IChildRootProperty {
  73441. /**
  73442. * 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
  73443. */
  73444. uri?: string;
  73445. /**
  73446. * The image's MIME type
  73447. */
  73448. mimeType?: ImageMimeType;
  73449. /**
  73450. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  73451. */
  73452. bufferView?: number;
  73453. }
  73454. /**
  73455. * Material Normal Texture Info
  73456. */
  73457. interface IMaterialNormalTextureInfo extends ITextureInfo {
  73458. /**
  73459. * The scalar multiplier applied to each normal vector of the normal texture
  73460. */
  73461. scale?: number;
  73462. }
  73463. /**
  73464. * Material Occlusion Texture Info
  73465. */
  73466. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  73467. /**
  73468. * A scalar multiplier controlling the amount of occlusion applied
  73469. */
  73470. strength?: number;
  73471. }
  73472. /**
  73473. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  73474. */
  73475. interface IMaterialPbrMetallicRoughness {
  73476. /**
  73477. * The material's base color factor
  73478. */
  73479. baseColorFactor?: number[];
  73480. /**
  73481. * The base color texture
  73482. */
  73483. baseColorTexture?: ITextureInfo;
  73484. /**
  73485. * The metalness of the material
  73486. */
  73487. metallicFactor?: number;
  73488. /**
  73489. * The roughness of the material
  73490. */
  73491. roughnessFactor?: number;
  73492. /**
  73493. * The metallic-roughness texture
  73494. */
  73495. metallicRoughnessTexture?: ITextureInfo;
  73496. }
  73497. /**
  73498. * The material appearance of a primitive
  73499. */
  73500. interface IMaterial extends IChildRootProperty {
  73501. /**
  73502. * 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
  73503. */
  73504. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  73505. /**
  73506. * The normal map texture
  73507. */
  73508. normalTexture?: IMaterialNormalTextureInfo;
  73509. /**
  73510. * The occlusion map texture
  73511. */
  73512. occlusionTexture?: IMaterialOcclusionTextureInfo;
  73513. /**
  73514. * The emissive map texture
  73515. */
  73516. emissiveTexture?: ITextureInfo;
  73517. /**
  73518. * 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
  73519. */
  73520. emissiveFactor?: number[];
  73521. /**
  73522. * The alpha rendering mode of the material
  73523. */
  73524. alphaMode?: MaterialAlphaMode;
  73525. /**
  73526. * The alpha cutoff value of the material
  73527. */
  73528. alphaCutoff?: number;
  73529. /**
  73530. * Specifies whether the material is double sided
  73531. */
  73532. doubleSided?: boolean;
  73533. }
  73534. /**
  73535. * Geometry to be rendered with the given material
  73536. */
  73537. interface IMeshPrimitive extends IProperty {
  73538. /**
  73539. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  73540. */
  73541. attributes: {
  73542. [name: string]: number;
  73543. };
  73544. /**
  73545. * The index of the accessor that contains the indices
  73546. */
  73547. indices?: number;
  73548. /**
  73549. * The index of the material to apply to this primitive when rendering
  73550. */
  73551. material?: number;
  73552. /**
  73553. * The type of primitives to render. All valid values correspond to WebGL enums
  73554. */
  73555. mode?: MeshPrimitiveMode;
  73556. /**
  73557. * 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
  73558. */
  73559. targets?: {
  73560. [name: string]: number;
  73561. }[];
  73562. }
  73563. /**
  73564. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  73565. */
  73566. interface IMesh extends IChildRootProperty {
  73567. /**
  73568. * An array of primitives, each defining geometry to be rendered with a material
  73569. */
  73570. primitives: IMeshPrimitive[];
  73571. /**
  73572. * Array of weights to be applied to the Morph Targets
  73573. */
  73574. weights?: number[];
  73575. }
  73576. /**
  73577. * A node in the node hierarchy
  73578. */
  73579. interface INode extends IChildRootProperty {
  73580. /**
  73581. * The index of the camera referenced by this node
  73582. */
  73583. camera?: number;
  73584. /**
  73585. * The indices of this node's children
  73586. */
  73587. children?: number[];
  73588. /**
  73589. * The index of the skin referenced by this node
  73590. */
  73591. skin?: number;
  73592. /**
  73593. * A floating-point 4x4 transformation matrix stored in column-major order
  73594. */
  73595. matrix?: number[];
  73596. /**
  73597. * The index of the mesh in this node
  73598. */
  73599. mesh?: number;
  73600. /**
  73601. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  73602. */
  73603. rotation?: number[];
  73604. /**
  73605. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  73606. */
  73607. scale?: number[];
  73608. /**
  73609. * The node's translation along the x, y, and z axes
  73610. */
  73611. translation?: number[];
  73612. /**
  73613. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  73614. */
  73615. weights?: number[];
  73616. }
  73617. /**
  73618. * Texture sampler properties for filtering and wrapping modes
  73619. */
  73620. interface ISampler extends IChildRootProperty {
  73621. /**
  73622. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  73623. */
  73624. magFilter?: TextureMagFilter;
  73625. /**
  73626. * Minification filter. All valid values correspond to WebGL enums
  73627. */
  73628. minFilter?: TextureMinFilter;
  73629. /**
  73630. * S (U) wrapping mode. All valid values correspond to WebGL enums
  73631. */
  73632. wrapS?: TextureWrapMode;
  73633. /**
  73634. * T (V) wrapping mode. All valid values correspond to WebGL enums
  73635. */
  73636. wrapT?: TextureWrapMode;
  73637. }
  73638. /**
  73639. * The root nodes of a scene
  73640. */
  73641. interface IScene extends IChildRootProperty {
  73642. /**
  73643. * The indices of each root node
  73644. */
  73645. nodes: number[];
  73646. }
  73647. /**
  73648. * Joints and matrices defining a skin
  73649. */
  73650. interface ISkin extends IChildRootProperty {
  73651. /**
  73652. * 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
  73653. */
  73654. inverseBindMatrices?: number;
  73655. /**
  73656. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  73657. */
  73658. skeleton?: number;
  73659. /**
  73660. * 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)
  73661. */
  73662. joints: number[];
  73663. }
  73664. /**
  73665. * A texture and its sampler
  73666. */
  73667. interface ITexture extends IChildRootProperty {
  73668. /**
  73669. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  73670. */
  73671. sampler?: number;
  73672. /**
  73673. * The index of the image used by this texture
  73674. */
  73675. source: number;
  73676. }
  73677. /**
  73678. * Reference to a texture
  73679. */
  73680. interface ITextureInfo extends IProperty {
  73681. /**
  73682. * The index of the texture
  73683. */
  73684. index: number;
  73685. /**
  73686. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  73687. */
  73688. texCoord?: number;
  73689. }
  73690. /**
  73691. * The root object for a glTF asset
  73692. */
  73693. interface IGLTF extends IProperty {
  73694. /**
  73695. * An array of accessors. An accessor is a typed view into a bufferView
  73696. */
  73697. accessors?: IAccessor[];
  73698. /**
  73699. * An array of keyframe animations
  73700. */
  73701. animations?: IAnimation[];
  73702. /**
  73703. * Metadata about the glTF asset
  73704. */
  73705. asset: IAsset;
  73706. /**
  73707. * An array of buffers. A buffer points to binary geometry, animation, or skins
  73708. */
  73709. buffers?: IBuffer[];
  73710. /**
  73711. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  73712. */
  73713. bufferViews?: IBufferView[];
  73714. /**
  73715. * An array of cameras
  73716. */
  73717. cameras?: ICamera[];
  73718. /**
  73719. * Names of glTF extensions used somewhere in this asset
  73720. */
  73721. extensionsUsed?: string[];
  73722. /**
  73723. * Names of glTF extensions required to properly load this asset
  73724. */
  73725. extensionsRequired?: string[];
  73726. /**
  73727. * An array of images. An image defines data used to create a texture
  73728. */
  73729. images?: IImage[];
  73730. /**
  73731. * An array of materials. A material defines the appearance of a primitive
  73732. */
  73733. materials?: IMaterial[];
  73734. /**
  73735. * An array of meshes. A mesh is a set of primitives to be rendered
  73736. */
  73737. meshes?: IMesh[];
  73738. /**
  73739. * An array of nodes
  73740. */
  73741. nodes?: INode[];
  73742. /**
  73743. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  73744. */
  73745. samplers?: ISampler[];
  73746. /**
  73747. * The index of the default scene
  73748. */
  73749. scene?: number;
  73750. /**
  73751. * An array of scenes
  73752. */
  73753. scenes?: IScene[];
  73754. /**
  73755. * An array of skins. A skin is defined by joints and matrices
  73756. */
  73757. skins?: ISkin[];
  73758. /**
  73759. * An array of textures
  73760. */
  73761. textures?: ITexture[];
  73762. }
  73763. /**
  73764. * The glTF validation results
  73765. * @ignore
  73766. */
  73767. interface IGLTFValidationResults {
  73768. info: {
  73769. generator: string;
  73770. hasAnimations: boolean;
  73771. hasDefaultScene: boolean;
  73772. hasMaterials: boolean;
  73773. hasMorphTargets: boolean;
  73774. hasSkins: boolean;
  73775. hasTextures: boolean;
  73776. maxAttributesUsed: number;
  73777. primitivesCount: number
  73778. };
  73779. issues: {
  73780. messages: Array<string>;
  73781. numErrors: number;
  73782. numHints: number;
  73783. numInfos: number;
  73784. numWarnings: number;
  73785. truncated: boolean
  73786. };
  73787. mimeType: string;
  73788. uri: string;
  73789. validatedAt: string;
  73790. validatorVersion: string;
  73791. }
  73792. /**
  73793. * The glTF validation options
  73794. */
  73795. interface IGLTFValidationOptions {
  73796. /** Uri to use */
  73797. uri?: string;
  73798. /** Function used to load external resources */
  73799. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  73800. /** Boolean indicating that we need to validate accessor data */
  73801. validateAccessorData?: boolean;
  73802. /** max number of issues allowed */
  73803. maxIssues?: number;
  73804. /** Ignored issues */
  73805. ignoredIssues?: Array<string>;
  73806. /** Value to override severy settings */
  73807. severityOverrides?: Object;
  73808. }
  73809. /**
  73810. * The glTF validator object
  73811. * @ignore
  73812. */
  73813. interface IGLTFValidator {
  73814. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  73815. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  73816. }
  73817. }
  73818. declare module BABYLON {
  73819. /** @hidden */
  73820. export var cellPixelShader: {
  73821. name: string;
  73822. shader: string;
  73823. };
  73824. }
  73825. declare module BABYLON {
  73826. /** @hidden */
  73827. export var cellVertexShader: {
  73828. name: string;
  73829. shader: string;
  73830. };
  73831. }
  73832. declare module BABYLON {
  73833. export class CellMaterial extends BABYLON.PushMaterial {
  73834. private _diffuseTexture;
  73835. diffuseTexture: BABYLON.BaseTexture;
  73836. diffuseColor: BABYLON.Color3;
  73837. _computeHighLevel: boolean;
  73838. computeHighLevel: boolean;
  73839. private _disableLighting;
  73840. disableLighting: boolean;
  73841. private _maxSimultaneousLights;
  73842. maxSimultaneousLights: number;
  73843. private _renderId;
  73844. constructor(name: string, scene: BABYLON.Scene);
  73845. needAlphaBlending(): boolean;
  73846. needAlphaTesting(): boolean;
  73847. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73848. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73849. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73850. getAnimatables(): BABYLON.IAnimatable[];
  73851. getActiveTextures(): BABYLON.BaseTexture[];
  73852. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73853. dispose(forceDisposeEffect?: boolean): void;
  73854. getClassName(): string;
  73855. clone(name: string): CellMaterial;
  73856. serialize(): any;
  73857. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  73858. }
  73859. }
  73860. declare module BABYLON {
  73861. export class CustomShaderStructure {
  73862. FragmentStore: string;
  73863. VertexStore: string;
  73864. constructor();
  73865. }
  73866. export class ShaderSpecialParts {
  73867. constructor();
  73868. Fragment_Begin: string;
  73869. Fragment_Definitions: string;
  73870. Fragment_MainBegin: string;
  73871. Fragment_Custom_Diffuse: string;
  73872. Fragment_Before_Lights: string;
  73873. Fragment_Before_Fog: string;
  73874. Fragment_Custom_Alpha: string;
  73875. Fragment_Before_FragColor: string;
  73876. Vertex_Begin: string;
  73877. Vertex_Definitions: string;
  73878. Vertex_MainBegin: string;
  73879. Vertex_Before_PositionUpdated: string;
  73880. Vertex_Before_NormalUpdated: string;
  73881. Vertex_MainEnd: string;
  73882. }
  73883. export class CustomMaterial extends BABYLON.StandardMaterial {
  73884. static ShaderIndexer: number;
  73885. CustomParts: ShaderSpecialParts;
  73886. _isCreatedShader: boolean;
  73887. _createdShaderName: string;
  73888. _customUniform: string[];
  73889. _newUniforms: string[];
  73890. _newUniformInstances: any[];
  73891. _newSamplerInstances: BABYLON.Texture[];
  73892. FragmentShader: string;
  73893. VertexShader: string;
  73894. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  73895. ReviewUniform(name: string, arr: string[]): string[];
  73896. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  73897. constructor(name: string, scene: BABYLON.Scene);
  73898. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  73899. Fragment_Begin(shaderPart: string): CustomMaterial;
  73900. Fragment_Definitions(shaderPart: string): CustomMaterial;
  73901. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  73902. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  73903. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  73904. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  73905. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  73906. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  73907. Vertex_Begin(shaderPart: string): CustomMaterial;
  73908. Vertex_Definitions(shaderPart: string): CustomMaterial;
  73909. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  73910. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  73911. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  73912. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  73913. }
  73914. }
  73915. declare module BABYLON {
  73916. export class ShaderAlebdoParts {
  73917. constructor();
  73918. Fragment_Begin: string;
  73919. Fragment_Definitions: string;
  73920. Fragment_MainBegin: string;
  73921. Fragment_Custom_Albedo: string;
  73922. Fragment_Before_Lights: string;
  73923. Fragment_Custom_MetallicRoughness: string;
  73924. Fragment_Custom_MicroSurface: string;
  73925. Fragment_Before_Fog: string;
  73926. Fragment_Custom_Alpha: string;
  73927. Fragment_Before_FragColor: string;
  73928. Vertex_Begin: string;
  73929. Vertex_Definitions: string;
  73930. Vertex_MainBegin: string;
  73931. Vertex_Before_PositionUpdated: string;
  73932. Vertex_Before_NormalUpdated: string;
  73933. Vertex_MainEnd: string;
  73934. }
  73935. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  73936. static ShaderIndexer: number;
  73937. CustomParts: ShaderAlebdoParts;
  73938. _isCreatedShader: boolean;
  73939. _createdShaderName: string;
  73940. _customUniform: string[];
  73941. _newUniforms: string[];
  73942. _newUniformInstances: any[];
  73943. _newSamplerInstances: BABYLON.Texture[];
  73944. FragmentShader: string;
  73945. VertexShader: string;
  73946. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  73947. ReviewUniform(name: string, arr: string[]): string[];
  73948. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  73949. constructor(name: string, scene: BABYLON.Scene);
  73950. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  73951. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  73952. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  73953. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  73954. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  73955. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  73956. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  73957. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  73958. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  73959. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  73960. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  73961. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  73962. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  73963. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  73964. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  73965. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  73966. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  73967. }
  73968. }
  73969. declare module BABYLON {
  73970. /** @hidden */
  73971. export var firePixelShader: {
  73972. name: string;
  73973. shader: string;
  73974. };
  73975. }
  73976. declare module BABYLON {
  73977. /** @hidden */
  73978. export var fireVertexShader: {
  73979. name: string;
  73980. shader: string;
  73981. };
  73982. }
  73983. declare module BABYLON {
  73984. export class FireMaterial extends BABYLON.PushMaterial {
  73985. private _diffuseTexture;
  73986. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  73987. private _distortionTexture;
  73988. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  73989. private _opacityTexture;
  73990. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  73991. diffuseColor: BABYLON.Color3;
  73992. speed: number;
  73993. private _scaledDiffuse;
  73994. private _renderId;
  73995. private _lastTime;
  73996. constructor(name: string, scene: BABYLON.Scene);
  73997. needAlphaBlending(): boolean;
  73998. needAlphaTesting(): boolean;
  73999. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74000. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74001. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74002. getAnimatables(): BABYLON.IAnimatable[];
  74003. getActiveTextures(): BABYLON.BaseTexture[];
  74004. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74005. getClassName(): string;
  74006. dispose(forceDisposeEffect?: boolean): void;
  74007. clone(name: string): FireMaterial;
  74008. serialize(): any;
  74009. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  74010. }
  74011. }
  74012. declare module BABYLON {
  74013. /** @hidden */
  74014. export var furPixelShader: {
  74015. name: string;
  74016. shader: string;
  74017. };
  74018. }
  74019. declare module BABYLON {
  74020. /** @hidden */
  74021. export var furVertexShader: {
  74022. name: string;
  74023. shader: string;
  74024. };
  74025. }
  74026. declare module BABYLON {
  74027. export class FurMaterial extends BABYLON.PushMaterial {
  74028. private _diffuseTexture;
  74029. diffuseTexture: BABYLON.BaseTexture;
  74030. private _heightTexture;
  74031. heightTexture: BABYLON.BaseTexture;
  74032. diffuseColor: BABYLON.Color3;
  74033. furLength: number;
  74034. furAngle: number;
  74035. furColor: BABYLON.Color3;
  74036. furOffset: number;
  74037. furSpacing: number;
  74038. furGravity: BABYLON.Vector3;
  74039. furSpeed: number;
  74040. furDensity: number;
  74041. furOcclusion: number;
  74042. furTexture: BABYLON.DynamicTexture;
  74043. private _disableLighting;
  74044. disableLighting: boolean;
  74045. private _maxSimultaneousLights;
  74046. maxSimultaneousLights: number;
  74047. highLevelFur: boolean;
  74048. _meshes: BABYLON.AbstractMesh[];
  74049. private _renderId;
  74050. private _furTime;
  74051. constructor(name: string, scene: BABYLON.Scene);
  74052. furTime: number;
  74053. needAlphaBlending(): boolean;
  74054. needAlphaTesting(): boolean;
  74055. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74056. updateFur(): void;
  74057. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74058. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74059. getAnimatables(): BABYLON.IAnimatable[];
  74060. getActiveTextures(): BABYLON.BaseTexture[];
  74061. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74062. dispose(forceDisposeEffect?: boolean): void;
  74063. clone(name: string): FurMaterial;
  74064. serialize(): any;
  74065. getClassName(): string;
  74066. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  74067. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  74068. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  74069. }
  74070. }
  74071. declare module BABYLON {
  74072. /** @hidden */
  74073. export var gradientPixelShader: {
  74074. name: string;
  74075. shader: string;
  74076. };
  74077. }
  74078. declare module BABYLON {
  74079. /** @hidden */
  74080. export var gradientVertexShader: {
  74081. name: string;
  74082. shader: string;
  74083. };
  74084. }
  74085. declare module BABYLON {
  74086. export class GradientMaterial extends BABYLON.PushMaterial {
  74087. private _maxSimultaneousLights;
  74088. maxSimultaneousLights: number;
  74089. topColor: BABYLON.Color3;
  74090. topColorAlpha: number;
  74091. bottomColor: BABYLON.Color3;
  74092. bottomColorAlpha: number;
  74093. offset: number;
  74094. scale: number;
  74095. smoothness: number;
  74096. private _disableLighting;
  74097. disableLighting: boolean;
  74098. private _renderId;
  74099. constructor(name: string, scene: BABYLON.Scene);
  74100. needAlphaBlending(): boolean;
  74101. needAlphaTesting(): boolean;
  74102. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74103. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74104. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74105. getAnimatables(): BABYLON.IAnimatable[];
  74106. dispose(forceDisposeEffect?: boolean): void;
  74107. clone(name: string): GradientMaterial;
  74108. serialize(): any;
  74109. getClassName(): string;
  74110. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  74111. }
  74112. }
  74113. declare module BABYLON {
  74114. /** @hidden */
  74115. export var gridPixelShader: {
  74116. name: string;
  74117. shader: string;
  74118. };
  74119. }
  74120. declare module BABYLON {
  74121. /** @hidden */
  74122. export var gridVertexShader: {
  74123. name: string;
  74124. shader: string;
  74125. };
  74126. }
  74127. declare module BABYLON {
  74128. /**
  74129. * The grid materials allows you to wrap any shape with a grid.
  74130. * Colors are customizable.
  74131. */
  74132. export class GridMaterial extends BABYLON.PushMaterial {
  74133. /**
  74134. * Main color of the grid (e.g. between lines)
  74135. */
  74136. mainColor: BABYLON.Color3;
  74137. /**
  74138. * Color of the grid lines.
  74139. */
  74140. lineColor: BABYLON.Color3;
  74141. /**
  74142. * The scale of the grid compared to unit.
  74143. */
  74144. gridRatio: number;
  74145. /**
  74146. * Allows setting an offset for the grid lines.
  74147. */
  74148. gridOffset: BABYLON.Vector3;
  74149. /**
  74150. * The frequency of thicker lines.
  74151. */
  74152. majorUnitFrequency: number;
  74153. /**
  74154. * The visibility of minor units in the grid.
  74155. */
  74156. minorUnitVisibility: number;
  74157. /**
  74158. * The grid opacity outside of the lines.
  74159. */
  74160. opacity: number;
  74161. /**
  74162. * Determine RBG output is premultiplied by alpha value.
  74163. */
  74164. preMultiplyAlpha: boolean;
  74165. private _opacityTexture;
  74166. opacityTexture: BABYLON.BaseTexture;
  74167. private _gridControl;
  74168. private _renderId;
  74169. /**
  74170. * constructor
  74171. * @param name The name given to the material in order to identify it afterwards.
  74172. * @param scene The scene the material is used in.
  74173. */
  74174. constructor(name: string, scene: BABYLON.Scene);
  74175. /**
  74176. * Returns wehter or not the grid requires alpha blending.
  74177. */
  74178. needAlphaBlending(): boolean;
  74179. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  74180. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74181. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74182. /**
  74183. * Dispose the material and its associated resources.
  74184. * @param forceDisposeEffect will also dispose the used effect when true
  74185. */
  74186. dispose(forceDisposeEffect?: boolean): void;
  74187. clone(name: string): GridMaterial;
  74188. serialize(): any;
  74189. getClassName(): string;
  74190. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  74191. }
  74192. }
  74193. declare module BABYLON {
  74194. /** @hidden */
  74195. export var lavaPixelShader: {
  74196. name: string;
  74197. shader: string;
  74198. };
  74199. }
  74200. declare module BABYLON {
  74201. /** @hidden */
  74202. export var lavaVertexShader: {
  74203. name: string;
  74204. shader: string;
  74205. };
  74206. }
  74207. declare module BABYLON {
  74208. export class LavaMaterial extends BABYLON.PushMaterial {
  74209. private _diffuseTexture;
  74210. diffuseTexture: BABYLON.BaseTexture;
  74211. noiseTexture: BABYLON.BaseTexture;
  74212. fogColor: BABYLON.Color3;
  74213. speed: number;
  74214. movingSpeed: number;
  74215. lowFrequencySpeed: number;
  74216. fogDensity: number;
  74217. private _lastTime;
  74218. diffuseColor: BABYLON.Color3;
  74219. private _disableLighting;
  74220. disableLighting: boolean;
  74221. private _unlit;
  74222. unlit: boolean;
  74223. private _maxSimultaneousLights;
  74224. maxSimultaneousLights: number;
  74225. private _scaledDiffuse;
  74226. private _renderId;
  74227. constructor(name: string, scene: BABYLON.Scene);
  74228. needAlphaBlending(): boolean;
  74229. needAlphaTesting(): boolean;
  74230. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74231. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74232. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74233. getAnimatables(): BABYLON.IAnimatable[];
  74234. getActiveTextures(): BABYLON.BaseTexture[];
  74235. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74236. dispose(forceDisposeEffect?: boolean): void;
  74237. clone(name: string): LavaMaterial;
  74238. serialize(): any;
  74239. getClassName(): string;
  74240. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  74241. }
  74242. }
  74243. declare module BABYLON {
  74244. /** @hidden */
  74245. export var mixPixelShader: {
  74246. name: string;
  74247. shader: string;
  74248. };
  74249. }
  74250. declare module BABYLON {
  74251. /** @hidden */
  74252. export var mixVertexShader: {
  74253. name: string;
  74254. shader: string;
  74255. };
  74256. }
  74257. declare module BABYLON {
  74258. export class MixMaterial extends BABYLON.PushMaterial {
  74259. /**
  74260. * Mix textures
  74261. */
  74262. private _mixTexture1;
  74263. mixTexture1: BABYLON.BaseTexture;
  74264. private _mixTexture2;
  74265. mixTexture2: BABYLON.BaseTexture;
  74266. /**
  74267. * Diffuse textures
  74268. */
  74269. private _diffuseTexture1;
  74270. diffuseTexture1: BABYLON.Texture;
  74271. private _diffuseTexture2;
  74272. diffuseTexture2: BABYLON.Texture;
  74273. private _diffuseTexture3;
  74274. diffuseTexture3: BABYLON.Texture;
  74275. private _diffuseTexture4;
  74276. diffuseTexture4: BABYLON.Texture;
  74277. private _diffuseTexture5;
  74278. diffuseTexture5: BABYLON.Texture;
  74279. private _diffuseTexture6;
  74280. diffuseTexture6: BABYLON.Texture;
  74281. private _diffuseTexture7;
  74282. diffuseTexture7: BABYLON.Texture;
  74283. private _diffuseTexture8;
  74284. diffuseTexture8: BABYLON.Texture;
  74285. /**
  74286. * Uniforms
  74287. */
  74288. diffuseColor: BABYLON.Color3;
  74289. specularColor: BABYLON.Color3;
  74290. specularPower: number;
  74291. private _disableLighting;
  74292. disableLighting: boolean;
  74293. private _maxSimultaneousLights;
  74294. maxSimultaneousLights: number;
  74295. private _renderId;
  74296. constructor(name: string, scene: BABYLON.Scene);
  74297. needAlphaBlending(): boolean;
  74298. needAlphaTesting(): boolean;
  74299. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74300. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74301. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74302. getAnimatables(): BABYLON.IAnimatable[];
  74303. getActiveTextures(): BABYLON.BaseTexture[];
  74304. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74305. dispose(forceDisposeEffect?: boolean): void;
  74306. clone(name: string): MixMaterial;
  74307. serialize(): any;
  74308. getClassName(): string;
  74309. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  74310. }
  74311. }
  74312. declare module BABYLON {
  74313. /** @hidden */
  74314. export var normalPixelShader: {
  74315. name: string;
  74316. shader: string;
  74317. };
  74318. }
  74319. declare module BABYLON {
  74320. /** @hidden */
  74321. export var normalVertexShader: {
  74322. name: string;
  74323. shader: string;
  74324. };
  74325. }
  74326. declare module BABYLON {
  74327. export class NormalMaterial extends BABYLON.PushMaterial {
  74328. private _diffuseTexture;
  74329. diffuseTexture: BABYLON.BaseTexture;
  74330. diffuseColor: BABYLON.Color3;
  74331. private _disableLighting;
  74332. disableLighting: boolean;
  74333. private _maxSimultaneousLights;
  74334. maxSimultaneousLights: number;
  74335. private _renderId;
  74336. constructor(name: string, scene: BABYLON.Scene);
  74337. needAlphaBlending(): boolean;
  74338. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  74339. needAlphaTesting(): boolean;
  74340. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74341. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74342. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74343. getAnimatables(): BABYLON.IAnimatable[];
  74344. getActiveTextures(): BABYLON.BaseTexture[];
  74345. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74346. dispose(forceDisposeEffect?: boolean): void;
  74347. clone(name: string): NormalMaterial;
  74348. serialize(): any;
  74349. getClassName(): string;
  74350. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  74351. }
  74352. }
  74353. declare module BABYLON {
  74354. /** @hidden */
  74355. export var shadowOnlyPixelShader: {
  74356. name: string;
  74357. shader: string;
  74358. };
  74359. }
  74360. declare module BABYLON {
  74361. /** @hidden */
  74362. export var shadowOnlyVertexShader: {
  74363. name: string;
  74364. shader: string;
  74365. };
  74366. }
  74367. declare module BABYLON {
  74368. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  74369. private _renderId;
  74370. private _activeLight;
  74371. constructor(name: string, scene: BABYLON.Scene);
  74372. shadowColor: BABYLON.Color3;
  74373. needAlphaBlending(): boolean;
  74374. needAlphaTesting(): boolean;
  74375. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74376. activeLight: BABYLON.IShadowLight;
  74377. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74378. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74379. clone(name: string): ShadowOnlyMaterial;
  74380. serialize(): any;
  74381. getClassName(): string;
  74382. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  74383. }
  74384. }
  74385. declare module BABYLON {
  74386. /** @hidden */
  74387. export var simplePixelShader: {
  74388. name: string;
  74389. shader: string;
  74390. };
  74391. }
  74392. declare module BABYLON {
  74393. /** @hidden */
  74394. export var simpleVertexShader: {
  74395. name: string;
  74396. shader: string;
  74397. };
  74398. }
  74399. declare module BABYLON {
  74400. export class SimpleMaterial extends BABYLON.PushMaterial {
  74401. private _diffuseTexture;
  74402. diffuseTexture: BABYLON.BaseTexture;
  74403. diffuseColor: BABYLON.Color3;
  74404. private _disableLighting;
  74405. disableLighting: boolean;
  74406. private _maxSimultaneousLights;
  74407. maxSimultaneousLights: number;
  74408. private _renderId;
  74409. constructor(name: string, scene: BABYLON.Scene);
  74410. needAlphaBlending(): boolean;
  74411. needAlphaTesting(): boolean;
  74412. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74413. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74414. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74415. getAnimatables(): BABYLON.IAnimatable[];
  74416. getActiveTextures(): BABYLON.BaseTexture[];
  74417. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74418. dispose(forceDisposeEffect?: boolean): void;
  74419. clone(name: string): SimpleMaterial;
  74420. serialize(): any;
  74421. getClassName(): string;
  74422. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  74423. }
  74424. }
  74425. declare module BABYLON {
  74426. /** @hidden */
  74427. export var skyPixelShader: {
  74428. name: string;
  74429. shader: string;
  74430. };
  74431. }
  74432. declare module BABYLON {
  74433. /** @hidden */
  74434. export var skyVertexShader: {
  74435. name: string;
  74436. shader: string;
  74437. };
  74438. }
  74439. declare module BABYLON {
  74440. /**
  74441. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  74442. * @see https://doc.babylonjs.com/extensions/sky
  74443. */
  74444. export class SkyMaterial extends BABYLON.PushMaterial {
  74445. /**
  74446. * Defines the overall luminance of sky in interval ]0, 1[.
  74447. */
  74448. luminance: number;
  74449. /**
  74450. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  74451. */
  74452. turbidity: number;
  74453. /**
  74454. * Defines the sky appearance (light intensity).
  74455. */
  74456. rayleigh: number;
  74457. /**
  74458. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  74459. */
  74460. mieCoefficient: number;
  74461. /**
  74462. * Defines the amount of haze particles following the Mie scattering theory.
  74463. */
  74464. mieDirectionalG: number;
  74465. /**
  74466. * Defines the distance of the sun according to the active scene camera.
  74467. */
  74468. distance: number;
  74469. /**
  74470. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  74471. * "inclined".
  74472. */
  74473. inclination: number;
  74474. /**
  74475. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  74476. * an object direction and a reference direction.
  74477. */
  74478. azimuth: number;
  74479. /**
  74480. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  74481. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  74482. */
  74483. sunPosition: BABYLON.Vector3;
  74484. /**
  74485. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  74486. * .sunPosition property.
  74487. */
  74488. useSunPosition: boolean;
  74489. /**
  74490. * Defines an offset vector used to get a horizon offset.
  74491. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  74492. */
  74493. cameraOffset: BABYLON.Vector3;
  74494. private _cameraPosition;
  74495. private _renderId;
  74496. /**
  74497. * Instantiates a new sky material.
  74498. * This material allows to create dynamic and texture free
  74499. * effects for skyboxes by taking care of the atmosphere state.
  74500. * @see https://doc.babylonjs.com/extensions/sky
  74501. * @param name Define the name of the material in the scene
  74502. * @param scene Define the scene the material belong to
  74503. */
  74504. constructor(name: string, scene: BABYLON.Scene);
  74505. /**
  74506. * Specifies if the material will require alpha blending
  74507. * @returns a boolean specifying if alpha blending is needed
  74508. */
  74509. needAlphaBlending(): boolean;
  74510. /**
  74511. * Specifies if this material should be rendered in alpha test mode
  74512. * @returns false as the sky material doesn't need alpha testing.
  74513. */
  74514. needAlphaTesting(): boolean;
  74515. /**
  74516. * Get the texture used for alpha test purpose.
  74517. * @returns null as the sky material has no texture.
  74518. */
  74519. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74520. /**
  74521. * Get if the submesh is ready to be used and all its information available.
  74522. * Child classes can use it to update shaders
  74523. * @param mesh defines the mesh to check
  74524. * @param subMesh defines which submesh to check
  74525. * @param useInstances specifies that instances should be used
  74526. * @returns a boolean indicating that the submesh is ready or not
  74527. */
  74528. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74529. /**
  74530. * Binds the submesh to this material by preparing the effect and shader to draw
  74531. * @param world defines the world transformation matrix
  74532. * @param mesh defines the mesh containing the submesh
  74533. * @param subMesh defines the submesh to bind the material to
  74534. */
  74535. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74536. /**
  74537. * Get the list of animatables in the material.
  74538. * @returns the list of animatables object used in the material
  74539. */
  74540. getAnimatables(): BABYLON.IAnimatable[];
  74541. /**
  74542. * Disposes the material
  74543. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  74544. */
  74545. dispose(forceDisposeEffect?: boolean): void;
  74546. /**
  74547. * Makes a duplicate of the material, and gives it a new name
  74548. * @param name defines the new name for the duplicated material
  74549. * @returns the cloned material
  74550. */
  74551. clone(name: string): SkyMaterial;
  74552. /**
  74553. * Serializes this material in a JSON representation
  74554. * @returns the serialized material object
  74555. */
  74556. serialize(): any;
  74557. /**
  74558. * Gets the current class name of the material e.g. "SkyMaterial"
  74559. * Mainly use in serialization.
  74560. * @returns the class name
  74561. */
  74562. getClassName(): string;
  74563. /**
  74564. * Creates a sky material from parsed material data
  74565. * @param source defines the JSON representation of the material
  74566. * @param scene defines the hosting scene
  74567. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  74568. * @returns a new sky material
  74569. */
  74570. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  74571. }
  74572. }
  74573. declare module BABYLON {
  74574. /** @hidden */
  74575. export var terrainPixelShader: {
  74576. name: string;
  74577. shader: string;
  74578. };
  74579. }
  74580. declare module BABYLON {
  74581. /** @hidden */
  74582. export var terrainVertexShader: {
  74583. name: string;
  74584. shader: string;
  74585. };
  74586. }
  74587. declare module BABYLON {
  74588. export class TerrainMaterial extends BABYLON.PushMaterial {
  74589. private _mixTexture;
  74590. mixTexture: BABYLON.BaseTexture;
  74591. private _diffuseTexture1;
  74592. diffuseTexture1: BABYLON.Texture;
  74593. private _diffuseTexture2;
  74594. diffuseTexture2: BABYLON.Texture;
  74595. private _diffuseTexture3;
  74596. diffuseTexture3: BABYLON.Texture;
  74597. private _bumpTexture1;
  74598. bumpTexture1: BABYLON.Texture;
  74599. private _bumpTexture2;
  74600. bumpTexture2: BABYLON.Texture;
  74601. private _bumpTexture3;
  74602. bumpTexture3: BABYLON.Texture;
  74603. diffuseColor: BABYLON.Color3;
  74604. specularColor: BABYLON.Color3;
  74605. specularPower: number;
  74606. private _disableLighting;
  74607. disableLighting: boolean;
  74608. private _maxSimultaneousLights;
  74609. maxSimultaneousLights: number;
  74610. private _renderId;
  74611. constructor(name: string, scene: BABYLON.Scene);
  74612. needAlphaBlending(): boolean;
  74613. needAlphaTesting(): boolean;
  74614. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74615. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74616. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74617. getAnimatables(): BABYLON.IAnimatable[];
  74618. getActiveTextures(): BABYLON.BaseTexture[];
  74619. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74620. dispose(forceDisposeEffect?: boolean): void;
  74621. clone(name: string): TerrainMaterial;
  74622. serialize(): any;
  74623. getClassName(): string;
  74624. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  74625. }
  74626. }
  74627. declare module BABYLON {
  74628. /** @hidden */
  74629. export var triplanarPixelShader: {
  74630. name: string;
  74631. shader: string;
  74632. };
  74633. }
  74634. declare module BABYLON {
  74635. /** @hidden */
  74636. export var triplanarVertexShader: {
  74637. name: string;
  74638. shader: string;
  74639. };
  74640. }
  74641. declare module BABYLON {
  74642. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  74643. mixTexture: BABYLON.BaseTexture;
  74644. private _diffuseTextureX;
  74645. diffuseTextureX: BABYLON.BaseTexture;
  74646. private _diffuseTextureY;
  74647. diffuseTextureY: BABYLON.BaseTexture;
  74648. private _diffuseTextureZ;
  74649. diffuseTextureZ: BABYLON.BaseTexture;
  74650. private _normalTextureX;
  74651. normalTextureX: BABYLON.BaseTexture;
  74652. private _normalTextureY;
  74653. normalTextureY: BABYLON.BaseTexture;
  74654. private _normalTextureZ;
  74655. normalTextureZ: BABYLON.BaseTexture;
  74656. tileSize: number;
  74657. diffuseColor: BABYLON.Color3;
  74658. specularColor: BABYLON.Color3;
  74659. specularPower: number;
  74660. private _disableLighting;
  74661. disableLighting: boolean;
  74662. private _maxSimultaneousLights;
  74663. maxSimultaneousLights: number;
  74664. private _renderId;
  74665. constructor(name: string, scene: BABYLON.Scene);
  74666. needAlphaBlending(): boolean;
  74667. needAlphaTesting(): boolean;
  74668. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74669. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74670. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74671. getAnimatables(): BABYLON.IAnimatable[];
  74672. getActiveTextures(): BABYLON.BaseTexture[];
  74673. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74674. dispose(forceDisposeEffect?: boolean): void;
  74675. clone(name: string): TriPlanarMaterial;
  74676. serialize(): any;
  74677. getClassName(): string;
  74678. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  74679. }
  74680. }
  74681. declare module BABYLON {
  74682. /** @hidden */
  74683. export var waterPixelShader: {
  74684. name: string;
  74685. shader: string;
  74686. };
  74687. }
  74688. declare module BABYLON {
  74689. /** @hidden */
  74690. export var waterVertexShader: {
  74691. name: string;
  74692. shader: string;
  74693. };
  74694. }
  74695. declare module BABYLON {
  74696. export class WaterMaterial extends BABYLON.PushMaterial {
  74697. renderTargetSize: BABYLON.Vector2;
  74698. private _bumpTexture;
  74699. bumpTexture: BABYLON.BaseTexture;
  74700. diffuseColor: BABYLON.Color3;
  74701. specularColor: BABYLON.Color3;
  74702. specularPower: number;
  74703. private _disableLighting;
  74704. disableLighting: boolean;
  74705. private _maxSimultaneousLights;
  74706. maxSimultaneousLights: number;
  74707. /**
  74708. * @param {number}: Represents the wind force
  74709. */
  74710. windForce: number;
  74711. /**
  74712. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  74713. */
  74714. windDirection: BABYLON.Vector2;
  74715. /**
  74716. * @param {number}: Wave height, represents the height of the waves
  74717. */
  74718. waveHeight: number;
  74719. /**
  74720. * @param {number}: Bump height, represents the bump height related to the bump map
  74721. */
  74722. bumpHeight: number;
  74723. /**
  74724. * @param {boolean}: Add a smaller moving bump to less steady waves.
  74725. */
  74726. private _bumpSuperimpose;
  74727. bumpSuperimpose: boolean;
  74728. /**
  74729. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  74730. */
  74731. private _fresnelSeparate;
  74732. fresnelSeparate: boolean;
  74733. /**
  74734. * @param {boolean}: bump Waves modify the reflection.
  74735. */
  74736. private _bumpAffectsReflection;
  74737. bumpAffectsReflection: boolean;
  74738. /**
  74739. * @param {number}: The water color blended with the refraction (near)
  74740. */
  74741. waterColor: BABYLON.Color3;
  74742. /**
  74743. * @param {number}: The blend factor related to the water color
  74744. */
  74745. colorBlendFactor: number;
  74746. /**
  74747. * @param {number}: The water color blended with the reflection (far)
  74748. */
  74749. waterColor2: BABYLON.Color3;
  74750. /**
  74751. * @param {number}: The blend factor related to the water color (reflection, far)
  74752. */
  74753. colorBlendFactor2: number;
  74754. /**
  74755. * @param {number}: Represents the maximum length of a wave
  74756. */
  74757. waveLength: number;
  74758. /**
  74759. * @param {number}: Defines the waves speed
  74760. */
  74761. waveSpeed: number;
  74762. /**
  74763. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  74764. * will avoid calculating useless pixels in the pixel shader of the water material.
  74765. */
  74766. disableClipPlane: boolean;
  74767. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  74768. private _mesh;
  74769. private _refractionRTT;
  74770. private _reflectionRTT;
  74771. private _reflectionTransform;
  74772. private _lastTime;
  74773. private _lastDeltaTime;
  74774. private _renderId;
  74775. private _useLogarithmicDepth;
  74776. private _waitingRenderList;
  74777. private _imageProcessingConfiguration;
  74778. private _imageProcessingObserver;
  74779. /**
  74780. * Gets a boolean indicating that current material needs to register RTT
  74781. */
  74782. readonly hasRenderTargetTextures: boolean;
  74783. /**
  74784. * Constructor
  74785. */
  74786. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  74787. useLogarithmicDepth: boolean;
  74788. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  74789. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  74790. addToRenderList(node: any): void;
  74791. enableRenderTargets(enable: boolean): void;
  74792. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  74793. readonly renderTargetsEnabled: boolean;
  74794. needAlphaBlending(): boolean;
  74795. needAlphaTesting(): boolean;
  74796. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74797. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74798. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74799. private _createRenderTargets;
  74800. getAnimatables(): BABYLON.IAnimatable[];
  74801. getActiveTextures(): BABYLON.BaseTexture[];
  74802. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74803. dispose(forceDisposeEffect?: boolean): void;
  74804. clone(name: string): WaterMaterial;
  74805. serialize(): any;
  74806. getClassName(): string;
  74807. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  74808. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  74809. }
  74810. }
  74811. declare module BABYLON {
  74812. /** @hidden */
  74813. export var asciiartPixelShader: {
  74814. name: string;
  74815. shader: string;
  74816. };
  74817. }
  74818. declare module BABYLON {
  74819. /**
  74820. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  74821. *
  74822. * It basically takes care rendering the font front the given font size to a texture.
  74823. * This is used later on in the postprocess.
  74824. */
  74825. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  74826. private _font;
  74827. private _text;
  74828. private _charSize;
  74829. /**
  74830. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  74831. */
  74832. readonly charSize: number;
  74833. /**
  74834. * Create a new instance of the Ascii Art FontTexture class
  74835. * @param name the name of the texture
  74836. * @param font the font to use, use the W3C CSS notation
  74837. * @param text the caracter set to use in the rendering.
  74838. * @param scene the scene that owns the texture
  74839. */
  74840. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  74841. /**
  74842. * Gets the max char width of a font.
  74843. * @param font the font to use, use the W3C CSS notation
  74844. * @return the max char width
  74845. */
  74846. private getFontWidth;
  74847. /**
  74848. * Gets the max char height of a font.
  74849. * @param font the font to use, use the W3C CSS notation
  74850. * @return the max char height
  74851. */
  74852. private getFontHeight;
  74853. /**
  74854. * Clones the current AsciiArtTexture.
  74855. * @return the clone of the texture.
  74856. */
  74857. clone(): AsciiArtFontTexture;
  74858. /**
  74859. * Parses a json object representing the texture and returns an instance of it.
  74860. * @param source the source JSON representation
  74861. * @param scene the scene to create the texture for
  74862. * @return the parsed texture
  74863. */
  74864. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  74865. }
  74866. /**
  74867. * Option available in the Ascii Art Post Process.
  74868. */
  74869. export interface IAsciiArtPostProcessOptions {
  74870. /**
  74871. * The font to use following the w3c font definition.
  74872. */
  74873. font?: string;
  74874. /**
  74875. * The character set to use in the postprocess.
  74876. */
  74877. characterSet?: string;
  74878. /**
  74879. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  74880. * This number is defined between 0 and 1;
  74881. */
  74882. mixToTile?: number;
  74883. /**
  74884. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  74885. * This number is defined between 0 and 1;
  74886. */
  74887. mixToNormal?: number;
  74888. }
  74889. /**
  74890. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  74891. *
  74892. * Simmply add it to your scene and let the nerd that lives in you have fun.
  74893. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  74894. */
  74895. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  74896. /**
  74897. * The font texture used to render the char in the post process.
  74898. */
  74899. private _asciiArtFontTexture;
  74900. /**
  74901. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  74902. * This number is defined between 0 and 1;
  74903. */
  74904. mixToTile: number;
  74905. /**
  74906. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  74907. * This number is defined between 0 and 1;
  74908. */
  74909. mixToNormal: number;
  74910. /**
  74911. * Instantiates a new Ascii Art Post Process.
  74912. * @param name the name to give to the postprocess
  74913. * @camera the camera to apply the post process to.
  74914. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  74915. */
  74916. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  74917. }
  74918. }
  74919. declare module BABYLON {
  74920. /** @hidden */
  74921. export var digitalrainPixelShader: {
  74922. name: string;
  74923. shader: string;
  74924. };
  74925. }
  74926. declare module BABYLON {
  74927. /**
  74928. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  74929. *
  74930. * It basically takes care rendering the font front the given font size to a texture.
  74931. * This is used later on in the postprocess.
  74932. */
  74933. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  74934. private _font;
  74935. private _text;
  74936. private _charSize;
  74937. /**
  74938. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  74939. */
  74940. readonly charSize: number;
  74941. /**
  74942. * Create a new instance of the Digital Rain FontTexture class
  74943. * @param name the name of the texture
  74944. * @param font the font to use, use the W3C CSS notation
  74945. * @param text the caracter set to use in the rendering.
  74946. * @param scene the scene that owns the texture
  74947. */
  74948. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  74949. /**
  74950. * Gets the max char width of a font.
  74951. * @param font the font to use, use the W3C CSS notation
  74952. * @return the max char width
  74953. */
  74954. private getFontWidth;
  74955. /**
  74956. * Gets the max char height of a font.
  74957. * @param font the font to use, use the W3C CSS notation
  74958. * @return the max char height
  74959. */
  74960. private getFontHeight;
  74961. /**
  74962. * Clones the current DigitalRainFontTexture.
  74963. * @return the clone of the texture.
  74964. */
  74965. clone(): DigitalRainFontTexture;
  74966. /**
  74967. * Parses a json object representing the texture and returns an instance of it.
  74968. * @param source the source JSON representation
  74969. * @param scene the scene to create the texture for
  74970. * @return the parsed texture
  74971. */
  74972. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  74973. }
  74974. /**
  74975. * Option available in the Digital Rain Post Process.
  74976. */
  74977. export interface IDigitalRainPostProcessOptions {
  74978. /**
  74979. * The font to use following the w3c font definition.
  74980. */
  74981. font?: string;
  74982. /**
  74983. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  74984. * This number is defined between 0 and 1;
  74985. */
  74986. mixToTile?: number;
  74987. /**
  74988. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  74989. * This number is defined between 0 and 1;
  74990. */
  74991. mixToNormal?: number;
  74992. }
  74993. /**
  74994. * DigitalRainPostProcess helps rendering everithing in digital rain.
  74995. *
  74996. * Simmply add it to your scene and let the nerd that lives in you have fun.
  74997. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  74998. */
  74999. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  75000. /**
  75001. * The font texture used to render the char in the post process.
  75002. */
  75003. private _digitalRainFontTexture;
  75004. /**
  75005. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  75006. * This number is defined between 0 and 1;
  75007. */
  75008. mixToTile: number;
  75009. /**
  75010. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  75011. * This number is defined between 0 and 1;
  75012. */
  75013. mixToNormal: number;
  75014. /**
  75015. * Instantiates a new Digital Rain Post Process.
  75016. * @param name the name to give to the postprocess
  75017. * @camera the camera to apply the post process to.
  75018. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  75019. */
  75020. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  75021. }
  75022. }
  75023. declare module BABYLON {
  75024. /** @hidden */
  75025. export var oceanPostProcessPixelShader: {
  75026. name: string;
  75027. shader: string;
  75028. };
  75029. }
  75030. declare module BABYLON {
  75031. /**
  75032. * Option available in the Ocean Post Process.
  75033. */
  75034. export interface IOceanPostProcessOptions {
  75035. /**
  75036. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  75037. */
  75038. reflectionSize?: number | {
  75039. width: number;
  75040. height: number;
  75041. } | {
  75042. ratio: number;
  75043. };
  75044. /**
  75045. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  75046. */
  75047. refractionSize?: number | {
  75048. width: number;
  75049. height: number;
  75050. } | {
  75051. ratio: number;
  75052. };
  75053. }
  75054. /**
  75055. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  75056. *
  75057. * Simmply add it to your scene and let the nerd that lives in you have fun.
  75058. * Example usage:
  75059. * var pp = new OceanPostProcess("myOcean", camera);
  75060. * pp.reflectionEnabled = true;
  75061. * pp.refractionEnabled = true;
  75062. */
  75063. export class OceanPostProcess extends BABYLON.PostProcess {
  75064. /**
  75065. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  75066. */
  75067. /**
  75068. * Sets weither or not the real-time reflection is enabled on the ocean.
  75069. * Is set to true, the reflection mirror texture will be used as reflection texture.
  75070. */
  75071. reflectionEnabled: boolean;
  75072. /**
  75073. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  75074. */
  75075. /**
  75076. * Sets weither or not the real-time refraction is enabled on the ocean.
  75077. * Is set to true, the refraction render target texture will be used as refraction texture.
  75078. */
  75079. refractionEnabled: boolean;
  75080. /**
  75081. * Gets wether or not the post-processes is supported by the running hardware.
  75082. * This requires draw buffer supports.
  75083. */
  75084. readonly isSupported: boolean;
  75085. /**
  75086. * This is the reflection mirror texture used to display reflections on the ocean.
  75087. * By default, render list is empty.
  75088. */
  75089. reflectionTexture: BABYLON.MirrorTexture;
  75090. /**
  75091. * This is the refraction render target texture used to display refraction on the ocean.
  75092. * By default, render list is empty.
  75093. */
  75094. refractionTexture: BABYLON.RenderTargetTexture;
  75095. private _time;
  75096. private _cameraRotation;
  75097. private _cameraViewMatrix;
  75098. private _reflectionEnabled;
  75099. private _refractionEnabled;
  75100. private _geometryRenderer;
  75101. /**
  75102. * Instantiates a new Ocean Post Process.
  75103. * @param name the name to give to the postprocess.
  75104. * @camera the camera to apply the post process to.
  75105. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  75106. */
  75107. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  75108. /**
  75109. * Returns the appropriate defines according to the current configuration.
  75110. */
  75111. private _getDefines;
  75112. /**
  75113. * Computes the current camera rotation as the shader requires a camera rotation.
  75114. */
  75115. private _computeCameraRotation;
  75116. }
  75117. }
  75118. declare module BABYLON {
  75119. /** @hidden */
  75120. export var brickProceduralTexturePixelShader: {
  75121. name: string;
  75122. shader: string;
  75123. };
  75124. }
  75125. declare module BABYLON {
  75126. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  75127. private _numberOfBricksHeight;
  75128. private _numberOfBricksWidth;
  75129. private _jointColor;
  75130. private _brickColor;
  75131. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75132. updateShaderUniforms(): void;
  75133. numberOfBricksHeight: number;
  75134. numberOfBricksWidth: number;
  75135. jointColor: BABYLON.Color3;
  75136. brickColor: BABYLON.Color3;
  75137. /**
  75138. * Serializes this brick procedural texture
  75139. * @returns a serialized brick procedural texture object
  75140. */
  75141. serialize(): any;
  75142. /**
  75143. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  75144. * @param parsedTexture defines parsed texture data
  75145. * @param scene defines the current scene
  75146. * @param rootUrl defines the root URL containing brick procedural texture information
  75147. * @returns a parsed Brick Procedural BABYLON.Texture
  75148. */
  75149. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  75150. }
  75151. }
  75152. declare module BABYLON {
  75153. /** @hidden */
  75154. export var cloudProceduralTexturePixelShader: {
  75155. name: string;
  75156. shader: string;
  75157. };
  75158. }
  75159. declare module BABYLON {
  75160. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  75161. private _skyColor;
  75162. private _cloudColor;
  75163. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75164. updateShaderUniforms(): void;
  75165. skyColor: BABYLON.Color4;
  75166. cloudColor: BABYLON.Color4;
  75167. /**
  75168. * Serializes this cloud procedural texture
  75169. * @returns a serialized cloud procedural texture object
  75170. */
  75171. serialize(): any;
  75172. /**
  75173. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  75174. * @param parsedTexture defines parsed texture data
  75175. * @param scene defines the current scene
  75176. * @param rootUrl defines the root URL containing cloud procedural texture information
  75177. * @returns a parsed Cloud Procedural BABYLON.Texture
  75178. */
  75179. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  75180. }
  75181. }
  75182. declare module BABYLON {
  75183. /** @hidden */
  75184. export var fireProceduralTexturePixelShader: {
  75185. name: string;
  75186. shader: string;
  75187. };
  75188. }
  75189. declare module BABYLON {
  75190. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  75191. private _time;
  75192. private _speed;
  75193. private _autoGenerateTime;
  75194. private _fireColors;
  75195. private _alphaThreshold;
  75196. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75197. updateShaderUniforms(): void;
  75198. render(useCameraPostProcess?: boolean): void;
  75199. static readonly PurpleFireColors: BABYLON.Color3[];
  75200. static readonly GreenFireColors: BABYLON.Color3[];
  75201. static readonly RedFireColors: BABYLON.Color3[];
  75202. static readonly BlueFireColors: BABYLON.Color3[];
  75203. autoGenerateTime: boolean;
  75204. fireColors: BABYLON.Color3[];
  75205. time: number;
  75206. speed: BABYLON.Vector2;
  75207. alphaThreshold: number;
  75208. /**
  75209. * Serializes this fire procedural texture
  75210. * @returns a serialized fire procedural texture object
  75211. */
  75212. serialize(): any;
  75213. /**
  75214. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  75215. * @param parsedTexture defines parsed texture data
  75216. * @param scene defines the current scene
  75217. * @param rootUrl defines the root URL containing fire procedural texture information
  75218. * @returns a parsed Fire Procedural BABYLON.Texture
  75219. */
  75220. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  75221. }
  75222. }
  75223. declare module BABYLON {
  75224. /** @hidden */
  75225. export var grassProceduralTexturePixelShader: {
  75226. name: string;
  75227. shader: string;
  75228. };
  75229. }
  75230. declare module BABYLON {
  75231. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  75232. private _grassColors;
  75233. private _groundColor;
  75234. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75235. updateShaderUniforms(): void;
  75236. grassColors: BABYLON.Color3[];
  75237. groundColor: BABYLON.Color3;
  75238. /**
  75239. * Serializes this grass procedural texture
  75240. * @returns a serialized grass procedural texture object
  75241. */
  75242. serialize(): any;
  75243. /**
  75244. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  75245. * @param parsedTexture defines parsed texture data
  75246. * @param scene defines the current scene
  75247. * @param rootUrl defines the root URL containing grass procedural texture information
  75248. * @returns a parsed Grass Procedural BABYLON.Texture
  75249. */
  75250. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  75251. }
  75252. }
  75253. declare module BABYLON {
  75254. /** @hidden */
  75255. export var marbleProceduralTexturePixelShader: {
  75256. name: string;
  75257. shader: string;
  75258. };
  75259. }
  75260. declare module BABYLON {
  75261. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  75262. private _numberOfTilesHeight;
  75263. private _numberOfTilesWidth;
  75264. private _amplitude;
  75265. private _jointColor;
  75266. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75267. updateShaderUniforms(): void;
  75268. numberOfTilesHeight: number;
  75269. amplitude: number;
  75270. numberOfTilesWidth: number;
  75271. jointColor: BABYLON.Color3;
  75272. /**
  75273. * Serializes this marble procedural texture
  75274. * @returns a serialized marble procedural texture object
  75275. */
  75276. serialize(): any;
  75277. /**
  75278. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  75279. * @param parsedTexture defines parsed texture data
  75280. * @param scene defines the current scene
  75281. * @param rootUrl defines the root URL containing marble procedural texture information
  75282. * @returns a parsed Marble Procedural BABYLON.Texture
  75283. */
  75284. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  75285. }
  75286. }
  75287. declare module BABYLON {
  75288. /** @hidden */
  75289. export var normalMapProceduralTexturePixelShader: {
  75290. name: string;
  75291. shader: string;
  75292. };
  75293. }
  75294. declare module BABYLON {
  75295. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  75296. private _baseTexture;
  75297. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75298. updateShaderUniforms(): void;
  75299. render(useCameraPostProcess?: boolean): void;
  75300. resize(size: any, generateMipMaps: any): void;
  75301. baseTexture: BABYLON.Texture;
  75302. /**
  75303. * Serializes this normal map procedural texture
  75304. * @returns a serialized normal map procedural texture object
  75305. */
  75306. serialize(): any;
  75307. /**
  75308. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  75309. * @param parsedTexture defines parsed texture data
  75310. * @param scene defines the current scene
  75311. * @param rootUrl defines the root URL containing normal map procedural texture information
  75312. * @returns a parsed Normal Map Procedural BABYLON.Texture
  75313. */
  75314. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  75315. }
  75316. }
  75317. declare module BABYLON {
  75318. /** @hidden */
  75319. export var perlinNoiseProceduralTexturePixelShader: {
  75320. name: string;
  75321. shader: string;
  75322. };
  75323. }
  75324. declare module BABYLON {
  75325. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  75326. time: number;
  75327. timeScale: number;
  75328. translationSpeed: number;
  75329. private _currentTranslation;
  75330. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75331. updateShaderUniforms(): void;
  75332. render(useCameraPostProcess?: boolean): void;
  75333. resize(size: any, generateMipMaps: any): void;
  75334. /**
  75335. * Serializes this perlin noise procedural texture
  75336. * @returns a serialized perlin noise procedural texture object
  75337. */
  75338. serialize(): any;
  75339. /**
  75340. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  75341. * @param parsedTexture defines parsed texture data
  75342. * @param scene defines the current scene
  75343. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  75344. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  75345. */
  75346. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  75347. }
  75348. }
  75349. declare module BABYLON {
  75350. /** @hidden */
  75351. export var roadProceduralTexturePixelShader: {
  75352. name: string;
  75353. shader: string;
  75354. };
  75355. }
  75356. declare module BABYLON {
  75357. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  75358. private _roadColor;
  75359. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75360. updateShaderUniforms(): void;
  75361. roadColor: BABYLON.Color3;
  75362. /**
  75363. * Serializes this road procedural texture
  75364. * @returns a serialized road procedural texture object
  75365. */
  75366. serialize(): any;
  75367. /**
  75368. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  75369. * @param parsedTexture defines parsed texture data
  75370. * @param scene defines the current scene
  75371. * @param rootUrl defines the root URL containing road procedural texture information
  75372. * @returns a parsed Road Procedural BABYLON.Texture
  75373. */
  75374. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  75375. }
  75376. }
  75377. declare module BABYLON {
  75378. /** @hidden */
  75379. export var starfieldProceduralTexturePixelShader: {
  75380. name: string;
  75381. shader: string;
  75382. };
  75383. }
  75384. declare module BABYLON {
  75385. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  75386. private _time;
  75387. private _alpha;
  75388. private _beta;
  75389. private _zoom;
  75390. private _formuparam;
  75391. private _stepsize;
  75392. private _tile;
  75393. private _brightness;
  75394. private _darkmatter;
  75395. private _distfading;
  75396. private _saturation;
  75397. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75398. updateShaderUniforms(): void;
  75399. time: number;
  75400. alpha: number;
  75401. beta: number;
  75402. formuparam: number;
  75403. stepsize: number;
  75404. zoom: number;
  75405. tile: number;
  75406. brightness: number;
  75407. darkmatter: number;
  75408. distfading: number;
  75409. saturation: number;
  75410. /**
  75411. * Serializes this starfield procedural texture
  75412. * @returns a serialized starfield procedural texture object
  75413. */
  75414. serialize(): any;
  75415. /**
  75416. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  75417. * @param parsedTexture defines parsed texture data
  75418. * @param scene defines the current scene
  75419. * @param rootUrl defines the root URL containing startfield procedural texture information
  75420. * @returns a parsed Starfield Procedural BABYLON.Texture
  75421. */
  75422. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  75423. }
  75424. }
  75425. declare module BABYLON {
  75426. /** @hidden */
  75427. export var woodProceduralTexturePixelShader: {
  75428. name: string;
  75429. shader: string;
  75430. };
  75431. }
  75432. declare module BABYLON {
  75433. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  75434. private _ampScale;
  75435. private _woodColor;
  75436. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75437. updateShaderUniforms(): void;
  75438. ampScale: number;
  75439. woodColor: BABYLON.Color3;
  75440. /**
  75441. * Serializes this wood procedural texture
  75442. * @returns a serialized wood procedural texture object
  75443. */
  75444. serialize(): any;
  75445. /**
  75446. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  75447. * @param parsedTexture defines parsed texture data
  75448. * @param scene defines the current scene
  75449. * @param rootUrl defines the root URL containing wood procedural texture information
  75450. * @returns a parsed Wood Procedural BABYLON.Texture
  75451. */
  75452. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  75453. }
  75454. }