documentation.d.ts 3.4 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static get LogCache(): string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static set LogLevels(level: number);
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. /**
  408. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  409. * @param num the number to convert and pad
  410. * @param length the expected length of the string
  411. * @returns the padded string
  412. */
  413. static PadNumber(num: number, length: number): string;
  414. }
  415. }
  416. declare module BABYLON {
  417. /**
  418. * Class containing a set of static utilities functions for deep copy.
  419. */
  420. export class DeepCopier {
  421. /**
  422. * Tries to copy an object by duplicating every property
  423. * @param source defines the source object
  424. * @param destination defines the target object
  425. * @param doNotCopyList defines a list of properties to avoid
  426. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  427. */
  428. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  429. }
  430. }
  431. declare module BABYLON {
  432. /**
  433. * Class containing a set of static utilities functions for precision date
  434. */
  435. export class PrecisionDate {
  436. /**
  437. * Gets either window.performance.now() if supported or Date.now() else
  438. */
  439. static get Now(): number;
  440. }
  441. }
  442. declare module BABYLON {
  443. /** @hidden */
  444. export class _DevTools {
  445. static WarnImport(name: string): string;
  446. }
  447. }
  448. declare module BABYLON {
  449. /**
  450. * Interface used to define the mechanism to get data from the network
  451. */
  452. export interface IWebRequest {
  453. /**
  454. * Returns client's response url
  455. */
  456. responseURL: string;
  457. /**
  458. * Returns client's status
  459. */
  460. status: number;
  461. /**
  462. * Returns client's status as a text
  463. */
  464. statusText: string;
  465. }
  466. }
  467. declare module BABYLON {
  468. /**
  469. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  470. */
  471. export class WebRequest implements IWebRequest {
  472. private _xhr;
  473. /**
  474. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  475. * i.e. when loading files, where the server/service expects an Authorization header
  476. */
  477. static CustomRequestHeaders: {
  478. [key: string]: string;
  479. };
  480. /**
  481. * Add callback functions in this array to update all the requests before they get sent to the network
  482. */
  483. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  484. private _injectCustomRequestHeaders;
  485. /**
  486. * Gets or sets a function to be called when loading progress changes
  487. */
  488. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  489. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  490. /**
  491. * Returns client's state
  492. */
  493. get readyState(): number;
  494. /**
  495. * Returns client's status
  496. */
  497. get status(): number;
  498. /**
  499. * Returns client's status as a text
  500. */
  501. get statusText(): string;
  502. /**
  503. * Returns client's response
  504. */
  505. get response(): any;
  506. /**
  507. * Returns client's response url
  508. */
  509. get responseURL(): string;
  510. /**
  511. * Returns client's response as text
  512. */
  513. get responseText(): string;
  514. /**
  515. * Gets or sets the expected response type
  516. */
  517. get responseType(): XMLHttpRequestResponseType;
  518. set responseType(value: XMLHttpRequestResponseType);
  519. /** @hidden */
  520. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  521. /** @hidden */
  522. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  523. /**
  524. * Cancels any network activity
  525. */
  526. abort(): void;
  527. /**
  528. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  529. * @param body defines an optional request body
  530. */
  531. send(body?: Document | BodyInit | null): void;
  532. /**
  533. * Sets the request method, request URL
  534. * @param method defines the method to use (GET, POST, etc..)
  535. * @param url defines the url to connect with
  536. */
  537. open(method: string, url: string): void;
  538. /**
  539. * Sets the value of a request header.
  540. * @param name The name of the header whose value is to be set
  541. * @param value The value to set as the body of the header
  542. */
  543. setRequestHeader(name: string, value: string): void;
  544. /**
  545. * Get the string containing the text of a particular header's value.
  546. * @param name The name of the header
  547. * @returns The string containing the text of the given header name
  548. */
  549. getResponseHeader(name: string): Nullable<string>;
  550. }
  551. }
  552. declare module BABYLON {
  553. /**
  554. * File request interface
  555. */
  556. export interface IFileRequest {
  557. /**
  558. * Raised when the request is complete (success or error).
  559. */
  560. onCompleteObservable: Observable<IFileRequest>;
  561. /**
  562. * Aborts the request for a file.
  563. */
  564. abort: () => void;
  565. }
  566. }
  567. declare module BABYLON {
  568. /**
  569. * Define options used to create a render target texture
  570. */
  571. export class RenderTargetCreationOptions {
  572. /**
  573. * Specifies is mipmaps must be generated
  574. */
  575. generateMipMaps?: boolean;
  576. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  577. generateDepthBuffer?: boolean;
  578. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  579. generateStencilBuffer?: boolean;
  580. /** Defines texture type (int by default) */
  581. type?: number;
  582. /** Defines sampling mode (trilinear by default) */
  583. samplingMode?: number;
  584. /** Defines format (RGBA by default) */
  585. format?: number;
  586. }
  587. }
  588. declare module BABYLON {
  589. /** Defines the cross module used constants to avoid circular dependncies */
  590. export class Constants {
  591. /** Defines that alpha blending is disabled */
  592. static readonly ALPHA_DISABLE: number;
  593. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  594. static readonly ALPHA_ADD: number;
  595. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  596. static readonly ALPHA_COMBINE: number;
  597. /** Defines that alpha blending is DEST - SRC * DEST */
  598. static readonly ALPHA_SUBTRACT: number;
  599. /** Defines that alpha blending is SRC * DEST */
  600. static readonly ALPHA_MULTIPLY: number;
  601. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  602. static readonly ALPHA_MAXIMIZED: number;
  603. /** Defines that alpha blending is SRC + DEST */
  604. static readonly ALPHA_ONEONE: number;
  605. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  606. static readonly ALPHA_PREMULTIPLIED: number;
  607. /**
  608. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  609. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  610. */
  611. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  612. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  613. static readonly ALPHA_INTERPOLATE: number;
  614. /**
  615. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  616. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_SCREENMODE: number;
  619. /**
  620. * Defines that alpha blending is SRC + DST
  621. * Alpha will be set to SRC ALPHA + DST ALPHA
  622. */
  623. static readonly ALPHA_ONEONE_ONEONE: number;
  624. /**
  625. * Defines that alpha blending is SRC * DST ALPHA + DST
  626. * Alpha will be set to 0
  627. */
  628. static readonly ALPHA_ALPHATOCOLOR: number;
  629. /**
  630. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  631. */
  632. static readonly ALPHA_REVERSEONEMINUS: number;
  633. /**
  634. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  635. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  636. */
  637. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST
  640. * Alpha will be set to SRC ALPHA
  641. */
  642. static readonly ALPHA_ONEONE_ONEZERO: number;
  643. /**
  644. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  645. * Alpha will be set to DST ALPHA
  646. */
  647. static readonly ALPHA_EXCLUSION: number;
  648. /** Defines that alpha blending equation a SUM */
  649. static readonly ALPHA_EQUATION_ADD: number;
  650. /** Defines that alpha blending equation a SUBSTRACTION */
  651. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  652. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  654. /** Defines that alpha blending equation a MAX operation */
  655. static readonly ALPHA_EQUATION_MAX: number;
  656. /** Defines that alpha blending equation a MIN operation */
  657. static readonly ALPHA_EQUATION_MIN: number;
  658. /**
  659. * Defines that alpha blending equation a DARKEN operation:
  660. * It takes the min of the src and sums the alpha channels.
  661. */
  662. static readonly ALPHA_EQUATION_DARKEN: number;
  663. /** Defines that the ressource is not delayed*/
  664. static readonly DELAYLOADSTATE_NONE: number;
  665. /** Defines that the ressource was successfully delay loaded */
  666. static readonly DELAYLOADSTATE_LOADED: number;
  667. /** Defines that the ressource is currently delay loading */
  668. static readonly DELAYLOADSTATE_LOADING: number;
  669. /** Defines that the ressource is delayed and has not started loading */
  670. static readonly DELAYLOADSTATE_NOTLOADED: number;
  671. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  672. static readonly NEVER: number;
  673. /** 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 */
  674. static readonly ALWAYS: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  676. static readonly LESS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  678. static readonly EQUAL: number;
  679. /** 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 */
  680. static readonly LEQUAL: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  682. static readonly GREATER: number;
  683. /** 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 */
  684. static readonly GEQUAL: number;
  685. /** 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 */
  686. static readonly NOTEQUAL: number;
  687. /** Passed to stencilOperation to specify that stencil value must be kept */
  688. static readonly KEEP: number;
  689. /** Passed to stencilOperation to specify that stencil value must be replaced */
  690. static readonly REPLACE: number;
  691. /** Passed to stencilOperation to specify that stencil value must be incremented */
  692. static readonly INCR: number;
  693. /** Passed to stencilOperation to specify that stencil value must be decremented */
  694. static readonly DECR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be inverted */
  696. static readonly INVERT: number;
  697. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  698. static readonly INCR_WRAP: number;
  699. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  700. static readonly DECR_WRAP: number;
  701. /** Texture is not repeating outside of 0..1 UVs */
  702. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  703. /** Texture is repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  705. /** Texture is repeating and mirrored */
  706. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  707. /** ALPHA */
  708. static readonly TEXTUREFORMAT_ALPHA: number;
  709. /** LUMINANCE */
  710. static readonly TEXTUREFORMAT_LUMINANCE: number;
  711. /** LUMINANCE_ALPHA */
  712. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  713. /** RGB */
  714. static readonly TEXTUREFORMAT_RGB: number;
  715. /** RGBA */
  716. static readonly TEXTUREFORMAT_RGBA: number;
  717. /** RED */
  718. static readonly TEXTUREFORMAT_RED: number;
  719. /** RED (2nd reference) */
  720. static readonly TEXTUREFORMAT_R: number;
  721. /** RG */
  722. static readonly TEXTUREFORMAT_RG: number;
  723. /** RED_INTEGER */
  724. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  725. /** RED_INTEGER (2nd reference) */
  726. static readonly TEXTUREFORMAT_R_INTEGER: number;
  727. /** RG_INTEGER */
  728. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  729. /** RGB_INTEGER */
  730. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  731. /** RGBA_INTEGER */
  732. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  733. /** UNSIGNED_BYTE */
  734. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  735. /** UNSIGNED_BYTE (2nd reference) */
  736. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  737. /** FLOAT */
  738. static readonly TEXTURETYPE_FLOAT: number;
  739. /** HALF_FLOAT */
  740. static readonly TEXTURETYPE_HALF_FLOAT: number;
  741. /** BYTE */
  742. static readonly TEXTURETYPE_BYTE: number;
  743. /** SHORT */
  744. static readonly TEXTURETYPE_SHORT: number;
  745. /** UNSIGNED_SHORT */
  746. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  747. /** INT */
  748. static readonly TEXTURETYPE_INT: number;
  749. /** UNSIGNED_INT */
  750. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  751. /** UNSIGNED_SHORT_4_4_4_4 */
  752. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  753. /** UNSIGNED_SHORT_5_5_5_1 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  755. /** UNSIGNED_SHORT_5_6_5 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  757. /** UNSIGNED_INT_2_10_10_10_REV */
  758. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  759. /** UNSIGNED_INT_24_8 */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  761. /** UNSIGNED_INT_10F_11F_11F_REV */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  763. /** UNSIGNED_INT_5_9_9_9_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  765. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  766. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  767. /** nearest is mag = nearest and min = nearest and no mip */
  768. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  769. /** mag = nearest and min = nearest and mip = none */
  770. static readonly TEXTURE_NEAREST_NEAREST: number;
  771. /** Bilinear is mag = linear and min = linear and no mip */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** mag = linear and min = linear and mip = none */
  774. static readonly TEXTURE_LINEAR_LINEAR: number;
  775. /** Trilinear is mag = linear and min = linear and mip = linear */
  776. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  777. /** Trilinear is mag = linear and min = linear and mip = linear */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  779. /** mag = nearest and min = nearest and mip = nearest */
  780. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  781. /** mag = nearest and min = linear and mip = nearest */
  782. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = linear */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  785. /** mag = nearest and min = linear and mip = none */
  786. static readonly TEXTURE_NEAREST_LINEAR: number;
  787. /** nearest is mag = nearest and min = nearest and mip = linear */
  788. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  789. /** mag = linear and min = nearest and mip = nearest */
  790. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  791. /** mag = linear and min = nearest and mip = linear */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  793. /** Bilinear is mag = linear and min = linear and mip = nearest */
  794. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  795. /** mag = linear and min = nearest and mip = none */
  796. static readonly TEXTURE_LINEAR_NEAREST: number;
  797. /** Explicit coordinates mode */
  798. static readonly TEXTURE_EXPLICIT_MODE: number;
  799. /** Spherical coordinates mode */
  800. static readonly TEXTURE_SPHERICAL_MODE: number;
  801. /** Planar coordinates mode */
  802. static readonly TEXTURE_PLANAR_MODE: number;
  803. /** Cubic coordinates mode */
  804. static readonly TEXTURE_CUBIC_MODE: number;
  805. /** Projection coordinates mode */
  806. static readonly TEXTURE_PROJECTION_MODE: number;
  807. /** Skybox coordinates mode */
  808. static readonly TEXTURE_SKYBOX_MODE: number;
  809. /** Inverse Cubic coordinates mode */
  810. static readonly TEXTURE_INVCUBIC_MODE: number;
  811. /** Equirectangular coordinates mode */
  812. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  813. /** Equirectangular Fixed coordinates mode */
  814. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed Mirrored coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  817. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  818. static readonly SCALEMODE_FLOOR: number;
  819. /** Defines that texture rescaling will look for the nearest power of 2 size */
  820. static readonly SCALEMODE_NEAREST: number;
  821. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  822. static readonly SCALEMODE_CEILING: number;
  823. /**
  824. * The dirty texture flag value
  825. */
  826. static readonly MATERIAL_TextureDirtyFlag: number;
  827. /**
  828. * The dirty light flag value
  829. */
  830. static readonly MATERIAL_LightDirtyFlag: number;
  831. /**
  832. * The dirty fresnel flag value
  833. */
  834. static readonly MATERIAL_FresnelDirtyFlag: number;
  835. /**
  836. * The dirty attribute flag value
  837. */
  838. static readonly MATERIAL_AttributesDirtyFlag: number;
  839. /**
  840. * The dirty misc flag value
  841. */
  842. static readonly MATERIAL_MiscDirtyFlag: number;
  843. /**
  844. * The all dirty flag value
  845. */
  846. static readonly MATERIAL_AllDirtyFlag: number;
  847. /**
  848. * Returns the triangle fill mode
  849. */
  850. static readonly MATERIAL_TriangleFillMode: number;
  851. /**
  852. * Returns the wireframe mode
  853. */
  854. static readonly MATERIAL_WireFrameFillMode: number;
  855. /**
  856. * Returns the point fill mode
  857. */
  858. static readonly MATERIAL_PointFillMode: number;
  859. /**
  860. * Returns the point list draw mode
  861. */
  862. static readonly MATERIAL_PointListDrawMode: number;
  863. /**
  864. * Returns the line list draw mode
  865. */
  866. static readonly MATERIAL_LineListDrawMode: number;
  867. /**
  868. * Returns the line loop draw mode
  869. */
  870. static readonly MATERIAL_LineLoopDrawMode: number;
  871. /**
  872. * Returns the line strip draw mode
  873. */
  874. static readonly MATERIAL_LineStripDrawMode: number;
  875. /**
  876. * Returns the triangle strip draw mode
  877. */
  878. static readonly MATERIAL_TriangleStripDrawMode: number;
  879. /**
  880. * Returns the triangle fan draw mode
  881. */
  882. static readonly MATERIAL_TriangleFanDrawMode: number;
  883. /**
  884. * Stores the clock-wise side orientation
  885. */
  886. static readonly MATERIAL_ClockWiseSideOrientation: number;
  887. /**
  888. * Stores the counter clock-wise side orientation
  889. */
  890. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  891. /**
  892. * Nothing
  893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  894. */
  895. static readonly ACTION_NothingTrigger: number;
  896. /**
  897. * On pick
  898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  899. */
  900. static readonly ACTION_OnPickTrigger: number;
  901. /**
  902. * On left pick
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnLeftPickTrigger: number;
  906. /**
  907. * On right pick
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnRightPickTrigger: number;
  911. /**
  912. * On center pick
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnCenterPickTrigger: number;
  916. /**
  917. * On pick down
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnPickDownTrigger: number;
  921. /**
  922. * On double pick
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnDoublePickTrigger: number;
  926. /**
  927. * On pick up
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnPickUpTrigger: number;
  931. /**
  932. * On pick out.
  933. * This trigger will only be raised if you also declared a OnPickDown
  934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  935. */
  936. static readonly ACTION_OnPickOutTrigger: number;
  937. /**
  938. * On long press
  939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  940. */
  941. static readonly ACTION_OnLongPressTrigger: number;
  942. /**
  943. * On pointer over
  944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  945. */
  946. static readonly ACTION_OnPointerOverTrigger: number;
  947. /**
  948. * On pointer out
  949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_OnPointerOutTrigger: number;
  952. /**
  953. * On every frame
  954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnEveryFrameTrigger: number;
  957. /**
  958. * On intersection enter
  959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnIntersectionEnterTrigger: number;
  962. /**
  963. * On intersection exit
  964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnIntersectionExitTrigger: number;
  967. /**
  968. * On key down
  969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnKeyDownTrigger: number;
  972. /**
  973. * On key up
  974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnKeyUpTrigger: number;
  977. /**
  978. * Billboard mode will only apply to Y axis
  979. */
  980. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  981. /**
  982. * Billboard mode will apply to all axes
  983. */
  984. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  985. /**
  986. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  987. */
  988. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  989. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  990. * Test order :
  991. * Is the bounding sphere outside the frustum ?
  992. * If not, are the bounding box vertices outside the frustum ?
  993. * It not, then the cullable object is in the frustum.
  994. */
  995. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  996. /** Culling strategy : Bounding Sphere Only.
  997. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  998. * It's also less accurate than the standard because some not visible objects can still be selected.
  999. * Test : is the bounding sphere outside the frustum ?
  1000. * If not, then the cullable object is in the frustum.
  1001. */
  1002. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1003. /** Culling strategy : Optimistic Inclusion.
  1004. * This in an inclusion test first, then the standard exclusion test.
  1005. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1006. * 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.
  1007. * Anyway, it's as accurate as the standard strategy.
  1008. * Test :
  1009. * Is the cullable object bounding sphere center in the frustum ?
  1010. * If not, apply the default culling strategy.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1013. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1014. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1015. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1016. * 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.
  1017. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1018. * Test :
  1019. * Is the cullable object bounding sphere center in the frustum ?
  1020. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1021. */
  1022. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1023. /**
  1024. * No logging while loading
  1025. */
  1026. static readonly SCENELOADER_NO_LOGGING: number;
  1027. /**
  1028. * Minimal logging while loading
  1029. */
  1030. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1031. /**
  1032. * Summary logging while loading
  1033. */
  1034. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1035. /**
  1036. * Detailled logging while loading
  1037. */
  1038. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1039. }
  1040. }
  1041. declare module BABYLON {
  1042. /**
  1043. * This represents the required contract to create a new type of texture loader.
  1044. */
  1045. export interface IInternalTextureLoader {
  1046. /**
  1047. * Defines wether the loader supports cascade loading the different faces.
  1048. */
  1049. supportCascades: boolean;
  1050. /**
  1051. * This returns if the loader support the current file information.
  1052. * @param extension defines the file extension of the file being loaded
  1053. * @returns true if the loader can load the specified file
  1054. */
  1055. canLoad(extension: string): boolean;
  1056. /**
  1057. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1058. * @param data contains the texture data
  1059. * @param texture defines the BabylonJS internal texture
  1060. * @param createPolynomials will be true if polynomials have been requested
  1061. * @param onLoad defines the callback to trigger once the texture is ready
  1062. * @param onError defines the callback to trigger in case of error
  1063. */
  1064. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1065. /**
  1066. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1067. * @param data contains the texture data
  1068. * @param texture defines the BabylonJS internal texture
  1069. * @param callback defines the method to call once ready to upload
  1070. */
  1071. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1072. }
  1073. }
  1074. declare module BABYLON {
  1075. /**
  1076. * Class used to store and describe the pipeline context associated with an effect
  1077. */
  1078. export interface IPipelineContext {
  1079. /**
  1080. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1081. */
  1082. isAsync: boolean;
  1083. /**
  1084. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1085. */
  1086. isReady: boolean;
  1087. /** @hidden */
  1088. _getVertexShaderCode(): string | null;
  1089. /** @hidden */
  1090. _getFragmentShaderCode(): string | null;
  1091. /** @hidden */
  1092. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1093. }
  1094. }
  1095. declare module BABYLON {
  1096. /**
  1097. * Class used to store gfx data (like WebGLBuffer)
  1098. */
  1099. export class DataBuffer {
  1100. /**
  1101. * Gets or sets the number of objects referencing this buffer
  1102. */
  1103. references: number;
  1104. /** Gets or sets the size of the underlying buffer */
  1105. capacity: number;
  1106. /**
  1107. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1108. */
  1109. is32Bits: boolean;
  1110. /**
  1111. * Gets the underlying buffer
  1112. */
  1113. get underlyingResource(): any;
  1114. }
  1115. }
  1116. declare module BABYLON {
  1117. /** @hidden */
  1118. export interface IShaderProcessor {
  1119. attributeProcessor?: (attribute: string) => string;
  1120. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1121. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1122. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1123. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1124. lineProcessor?: (line: string, isFragment: boolean) => string;
  1125. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1126. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1127. }
  1128. }
  1129. declare module BABYLON {
  1130. /** @hidden */
  1131. export interface ProcessingOptions {
  1132. defines: string[];
  1133. indexParameters: any;
  1134. isFragment: boolean;
  1135. shouldUseHighPrecisionShader: boolean;
  1136. supportsUniformBuffers: boolean;
  1137. shadersRepository: string;
  1138. includesShadersStore: {
  1139. [key: string]: string;
  1140. };
  1141. processor?: IShaderProcessor;
  1142. version: string;
  1143. platformName: string;
  1144. lookForClosingBracketForUniformBuffer?: boolean;
  1145. }
  1146. }
  1147. declare module BABYLON {
  1148. /** @hidden */
  1149. export class ShaderCodeNode {
  1150. line: string;
  1151. children: ShaderCodeNode[];
  1152. additionalDefineKey?: string;
  1153. additionalDefineValue?: string;
  1154. isValid(preprocessors: {
  1155. [key: string]: string;
  1156. }): boolean;
  1157. process(preprocessors: {
  1158. [key: string]: string;
  1159. }, options: ProcessingOptions): string;
  1160. }
  1161. }
  1162. declare module BABYLON {
  1163. /** @hidden */
  1164. export class ShaderCodeCursor {
  1165. private _lines;
  1166. lineIndex: number;
  1167. get currentLine(): string;
  1168. get canRead(): boolean;
  1169. set lines(value: string[]);
  1170. }
  1171. }
  1172. declare module BABYLON {
  1173. /** @hidden */
  1174. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1175. process(preprocessors: {
  1176. [key: string]: string;
  1177. }, options: ProcessingOptions): string;
  1178. }
  1179. }
  1180. declare module BABYLON {
  1181. /** @hidden */
  1182. export class ShaderDefineExpression {
  1183. isTrue(preprocessors: {
  1184. [key: string]: string;
  1185. }): boolean;
  1186. private static _OperatorPriority;
  1187. private static _Stack;
  1188. static postfixToInfix(postfix: string[]): string;
  1189. static infixToPostfix(infix: string): string[];
  1190. }
  1191. }
  1192. declare module BABYLON {
  1193. /** @hidden */
  1194. export class ShaderCodeTestNode extends ShaderCodeNode {
  1195. testExpression: ShaderDefineExpression;
  1196. isValid(preprocessors: {
  1197. [key: string]: string;
  1198. }): boolean;
  1199. }
  1200. }
  1201. declare module BABYLON {
  1202. /** @hidden */
  1203. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1204. define: string;
  1205. not: boolean;
  1206. constructor(define: string, not?: boolean);
  1207. isTrue(preprocessors: {
  1208. [key: string]: string;
  1209. }): boolean;
  1210. }
  1211. }
  1212. declare module BABYLON {
  1213. /** @hidden */
  1214. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1215. leftOperand: ShaderDefineExpression;
  1216. rightOperand: ShaderDefineExpression;
  1217. isTrue(preprocessors: {
  1218. [key: string]: string;
  1219. }): boolean;
  1220. }
  1221. }
  1222. declare module BABYLON {
  1223. /** @hidden */
  1224. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1225. leftOperand: ShaderDefineExpression;
  1226. rightOperand: ShaderDefineExpression;
  1227. isTrue(preprocessors: {
  1228. [key: string]: string;
  1229. }): boolean;
  1230. }
  1231. }
  1232. declare module BABYLON {
  1233. /** @hidden */
  1234. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1235. define: string;
  1236. operand: string;
  1237. testValue: string;
  1238. constructor(define: string, operand: string, testValue: string);
  1239. isTrue(preprocessors: {
  1240. [key: string]: string;
  1241. }): boolean;
  1242. }
  1243. }
  1244. declare module BABYLON {
  1245. /**
  1246. * Class used to enable access to offline support
  1247. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1248. */
  1249. export interface IOfflineProvider {
  1250. /**
  1251. * Gets a boolean indicating if scene must be saved in the database
  1252. */
  1253. enableSceneOffline: boolean;
  1254. /**
  1255. * Gets a boolean indicating if textures must be saved in the database
  1256. */
  1257. enableTexturesOffline: boolean;
  1258. /**
  1259. * Open the offline support and make it available
  1260. * @param successCallback defines the callback to call on success
  1261. * @param errorCallback defines the callback to call on error
  1262. */
  1263. open(successCallback: () => void, errorCallback: () => void): void;
  1264. /**
  1265. * Loads an image from the offline support
  1266. * @param url defines the url to load from
  1267. * @param image defines the target DOM image
  1268. */
  1269. loadImage(url: string, image: HTMLImageElement): void;
  1270. /**
  1271. * Loads a file from offline support
  1272. * @param url defines the URL to load from
  1273. * @param sceneLoaded defines a callback to call on success
  1274. * @param progressCallBack defines a callback to call when progress changed
  1275. * @param errorCallback defines a callback to call on error
  1276. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1277. */
  1278. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1279. }
  1280. }
  1281. declare module BABYLON {
  1282. /**
  1283. * Class used to help managing file picking and drag'n'drop
  1284. * File Storage
  1285. */
  1286. export class FilesInputStore {
  1287. /**
  1288. * List of files ready to be loaded
  1289. */
  1290. static FilesToLoad: {
  1291. [key: string]: File;
  1292. };
  1293. }
  1294. }
  1295. declare module BABYLON {
  1296. /**
  1297. * Class used to define a retry strategy when error happens while loading assets
  1298. */
  1299. export class RetryStrategy {
  1300. /**
  1301. * Function used to defines an exponential back off strategy
  1302. * @param maxRetries defines the maximum number of retries (3 by default)
  1303. * @param baseInterval defines the interval between retries
  1304. * @returns the strategy function to use
  1305. */
  1306. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1307. }
  1308. }
  1309. declare module BABYLON {
  1310. /**
  1311. * @ignore
  1312. * Application error to support additional information when loading a file
  1313. */
  1314. export abstract class BaseError extends Error {
  1315. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1316. }
  1317. }
  1318. declare module BABYLON {
  1319. /** @ignore */
  1320. export class LoadFileError extends BaseError {
  1321. request?: WebRequest;
  1322. file?: File;
  1323. /**
  1324. * Creates a new LoadFileError
  1325. * @param message defines the message of the error
  1326. * @param request defines the optional web request
  1327. * @param file defines the optional file
  1328. */
  1329. constructor(message: string, object?: WebRequest | File);
  1330. }
  1331. /** @ignore */
  1332. export class RequestFileError extends BaseError {
  1333. request: WebRequest;
  1334. /**
  1335. * Creates a new LoadFileError
  1336. * @param message defines the message of the error
  1337. * @param request defines the optional web request
  1338. */
  1339. constructor(message: string, request: WebRequest);
  1340. }
  1341. /** @ignore */
  1342. export class ReadFileError extends BaseError {
  1343. file: File;
  1344. /**
  1345. * Creates a new ReadFileError
  1346. * @param message defines the message of the error
  1347. * @param file defines the optional file
  1348. */
  1349. constructor(message: string, file: File);
  1350. }
  1351. /**
  1352. * @hidden
  1353. */
  1354. export class FileTools {
  1355. /**
  1356. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1357. */
  1358. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1359. /**
  1360. * Gets or sets the base URL to use to load assets
  1361. */
  1362. static BaseUrl: string;
  1363. /**
  1364. * Default behaviour for cors in the application.
  1365. * It can be a string if the expected behavior is identical in the entire app.
  1366. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1367. */
  1368. static CorsBehavior: string | ((url: string | string[]) => string);
  1369. /**
  1370. * Gets or sets a function used to pre-process url before using them to load assets
  1371. */
  1372. static PreprocessUrl: (url: string) => string;
  1373. /**
  1374. * Removes unwanted characters from an url
  1375. * @param url defines the url to clean
  1376. * @returns the cleaned url
  1377. */
  1378. private static _CleanUrl;
  1379. /**
  1380. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1381. * @param url define the url we are trying
  1382. * @param element define the dom element where to configure the cors policy
  1383. */
  1384. static SetCorsBehavior(url: string | string[], element: {
  1385. crossOrigin: string | null;
  1386. }): void;
  1387. /**
  1388. * Loads an image as an HTMLImageElement.
  1389. * @param input url string, ArrayBuffer, or Blob to load
  1390. * @param onLoad callback called when the image successfully loads
  1391. * @param onError callback called when the image fails to load
  1392. * @param offlineProvider offline provider for caching
  1393. * @param mimeType optional mime type
  1394. * @returns the HTMLImageElement of the loaded image
  1395. */
  1396. 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>;
  1397. /**
  1398. * Reads a file from a File object
  1399. * @param file defines the file to load
  1400. * @param onSuccess defines the callback to call when data is loaded
  1401. * @param onProgress defines the callback to call during loading process
  1402. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1403. * @param onError defines the callback to call when an error occurs
  1404. * @returns a file request object
  1405. */
  1406. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1407. /**
  1408. * Loads a file from a url
  1409. * @param url url to load
  1410. * @param onSuccess callback called when the file successfully loads
  1411. * @param onProgress callback called while file is loading (if the server supports this mode)
  1412. * @param offlineProvider defines the offline provider for caching
  1413. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1414. * @param onError callback called when the file fails to load
  1415. * @returns a file request object
  1416. */
  1417. 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;
  1418. /**
  1419. * Loads a file
  1420. * @param url url to load
  1421. * @param onSuccess callback called when the file successfully loads
  1422. * @param onProgress callback called while file is loading (if the server supports this mode)
  1423. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1424. * @param onError callback called when the file fails to load
  1425. * @param onOpened callback called when the web request is opened
  1426. * @returns a file request object
  1427. */
  1428. 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;
  1429. /**
  1430. * Checks if the loaded document was accessed via `file:`-Protocol.
  1431. * @returns boolean
  1432. */
  1433. static IsFileURL(): boolean;
  1434. }
  1435. }
  1436. declare module BABYLON {
  1437. /** @hidden */
  1438. export class ShaderProcessor {
  1439. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1440. private static _ProcessPrecision;
  1441. private static _ExtractOperation;
  1442. private static _BuildSubExpression;
  1443. private static _BuildExpression;
  1444. private static _MoveCursorWithinIf;
  1445. private static _MoveCursor;
  1446. private static _EvaluatePreProcessors;
  1447. private static _PreparePreProcessors;
  1448. private static _ProcessShaderConversion;
  1449. private static _ProcessIncludes;
  1450. /**
  1451. * Loads a file from a url
  1452. * @param url url to load
  1453. * @param onSuccess callback called when the file successfully loads
  1454. * @param onProgress callback called while file is loading (if the server supports this mode)
  1455. * @param offlineProvider defines the offline provider for caching
  1456. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1457. * @param onError callback called when the file fails to load
  1458. * @returns a file request object
  1459. * @hidden
  1460. */
  1461. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1462. }
  1463. }
  1464. declare module BABYLON {
  1465. /**
  1466. * @hidden
  1467. */
  1468. export interface IColor4Like {
  1469. r: float;
  1470. g: float;
  1471. b: float;
  1472. a: float;
  1473. }
  1474. /**
  1475. * @hidden
  1476. */
  1477. export interface IColor3Like {
  1478. r: float;
  1479. g: float;
  1480. b: float;
  1481. }
  1482. /**
  1483. * @hidden
  1484. */
  1485. export interface IVector4Like {
  1486. x: float;
  1487. y: float;
  1488. z: float;
  1489. w: float;
  1490. }
  1491. /**
  1492. * @hidden
  1493. */
  1494. export interface IVector3Like {
  1495. x: float;
  1496. y: float;
  1497. z: float;
  1498. }
  1499. /**
  1500. * @hidden
  1501. */
  1502. export interface IVector2Like {
  1503. x: float;
  1504. y: float;
  1505. }
  1506. /**
  1507. * @hidden
  1508. */
  1509. export interface IMatrixLike {
  1510. toArray(): DeepImmutable<Float32Array>;
  1511. updateFlag: int;
  1512. }
  1513. /**
  1514. * @hidden
  1515. */
  1516. export interface IViewportLike {
  1517. x: float;
  1518. y: float;
  1519. width: float;
  1520. height: float;
  1521. }
  1522. /**
  1523. * @hidden
  1524. */
  1525. export interface IPlaneLike {
  1526. normal: IVector3Like;
  1527. d: float;
  1528. normalize(): void;
  1529. }
  1530. }
  1531. declare module BABYLON {
  1532. /**
  1533. * Interface used to define common properties for effect fallbacks
  1534. */
  1535. export interface IEffectFallbacks {
  1536. /**
  1537. * Removes the defines that should be removed when falling back.
  1538. * @param currentDefines defines the current define statements for the shader.
  1539. * @param effect defines the current effect we try to compile
  1540. * @returns The resulting defines with defines of the current rank removed.
  1541. */
  1542. reduce(currentDefines: string, effect: Effect): string;
  1543. /**
  1544. * Removes the fallback from the bound mesh.
  1545. */
  1546. unBindMesh(): void;
  1547. /**
  1548. * Checks to see if more fallbacks are still availible.
  1549. */
  1550. hasMoreFallbacks: boolean;
  1551. }
  1552. }
  1553. declare module BABYLON {
  1554. /**
  1555. * Class used to evalaute queries containing `and` and `or` operators
  1556. */
  1557. export class AndOrNotEvaluator {
  1558. /**
  1559. * Evaluate a query
  1560. * @param query defines the query to evaluate
  1561. * @param evaluateCallback defines the callback used to filter result
  1562. * @returns true if the query matches
  1563. */
  1564. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1565. private static _HandleParenthesisContent;
  1566. private static _SimplifyNegation;
  1567. }
  1568. }
  1569. declare module BABYLON {
  1570. /**
  1571. * Class used to store custom tags
  1572. */
  1573. export class Tags {
  1574. /**
  1575. * Adds support for tags on the given object
  1576. * @param obj defines the object to use
  1577. */
  1578. static EnableFor(obj: any): void;
  1579. /**
  1580. * Removes tags support
  1581. * @param obj defines the object to use
  1582. */
  1583. static DisableFor(obj: any): void;
  1584. /**
  1585. * Gets a boolean indicating if the given object has tags
  1586. * @param obj defines the object to use
  1587. * @returns a boolean
  1588. */
  1589. static HasTags(obj: any): boolean;
  1590. /**
  1591. * Gets the tags available on a given object
  1592. * @param obj defines the object to use
  1593. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1594. * @returns the tags
  1595. */
  1596. static GetTags(obj: any, asString?: boolean): any;
  1597. /**
  1598. * Adds tags to an object
  1599. * @param obj defines the object to use
  1600. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1601. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1602. */
  1603. static AddTagsTo(obj: any, tagsString: string): void;
  1604. /**
  1605. * @hidden
  1606. */
  1607. static _AddTagTo(obj: any, tag: string): void;
  1608. /**
  1609. * Removes specific tags from a specific object
  1610. * @param obj defines the object to use
  1611. * @param tagsString defines the tags to remove
  1612. */
  1613. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1614. /**
  1615. * @hidden
  1616. */
  1617. static _RemoveTagFrom(obj: any, tag: string): void;
  1618. /**
  1619. * Defines if tags hosted on an object match a given query
  1620. * @param obj defines the object to use
  1621. * @param tagsQuery defines the tag query
  1622. * @returns a boolean
  1623. */
  1624. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1625. }
  1626. }
  1627. declare module BABYLON {
  1628. /**
  1629. * Scalar computation library
  1630. */
  1631. export class Scalar {
  1632. /**
  1633. * Two pi constants convenient for computation.
  1634. */
  1635. static TwoPi: number;
  1636. /**
  1637. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1638. * @param a number
  1639. * @param b number
  1640. * @param epsilon (default = 1.401298E-45)
  1641. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1642. */
  1643. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1644. /**
  1645. * Returns a string : the upper case translation of the number i to hexadecimal.
  1646. * @param i number
  1647. * @returns the upper case translation of the number i to hexadecimal.
  1648. */
  1649. static ToHex(i: number): string;
  1650. /**
  1651. * Returns -1 if value is negative and +1 is value is positive.
  1652. * @param value the value
  1653. * @returns the value itself if it's equal to zero.
  1654. */
  1655. static Sign(value: number): number;
  1656. /**
  1657. * Returns the value itself if it's between min and max.
  1658. * Returns min if the value is lower than min.
  1659. * Returns max if the value is greater than max.
  1660. * @param value the value to clmap
  1661. * @param min the min value to clamp to (default: 0)
  1662. * @param max the max value to clamp to (default: 1)
  1663. * @returns the clamped value
  1664. */
  1665. static Clamp(value: number, min?: number, max?: number): number;
  1666. /**
  1667. * the log2 of value.
  1668. * @param value the value to compute log2 of
  1669. * @returns the log2 of value.
  1670. */
  1671. static Log2(value: number): number;
  1672. /**
  1673. * Loops the value, so that it is never larger than length and never smaller than 0.
  1674. *
  1675. * This is similar to the modulo operator but it works with floating point numbers.
  1676. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1677. * With t = 5 and length = 2.5, the result would be 0.0.
  1678. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1679. * @param value the value
  1680. * @param length the length
  1681. * @returns the looped value
  1682. */
  1683. static Repeat(value: number, length: number): number;
  1684. /**
  1685. * Normalize the value between 0.0 and 1.0 using min and max values
  1686. * @param value value to normalize
  1687. * @param min max to normalize between
  1688. * @param max min to normalize between
  1689. * @returns the normalized value
  1690. */
  1691. static Normalize(value: number, min: number, max: number): number;
  1692. /**
  1693. * Denormalize the value from 0.0 and 1.0 using min and max values
  1694. * @param normalized value to denormalize
  1695. * @param min max to denormalize between
  1696. * @param max min to denormalize between
  1697. * @returns the denormalized value
  1698. */
  1699. static Denormalize(normalized: number, min: number, max: number): number;
  1700. /**
  1701. * Calculates the shortest difference between two given angles given in degrees.
  1702. * @param current current angle in degrees
  1703. * @param target target angle in degrees
  1704. * @returns the delta
  1705. */
  1706. static DeltaAngle(current: number, target: number): number;
  1707. /**
  1708. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1709. * @param tx value
  1710. * @param length length
  1711. * @returns The returned value will move back and forth between 0 and length
  1712. */
  1713. static PingPong(tx: number, length: number): number;
  1714. /**
  1715. * Interpolates between min and max with smoothing at the limits.
  1716. *
  1717. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1718. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1719. * @param from from
  1720. * @param to to
  1721. * @param tx value
  1722. * @returns the smooth stepped value
  1723. */
  1724. static SmoothStep(from: number, to: number, tx: number): number;
  1725. /**
  1726. * Moves a value current towards target.
  1727. *
  1728. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1729. * Negative values of maxDelta pushes the value away from target.
  1730. * @param current current value
  1731. * @param target target value
  1732. * @param maxDelta max distance to move
  1733. * @returns resulting value
  1734. */
  1735. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1736. /**
  1737. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1738. *
  1739. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1740. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1741. * @param current current value
  1742. * @param target target value
  1743. * @param maxDelta max distance to move
  1744. * @returns resulting angle
  1745. */
  1746. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1747. /**
  1748. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1749. * @param start start value
  1750. * @param end target value
  1751. * @param amount amount to lerp between
  1752. * @returns the lerped value
  1753. */
  1754. static Lerp(start: number, end: number, amount: number): number;
  1755. /**
  1756. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1757. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1758. * @param start start value
  1759. * @param end target value
  1760. * @param amount amount to lerp between
  1761. * @returns the lerped value
  1762. */
  1763. static LerpAngle(start: number, end: number, amount: number): number;
  1764. /**
  1765. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1766. * @param a start value
  1767. * @param b target value
  1768. * @param value value between a and b
  1769. * @returns the inverseLerp value
  1770. */
  1771. static InverseLerp(a: number, b: number, value: number): number;
  1772. /**
  1773. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1774. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1775. * @param value1 spline value
  1776. * @param tangent1 spline value
  1777. * @param value2 spline value
  1778. * @param tangent2 spline value
  1779. * @param amount input value
  1780. * @returns hermite result
  1781. */
  1782. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1783. /**
  1784. * Returns a random float number between and min and max values
  1785. * @param min min value of random
  1786. * @param max max value of random
  1787. * @returns random value
  1788. */
  1789. static RandomRange(min: number, max: number): number;
  1790. /**
  1791. * This function returns percentage of a number in a given range.
  1792. *
  1793. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1794. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1795. * @param number to convert to percentage
  1796. * @param min min range
  1797. * @param max max range
  1798. * @returns the percentage
  1799. */
  1800. static RangeToPercent(number: number, min: number, max: number): number;
  1801. /**
  1802. * This function returns number that corresponds to the percentage in a given range.
  1803. *
  1804. * PercentToRange(0.34,0,100) will return 34.
  1805. * @param percent to convert to number
  1806. * @param min min range
  1807. * @param max max range
  1808. * @returns the number
  1809. */
  1810. static PercentToRange(percent: number, min: number, max: number): number;
  1811. /**
  1812. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1813. * @param angle The angle to normalize in radian.
  1814. * @return The converted angle.
  1815. */
  1816. static NormalizeRadians(angle: number): number;
  1817. }
  1818. }
  1819. declare module BABYLON {
  1820. /**
  1821. * Constant used to convert a value to gamma space
  1822. * @ignorenaming
  1823. */
  1824. export const ToGammaSpace: number;
  1825. /**
  1826. * Constant used to convert a value to linear space
  1827. * @ignorenaming
  1828. */
  1829. export const ToLinearSpace = 2.2;
  1830. /**
  1831. * Constant used to define the minimal number value in Babylon.js
  1832. * @ignorenaming
  1833. */
  1834. let Epsilon: number;
  1835. }
  1836. declare module BABYLON {
  1837. /**
  1838. * Class used to represent a viewport on screen
  1839. */
  1840. export class Viewport {
  1841. /** viewport left coordinate */
  1842. x: number;
  1843. /** viewport top coordinate */
  1844. y: number;
  1845. /**viewport width */
  1846. width: number;
  1847. /** viewport height */
  1848. height: number;
  1849. /**
  1850. * Creates a Viewport object located at (x, y) and sized (width, height)
  1851. * @param x defines viewport left coordinate
  1852. * @param y defines viewport top coordinate
  1853. * @param width defines the viewport width
  1854. * @param height defines the viewport height
  1855. */
  1856. constructor(
  1857. /** viewport left coordinate */
  1858. x: number,
  1859. /** viewport top coordinate */
  1860. y: number,
  1861. /**viewport width */
  1862. width: number,
  1863. /** viewport height */
  1864. height: number);
  1865. /**
  1866. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1867. * @param renderWidth defines the rendering width
  1868. * @param renderHeight defines the rendering height
  1869. * @returns a new Viewport
  1870. */
  1871. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1872. /**
  1873. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1874. * @param renderWidth defines the rendering width
  1875. * @param renderHeight defines the rendering height
  1876. * @param ref defines the target viewport
  1877. * @returns the current viewport
  1878. */
  1879. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1880. /**
  1881. * Returns a new Viewport copied from the current one
  1882. * @returns a new Viewport
  1883. */
  1884. clone(): Viewport;
  1885. }
  1886. }
  1887. declare module BABYLON {
  1888. /**
  1889. * Class containing a set of static utilities functions for arrays.
  1890. */
  1891. export class ArrayTools {
  1892. /**
  1893. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1894. * @param size the number of element to construct and put in the array
  1895. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1896. * @returns a new array filled with new objects
  1897. */
  1898. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1899. }
  1900. }
  1901. declare module BABYLON {
  1902. /**
  1903. * Class representing a vector containing 2 coordinates
  1904. */
  1905. export class Vector2 {
  1906. /** defines the first coordinate */
  1907. x: number;
  1908. /** defines the second coordinate */
  1909. y: number;
  1910. /**
  1911. * Creates a new Vector2 from the given x and y coordinates
  1912. * @param x defines the first coordinate
  1913. * @param y defines the second coordinate
  1914. */
  1915. constructor(
  1916. /** defines the first coordinate */
  1917. x?: number,
  1918. /** defines the second coordinate */
  1919. y?: number);
  1920. /**
  1921. * Gets a string with the Vector2 coordinates
  1922. * @returns a string with the Vector2 coordinates
  1923. */
  1924. toString(): string;
  1925. /**
  1926. * Gets class name
  1927. * @returns the string "Vector2"
  1928. */
  1929. getClassName(): string;
  1930. /**
  1931. * Gets current vector hash code
  1932. * @returns the Vector2 hash code as a number
  1933. */
  1934. getHashCode(): number;
  1935. /**
  1936. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1937. * @param array defines the source array
  1938. * @param index defines the offset in source array
  1939. * @returns the current Vector2
  1940. */
  1941. toArray(array: FloatArray, index?: number): Vector2;
  1942. /**
  1943. * Copy the current vector to an array
  1944. * @returns a new array with 2 elements: the Vector2 coordinates.
  1945. */
  1946. asArray(): number[];
  1947. /**
  1948. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1949. * @param source defines the source Vector2
  1950. * @returns the current updated Vector2
  1951. */
  1952. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1953. /**
  1954. * Sets the Vector2 coordinates with the given floats
  1955. * @param x defines the first coordinate
  1956. * @param y defines the second coordinate
  1957. * @returns the current updated Vector2
  1958. */
  1959. copyFromFloats(x: number, y: number): Vector2;
  1960. /**
  1961. * Sets the Vector2 coordinates with the given floats
  1962. * @param x defines the first coordinate
  1963. * @param y defines the second coordinate
  1964. * @returns the current updated Vector2
  1965. */
  1966. set(x: number, y: number): Vector2;
  1967. /**
  1968. * Add another vector with the current one
  1969. * @param otherVector defines the other vector
  1970. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1971. */
  1972. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1973. /**
  1974. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1975. * @param otherVector defines the other vector
  1976. * @param result defines the target vector
  1977. * @returns the unmodified current Vector2
  1978. */
  1979. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1980. /**
  1981. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1982. * @param otherVector defines the other vector
  1983. * @returns the current updated Vector2
  1984. */
  1985. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1986. /**
  1987. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1988. * @param otherVector defines the other vector
  1989. * @returns a new Vector2
  1990. */
  1991. addVector3(otherVector: Vector3): Vector2;
  1992. /**
  1993. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1994. * @param otherVector defines the other vector
  1995. * @returns a new Vector2
  1996. */
  1997. subtract(otherVector: Vector2): Vector2;
  1998. /**
  1999. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2000. * @param otherVector defines the other vector
  2001. * @param result defines the target vector
  2002. * @returns the unmodified current Vector2
  2003. */
  2004. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2005. /**
  2006. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2007. * @param otherVector defines the other vector
  2008. * @returns the current updated Vector2
  2009. */
  2010. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2011. /**
  2012. * Multiplies in place the current Vector2 coordinates by the given ones
  2013. * @param otherVector defines the other vector
  2014. * @returns the current updated Vector2
  2015. */
  2016. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2017. /**
  2018. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2019. * @param otherVector defines the other vector
  2020. * @returns a new Vector2
  2021. */
  2022. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2023. /**
  2024. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2025. * @param otherVector defines the other vector
  2026. * @param result defines the target vector
  2027. * @returns the unmodified current Vector2
  2028. */
  2029. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2030. /**
  2031. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2032. * @param x defines the first coordinate
  2033. * @param y defines the second coordinate
  2034. * @returns a new Vector2
  2035. */
  2036. multiplyByFloats(x: number, y: number): Vector2;
  2037. /**
  2038. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2039. * @param otherVector defines the other vector
  2040. * @returns a new Vector2
  2041. */
  2042. divide(otherVector: Vector2): Vector2;
  2043. /**
  2044. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2045. * @param otherVector defines the other vector
  2046. * @param result defines the target vector
  2047. * @returns the unmodified current Vector2
  2048. */
  2049. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2050. /**
  2051. * Divides the current Vector2 coordinates by the given ones
  2052. * @param otherVector defines the other vector
  2053. * @returns the current updated Vector2
  2054. */
  2055. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2056. /**
  2057. * Gets a new Vector2 with current Vector2 negated coordinates
  2058. * @returns a new Vector2
  2059. */
  2060. negate(): Vector2;
  2061. /**
  2062. * Negate this vector in place
  2063. * @returns this
  2064. */
  2065. negateInPlace(): Vector2;
  2066. /**
  2067. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2068. * @param result defines the Vector3 object where to store the result
  2069. * @returns the current Vector2
  2070. */
  2071. negateToRef(result: Vector2): Vector2;
  2072. /**
  2073. * Multiply the Vector2 coordinates by scale
  2074. * @param scale defines the scaling factor
  2075. * @returns the current updated Vector2
  2076. */
  2077. scaleInPlace(scale: number): Vector2;
  2078. /**
  2079. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2080. * @param scale defines the scaling factor
  2081. * @returns a new Vector2
  2082. */
  2083. scale(scale: number): Vector2;
  2084. /**
  2085. * Scale the current Vector2 values by a factor to a given Vector2
  2086. * @param scale defines the scale factor
  2087. * @param result defines the Vector2 object where to store the result
  2088. * @returns the unmodified current Vector2
  2089. */
  2090. scaleToRef(scale: number, result: Vector2): Vector2;
  2091. /**
  2092. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2093. * @param scale defines the scale factor
  2094. * @param result defines the Vector2 object where to store the result
  2095. * @returns the unmodified current Vector2
  2096. */
  2097. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2098. /**
  2099. * Gets a boolean if two vectors are equals
  2100. * @param otherVector defines the other vector
  2101. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2102. */
  2103. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2104. /**
  2105. * Gets a boolean if two vectors are equals (using an epsilon value)
  2106. * @param otherVector defines the other vector
  2107. * @param epsilon defines the minimal distance to consider equality
  2108. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2109. */
  2110. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2111. /**
  2112. * Gets a new Vector2 from current Vector2 floored values
  2113. * @returns a new Vector2
  2114. */
  2115. floor(): Vector2;
  2116. /**
  2117. * Gets a new Vector2 from current Vector2 floored values
  2118. * @returns a new Vector2
  2119. */
  2120. fract(): Vector2;
  2121. /**
  2122. * Gets the length of the vector
  2123. * @returns the vector length (float)
  2124. */
  2125. length(): number;
  2126. /**
  2127. * Gets the vector squared length
  2128. * @returns the vector squared length (float)
  2129. */
  2130. lengthSquared(): number;
  2131. /**
  2132. * Normalize the vector
  2133. * @returns the current updated Vector2
  2134. */
  2135. normalize(): Vector2;
  2136. /**
  2137. * Gets a new Vector2 copied from the Vector2
  2138. * @returns a new Vector2
  2139. */
  2140. clone(): Vector2;
  2141. /**
  2142. * Gets a new Vector2(0, 0)
  2143. * @returns a new Vector2
  2144. */
  2145. static Zero(): Vector2;
  2146. /**
  2147. * Gets a new Vector2(1, 1)
  2148. * @returns a new Vector2
  2149. */
  2150. static One(): Vector2;
  2151. /**
  2152. * Gets a new Vector2 set from the given index element of the given array
  2153. * @param array defines the data source
  2154. * @param offset defines the offset in the data source
  2155. * @returns a new Vector2
  2156. */
  2157. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2158. /**
  2159. * Sets "result" from the given index element of the given array
  2160. * @param array defines the data source
  2161. * @param offset defines the offset in the data source
  2162. * @param result defines the target vector
  2163. */
  2164. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2165. /**
  2166. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2167. * @param value1 defines 1st point of control
  2168. * @param value2 defines 2nd point of control
  2169. * @param value3 defines 3rd point of control
  2170. * @param value4 defines 4th point of control
  2171. * @param amount defines the interpolation factor
  2172. * @returns a new Vector2
  2173. */
  2174. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2175. /**
  2176. * 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".
  2177. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2178. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2179. * @param value defines the value to clamp
  2180. * @param min defines the lower limit
  2181. * @param max defines the upper limit
  2182. * @returns a new Vector2
  2183. */
  2184. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2185. /**
  2186. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2187. * @param value1 defines the 1st control point
  2188. * @param tangent1 defines the outgoing tangent
  2189. * @param value2 defines the 2nd control point
  2190. * @param tangent2 defines the incoming tangent
  2191. * @param amount defines the interpolation factor
  2192. * @returns a new Vector2
  2193. */
  2194. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2195. /**
  2196. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2197. * @param start defines the start vector
  2198. * @param end defines the end vector
  2199. * @param amount defines the interpolation factor
  2200. * @returns a new Vector2
  2201. */
  2202. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2203. /**
  2204. * Gets the dot product of the vector "left" and the vector "right"
  2205. * @param left defines first vector
  2206. * @param right defines second vector
  2207. * @returns the dot product (float)
  2208. */
  2209. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2210. /**
  2211. * Returns a new Vector2 equal to the normalized given vector
  2212. * @param vector defines the vector to normalize
  2213. * @returns a new Vector2
  2214. */
  2215. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2216. /**
  2217. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2218. * @param left defines 1st vector
  2219. * @param right defines 2nd vector
  2220. * @returns a new Vector2
  2221. */
  2222. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2223. /**
  2224. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2225. * @param left defines 1st vector
  2226. * @param right defines 2nd vector
  2227. * @returns a new Vector2
  2228. */
  2229. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2232. * @param vector defines the vector to transform
  2233. * @param transformation defines the matrix to apply
  2234. * @returns a new Vector2
  2235. */
  2236. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2237. /**
  2238. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2239. * @param vector defines the vector to transform
  2240. * @param transformation defines the matrix to apply
  2241. * @param result defines the target vector
  2242. */
  2243. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2244. /**
  2245. * Determines if a given vector is included in a triangle
  2246. * @param p defines the vector to test
  2247. * @param p0 defines 1st triangle point
  2248. * @param p1 defines 2nd triangle point
  2249. * @param p2 defines 3rd triangle point
  2250. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2251. */
  2252. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2253. /**
  2254. * Gets the distance between the vectors "value1" and "value2"
  2255. * @param value1 defines first vector
  2256. * @param value2 defines second vector
  2257. * @returns the distance between vectors
  2258. */
  2259. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2260. /**
  2261. * Returns the squared distance between the vectors "value1" and "value2"
  2262. * @param value1 defines first vector
  2263. * @param value2 defines second vector
  2264. * @returns the squared distance between vectors
  2265. */
  2266. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2267. /**
  2268. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2269. * @param value1 defines first vector
  2270. * @param value2 defines second vector
  2271. * @returns a new Vector2
  2272. */
  2273. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2274. /**
  2275. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2276. * @param p defines the middle point
  2277. * @param segA defines one point of the segment
  2278. * @param segB defines the other point of the segment
  2279. * @returns the shortest distance
  2280. */
  2281. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2282. }
  2283. /**
  2284. * Class used to store (x,y,z) vector representation
  2285. * A Vector3 is the main object used in 3D geometry
  2286. * It can represent etiher the coordinates of a point the space, either a direction
  2287. * Reminder: js uses a left handed forward facing system
  2288. */
  2289. export class Vector3 {
  2290. /**
  2291. * Defines the first coordinates (on X axis)
  2292. */
  2293. x: number;
  2294. /**
  2295. * Defines the second coordinates (on Y axis)
  2296. */
  2297. y: number;
  2298. /**
  2299. * Defines the third coordinates (on Z axis)
  2300. */
  2301. z: number;
  2302. private static _UpReadOnly;
  2303. private static _ZeroReadOnly;
  2304. /**
  2305. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2306. * @param x defines the first coordinates (on X axis)
  2307. * @param y defines the second coordinates (on Y axis)
  2308. * @param z defines the third coordinates (on Z axis)
  2309. */
  2310. constructor(
  2311. /**
  2312. * Defines the first coordinates (on X axis)
  2313. */
  2314. x?: number,
  2315. /**
  2316. * Defines the second coordinates (on Y axis)
  2317. */
  2318. y?: number,
  2319. /**
  2320. * Defines the third coordinates (on Z axis)
  2321. */
  2322. z?: number);
  2323. /**
  2324. * Creates a string representation of the Vector3
  2325. * @returns a string with the Vector3 coordinates.
  2326. */
  2327. toString(): string;
  2328. /**
  2329. * Gets the class name
  2330. * @returns the string "Vector3"
  2331. */
  2332. getClassName(): string;
  2333. /**
  2334. * Creates the Vector3 hash code
  2335. * @returns a number which tends to be unique between Vector3 instances
  2336. */
  2337. getHashCode(): number;
  2338. /**
  2339. * Creates an array containing three elements : the coordinates of the Vector3
  2340. * @returns a new array of numbers
  2341. */
  2342. asArray(): number[];
  2343. /**
  2344. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2345. * @param array defines the destination array
  2346. * @param index defines the offset in the destination array
  2347. * @returns the current Vector3
  2348. */
  2349. toArray(array: FloatArray, index?: number): Vector3;
  2350. /**
  2351. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2352. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2353. */
  2354. toQuaternion(): Quaternion;
  2355. /**
  2356. * Adds the given vector to the current Vector3
  2357. * @param otherVector defines the second operand
  2358. * @returns the current updated Vector3
  2359. */
  2360. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2361. /**
  2362. * Adds the given coordinates to the current Vector3
  2363. * @param x defines the x coordinate of the operand
  2364. * @param y defines the y coordinate of the operand
  2365. * @param z defines the z coordinate of the operand
  2366. * @returns the current updated Vector3
  2367. */
  2368. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2369. /**
  2370. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2371. * @param otherVector defines the second operand
  2372. * @returns the resulting Vector3
  2373. */
  2374. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2375. /**
  2376. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2377. * @param otherVector defines the second operand
  2378. * @param result defines the Vector3 object where to store the result
  2379. * @returns the current Vector3
  2380. */
  2381. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2382. /**
  2383. * Subtract the given vector from the current Vector3
  2384. * @param otherVector defines the second operand
  2385. * @returns the current updated Vector3
  2386. */
  2387. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2388. /**
  2389. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2390. * @param otherVector defines the second operand
  2391. * @returns the resulting Vector3
  2392. */
  2393. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2394. /**
  2395. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2396. * @param otherVector defines the second operand
  2397. * @param result defines the Vector3 object where to store the result
  2398. * @returns the current Vector3
  2399. */
  2400. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2401. /**
  2402. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2403. * @param x defines the x coordinate of the operand
  2404. * @param y defines the y coordinate of the operand
  2405. * @param z defines the z coordinate of the operand
  2406. * @returns the resulting Vector3
  2407. */
  2408. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2409. /**
  2410. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2411. * @param x defines the x coordinate of the operand
  2412. * @param y defines the y coordinate of the operand
  2413. * @param z defines the z coordinate of the operand
  2414. * @param result defines the Vector3 object where to store the result
  2415. * @returns the current Vector3
  2416. */
  2417. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2418. /**
  2419. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2420. * @returns a new Vector3
  2421. */
  2422. negate(): Vector3;
  2423. /**
  2424. * Negate this vector in place
  2425. * @returns this
  2426. */
  2427. negateInPlace(): Vector3;
  2428. /**
  2429. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2430. * @param result defines the Vector3 object where to store the result
  2431. * @returns the current Vector3
  2432. */
  2433. negateToRef(result: Vector3): Vector3;
  2434. /**
  2435. * Multiplies the Vector3 coordinates by the float "scale"
  2436. * @param scale defines the multiplier factor
  2437. * @returns the current updated Vector3
  2438. */
  2439. scaleInPlace(scale: number): Vector3;
  2440. /**
  2441. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2442. * @param scale defines the multiplier factor
  2443. * @returns a new Vector3
  2444. */
  2445. scale(scale: number): Vector3;
  2446. /**
  2447. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2448. * @param scale defines the multiplier factor
  2449. * @param result defines the Vector3 object where to store the result
  2450. * @returns the current Vector3
  2451. */
  2452. scaleToRef(scale: number, result: Vector3): Vector3;
  2453. /**
  2454. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2455. * @param scale defines the scale factor
  2456. * @param result defines the Vector3 object where to store the result
  2457. * @returns the unmodified current Vector3
  2458. */
  2459. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2460. /**
  2461. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2462. * @param otherVector defines the second operand
  2463. * @returns true if both vectors are equals
  2464. */
  2465. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2466. /**
  2467. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2468. * @param otherVector defines the second operand
  2469. * @param epsilon defines the minimal distance to define values as equals
  2470. * @returns true if both vectors are distant less than epsilon
  2471. */
  2472. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2473. /**
  2474. * Returns true if the current Vector3 coordinates equals 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 true if both vectors are equals
  2479. */
  2480. equalsToFloats(x: number, y: number, z: number): boolean;
  2481. /**
  2482. * Multiplies the current Vector3 coordinates by the given ones
  2483. * @param otherVector defines the second operand
  2484. * @returns the current updated Vector3
  2485. */
  2486. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2487. /**
  2488. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2489. * @param otherVector defines the second operand
  2490. * @returns the new Vector3
  2491. */
  2492. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2493. /**
  2494. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2495. * @param otherVector defines the second operand
  2496. * @param result defines the Vector3 object where to store the result
  2497. * @returns the current Vector3
  2498. */
  2499. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2500. /**
  2501. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2502. * @param x defines the x coordinate of the operand
  2503. * @param y defines the y coordinate of the operand
  2504. * @param z defines the z coordinate of the operand
  2505. * @returns the new Vector3
  2506. */
  2507. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2508. /**
  2509. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2510. * @param otherVector defines the second operand
  2511. * @returns the new Vector3
  2512. */
  2513. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2514. /**
  2515. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2516. * @param otherVector defines the second operand
  2517. * @param result defines the Vector3 object where to store the result
  2518. * @returns the current Vector3
  2519. */
  2520. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2521. /**
  2522. * Divides the current Vector3 coordinates by the given ones.
  2523. * @param otherVector defines the second operand
  2524. * @returns the current updated Vector3
  2525. */
  2526. divideInPlace(otherVector: Vector3): Vector3;
  2527. /**
  2528. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2529. * @param other defines the second operand
  2530. * @returns the current updated Vector3
  2531. */
  2532. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2533. /**
  2534. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2535. * @param other defines the second operand
  2536. * @returns the current updated Vector3
  2537. */
  2538. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2539. /**
  2540. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2541. * @param x defines the x coordinate of the operand
  2542. * @param y defines the y coordinate of the operand
  2543. * @param z defines the z coordinate of the operand
  2544. * @returns the current updated Vector3
  2545. */
  2546. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2547. /**
  2548. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2549. * @param x defines the x coordinate of the operand
  2550. * @param y defines the y coordinate of the operand
  2551. * @param z defines the z coordinate of the operand
  2552. * @returns the current updated Vector3
  2553. */
  2554. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2555. /**
  2556. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2557. * Check if is non uniform within a certain amount of decimal places to account for this
  2558. * @param epsilon the amount the values can differ
  2559. * @returns if the the vector is non uniform to a certain number of decimal places
  2560. */
  2561. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2562. /**
  2563. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2564. */
  2565. get isNonUniform(): boolean;
  2566. /**
  2567. * Gets a new Vector3 from current Vector3 floored values
  2568. * @returns a new Vector3
  2569. */
  2570. floor(): Vector3;
  2571. /**
  2572. * Gets a new Vector3 from current Vector3 floored values
  2573. * @returns a new Vector3
  2574. */
  2575. fract(): Vector3;
  2576. /**
  2577. * Gets the length of the Vector3
  2578. * @returns the length of the Vector3
  2579. */
  2580. length(): number;
  2581. /**
  2582. * Gets the squared length of the Vector3
  2583. * @returns squared length of the Vector3
  2584. */
  2585. lengthSquared(): number;
  2586. /**
  2587. * Normalize the current Vector3.
  2588. * Please note that this is an in place operation.
  2589. * @returns the current updated Vector3
  2590. */
  2591. normalize(): Vector3;
  2592. /**
  2593. * Reorders the x y z properties of the vector in place
  2594. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2595. * @returns the current updated vector
  2596. */
  2597. reorderInPlace(order: string): this;
  2598. /**
  2599. * Rotates the vector around 0,0,0 by a quaternion
  2600. * @param quaternion the rotation quaternion
  2601. * @param result vector to store the result
  2602. * @returns the resulting vector
  2603. */
  2604. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2605. /**
  2606. * Rotates a vector around a given point
  2607. * @param quaternion the rotation quaternion
  2608. * @param point the point to rotate around
  2609. * @param result vector to store the result
  2610. * @returns the resulting vector
  2611. */
  2612. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2613. /**
  2614. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2615. * The cross product is then orthogonal to both current and "other"
  2616. * @param other defines the right operand
  2617. * @returns the cross product
  2618. */
  2619. cross(other: Vector3): Vector3;
  2620. /**
  2621. * Normalize the current Vector3 with the given input length.
  2622. * Please note that this is an in place operation.
  2623. * @param len the length of the vector
  2624. * @returns the current updated Vector3
  2625. */
  2626. normalizeFromLength(len: number): Vector3;
  2627. /**
  2628. * Normalize the current Vector3 to a new vector
  2629. * @returns the new Vector3
  2630. */
  2631. normalizeToNew(): Vector3;
  2632. /**
  2633. * Normalize the current Vector3 to the reference
  2634. * @param reference define the Vector3 to update
  2635. * @returns the updated Vector3
  2636. */
  2637. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2638. /**
  2639. * Creates a new Vector3 copied from the current Vector3
  2640. * @returns the new Vector3
  2641. */
  2642. clone(): Vector3;
  2643. /**
  2644. * Copies the given vector coordinates to the current Vector3 ones
  2645. * @param source defines the source Vector3
  2646. * @returns the current updated Vector3
  2647. */
  2648. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2649. /**
  2650. * Copies the given floats to the current Vector3 coordinates
  2651. * @param x defines the x coordinate of the operand
  2652. * @param y defines the y coordinate of the operand
  2653. * @param z defines the z coordinate of the operand
  2654. * @returns the current updated Vector3
  2655. */
  2656. copyFromFloats(x: number, y: number, z: number): Vector3;
  2657. /**
  2658. * Copies the given floats to the current Vector3 coordinates
  2659. * @param x defines the x coordinate of the operand
  2660. * @param y defines the y coordinate of the operand
  2661. * @param z defines the z coordinate of the operand
  2662. * @returns the current updated Vector3
  2663. */
  2664. set(x: number, y: number, z: number): Vector3;
  2665. /**
  2666. * Copies the given float to the current Vector3 coordinates
  2667. * @param v defines the x, y and z coordinates of the operand
  2668. * @returns the current updated Vector3
  2669. */
  2670. setAll(v: number): Vector3;
  2671. /**
  2672. * Get the clip factor between two vectors
  2673. * @param vector0 defines the first operand
  2674. * @param vector1 defines the second operand
  2675. * @param axis defines the axis to use
  2676. * @param size defines the size along the axis
  2677. * @returns the clip factor
  2678. */
  2679. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2680. /**
  2681. * Get angle between two vectors
  2682. * @param vector0 angle between vector0 and vector1
  2683. * @param vector1 angle between vector0 and vector1
  2684. * @param normal direction of the normal
  2685. * @return the angle between vector0 and vector1
  2686. */
  2687. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2688. /**
  2689. * Returns a new Vector3 set from the index "offset" of the given array
  2690. * @param array defines the source array
  2691. * @param offset defines the offset in the source array
  2692. * @returns the new Vector3
  2693. */
  2694. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2695. /**
  2696. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2697. * @param array defines the source array
  2698. * @param offset defines the offset in the source array
  2699. * @returns the new Vector3
  2700. * @deprecated Please use FromArray instead.
  2701. */
  2702. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2703. /**
  2704. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2705. * @param array defines the source array
  2706. * @param offset defines the offset in the source array
  2707. * @param result defines the Vector3 where to store the result
  2708. */
  2709. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2710. /**
  2711. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2712. * @param array defines the source array
  2713. * @param offset defines the offset in the source array
  2714. * @param result defines the Vector3 where to store the result
  2715. * @deprecated Please use FromArrayToRef instead.
  2716. */
  2717. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2718. /**
  2719. * Sets the given vector "result" with the given floats.
  2720. * @param x defines the x coordinate of the source
  2721. * @param y defines the y coordinate of the source
  2722. * @param z defines the z coordinate of the source
  2723. * @param result defines the Vector3 where to store the result
  2724. */
  2725. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2726. /**
  2727. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2728. * @returns a new empty Vector3
  2729. */
  2730. static Zero(): Vector3;
  2731. /**
  2732. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2733. * @returns a new unit Vector3
  2734. */
  2735. static One(): Vector3;
  2736. /**
  2737. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2738. * @returns a new up Vector3
  2739. */
  2740. static Up(): Vector3;
  2741. /**
  2742. * Gets a up Vector3 that must not be updated
  2743. */
  2744. static get UpReadOnly(): DeepImmutable<Vector3>;
  2745. /**
  2746. * Gets a zero Vector3 that must not be updated
  2747. */
  2748. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2749. /**
  2750. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2751. * @returns a new down Vector3
  2752. */
  2753. static Down(): Vector3;
  2754. /**
  2755. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2756. * @returns a new forward Vector3
  2757. */
  2758. static Forward(): Vector3;
  2759. /**
  2760. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2761. * @returns a new forward Vector3
  2762. */
  2763. static Backward(): Vector3;
  2764. /**
  2765. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2766. * @returns a new right Vector3
  2767. */
  2768. static Right(): Vector3;
  2769. /**
  2770. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2771. * @returns a new left Vector3
  2772. */
  2773. static Left(): Vector3;
  2774. /**
  2775. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2776. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2777. * @param vector defines the Vector3 to transform
  2778. * @param transformation defines the transformation matrix
  2779. * @returns the transformed Vector3
  2780. */
  2781. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2782. /**
  2783. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2784. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2785. * @param vector defines the Vector3 to transform
  2786. * @param transformation defines the transformation matrix
  2787. * @param result defines the Vector3 where to store the result
  2788. */
  2789. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2790. /**
  2791. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2792. * This method computes tranformed coordinates only, not transformed direction vectors
  2793. * @param x define the x coordinate of the source vector
  2794. * @param y define the y coordinate of the source vector
  2795. * @param z define the z coordinate of the source vector
  2796. * @param transformation defines the transformation matrix
  2797. * @param result defines the Vector3 where to store the result
  2798. */
  2799. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2800. /**
  2801. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2802. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2803. * @param vector defines the Vector3 to transform
  2804. * @param transformation defines the transformation matrix
  2805. * @returns the new Vector3
  2806. */
  2807. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2808. /**
  2809. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2810. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2811. * @param vector defines the Vector3 to transform
  2812. * @param transformation defines the transformation matrix
  2813. * @param result defines the Vector3 where to store the result
  2814. */
  2815. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2816. /**
  2817. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2818. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2819. * @param x define the x coordinate of the source vector
  2820. * @param y define the y coordinate of the source vector
  2821. * @param z define the z coordinate of the source vector
  2822. * @param transformation defines the transformation matrix
  2823. * @param result defines the Vector3 where to store the result
  2824. */
  2825. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2826. /**
  2827. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2828. * @param value1 defines the first control point
  2829. * @param value2 defines the second control point
  2830. * @param value3 defines the third control point
  2831. * @param value4 defines the fourth control point
  2832. * @param amount defines the amount on the spline to use
  2833. * @returns the new Vector3
  2834. */
  2835. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2836. /**
  2837. * 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"
  2838. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2839. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2840. * @param value defines the current value
  2841. * @param min defines the lower range value
  2842. * @param max defines the upper range value
  2843. * @returns the new Vector3
  2844. */
  2845. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2846. /**
  2847. * 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"
  2848. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2849. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2850. * @param value defines the current value
  2851. * @param min defines the lower range value
  2852. * @param max defines the upper range value
  2853. * @param result defines the Vector3 where to store the result
  2854. */
  2855. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2856. /**
  2857. * Checks if a given vector is inside a specific range
  2858. * @param v defines the vector to test
  2859. * @param min defines the minimum range
  2860. * @param max defines the maximum range
  2861. */
  2862. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2863. /**
  2864. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2865. * @param value1 defines the first control point
  2866. * @param tangent1 defines the first tangent vector
  2867. * @param value2 defines the second control point
  2868. * @param tangent2 defines the second tangent vector
  2869. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2870. * @returns the new Vector3
  2871. */
  2872. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2873. /**
  2874. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2875. * @param start defines the start value
  2876. * @param end defines the end value
  2877. * @param amount max defines amount between both (between 0 and 1)
  2878. * @returns the new Vector3
  2879. */
  2880. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2881. /**
  2882. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2883. * @param start defines the start value
  2884. * @param end defines the end value
  2885. * @param amount max defines amount between both (between 0 and 1)
  2886. * @param result defines the Vector3 where to store the result
  2887. */
  2888. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2889. /**
  2890. * Returns the dot product (float) between the vectors "left" and "right"
  2891. * @param left defines the left operand
  2892. * @param right defines the right operand
  2893. * @returns the dot product
  2894. */
  2895. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2896. /**
  2897. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2898. * The cross product is then orthogonal to both "left" and "right"
  2899. * @param left defines the left operand
  2900. * @param right defines the right operand
  2901. * @returns the cross product
  2902. */
  2903. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2904. /**
  2905. * Sets the given vector "result" with the cross product of "left" and "right"
  2906. * The cross product is then orthogonal to both "left" and "right"
  2907. * @param left defines the left operand
  2908. * @param right defines the right operand
  2909. * @param result defines the Vector3 where to store the result
  2910. */
  2911. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2912. /**
  2913. * Returns a new Vector3 as the normalization of the given vector
  2914. * @param vector defines the Vector3 to normalize
  2915. * @returns the new Vector3
  2916. */
  2917. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2918. /**
  2919. * Sets the given vector "result" with the normalization of the given first vector
  2920. * @param vector defines the Vector3 to normalize
  2921. * @param result defines the Vector3 where to store the result
  2922. */
  2923. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2924. /**
  2925. * Project a Vector3 onto screen space
  2926. * @param vector defines the Vector3 to project
  2927. * @param world defines the world matrix to use
  2928. * @param transform defines the transform (view x projection) matrix to use
  2929. * @param viewport defines the screen viewport to use
  2930. * @returns the new Vector3
  2931. */
  2932. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2933. /** @hidden */
  2934. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2935. /**
  2936. * Unproject from screen space to object space
  2937. * @param source defines the screen space Vector3 to use
  2938. * @param viewportWidth defines the current width of the viewport
  2939. * @param viewportHeight defines the current height of the viewport
  2940. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2941. * @param transform defines the transform (view x projection) matrix to use
  2942. * @returns the new Vector3
  2943. */
  2944. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2945. /**
  2946. * Unproject from screen space to object space
  2947. * @param source defines the screen space Vector3 to use
  2948. * @param viewportWidth defines the current width of the viewport
  2949. * @param viewportHeight defines the current height of the viewport
  2950. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2951. * @param view defines the view matrix to use
  2952. * @param projection defines the projection matrix to use
  2953. * @returns the new Vector3
  2954. */
  2955. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2956. /**
  2957. * Unproject from screen space to object space
  2958. * @param source defines the screen space Vector3 to use
  2959. * @param viewportWidth defines the current width of the viewport
  2960. * @param viewportHeight defines the current height of the viewport
  2961. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2962. * @param view defines the view matrix to use
  2963. * @param projection defines the projection matrix to use
  2964. * @param result defines the Vector3 where to store the result
  2965. */
  2966. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2967. /**
  2968. * Unproject from screen space to object space
  2969. * @param sourceX defines the screen space x coordinate to use
  2970. * @param sourceY defines the screen space y coordinate to use
  2971. * @param sourceZ defines the screen space z coordinate to use
  2972. * @param viewportWidth defines the current width of the viewport
  2973. * @param viewportHeight defines the current height of the viewport
  2974. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2975. * @param view defines the view matrix to use
  2976. * @param projection defines the projection matrix to use
  2977. * @param result defines the Vector3 where to store the result
  2978. */
  2979. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2980. /**
  2981. * Gets the minimal coordinate values between two Vector3
  2982. * @param left defines the first operand
  2983. * @param right defines the second operand
  2984. * @returns the new Vector3
  2985. */
  2986. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2987. /**
  2988. * Gets the maximal coordinate values between two Vector3
  2989. * @param left defines the first operand
  2990. * @param right defines the second operand
  2991. * @returns the new Vector3
  2992. */
  2993. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2994. /**
  2995. * Returns the distance between the vectors "value1" and "value2"
  2996. * @param value1 defines the first operand
  2997. * @param value2 defines the second operand
  2998. * @returns the distance
  2999. */
  3000. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3001. /**
  3002. * Returns the squared distance between the vectors "value1" and "value2"
  3003. * @param value1 defines the first operand
  3004. * @param value2 defines the second operand
  3005. * @returns the squared distance
  3006. */
  3007. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3008. /**
  3009. * Returns a new Vector3 located at the center between "value1" and "value2"
  3010. * @param value1 defines the first operand
  3011. * @param value2 defines the second operand
  3012. * @returns the new Vector3
  3013. */
  3014. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3015. /**
  3016. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3017. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3018. * to something in order to rotate it from its local system to the given target system
  3019. * Note: axis1, axis2 and axis3 are normalized during this operation
  3020. * @param axis1 defines the first axis
  3021. * @param axis2 defines the second axis
  3022. * @param axis3 defines the third axis
  3023. * @returns a new Vector3
  3024. */
  3025. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3026. /**
  3027. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3028. * @param axis1 defines the first axis
  3029. * @param axis2 defines the second axis
  3030. * @param axis3 defines the third axis
  3031. * @param ref defines the Vector3 where to store the result
  3032. */
  3033. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3034. }
  3035. /**
  3036. * Vector4 class created for EulerAngle class conversion to Quaternion
  3037. */
  3038. export class Vector4 {
  3039. /** x value of the vector */
  3040. x: number;
  3041. /** y value of the vector */
  3042. y: number;
  3043. /** z value of the vector */
  3044. z: number;
  3045. /** w value of the vector */
  3046. w: number;
  3047. /**
  3048. * Creates a Vector4 object from the given floats.
  3049. * @param x x value of the vector
  3050. * @param y y value of the vector
  3051. * @param z z value of the vector
  3052. * @param w w value of the vector
  3053. */
  3054. constructor(
  3055. /** x value of the vector */
  3056. x: number,
  3057. /** y value of the vector */
  3058. y: number,
  3059. /** z value of the vector */
  3060. z: number,
  3061. /** w value of the vector */
  3062. w: number);
  3063. /**
  3064. * Returns the string with the Vector4 coordinates.
  3065. * @returns a string containing all the vector values
  3066. */
  3067. toString(): string;
  3068. /**
  3069. * Returns the string "Vector4".
  3070. * @returns "Vector4"
  3071. */
  3072. getClassName(): string;
  3073. /**
  3074. * Returns the Vector4 hash code.
  3075. * @returns a unique hash code
  3076. */
  3077. getHashCode(): number;
  3078. /**
  3079. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3080. * @returns the resulting array
  3081. */
  3082. asArray(): number[];
  3083. /**
  3084. * Populates the given array from the given index with the Vector4 coordinates.
  3085. * @param array array to populate
  3086. * @param index index of the array to start at (default: 0)
  3087. * @returns the Vector4.
  3088. */
  3089. toArray(array: FloatArray, index?: number): Vector4;
  3090. /**
  3091. * Adds the given vector to the current Vector4.
  3092. * @param otherVector the vector to add
  3093. * @returns the updated Vector4.
  3094. */
  3095. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3096. /**
  3097. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3098. * @param otherVector the vector to add
  3099. * @returns the resulting vector
  3100. */
  3101. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3102. /**
  3103. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3104. * @param otherVector the vector to add
  3105. * @param result the vector to store the result
  3106. * @returns the current Vector4.
  3107. */
  3108. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3109. /**
  3110. * Subtract in place the given vector from the current Vector4.
  3111. * @param otherVector the vector to subtract
  3112. * @returns the updated Vector4.
  3113. */
  3114. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3115. /**
  3116. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3117. * @param otherVector the vector to add
  3118. * @returns the new vector with the result
  3119. */
  3120. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3121. /**
  3122. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3123. * @param otherVector the vector to subtract
  3124. * @param result the vector to store the result
  3125. * @returns the current Vector4.
  3126. */
  3127. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3128. /**
  3129. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3130. */
  3131. /**
  3132. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3133. * @param x value to subtract
  3134. * @param y value to subtract
  3135. * @param z value to subtract
  3136. * @param w value to subtract
  3137. * @returns new vector containing the result
  3138. */
  3139. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3140. /**
  3141. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3142. * @param x value to subtract
  3143. * @param y value to subtract
  3144. * @param z value to subtract
  3145. * @param w value to subtract
  3146. * @param result the vector to store the result in
  3147. * @returns the current Vector4.
  3148. */
  3149. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3150. /**
  3151. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3152. * @returns a new vector with the negated values
  3153. */
  3154. negate(): Vector4;
  3155. /**
  3156. * Negate this vector in place
  3157. * @returns this
  3158. */
  3159. negateInPlace(): Vector4;
  3160. /**
  3161. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3162. * @param result defines the Vector3 object where to store the result
  3163. * @returns the current Vector4
  3164. */
  3165. negateToRef(result: Vector4): Vector4;
  3166. /**
  3167. * Multiplies the current Vector4 coordinates by scale (float).
  3168. * @param scale the number to scale with
  3169. * @returns the updated Vector4.
  3170. */
  3171. scaleInPlace(scale: number): Vector4;
  3172. /**
  3173. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3174. * @param scale the number to scale with
  3175. * @returns a new vector with the result
  3176. */
  3177. scale(scale: number): Vector4;
  3178. /**
  3179. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3180. * @param scale the number to scale with
  3181. * @param result a vector to store the result in
  3182. * @returns the current Vector4.
  3183. */
  3184. scaleToRef(scale: number, result: Vector4): Vector4;
  3185. /**
  3186. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3187. * @param scale defines the scale factor
  3188. * @param result defines the Vector4 object where to store the result
  3189. * @returns the unmodified current Vector4
  3190. */
  3191. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3192. /**
  3193. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3194. * @param otherVector the vector to compare against
  3195. * @returns true if they are equal
  3196. */
  3197. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3198. /**
  3199. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3200. * @param otherVector vector to compare against
  3201. * @param epsilon (Default: very small number)
  3202. * @returns true if they are equal
  3203. */
  3204. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3205. /**
  3206. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3207. * @param x x value to compare against
  3208. * @param y y value to compare against
  3209. * @param z z value to compare against
  3210. * @param w w value to compare against
  3211. * @returns true if equal
  3212. */
  3213. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3214. /**
  3215. * Multiplies in place the current Vector4 by the given one.
  3216. * @param otherVector vector to multiple with
  3217. * @returns the updated Vector4.
  3218. */
  3219. multiplyInPlace(otherVector: Vector4): Vector4;
  3220. /**
  3221. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3222. * @param otherVector vector to multiple with
  3223. * @returns resulting new vector
  3224. */
  3225. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3226. /**
  3227. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3228. * @param otherVector vector to multiple with
  3229. * @param result vector to store the result
  3230. * @returns the current Vector4.
  3231. */
  3232. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3233. /**
  3234. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3235. * @param x x value multiply with
  3236. * @param y y value multiply with
  3237. * @param z z value multiply with
  3238. * @param w w value multiply with
  3239. * @returns resulting new vector
  3240. */
  3241. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3242. /**
  3243. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3244. * @param otherVector vector to devide with
  3245. * @returns resulting new vector
  3246. */
  3247. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3248. /**
  3249. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3250. * @param otherVector vector to devide with
  3251. * @param result vector to store the result
  3252. * @returns the current Vector4.
  3253. */
  3254. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3255. /**
  3256. * Divides the current Vector3 coordinates by the given ones.
  3257. * @param otherVector vector to devide with
  3258. * @returns the updated Vector3.
  3259. */
  3260. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3261. /**
  3262. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3263. * @param other defines the second operand
  3264. * @returns the current updated Vector4
  3265. */
  3266. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3267. /**
  3268. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3269. * @param other defines the second operand
  3270. * @returns the current updated Vector4
  3271. */
  3272. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3273. /**
  3274. * Gets a new Vector4 from current Vector4 floored values
  3275. * @returns a new Vector4
  3276. */
  3277. floor(): Vector4;
  3278. /**
  3279. * Gets a new Vector4 from current Vector3 floored values
  3280. * @returns a new Vector4
  3281. */
  3282. fract(): Vector4;
  3283. /**
  3284. * Returns the Vector4 length (float).
  3285. * @returns the length
  3286. */
  3287. length(): number;
  3288. /**
  3289. * Returns the Vector4 squared length (float).
  3290. * @returns the length squared
  3291. */
  3292. lengthSquared(): number;
  3293. /**
  3294. * Normalizes in place the Vector4.
  3295. * @returns the updated Vector4.
  3296. */
  3297. normalize(): Vector4;
  3298. /**
  3299. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3300. * @returns this converted to a new vector3
  3301. */
  3302. toVector3(): Vector3;
  3303. /**
  3304. * Returns a new Vector4 copied from the current one.
  3305. * @returns the new cloned vector
  3306. */
  3307. clone(): Vector4;
  3308. /**
  3309. * Updates the current Vector4 with the given one coordinates.
  3310. * @param source the source vector to copy from
  3311. * @returns the updated Vector4.
  3312. */
  3313. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3314. /**
  3315. * Updates the current Vector4 coordinates with the given floats.
  3316. * @param x float to copy from
  3317. * @param y float to copy from
  3318. * @param z float to copy from
  3319. * @param w float to copy from
  3320. * @returns the updated Vector4.
  3321. */
  3322. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3323. /**
  3324. * Updates the current Vector4 coordinates with the given floats.
  3325. * @param x float to set from
  3326. * @param y float to set from
  3327. * @param z float to set from
  3328. * @param w float to set from
  3329. * @returns the updated Vector4.
  3330. */
  3331. set(x: number, y: number, z: number, w: number): Vector4;
  3332. /**
  3333. * Copies the given float to the current Vector3 coordinates
  3334. * @param v defines the x, y, z and w coordinates of the operand
  3335. * @returns the current updated Vector3
  3336. */
  3337. setAll(v: number): Vector4;
  3338. /**
  3339. * Returns a new Vector4 set from the starting index of the given array.
  3340. * @param array the array to pull values from
  3341. * @param offset the offset into the array to start at
  3342. * @returns the new vector
  3343. */
  3344. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3345. /**
  3346. * Updates the given vector "result" from the starting index of the given array.
  3347. * @param array the array to pull values from
  3348. * @param offset the offset into the array to start at
  3349. * @param result the vector to store the result in
  3350. */
  3351. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3352. /**
  3353. * Updates the given vector "result" from the starting index of the given Float32Array.
  3354. * @param array the array to pull values from
  3355. * @param offset the offset into the array to start at
  3356. * @param result the vector to store the result in
  3357. */
  3358. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3359. /**
  3360. * Updates the given vector "result" coordinates from the given floats.
  3361. * @param x float to set from
  3362. * @param y float to set from
  3363. * @param z float to set from
  3364. * @param w float to set from
  3365. * @param result the vector to the floats in
  3366. */
  3367. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3368. /**
  3369. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3370. * @returns the new vector
  3371. */
  3372. static Zero(): Vector4;
  3373. /**
  3374. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3375. * @returns the new vector
  3376. */
  3377. static One(): Vector4;
  3378. /**
  3379. * Returns a new normalized Vector4 from the given one.
  3380. * @param vector the vector to normalize
  3381. * @returns the vector
  3382. */
  3383. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3384. /**
  3385. * Updates the given vector "result" from the normalization of the given one.
  3386. * @param vector the vector to normalize
  3387. * @param result the vector to store the result in
  3388. */
  3389. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3390. /**
  3391. * Returns a vector with the minimum values from the left and right vectors
  3392. * @param left left vector to minimize
  3393. * @param right right vector to minimize
  3394. * @returns a new vector with the minimum of the left and right vector values
  3395. */
  3396. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3397. /**
  3398. * Returns a vector with the maximum values from the left and right vectors
  3399. * @param left left vector to maximize
  3400. * @param right right vector to maximize
  3401. * @returns a new vector with the maximum of the left and right vector values
  3402. */
  3403. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3404. /**
  3405. * Returns the distance (float) between the vectors "value1" and "value2".
  3406. * @param value1 value to calulate the distance between
  3407. * @param value2 value to calulate the distance between
  3408. * @return the distance between the two vectors
  3409. */
  3410. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3411. /**
  3412. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3413. * @param value1 value to calulate the distance between
  3414. * @param value2 value to calulate the distance between
  3415. * @return the distance between the two vectors squared
  3416. */
  3417. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3418. /**
  3419. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3420. * @param value1 value to calulate the center between
  3421. * @param value2 value to calulate the center between
  3422. * @return the center between the two vectors
  3423. */
  3424. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3425. /**
  3426. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3427. * This methods computes transformed normalized direction vectors only.
  3428. * @param vector the vector to transform
  3429. * @param transformation the transformation matrix to apply
  3430. * @returns the new vector
  3431. */
  3432. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3433. /**
  3434. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3435. * This methods computes transformed normalized direction vectors only.
  3436. * @param vector the vector to transform
  3437. * @param transformation the transformation matrix to apply
  3438. * @param result the vector to store the result in
  3439. */
  3440. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3441. /**
  3442. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3443. * This methods computes transformed normalized direction vectors only.
  3444. * @param x value to transform
  3445. * @param y value to transform
  3446. * @param z value to transform
  3447. * @param w value to transform
  3448. * @param transformation the transformation matrix to apply
  3449. * @param result the vector to store the results in
  3450. */
  3451. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3452. /**
  3453. * Creates a new Vector4 from a Vector3
  3454. * @param source defines the source data
  3455. * @param w defines the 4th component (default is 0)
  3456. * @returns a new Vector4
  3457. */
  3458. static FromVector3(source: Vector3, w?: number): Vector4;
  3459. }
  3460. /**
  3461. * Class used to store quaternion data
  3462. * @see https://en.wikipedia.org/wiki/Quaternion
  3463. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3464. */
  3465. export class Quaternion {
  3466. /** defines the first component (0 by default) */
  3467. x: number;
  3468. /** defines the second component (0 by default) */
  3469. y: number;
  3470. /** defines the third component (0 by default) */
  3471. z: number;
  3472. /** defines the fourth component (1.0 by default) */
  3473. w: number;
  3474. /**
  3475. * Creates a new Quaternion from the given floats
  3476. * @param x defines the first component (0 by default)
  3477. * @param y defines the second component (0 by default)
  3478. * @param z defines the third component (0 by default)
  3479. * @param w defines the fourth component (1.0 by default)
  3480. */
  3481. constructor(
  3482. /** defines the first component (0 by default) */
  3483. x?: number,
  3484. /** defines the second component (0 by default) */
  3485. y?: number,
  3486. /** defines the third component (0 by default) */
  3487. z?: number,
  3488. /** defines the fourth component (1.0 by default) */
  3489. w?: number);
  3490. /**
  3491. * Gets a string representation for the current quaternion
  3492. * @returns a string with the Quaternion coordinates
  3493. */
  3494. toString(): string;
  3495. /**
  3496. * Gets the class name of the quaternion
  3497. * @returns the string "Quaternion"
  3498. */
  3499. getClassName(): string;
  3500. /**
  3501. * Gets a hash code for this quaternion
  3502. * @returns the quaternion hash code
  3503. */
  3504. getHashCode(): number;
  3505. /**
  3506. * Copy the quaternion to an array
  3507. * @returns a new array populated with 4 elements from the quaternion coordinates
  3508. */
  3509. asArray(): number[];
  3510. /**
  3511. * Check if two quaternions are equals
  3512. * @param otherQuaternion defines the second operand
  3513. * @return true if the current quaternion and the given one coordinates are strictly equals
  3514. */
  3515. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3516. /**
  3517. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3518. * @param otherQuaternion defines the other quaternion
  3519. * @param epsilon defines the minimal distance to consider equality
  3520. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3521. */
  3522. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3523. /**
  3524. * Clone the current quaternion
  3525. * @returns a new quaternion copied from the current one
  3526. */
  3527. clone(): Quaternion;
  3528. /**
  3529. * Copy a quaternion to the current one
  3530. * @param other defines the other quaternion
  3531. * @returns the updated current quaternion
  3532. */
  3533. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3534. /**
  3535. * Updates the current quaternion with the given float coordinates
  3536. * @param x defines the x coordinate
  3537. * @param y defines the y coordinate
  3538. * @param z defines the z coordinate
  3539. * @param w defines the w coordinate
  3540. * @returns the updated current quaternion
  3541. */
  3542. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3543. /**
  3544. * Updates the current quaternion from the given float coordinates
  3545. * @param x defines the x coordinate
  3546. * @param y defines the y coordinate
  3547. * @param z defines the z coordinate
  3548. * @param w defines the w coordinate
  3549. * @returns the updated current quaternion
  3550. */
  3551. set(x: number, y: number, z: number, w: number): Quaternion;
  3552. /**
  3553. * Adds two quaternions
  3554. * @param other defines the second operand
  3555. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3556. */
  3557. add(other: DeepImmutable<Quaternion>): Quaternion;
  3558. /**
  3559. * Add a quaternion to the current one
  3560. * @param other defines the quaternion to add
  3561. * @returns the current quaternion
  3562. */
  3563. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3564. /**
  3565. * Subtract two quaternions
  3566. * @param other defines the second operand
  3567. * @returns a new quaternion as the subtraction result of the given one from the current one
  3568. */
  3569. subtract(other: Quaternion): Quaternion;
  3570. /**
  3571. * Multiplies the current quaternion by a scale factor
  3572. * @param value defines the scale factor
  3573. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3574. */
  3575. scale(value: number): Quaternion;
  3576. /**
  3577. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3578. * @param scale defines the scale factor
  3579. * @param result defines the Quaternion object where to store the result
  3580. * @returns the unmodified current quaternion
  3581. */
  3582. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3583. /**
  3584. * Multiplies in place the current quaternion by a scale factor
  3585. * @param value defines the scale factor
  3586. * @returns the current modified quaternion
  3587. */
  3588. scaleInPlace(value: number): Quaternion;
  3589. /**
  3590. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3591. * @param scale defines the scale factor
  3592. * @param result defines the Quaternion object where to store the result
  3593. * @returns the unmodified current quaternion
  3594. */
  3595. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3596. /**
  3597. * Multiplies two quaternions
  3598. * @param q1 defines the second operand
  3599. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3600. */
  3601. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3602. /**
  3603. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3604. * @param q1 defines the second operand
  3605. * @param result defines the target quaternion
  3606. * @returns the current quaternion
  3607. */
  3608. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3609. /**
  3610. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3611. * @param q1 defines the second operand
  3612. * @returns the currentupdated quaternion
  3613. */
  3614. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3615. /**
  3616. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3617. * @param ref defines the target quaternion
  3618. * @returns the current quaternion
  3619. */
  3620. conjugateToRef(ref: Quaternion): Quaternion;
  3621. /**
  3622. * Conjugates in place (1-q) the current quaternion
  3623. * @returns the current updated quaternion
  3624. */
  3625. conjugateInPlace(): Quaternion;
  3626. /**
  3627. * Conjugates in place (1-q) the current quaternion
  3628. * @returns a new quaternion
  3629. */
  3630. conjugate(): Quaternion;
  3631. /**
  3632. * Gets length of current quaternion
  3633. * @returns the quaternion length (float)
  3634. */
  3635. length(): number;
  3636. /**
  3637. * Normalize in place the current quaternion
  3638. * @returns the current updated quaternion
  3639. */
  3640. normalize(): Quaternion;
  3641. /**
  3642. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3643. * @param order is a reserved parameter and is ignore for now
  3644. * @returns a new Vector3 containing the Euler angles
  3645. */
  3646. toEulerAngles(order?: string): Vector3;
  3647. /**
  3648. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3649. * @param result defines the vector which will be filled with the Euler angles
  3650. * @param order is a reserved parameter and is ignore for now
  3651. * @returns the current unchanged quaternion
  3652. */
  3653. toEulerAnglesToRef(result: Vector3): Quaternion;
  3654. /**
  3655. * Updates the given rotation matrix with the current quaternion values
  3656. * @param result defines the target matrix
  3657. * @returns the current unchanged quaternion
  3658. */
  3659. toRotationMatrix(result: Matrix): Quaternion;
  3660. /**
  3661. * Updates the current quaternion from the given rotation matrix values
  3662. * @param matrix defines the source matrix
  3663. * @returns the current updated quaternion
  3664. */
  3665. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3666. /**
  3667. * Creates a new quaternion from a rotation matrix
  3668. * @param matrix defines the source matrix
  3669. * @returns a new quaternion created from the given rotation matrix values
  3670. */
  3671. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3672. /**
  3673. * Updates the given quaternion with the given rotation matrix values
  3674. * @param matrix defines the source matrix
  3675. * @param result defines the target quaternion
  3676. */
  3677. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3678. /**
  3679. * Returns the dot product (float) between the quaternions "left" and "right"
  3680. * @param left defines the left operand
  3681. * @param right defines the right operand
  3682. * @returns the dot product
  3683. */
  3684. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3685. /**
  3686. * Checks if the two quaternions are close to each other
  3687. * @param quat0 defines the first quaternion to check
  3688. * @param quat1 defines the second quaternion to check
  3689. * @returns true if the two quaternions are close to each other
  3690. */
  3691. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3692. /**
  3693. * Creates an empty quaternion
  3694. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3695. */
  3696. static Zero(): Quaternion;
  3697. /**
  3698. * Inverse a given quaternion
  3699. * @param q defines the source quaternion
  3700. * @returns a new quaternion as the inverted current quaternion
  3701. */
  3702. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3703. /**
  3704. * Inverse a given quaternion
  3705. * @param q defines the source quaternion
  3706. * @param result the quaternion the result will be stored in
  3707. * @returns the result quaternion
  3708. */
  3709. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3710. /**
  3711. * Creates an identity quaternion
  3712. * @returns the identity quaternion
  3713. */
  3714. static Identity(): Quaternion;
  3715. /**
  3716. * Gets a boolean indicating if the given quaternion is identity
  3717. * @param quaternion defines the quaternion to check
  3718. * @returns true if the quaternion is identity
  3719. */
  3720. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3721. /**
  3722. * Creates a quaternion from a rotation around an axis
  3723. * @param axis defines the axis to use
  3724. * @param angle defines the angle to use
  3725. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3726. */
  3727. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3728. /**
  3729. * Creates a rotation around an axis and stores it into the given quaternion
  3730. * @param axis defines the axis to use
  3731. * @param angle defines the angle to use
  3732. * @param result defines the target quaternion
  3733. * @returns the target quaternion
  3734. */
  3735. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3736. /**
  3737. * Creates a new quaternion from data stored into an array
  3738. * @param array defines the data source
  3739. * @param offset defines the offset in the source array where the data starts
  3740. * @returns a new quaternion
  3741. */
  3742. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3743. /**
  3744. * Updates the given quaternion "result" from the starting index of the given array.
  3745. * @param array the array to pull values from
  3746. * @param offset the offset into the array to start at
  3747. * @param result the quaternion to store the result in
  3748. */
  3749. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3750. /**
  3751. * Create a quaternion from Euler rotation angles
  3752. * @param x Pitch
  3753. * @param y Yaw
  3754. * @param z Roll
  3755. * @returns the new Quaternion
  3756. */
  3757. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3758. /**
  3759. * Updates a quaternion from Euler rotation angles
  3760. * @param x Pitch
  3761. * @param y Yaw
  3762. * @param z Roll
  3763. * @param result the quaternion to store the result
  3764. * @returns the updated quaternion
  3765. */
  3766. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3767. /**
  3768. * Create a quaternion from Euler rotation vector
  3769. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3770. * @returns the new Quaternion
  3771. */
  3772. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3773. /**
  3774. * Updates a quaternion from Euler rotation vector
  3775. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3776. * @param result the quaternion to store the result
  3777. * @returns the updated quaternion
  3778. */
  3779. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3780. /**
  3781. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3782. * @param yaw defines the rotation around Y axis
  3783. * @param pitch defines the rotation around X axis
  3784. * @param roll defines the rotation around Z axis
  3785. * @returns the new quaternion
  3786. */
  3787. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3788. /**
  3789. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3790. * @param yaw defines the rotation around Y axis
  3791. * @param pitch defines the rotation around X axis
  3792. * @param roll defines the rotation around Z axis
  3793. * @param result defines the target quaternion
  3794. */
  3795. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3796. /**
  3797. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3798. * @param alpha defines the rotation around first axis
  3799. * @param beta defines the rotation around second axis
  3800. * @param gamma defines the rotation around third axis
  3801. * @returns the new quaternion
  3802. */
  3803. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3804. /**
  3805. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3806. * @param alpha defines the rotation around first axis
  3807. * @param beta defines the rotation around second axis
  3808. * @param gamma defines the rotation around third axis
  3809. * @param result defines the target quaternion
  3810. */
  3811. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3812. /**
  3813. * 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)
  3814. * @param axis1 defines the first axis
  3815. * @param axis2 defines the second axis
  3816. * @param axis3 defines the third axis
  3817. * @returns the new quaternion
  3818. */
  3819. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3820. /**
  3821. * 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
  3822. * @param axis1 defines the first axis
  3823. * @param axis2 defines the second axis
  3824. * @param axis3 defines the third axis
  3825. * @param ref defines the target quaternion
  3826. */
  3827. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3828. /**
  3829. * Interpolates between two quaternions
  3830. * @param left defines first quaternion
  3831. * @param right defines second quaternion
  3832. * @param amount defines the gradient to use
  3833. * @returns the new interpolated quaternion
  3834. */
  3835. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3836. /**
  3837. * Interpolates between two quaternions and stores it into a target quaternion
  3838. * @param left defines first quaternion
  3839. * @param right defines second quaternion
  3840. * @param amount defines the gradient to use
  3841. * @param result defines the target quaternion
  3842. */
  3843. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3844. /**
  3845. * Interpolate between two quaternions using Hermite interpolation
  3846. * @param value1 defines first quaternion
  3847. * @param tangent1 defines the incoming tangent
  3848. * @param value2 defines second quaternion
  3849. * @param tangent2 defines the outgoing tangent
  3850. * @param amount defines the target quaternion
  3851. * @returns the new interpolated quaternion
  3852. */
  3853. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3854. }
  3855. /**
  3856. * Class used to store matrix data (4x4)
  3857. */
  3858. export class Matrix {
  3859. private static _updateFlagSeed;
  3860. private static _identityReadOnly;
  3861. private _isIdentity;
  3862. private _isIdentityDirty;
  3863. private _isIdentity3x2;
  3864. private _isIdentity3x2Dirty;
  3865. /**
  3866. * Gets the update flag of the matrix which is an unique number for the matrix.
  3867. * It will be incremented every time the matrix data change.
  3868. * You can use it to speed the comparison between two versions of the same matrix.
  3869. */
  3870. updateFlag: number;
  3871. private readonly _m;
  3872. /**
  3873. * Gets the internal data of the matrix
  3874. */
  3875. get m(): DeepImmutable<Float32Array>;
  3876. /** @hidden */
  3877. _markAsUpdated(): void;
  3878. /** @hidden */
  3879. private _updateIdentityStatus;
  3880. /**
  3881. * Creates an empty matrix (filled with zeros)
  3882. */
  3883. constructor();
  3884. /**
  3885. * Check if the current matrix is identity
  3886. * @returns true is the matrix is the identity matrix
  3887. */
  3888. isIdentity(): boolean;
  3889. /**
  3890. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3891. * @returns true is the matrix is the identity matrix
  3892. */
  3893. isIdentityAs3x2(): boolean;
  3894. /**
  3895. * Gets the determinant of the matrix
  3896. * @returns the matrix determinant
  3897. */
  3898. determinant(): number;
  3899. /**
  3900. * Returns the matrix as a Float32Array
  3901. * @returns the matrix underlying array
  3902. */
  3903. toArray(): DeepImmutable<Float32Array>;
  3904. /**
  3905. * Returns the matrix as a Float32Array
  3906. * @returns the matrix underlying array.
  3907. */
  3908. asArray(): DeepImmutable<Float32Array>;
  3909. /**
  3910. * Inverts the current matrix in place
  3911. * @returns the current inverted matrix
  3912. */
  3913. invert(): Matrix;
  3914. /**
  3915. * Sets all the matrix elements to zero
  3916. * @returns the current matrix
  3917. */
  3918. reset(): Matrix;
  3919. /**
  3920. * Adds the current matrix with a second one
  3921. * @param other defines the matrix to add
  3922. * @returns a new matrix as the addition of the current matrix and the given one
  3923. */
  3924. add(other: DeepImmutable<Matrix>): Matrix;
  3925. /**
  3926. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3927. * @param other defines the matrix to add
  3928. * @param result defines the target matrix
  3929. * @returns the current matrix
  3930. */
  3931. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3932. /**
  3933. * Adds in place the given matrix to the current matrix
  3934. * @param other defines the second operand
  3935. * @returns the current updated matrix
  3936. */
  3937. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3938. /**
  3939. * Sets the given matrix to the current inverted Matrix
  3940. * @param other defines the target matrix
  3941. * @returns the unmodified current matrix
  3942. */
  3943. invertToRef(other: Matrix): Matrix;
  3944. /**
  3945. * add a value at the specified position in the current Matrix
  3946. * @param index the index of the value within the matrix. between 0 and 15.
  3947. * @param value the value to be added
  3948. * @returns the current updated matrix
  3949. */
  3950. addAtIndex(index: number, value: number): Matrix;
  3951. /**
  3952. * mutiply the specified position in the current Matrix by a value
  3953. * @param index the index of the value within the matrix. between 0 and 15.
  3954. * @param value the value to be added
  3955. * @returns the current updated matrix
  3956. */
  3957. multiplyAtIndex(index: number, value: number): Matrix;
  3958. /**
  3959. * Inserts the translation vector (using 3 floats) in the current matrix
  3960. * @param x defines the 1st component of the translation
  3961. * @param y defines the 2nd component of the translation
  3962. * @param z defines the 3rd component of the translation
  3963. * @returns the current updated matrix
  3964. */
  3965. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3966. /**
  3967. * Adds the translation vector (using 3 floats) in the current matrix
  3968. * @param x defines the 1st component of the translation
  3969. * @param y defines the 2nd component of the translation
  3970. * @param z defines the 3rd component of the translation
  3971. * @returns the current updated matrix
  3972. */
  3973. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3974. /**
  3975. * Inserts the translation vector in the current matrix
  3976. * @param vector3 defines the translation to insert
  3977. * @returns the current updated matrix
  3978. */
  3979. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3980. /**
  3981. * Gets the translation value of the current matrix
  3982. * @returns a new Vector3 as the extracted translation from the matrix
  3983. */
  3984. getTranslation(): Vector3;
  3985. /**
  3986. * Fill a Vector3 with the extracted translation from the matrix
  3987. * @param result defines the Vector3 where to store the translation
  3988. * @returns the current matrix
  3989. */
  3990. getTranslationToRef(result: Vector3): Matrix;
  3991. /**
  3992. * Remove rotation and scaling part from the matrix
  3993. * @returns the updated matrix
  3994. */
  3995. removeRotationAndScaling(): Matrix;
  3996. /**
  3997. * Multiply two matrices
  3998. * @param other defines the second operand
  3999. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4000. */
  4001. multiply(other: DeepImmutable<Matrix>): Matrix;
  4002. /**
  4003. * Copy the current matrix from the given one
  4004. * @param other defines the source matrix
  4005. * @returns the current updated matrix
  4006. */
  4007. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4008. /**
  4009. * Populates the given array from the starting index with the current matrix values
  4010. * @param array defines the target array
  4011. * @param offset defines the offset in the target array where to start storing values
  4012. * @returns the current matrix
  4013. */
  4014. copyToArray(array: Float32Array, offset?: number): Matrix;
  4015. /**
  4016. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4017. * @param other defines the second operand
  4018. * @param result defines the matrix where to store the multiplication
  4019. * @returns the current matrix
  4020. */
  4021. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4022. /**
  4023. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4024. * @param other defines the second operand
  4025. * @param result defines the array where to store the multiplication
  4026. * @param offset defines the offset in the target array where to start storing values
  4027. * @returns the current matrix
  4028. */
  4029. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4030. /**
  4031. * Check equality between this matrix and a second one
  4032. * @param value defines the second matrix to compare
  4033. * @returns true is the current matrix and the given one values are strictly equal
  4034. */
  4035. equals(value: DeepImmutable<Matrix>): boolean;
  4036. /**
  4037. * Clone the current matrix
  4038. * @returns a new matrix from the current matrix
  4039. */
  4040. clone(): Matrix;
  4041. /**
  4042. * Returns the name of the current matrix class
  4043. * @returns the string "Matrix"
  4044. */
  4045. getClassName(): string;
  4046. /**
  4047. * Gets the hash code of the current matrix
  4048. * @returns the hash code
  4049. */
  4050. getHashCode(): number;
  4051. /**
  4052. * Decomposes the current Matrix into a translation, rotation and scaling components
  4053. * @param scale defines the scale vector3 given as a reference to update
  4054. * @param rotation defines the rotation quaternion given as a reference to update
  4055. * @param translation defines the translation vector3 given as a reference to update
  4056. * @returns true if operation was successful
  4057. */
  4058. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4059. /**
  4060. * Gets specific row of the matrix
  4061. * @param index defines the number of the row to get
  4062. * @returns the index-th row of the current matrix as a new Vector4
  4063. */
  4064. getRow(index: number): Nullable<Vector4>;
  4065. /**
  4066. * Sets the index-th row of the current matrix to the vector4 values
  4067. * @param index defines the number of the row to set
  4068. * @param row defines the target vector4
  4069. * @returns the updated current matrix
  4070. */
  4071. setRow(index: number, row: Vector4): Matrix;
  4072. /**
  4073. * Compute the transpose of the matrix
  4074. * @returns the new transposed matrix
  4075. */
  4076. transpose(): Matrix;
  4077. /**
  4078. * Compute the transpose of the matrix and store it in a given matrix
  4079. * @param result defines the target matrix
  4080. * @returns the current matrix
  4081. */
  4082. transposeToRef(result: Matrix): Matrix;
  4083. /**
  4084. * Sets the index-th row of the current matrix with the given 4 x float values
  4085. * @param index defines the row index
  4086. * @param x defines the x component to set
  4087. * @param y defines the y component to set
  4088. * @param z defines the z component to set
  4089. * @param w defines the w component to set
  4090. * @returns the updated current matrix
  4091. */
  4092. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4093. /**
  4094. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4095. * @param scale defines the scale factor
  4096. * @returns a new matrix
  4097. */
  4098. scale(scale: number): Matrix;
  4099. /**
  4100. * Scale the current matrix values by a factor to a given result matrix
  4101. * @param scale defines the scale factor
  4102. * @param result defines the matrix to store the result
  4103. * @returns the current matrix
  4104. */
  4105. scaleToRef(scale: number, result: Matrix): Matrix;
  4106. /**
  4107. * Scale the current matrix values by a factor and add the result to a given matrix
  4108. * @param scale defines the scale factor
  4109. * @param result defines the Matrix to store the result
  4110. * @returns the current matrix
  4111. */
  4112. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4113. /**
  4114. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4115. * @param ref matrix to store the result
  4116. */
  4117. toNormalMatrix(ref: Matrix): void;
  4118. /**
  4119. * Gets only rotation part of the current matrix
  4120. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4121. */
  4122. getRotationMatrix(): Matrix;
  4123. /**
  4124. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4125. * @param result defines the target matrix to store data to
  4126. * @returns the current matrix
  4127. */
  4128. getRotationMatrixToRef(result: Matrix): Matrix;
  4129. /**
  4130. * Toggles model matrix from being right handed to left handed in place and vice versa
  4131. */
  4132. toggleModelMatrixHandInPlace(): void;
  4133. /**
  4134. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4135. */
  4136. toggleProjectionMatrixHandInPlace(): void;
  4137. /**
  4138. * Creates a matrix from an array
  4139. * @param array defines the source array
  4140. * @param offset defines an offset in the source array
  4141. * @returns a new Matrix set from the starting index of the given array
  4142. */
  4143. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4144. /**
  4145. * Copy the content of an array into a given matrix
  4146. * @param array defines the source array
  4147. * @param offset defines an offset in the source array
  4148. * @param result defines the target matrix
  4149. */
  4150. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4151. /**
  4152. * Stores an array into a matrix after having multiplied each component by a given factor
  4153. * @param array defines the source array
  4154. * @param offset defines the offset in the source array
  4155. * @param scale defines the scaling factor
  4156. * @param result defines the target matrix
  4157. */
  4158. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4159. /**
  4160. * Gets an identity matrix that must not be updated
  4161. */
  4162. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4163. /**
  4164. * Stores a list of values (16) inside a given matrix
  4165. * @param initialM11 defines 1st value of 1st row
  4166. * @param initialM12 defines 2nd value of 1st row
  4167. * @param initialM13 defines 3rd value of 1st row
  4168. * @param initialM14 defines 4th value of 1st row
  4169. * @param initialM21 defines 1st value of 2nd row
  4170. * @param initialM22 defines 2nd value of 2nd row
  4171. * @param initialM23 defines 3rd value of 2nd row
  4172. * @param initialM24 defines 4th value of 2nd row
  4173. * @param initialM31 defines 1st value of 3rd row
  4174. * @param initialM32 defines 2nd value of 3rd row
  4175. * @param initialM33 defines 3rd value of 3rd row
  4176. * @param initialM34 defines 4th value of 3rd row
  4177. * @param initialM41 defines 1st value of 4th row
  4178. * @param initialM42 defines 2nd value of 4th row
  4179. * @param initialM43 defines 3rd value of 4th row
  4180. * @param initialM44 defines 4th value of 4th row
  4181. * @param result defines the target matrix
  4182. */
  4183. 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;
  4184. /**
  4185. * Creates new matrix from a list of values (16)
  4186. * @param initialM11 defines 1st value of 1st row
  4187. * @param initialM12 defines 2nd value of 1st row
  4188. * @param initialM13 defines 3rd value of 1st row
  4189. * @param initialM14 defines 4th value of 1st row
  4190. * @param initialM21 defines 1st value of 2nd row
  4191. * @param initialM22 defines 2nd value of 2nd row
  4192. * @param initialM23 defines 3rd value of 2nd row
  4193. * @param initialM24 defines 4th value of 2nd row
  4194. * @param initialM31 defines 1st value of 3rd row
  4195. * @param initialM32 defines 2nd value of 3rd row
  4196. * @param initialM33 defines 3rd value of 3rd row
  4197. * @param initialM34 defines 4th value of 3rd row
  4198. * @param initialM41 defines 1st value of 4th row
  4199. * @param initialM42 defines 2nd value of 4th row
  4200. * @param initialM43 defines 3rd value of 4th row
  4201. * @param initialM44 defines 4th value of 4th row
  4202. * @returns the new matrix
  4203. */
  4204. 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;
  4205. /**
  4206. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4207. * @param scale defines the scale vector3
  4208. * @param rotation defines the rotation quaternion
  4209. * @param translation defines the translation vector3
  4210. * @returns a new matrix
  4211. */
  4212. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4213. /**
  4214. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4215. * @param scale defines the scale vector3
  4216. * @param rotation defines the rotation quaternion
  4217. * @param translation defines the translation vector3
  4218. * @param result defines the target matrix
  4219. */
  4220. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4221. /**
  4222. * Creates a new identity matrix
  4223. * @returns a new identity matrix
  4224. */
  4225. static Identity(): Matrix;
  4226. /**
  4227. * Creates a new identity matrix and stores the result in a given matrix
  4228. * @param result defines the target matrix
  4229. */
  4230. static IdentityToRef(result: Matrix): void;
  4231. /**
  4232. * Creates a new zero matrix
  4233. * @returns a new zero matrix
  4234. */
  4235. static Zero(): Matrix;
  4236. /**
  4237. * Creates a new rotation matrix for "angle" radians around the X axis
  4238. * @param angle defines the angle (in radians) to use
  4239. * @return the new matrix
  4240. */
  4241. static RotationX(angle: number): Matrix;
  4242. /**
  4243. * Creates a new matrix as the invert of a given matrix
  4244. * @param source defines the source matrix
  4245. * @returns the new matrix
  4246. */
  4247. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4248. /**
  4249. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4250. * @param angle defines the angle (in radians) to use
  4251. * @param result defines the target matrix
  4252. */
  4253. static RotationXToRef(angle: number, result: Matrix): void;
  4254. /**
  4255. * Creates a new rotation matrix for "angle" radians around the Y axis
  4256. * @param angle defines the angle (in radians) to use
  4257. * @return the new matrix
  4258. */
  4259. static RotationY(angle: number): Matrix;
  4260. /**
  4261. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4262. * @param angle defines the angle (in radians) to use
  4263. * @param result defines the target matrix
  4264. */
  4265. static RotationYToRef(angle: number, result: Matrix): void;
  4266. /**
  4267. * Creates a new rotation matrix for "angle" radians around the Z axis
  4268. * @param angle defines the angle (in radians) to use
  4269. * @return the new matrix
  4270. */
  4271. static RotationZ(angle: number): Matrix;
  4272. /**
  4273. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4274. * @param angle defines the angle (in radians) to use
  4275. * @param result defines the target matrix
  4276. */
  4277. static RotationZToRef(angle: number, result: Matrix): void;
  4278. /**
  4279. * Creates a new rotation matrix for "angle" radians around the given axis
  4280. * @param axis defines the axis to use
  4281. * @param angle defines the angle (in radians) to use
  4282. * @return the new matrix
  4283. */
  4284. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4285. /**
  4286. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4287. * @param axis defines the axis to use
  4288. * @param angle defines the angle (in radians) to use
  4289. * @param result defines the target matrix
  4290. */
  4291. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4292. /**
  4293. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4294. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4295. * @param from defines the vector to align
  4296. * @param to defines the vector to align to
  4297. * @param result defines the target matrix
  4298. */
  4299. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4300. /**
  4301. * Creates a rotation matrix
  4302. * @param yaw defines the yaw angle in radians (Y axis)
  4303. * @param pitch defines the pitch angle in radians (X axis)
  4304. * @param roll defines the roll angle in radians (X axis)
  4305. * @returns the new rotation matrix
  4306. */
  4307. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4308. /**
  4309. * Creates a rotation matrix and stores it in a given matrix
  4310. * @param yaw defines the yaw angle in radians (Y axis)
  4311. * @param pitch defines the pitch angle in radians (X axis)
  4312. * @param roll defines the roll angle in radians (X axis)
  4313. * @param result defines the target matrix
  4314. */
  4315. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4316. /**
  4317. * Creates a scaling matrix
  4318. * @param x defines the scale factor on X axis
  4319. * @param y defines the scale factor on Y axis
  4320. * @param z defines the scale factor on Z axis
  4321. * @returns the new matrix
  4322. */
  4323. static Scaling(x: number, y: number, z: number): Matrix;
  4324. /**
  4325. * Creates a scaling matrix and stores it in a given matrix
  4326. * @param x defines the scale factor on X axis
  4327. * @param y defines the scale factor on Y axis
  4328. * @param z defines the scale factor on Z axis
  4329. * @param result defines the target matrix
  4330. */
  4331. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4332. /**
  4333. * Creates a translation matrix
  4334. * @param x defines the translation on X axis
  4335. * @param y defines the translation on Y axis
  4336. * @param z defines the translationon Z axis
  4337. * @returns the new matrix
  4338. */
  4339. static Translation(x: number, y: number, z: number): Matrix;
  4340. /**
  4341. * Creates a translation matrix and stores it in a given matrix
  4342. * @param x defines the translation on X axis
  4343. * @param y defines the translation on Y axis
  4344. * @param z defines the translationon Z axis
  4345. * @param result defines the target matrix
  4346. */
  4347. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4348. /**
  4349. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4350. * @param startValue defines the start value
  4351. * @param endValue defines the end value
  4352. * @param gradient defines the gradient factor
  4353. * @returns the new matrix
  4354. */
  4355. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4356. /**
  4357. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4358. * @param startValue defines the start value
  4359. * @param endValue defines the end value
  4360. * @param gradient defines the gradient factor
  4361. * @param result defines the Matrix object where to store data
  4362. */
  4363. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4364. /**
  4365. * Builds a new matrix whose values are computed by:
  4366. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4367. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4368. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4369. * @param startValue defines the first matrix
  4370. * @param endValue defines the second matrix
  4371. * @param gradient defines the gradient between the two matrices
  4372. * @returns the new matrix
  4373. */
  4374. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4375. /**
  4376. * Update a matrix to values which are computed by:
  4377. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4378. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4379. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4380. * @param startValue defines the first matrix
  4381. * @param endValue defines the second matrix
  4382. * @param gradient defines the gradient between the two matrices
  4383. * @param result defines the target matrix
  4384. */
  4385. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4386. /**
  4387. * 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"
  4388. * This function works in left handed mode
  4389. * @param eye defines the final position of the entity
  4390. * @param target defines where the entity should look at
  4391. * @param up defines the up vector for the entity
  4392. * @returns the new matrix
  4393. */
  4394. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4395. /**
  4396. * 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".
  4397. * This function works in left handed mode
  4398. * @param eye defines the final position of the entity
  4399. * @param target defines where the entity should look at
  4400. * @param up defines the up vector for the entity
  4401. * @param result defines the target matrix
  4402. */
  4403. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4404. /**
  4405. * 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"
  4406. * This function works in right handed mode
  4407. * @param eye defines the final position of the entity
  4408. * @param target defines where the entity should look at
  4409. * @param up defines the up vector for the entity
  4410. * @returns the new matrix
  4411. */
  4412. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4413. /**
  4414. * 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".
  4415. * This function works in right handed mode
  4416. * @param eye defines the final position of the entity
  4417. * @param target defines where the entity should look at
  4418. * @param up defines the up vector for the entity
  4419. * @param result defines the target matrix
  4420. */
  4421. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4422. /**
  4423. * Create a left-handed orthographic projection matrix
  4424. * @param width defines the viewport width
  4425. * @param height defines the viewport height
  4426. * @param znear defines the near clip plane
  4427. * @param zfar defines the far clip plane
  4428. * @returns a new matrix as a left-handed orthographic projection matrix
  4429. */
  4430. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4431. /**
  4432. * Store a left-handed orthographic projection to a given matrix
  4433. * @param width defines the viewport width
  4434. * @param height defines the viewport height
  4435. * @param znear defines the near clip plane
  4436. * @param zfar defines the far clip plane
  4437. * @param result defines the target matrix
  4438. */
  4439. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4440. /**
  4441. * Create a left-handed orthographic projection matrix
  4442. * @param left defines the viewport left coordinate
  4443. * @param right defines the viewport right coordinate
  4444. * @param bottom defines the viewport bottom coordinate
  4445. * @param top defines the viewport top coordinate
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @returns a new matrix as a left-handed orthographic projection matrix
  4449. */
  4450. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4451. /**
  4452. * Stores a left-handed orthographic projection into a given matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @param result defines the target matrix
  4460. */
  4461. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4462. /**
  4463. * Creates a right-handed orthographic projection matrix
  4464. * @param left defines the viewport left coordinate
  4465. * @param right defines the viewport right coordinate
  4466. * @param bottom defines the viewport bottom coordinate
  4467. * @param top defines the viewport top coordinate
  4468. * @param znear defines the near clip plane
  4469. * @param zfar defines the far clip plane
  4470. * @returns a new matrix as a right-handed orthographic projection matrix
  4471. */
  4472. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4473. /**
  4474. * Stores a right-handed orthographic projection into a given matrix
  4475. * @param left defines the viewport left coordinate
  4476. * @param right defines the viewport right coordinate
  4477. * @param bottom defines the viewport bottom coordinate
  4478. * @param top defines the viewport top coordinate
  4479. * @param znear defines the near clip plane
  4480. * @param zfar defines the far clip plane
  4481. * @param result defines the target matrix
  4482. */
  4483. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4484. /**
  4485. * Creates a left-handed perspective projection matrix
  4486. * @param width defines the viewport width
  4487. * @param height defines the viewport height
  4488. * @param znear defines the near clip plane
  4489. * @param zfar defines the far clip plane
  4490. * @returns a new matrix as a left-handed perspective projection matrix
  4491. */
  4492. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4493. /**
  4494. * Creates a left-handed perspective projection matrix
  4495. * @param fov defines the horizontal field of view
  4496. * @param aspect defines the aspect ratio
  4497. * @param znear defines the near clip plane
  4498. * @param zfar defines the far clip plane
  4499. * @returns a new matrix as a left-handed perspective projection matrix
  4500. */
  4501. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4502. /**
  4503. * Stores a left-handed perspective projection into a given matrix
  4504. * @param fov defines the horizontal field of view
  4505. * @param aspect defines the aspect ratio
  4506. * @param znear defines the near clip plane
  4507. * @param zfar defines the far clip plane
  4508. * @param result defines the target matrix
  4509. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4510. */
  4511. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4512. /**
  4513. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4514. * @param fov defines the horizontal field of view
  4515. * @param aspect defines the aspect ratio
  4516. * @param znear defines the near clip plane
  4517. * @param zfar not used as infinity is used as far clip
  4518. * @param result defines the target matrix
  4519. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4520. */
  4521. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4522. /**
  4523. * Creates a right-handed perspective projection matrix
  4524. * @param fov defines the horizontal field of view
  4525. * @param aspect defines the aspect ratio
  4526. * @param znear defines the near clip plane
  4527. * @param zfar defines the far clip plane
  4528. * @returns a new matrix as a right-handed perspective projection matrix
  4529. */
  4530. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4531. /**
  4532. * Stores a right-handed perspective projection into a given matrix
  4533. * @param fov defines the horizontal field of view
  4534. * @param aspect defines the aspect ratio
  4535. * @param znear defines the near clip plane
  4536. * @param zfar defines the far clip plane
  4537. * @param result defines the target matrix
  4538. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4539. */
  4540. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4541. /**
  4542. * Stores a right-handed perspective projection into a given matrix
  4543. * @param fov defines the horizontal field of view
  4544. * @param aspect defines the aspect ratio
  4545. * @param znear defines the near clip plane
  4546. * @param zfar not used as infinity is used as far clip
  4547. * @param result defines the target matrix
  4548. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4549. */
  4550. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4551. /**
  4552. * Stores a perspective projection for WebVR info a given matrix
  4553. * @param fov defines the field of view
  4554. * @param znear defines the near clip plane
  4555. * @param zfar defines the far clip plane
  4556. * @param result defines the target matrix
  4557. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4558. */
  4559. static PerspectiveFovWebVRToRef(fov: {
  4560. upDegrees: number;
  4561. downDegrees: number;
  4562. leftDegrees: number;
  4563. rightDegrees: number;
  4564. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4565. /**
  4566. * Computes a complete transformation matrix
  4567. * @param viewport defines the viewport to use
  4568. * @param world defines the world matrix
  4569. * @param view defines the view matrix
  4570. * @param projection defines the projection matrix
  4571. * @param zmin defines the near clip plane
  4572. * @param zmax defines the far clip plane
  4573. * @returns the transformation matrix
  4574. */
  4575. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4576. /**
  4577. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4578. * @param matrix defines the matrix to use
  4579. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4580. */
  4581. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4582. /**
  4583. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4584. * @param matrix defines the matrix to use
  4585. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4586. */
  4587. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4588. /**
  4589. * Compute the transpose of a given matrix
  4590. * @param matrix defines the matrix to transpose
  4591. * @returns the new matrix
  4592. */
  4593. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4594. /**
  4595. * Compute the transpose of a matrix and store it in a target matrix
  4596. * @param matrix defines the matrix to transpose
  4597. * @param result defines the target matrix
  4598. */
  4599. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4600. /**
  4601. * Computes a reflection matrix from a plane
  4602. * @param plane defines the reflection plane
  4603. * @returns a new matrix
  4604. */
  4605. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4606. /**
  4607. * Computes a reflection matrix from a plane
  4608. * @param plane defines the reflection plane
  4609. * @param result defines the target matrix
  4610. */
  4611. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4612. /**
  4613. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4614. * @param xaxis defines the value of the 1st axis
  4615. * @param yaxis defines the value of the 2nd axis
  4616. * @param zaxis defines the value of the 3rd axis
  4617. * @param result defines the target matrix
  4618. */
  4619. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4620. /**
  4621. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4622. * @param quat defines the quaternion to use
  4623. * @param result defines the target matrix
  4624. */
  4625. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4626. }
  4627. /**
  4628. * @hidden
  4629. */
  4630. export class TmpVectors {
  4631. static Vector2: Vector2[];
  4632. static Vector3: Vector3[];
  4633. static Vector4: Vector4[];
  4634. static Quaternion: Quaternion[];
  4635. static Matrix: Matrix[];
  4636. }
  4637. }
  4638. declare module BABYLON {
  4639. /**
  4640. * Defines potential orientation for back face culling
  4641. */
  4642. export enum Orientation {
  4643. /**
  4644. * Clockwise
  4645. */
  4646. CW = 0,
  4647. /** Counter clockwise */
  4648. CCW = 1
  4649. }
  4650. /** Class used to represent a Bezier curve */
  4651. export class BezierCurve {
  4652. /**
  4653. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4654. * @param t defines the time
  4655. * @param x1 defines the left coordinate on X axis
  4656. * @param y1 defines the left coordinate on Y axis
  4657. * @param x2 defines the right coordinate on X axis
  4658. * @param y2 defines the right coordinate on Y axis
  4659. * @returns the interpolated value
  4660. */
  4661. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4662. }
  4663. /**
  4664. * Defines angle representation
  4665. */
  4666. export class Angle {
  4667. private _radians;
  4668. /**
  4669. * Creates an Angle object of "radians" radians (float).
  4670. * @param radians the angle in radians
  4671. */
  4672. constructor(radians: number);
  4673. /**
  4674. * Get value in degrees
  4675. * @returns the Angle value in degrees (float)
  4676. */
  4677. degrees(): number;
  4678. /**
  4679. * Get value in radians
  4680. * @returns the Angle value in radians (float)
  4681. */
  4682. radians(): number;
  4683. /**
  4684. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4685. * @param a defines first vector
  4686. * @param b defines second vector
  4687. * @returns a new Angle
  4688. */
  4689. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4690. /**
  4691. * Gets a new Angle object from the given float in radians
  4692. * @param radians defines the angle value in radians
  4693. * @returns a new Angle
  4694. */
  4695. static FromRadians(radians: number): Angle;
  4696. /**
  4697. * Gets a new Angle object from the given float in degrees
  4698. * @param degrees defines the angle value in degrees
  4699. * @returns a new Angle
  4700. */
  4701. static FromDegrees(degrees: number): Angle;
  4702. }
  4703. /**
  4704. * This represents an arc in a 2d space.
  4705. */
  4706. export class Arc2 {
  4707. /** Defines the start point of the arc */
  4708. startPoint: Vector2;
  4709. /** Defines the mid point of the arc */
  4710. midPoint: Vector2;
  4711. /** Defines the end point of the arc */
  4712. endPoint: Vector2;
  4713. /**
  4714. * Defines the center point of the arc.
  4715. */
  4716. centerPoint: Vector2;
  4717. /**
  4718. * Defines the radius of the arc.
  4719. */
  4720. radius: number;
  4721. /**
  4722. * Defines the angle of the arc (from mid point to end point).
  4723. */
  4724. angle: Angle;
  4725. /**
  4726. * Defines the start angle of the arc (from start point to middle point).
  4727. */
  4728. startAngle: Angle;
  4729. /**
  4730. * Defines the orientation of the arc (clock wise/counter clock wise).
  4731. */
  4732. orientation: Orientation;
  4733. /**
  4734. * Creates an Arc object from the three given points : start, middle and end.
  4735. * @param startPoint Defines the start point of the arc
  4736. * @param midPoint Defines the midlle point of the arc
  4737. * @param endPoint Defines the end point of the arc
  4738. */
  4739. constructor(
  4740. /** Defines the start point of the arc */
  4741. startPoint: Vector2,
  4742. /** Defines the mid point of the arc */
  4743. midPoint: Vector2,
  4744. /** Defines the end point of the arc */
  4745. endPoint: Vector2);
  4746. }
  4747. /**
  4748. * Represents a 2D path made up of multiple 2D points
  4749. */
  4750. export class Path2 {
  4751. private _points;
  4752. private _length;
  4753. /**
  4754. * If the path start and end point are the same
  4755. */
  4756. closed: boolean;
  4757. /**
  4758. * Creates a Path2 object from the starting 2D coordinates x and y.
  4759. * @param x the starting points x value
  4760. * @param y the starting points y value
  4761. */
  4762. constructor(x: number, y: number);
  4763. /**
  4764. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4765. * @param x the added points x value
  4766. * @param y the added points y value
  4767. * @returns the updated Path2.
  4768. */
  4769. addLineTo(x: number, y: number): Path2;
  4770. /**
  4771. * 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.
  4772. * @param midX middle point x value
  4773. * @param midY middle point y value
  4774. * @param endX end point x value
  4775. * @param endY end point y value
  4776. * @param numberOfSegments (default: 36)
  4777. * @returns the updated Path2.
  4778. */
  4779. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4780. /**
  4781. * Closes the Path2.
  4782. * @returns the Path2.
  4783. */
  4784. close(): Path2;
  4785. /**
  4786. * Gets the sum of the distance between each sequential point in the path
  4787. * @returns the Path2 total length (float).
  4788. */
  4789. length(): number;
  4790. /**
  4791. * Gets the points which construct the path
  4792. * @returns the Path2 internal array of points.
  4793. */
  4794. getPoints(): Vector2[];
  4795. /**
  4796. * Retreives the point at the distance aways from the starting point
  4797. * @param normalizedLengthPosition the length along the path to retreive the point from
  4798. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4799. */
  4800. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4801. /**
  4802. * Creates a new path starting from an x and y position
  4803. * @param x starting x value
  4804. * @param y starting y value
  4805. * @returns a new Path2 starting at the coordinates (x, y).
  4806. */
  4807. static StartingAt(x: number, y: number): Path2;
  4808. }
  4809. /**
  4810. * Represents a 3D path made up of multiple 3D points
  4811. */
  4812. export class Path3D {
  4813. /**
  4814. * an array of Vector3, the curve axis of the Path3D
  4815. */
  4816. path: Vector3[];
  4817. private _curve;
  4818. private _distances;
  4819. private _tangents;
  4820. private _normals;
  4821. private _binormals;
  4822. private _raw;
  4823. private _alignTangentsWithPath;
  4824. private readonly _pointAtData;
  4825. /**
  4826. * new Path3D(path, normal, raw)
  4827. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4828. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4829. * @param path an array of Vector3, the curve axis of the Path3D
  4830. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4831. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4832. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4833. */
  4834. constructor(
  4835. /**
  4836. * an array of Vector3, the curve axis of the Path3D
  4837. */
  4838. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4839. /**
  4840. * Returns the Path3D array of successive Vector3 designing its curve.
  4841. * @returns the Path3D array of successive Vector3 designing its curve.
  4842. */
  4843. getCurve(): Vector3[];
  4844. /**
  4845. * Returns the Path3D array of successive Vector3 designing its curve.
  4846. * @returns the Path3D array of successive Vector3 designing its curve.
  4847. */
  4848. getPoints(): Vector3[];
  4849. /**
  4850. * @returns the computed length (float) of the path.
  4851. */
  4852. length(): number;
  4853. /**
  4854. * Returns an array populated with tangent vectors on each Path3D curve point.
  4855. * @returns an array populated with tangent vectors on each Path3D curve point.
  4856. */
  4857. getTangents(): Vector3[];
  4858. /**
  4859. * Returns an array populated with normal vectors on each Path3D curve point.
  4860. * @returns an array populated with normal vectors on each Path3D curve point.
  4861. */
  4862. getNormals(): Vector3[];
  4863. /**
  4864. * Returns an array populated with binormal vectors on each Path3D curve point.
  4865. * @returns an array populated with binormal vectors on each Path3D curve point.
  4866. */
  4867. getBinormals(): Vector3[];
  4868. /**
  4869. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4870. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4871. */
  4872. getDistances(): number[];
  4873. /**
  4874. * Returns an interpolated point along this path
  4875. * @param position the position of the point along this path, from 0.0 to 1.0
  4876. * @returns a new Vector3 as the point
  4877. */
  4878. getPointAt(position: number): Vector3;
  4879. /**
  4880. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4881. * @param position the position of the point along this path, from 0.0 to 1.0
  4882. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4883. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4884. */
  4885. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4886. /**
  4887. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4888. * @param position the position of the point along this path, from 0.0 to 1.0
  4889. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4890. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4891. */
  4892. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4893. /**
  4894. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4895. * @param position the position of the point along this path, from 0.0 to 1.0
  4896. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4897. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4898. */
  4899. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4900. /**
  4901. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4902. * @param position the position of the point along this path, from 0.0 to 1.0
  4903. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4904. */
  4905. getDistanceAt(position: number): number;
  4906. /**
  4907. * Returns the array index of the previous point of an interpolated point along this path
  4908. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4909. * @returns the array index
  4910. */
  4911. getPreviousPointIndexAt(position: number): number;
  4912. /**
  4913. * 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)
  4914. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4915. * @returns the sub position
  4916. */
  4917. getSubPositionAt(position: number): number;
  4918. /**
  4919. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4920. * @param target the vector of which to get the closest position to
  4921. * @returns the position of the closest virtual point on this path to the target vector
  4922. */
  4923. getClosestPositionTo(target: Vector3): number;
  4924. /**
  4925. * Returns a sub path (slice) of this path
  4926. * @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
  4927. * @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
  4928. * @returns a sub path (slice) of this path
  4929. */
  4930. slice(start?: number, end?: number): Path3D;
  4931. /**
  4932. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4933. * @param path path which all values are copied into the curves points
  4934. * @param firstNormal which should be projected onto the curve
  4935. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4936. * @returns the same object updated.
  4937. */
  4938. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4939. private _compute;
  4940. private _getFirstNonNullVector;
  4941. private _getLastNonNullVector;
  4942. private _normalVector;
  4943. /**
  4944. * Updates the point at data for an interpolated point along this curve
  4945. * @param position the position of the point along this curve, from 0.0 to 1.0
  4946. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4947. * @returns the (updated) point at data
  4948. */
  4949. private _updatePointAtData;
  4950. /**
  4951. * Updates the point at data from the specified parameters
  4952. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4953. * @param point the interpolated point
  4954. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4955. */
  4956. private _setPointAtData;
  4957. /**
  4958. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4959. */
  4960. private _updateInterpolationMatrix;
  4961. }
  4962. /**
  4963. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4964. * A Curve3 is designed from a series of successive Vector3.
  4965. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4966. */
  4967. export class Curve3 {
  4968. private _points;
  4969. private _length;
  4970. /**
  4971. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4972. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4973. * @param v1 (Vector3) the control point
  4974. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4975. * @param nbPoints (integer) the wanted number of points in the curve
  4976. * @returns the created Curve3
  4977. */
  4978. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4979. /**
  4980. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4981. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4982. * @param v1 (Vector3) the first control point
  4983. * @param v2 (Vector3) the second control point
  4984. * @param v3 (Vector3) the end point of the Cubic Bezier
  4985. * @param nbPoints (integer) the wanted number of points in the curve
  4986. * @returns the created Curve3
  4987. */
  4988. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4989. /**
  4990. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4991. * @param p1 (Vector3) the origin point of the Hermite Spline
  4992. * @param t1 (Vector3) the tangent vector at the origin point
  4993. * @param p2 (Vector3) the end point of the Hermite Spline
  4994. * @param t2 (Vector3) the tangent vector at the end point
  4995. * @param nbPoints (integer) the wanted number of points in the curve
  4996. * @returns the created Curve3
  4997. */
  4998. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4999. /**
  5000. * Returns a Curve3 object along a CatmullRom Spline curve :
  5001. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5002. * @param nbPoints (integer) the wanted number of points between each curve control points
  5003. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5004. * @returns the created Curve3
  5005. */
  5006. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5007. /**
  5008. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5009. * A Curve3 is designed from a series of successive Vector3.
  5010. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5011. * @param points points which make up the curve
  5012. */
  5013. constructor(points: Vector3[]);
  5014. /**
  5015. * @returns the Curve3 stored array of successive Vector3
  5016. */
  5017. getPoints(): Vector3[];
  5018. /**
  5019. * @returns the computed length (float) of the curve.
  5020. */
  5021. length(): number;
  5022. /**
  5023. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5024. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5025. * curveA and curveB keep unchanged.
  5026. * @param curve the curve to continue from this curve
  5027. * @returns the newly constructed curve
  5028. */
  5029. continue(curve: DeepImmutable<Curve3>): Curve3;
  5030. private _computeLength;
  5031. }
  5032. }
  5033. declare module BABYLON {
  5034. /**
  5035. * This represents the main contract an easing function should follow.
  5036. * Easing functions are used throughout the animation system.
  5037. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5038. */
  5039. export interface IEasingFunction {
  5040. /**
  5041. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5042. * of the easing function.
  5043. * The link below provides some of the most common examples of easing functions.
  5044. * @see https://easings.net/
  5045. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5046. * @returns the corresponding value on the curve defined by the easing function
  5047. */
  5048. ease(gradient: number): number;
  5049. }
  5050. /**
  5051. * Base class used for every default easing function.
  5052. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5053. */
  5054. export class EasingFunction implements IEasingFunction {
  5055. /**
  5056. * Interpolation follows the mathematical formula associated with the easing function.
  5057. */
  5058. static readonly EASINGMODE_EASEIN: number;
  5059. /**
  5060. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5061. */
  5062. static readonly EASINGMODE_EASEOUT: number;
  5063. /**
  5064. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5065. */
  5066. static readonly EASINGMODE_EASEINOUT: number;
  5067. private _easingMode;
  5068. /**
  5069. * Sets the easing mode of the current function.
  5070. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5071. */
  5072. setEasingMode(easingMode: number): void;
  5073. /**
  5074. * Gets the current easing mode.
  5075. * @returns the easing mode
  5076. */
  5077. getEasingMode(): number;
  5078. /**
  5079. * @hidden
  5080. */
  5081. easeInCore(gradient: number): number;
  5082. /**
  5083. * Given an input gradient between 0 and 1, this returns the corresponding value
  5084. * of the easing function.
  5085. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5086. * @returns the corresponding value on the curve defined by the easing function
  5087. */
  5088. ease(gradient: number): number;
  5089. }
  5090. /**
  5091. * Easing function with a circle shape (see link below).
  5092. * @see https://easings.net/#easeInCirc
  5093. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5094. */
  5095. export class CircleEase extends EasingFunction implements IEasingFunction {
  5096. /** @hidden */
  5097. easeInCore(gradient: number): number;
  5098. }
  5099. /**
  5100. * Easing function with a ease back shape (see link below).
  5101. * @see https://easings.net/#easeInBack
  5102. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5103. */
  5104. export class BackEase extends EasingFunction implements IEasingFunction {
  5105. /** Defines the amplitude of the function */
  5106. amplitude: number;
  5107. /**
  5108. * Instantiates a back ease easing
  5109. * @see https://easings.net/#easeInBack
  5110. * @param amplitude Defines the amplitude of the function
  5111. */
  5112. constructor(
  5113. /** Defines the amplitude of the function */
  5114. amplitude?: number);
  5115. /** @hidden */
  5116. easeInCore(gradient: number): number;
  5117. }
  5118. /**
  5119. * Easing function with a bouncing shape (see link below).
  5120. * @see https://easings.net/#easeInBounce
  5121. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5122. */
  5123. export class BounceEase extends EasingFunction implements IEasingFunction {
  5124. /** Defines the number of bounces */
  5125. bounces: number;
  5126. /** Defines the amplitude of the bounce */
  5127. bounciness: number;
  5128. /**
  5129. * Instantiates a bounce easing
  5130. * @see https://easings.net/#easeInBounce
  5131. * @param bounces Defines the number of bounces
  5132. * @param bounciness Defines the amplitude of the bounce
  5133. */
  5134. constructor(
  5135. /** Defines the number of bounces */
  5136. bounces?: number,
  5137. /** Defines the amplitude of the bounce */
  5138. bounciness?: number);
  5139. /** @hidden */
  5140. easeInCore(gradient: number): number;
  5141. }
  5142. /**
  5143. * Easing function with a power of 3 shape (see link below).
  5144. * @see https://easings.net/#easeInCubic
  5145. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5146. */
  5147. export class CubicEase extends EasingFunction implements IEasingFunction {
  5148. /** @hidden */
  5149. easeInCore(gradient: number): number;
  5150. }
  5151. /**
  5152. * Easing function with an elastic shape (see link below).
  5153. * @see https://easings.net/#easeInElastic
  5154. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5155. */
  5156. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5157. /** Defines the number of oscillations*/
  5158. oscillations: number;
  5159. /** Defines the amplitude of the oscillations*/
  5160. springiness: number;
  5161. /**
  5162. * Instantiates an elastic easing function
  5163. * @see https://easings.net/#easeInElastic
  5164. * @param oscillations Defines the number of oscillations
  5165. * @param springiness Defines the amplitude of the oscillations
  5166. */
  5167. constructor(
  5168. /** Defines the number of oscillations*/
  5169. oscillations?: number,
  5170. /** Defines the amplitude of the oscillations*/
  5171. springiness?: number);
  5172. /** @hidden */
  5173. easeInCore(gradient: number): number;
  5174. }
  5175. /**
  5176. * Easing function with an exponential shape (see link below).
  5177. * @see https://easings.net/#easeInExpo
  5178. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5179. */
  5180. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5181. /** Defines the exponent of the function */
  5182. exponent: number;
  5183. /**
  5184. * Instantiates an exponential easing function
  5185. * @see https://easings.net/#easeInExpo
  5186. * @param exponent Defines the exponent of the function
  5187. */
  5188. constructor(
  5189. /** Defines the exponent of the function */
  5190. exponent?: number);
  5191. /** @hidden */
  5192. easeInCore(gradient: number): number;
  5193. }
  5194. /**
  5195. * Easing function with a power shape (see link below).
  5196. * @see https://easings.net/#easeInQuad
  5197. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5198. */
  5199. export class PowerEase extends EasingFunction implements IEasingFunction {
  5200. /** Defines the power of the function */
  5201. power: number;
  5202. /**
  5203. * Instantiates an power base easing function
  5204. * @see https://easings.net/#easeInQuad
  5205. * @param power Defines the power of the function
  5206. */
  5207. constructor(
  5208. /** Defines the power of the function */
  5209. power?: number);
  5210. /** @hidden */
  5211. easeInCore(gradient: number): number;
  5212. }
  5213. /**
  5214. * Easing function with a power of 2 shape (see link below).
  5215. * @see https://easings.net/#easeInQuad
  5216. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5217. */
  5218. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5219. /** @hidden */
  5220. easeInCore(gradient: number): number;
  5221. }
  5222. /**
  5223. * Easing function with a power of 4 shape (see link below).
  5224. * @see https://easings.net/#easeInQuart
  5225. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5226. */
  5227. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5228. /** @hidden */
  5229. easeInCore(gradient: number): number;
  5230. }
  5231. /**
  5232. * Easing function with a power of 5 shape (see link below).
  5233. * @see https://easings.net/#easeInQuint
  5234. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5235. */
  5236. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5237. /** @hidden */
  5238. easeInCore(gradient: number): number;
  5239. }
  5240. /**
  5241. * Easing function with a sin shape (see link below).
  5242. * @see https://easings.net/#easeInSine
  5243. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5244. */
  5245. export class SineEase extends EasingFunction implements IEasingFunction {
  5246. /** @hidden */
  5247. easeInCore(gradient: number): number;
  5248. }
  5249. /**
  5250. * Easing function with a bezier shape (see link below).
  5251. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5252. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5253. */
  5254. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5255. /** Defines the x component of the start tangent in the bezier curve */
  5256. x1: number;
  5257. /** Defines the y component of the start tangent in the bezier curve */
  5258. y1: number;
  5259. /** Defines the x component of the end tangent in the bezier curve */
  5260. x2: number;
  5261. /** Defines the y component of the end tangent in the bezier curve */
  5262. y2: number;
  5263. /**
  5264. * Instantiates a bezier function
  5265. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5266. * @param x1 Defines the x component of the start tangent in the bezier curve
  5267. * @param y1 Defines the y component of the start tangent in the bezier curve
  5268. * @param x2 Defines the x component of the end tangent in the bezier curve
  5269. * @param y2 Defines the y component of the end tangent in the bezier curve
  5270. */
  5271. constructor(
  5272. /** Defines the x component of the start tangent in the bezier curve */
  5273. x1?: number,
  5274. /** Defines the y component of the start tangent in the bezier curve */
  5275. y1?: number,
  5276. /** Defines the x component of the end tangent in the bezier curve */
  5277. x2?: number,
  5278. /** Defines the y component of the end tangent in the bezier curve */
  5279. y2?: number);
  5280. /** @hidden */
  5281. easeInCore(gradient: number): number;
  5282. }
  5283. }
  5284. declare module BABYLON {
  5285. /**
  5286. * Class used to hold a RBG color
  5287. */
  5288. export class Color3 {
  5289. /**
  5290. * Defines the red component (between 0 and 1, default is 0)
  5291. */
  5292. r: number;
  5293. /**
  5294. * Defines the green component (between 0 and 1, default is 0)
  5295. */
  5296. g: number;
  5297. /**
  5298. * Defines the blue component (between 0 and 1, default is 0)
  5299. */
  5300. b: number;
  5301. /**
  5302. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5303. * @param r defines the red component (between 0 and 1, default is 0)
  5304. * @param g defines the green component (between 0 and 1, default is 0)
  5305. * @param b defines the blue component (between 0 and 1, default is 0)
  5306. */
  5307. constructor(
  5308. /**
  5309. * Defines the red component (between 0 and 1, default is 0)
  5310. */
  5311. r?: number,
  5312. /**
  5313. * Defines the green component (between 0 and 1, default is 0)
  5314. */
  5315. g?: number,
  5316. /**
  5317. * Defines the blue component (between 0 and 1, default is 0)
  5318. */
  5319. b?: number);
  5320. /**
  5321. * Creates a string with the Color3 current values
  5322. * @returns the string representation of the Color3 object
  5323. */
  5324. toString(): string;
  5325. /**
  5326. * Returns the string "Color3"
  5327. * @returns "Color3"
  5328. */
  5329. getClassName(): string;
  5330. /**
  5331. * Compute the Color3 hash code
  5332. * @returns an unique number that can be used to hash Color3 objects
  5333. */
  5334. getHashCode(): number;
  5335. /**
  5336. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5337. * @param array defines the array where to store the r,g,b components
  5338. * @param index defines an optional index in the target array to define where to start storing values
  5339. * @returns the current Color3 object
  5340. */
  5341. toArray(array: FloatArray, index?: number): Color3;
  5342. /**
  5343. * Returns a new Color4 object from the current Color3 and the given alpha
  5344. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5345. * @returns a new Color4 object
  5346. */
  5347. toColor4(alpha?: number): Color4;
  5348. /**
  5349. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5350. * @returns the new array
  5351. */
  5352. asArray(): number[];
  5353. /**
  5354. * Returns the luminance value
  5355. * @returns a float value
  5356. */
  5357. toLuminance(): number;
  5358. /**
  5359. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5360. * @param otherColor defines the second operand
  5361. * @returns the new Color3 object
  5362. */
  5363. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5364. /**
  5365. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5366. * @param otherColor defines the second operand
  5367. * @param result defines the Color3 object where to store the result
  5368. * @returns the current Color3
  5369. */
  5370. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5371. /**
  5372. * Determines equality between Color3 objects
  5373. * @param otherColor defines the second operand
  5374. * @returns true if the rgb values are equal to the given ones
  5375. */
  5376. equals(otherColor: DeepImmutable<Color3>): boolean;
  5377. /**
  5378. * Determines equality between the current Color3 object and a set of r,b,g values
  5379. * @param r defines the red component to check
  5380. * @param g defines the green component to check
  5381. * @param b defines the blue component to check
  5382. * @returns true if the rgb values are equal to the given ones
  5383. */
  5384. equalsFloats(r: number, g: number, b: number): boolean;
  5385. /**
  5386. * Multiplies in place each rgb value by scale
  5387. * @param scale defines the scaling factor
  5388. * @returns the updated Color3
  5389. */
  5390. scale(scale: number): Color3;
  5391. /**
  5392. * Multiplies the rgb values by scale and stores the result into "result"
  5393. * @param scale defines the scaling factor
  5394. * @param result defines the Color3 object where to store the result
  5395. * @returns the unmodified current Color3
  5396. */
  5397. scaleToRef(scale: number, result: Color3): Color3;
  5398. /**
  5399. * Scale the current Color3 values by a factor and add the result to a given Color3
  5400. * @param scale defines the scale factor
  5401. * @param result defines color to store the result into
  5402. * @returns the unmodified current Color3
  5403. */
  5404. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5405. /**
  5406. * Clamps the rgb values by the min and max values and stores the result into "result"
  5407. * @param min defines minimum clamping value (default is 0)
  5408. * @param max defines maximum clamping value (default is 1)
  5409. * @param result defines color to store the result into
  5410. * @returns the original Color3
  5411. */
  5412. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5413. /**
  5414. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5415. * @param otherColor defines the second operand
  5416. * @returns the new Color3
  5417. */
  5418. add(otherColor: DeepImmutable<Color3>): Color3;
  5419. /**
  5420. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5421. * @param otherColor defines the second operand
  5422. * @param result defines Color3 object to store the result into
  5423. * @returns the unmodified current Color3
  5424. */
  5425. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5426. /**
  5427. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5428. * @param otherColor defines the second operand
  5429. * @returns the new Color3
  5430. */
  5431. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5432. /**
  5433. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5434. * @param otherColor defines the second operand
  5435. * @param result defines Color3 object to store the result into
  5436. * @returns the unmodified current Color3
  5437. */
  5438. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5439. /**
  5440. * Copy the current object
  5441. * @returns a new Color3 copied the current one
  5442. */
  5443. clone(): Color3;
  5444. /**
  5445. * Copies the rgb values from the source in the current Color3
  5446. * @param source defines the source Color3 object
  5447. * @returns the updated Color3 object
  5448. */
  5449. copyFrom(source: DeepImmutable<Color3>): Color3;
  5450. /**
  5451. * Updates the Color3 rgb values from the given floats
  5452. * @param r defines the red component to read from
  5453. * @param g defines the green component to read from
  5454. * @param b defines the blue component to read from
  5455. * @returns the current Color3 object
  5456. */
  5457. copyFromFloats(r: number, g: number, b: number): Color3;
  5458. /**
  5459. * Updates the Color3 rgb values from the given floats
  5460. * @param r defines the red component to read from
  5461. * @param g defines the green component to read from
  5462. * @param b defines the blue component to read from
  5463. * @returns the current Color3 object
  5464. */
  5465. set(r: number, g: number, b: number): Color3;
  5466. /**
  5467. * Compute the Color3 hexadecimal code as a string
  5468. * @returns a string containing the hexadecimal representation of the Color3 object
  5469. */
  5470. toHexString(): string;
  5471. /**
  5472. * Computes a new Color3 converted from the current one to linear space
  5473. * @returns a new Color3 object
  5474. */
  5475. toLinearSpace(): Color3;
  5476. /**
  5477. * Converts current color in rgb space to HSV values
  5478. * @returns a new color3 representing the HSV values
  5479. */
  5480. toHSV(): Color3;
  5481. /**
  5482. * Converts current color in rgb space to HSV values
  5483. * @param result defines the Color3 where to store the HSV values
  5484. */
  5485. toHSVToRef(result: Color3): void;
  5486. /**
  5487. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5488. * @param convertedColor defines the Color3 object where to store the linear space version
  5489. * @returns the unmodified Color3
  5490. */
  5491. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5492. /**
  5493. * Computes a new Color3 converted from the current one to gamma space
  5494. * @returns a new Color3 object
  5495. */
  5496. toGammaSpace(): Color3;
  5497. /**
  5498. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5499. * @param convertedColor defines the Color3 object where to store the gamma space version
  5500. * @returns the unmodified Color3
  5501. */
  5502. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5503. private static _BlackReadOnly;
  5504. /**
  5505. * Convert Hue, saturation and value to a Color3 (RGB)
  5506. * @param hue defines the hue
  5507. * @param saturation defines the saturation
  5508. * @param value defines the value
  5509. * @param result defines the Color3 where to store the RGB values
  5510. */
  5511. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5512. /**
  5513. * Creates a new Color3 from the string containing valid hexadecimal values
  5514. * @param hex defines a string containing valid hexadecimal values
  5515. * @returns a new Color3 object
  5516. */
  5517. static FromHexString(hex: string): Color3;
  5518. /**
  5519. * Creates a new Color3 from the starting index of the given array
  5520. * @param array defines the source array
  5521. * @param offset defines an offset in the source array
  5522. * @returns a new Color3 object
  5523. */
  5524. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5525. /**
  5526. * Creates a new Color3 from integer values (< 256)
  5527. * @param r defines the red component to read from (value between 0 and 255)
  5528. * @param g defines the green component to read from (value between 0 and 255)
  5529. * @param b defines the blue component to read from (value between 0 and 255)
  5530. * @returns a new Color3 object
  5531. */
  5532. static FromInts(r: number, g: number, b: number): Color3;
  5533. /**
  5534. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5535. * @param start defines the start Color3 value
  5536. * @param end defines the end Color3 value
  5537. * @param amount defines the gradient value between start and end
  5538. * @returns a new Color3 object
  5539. */
  5540. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5541. /**
  5542. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5543. * @param left defines the start value
  5544. * @param right defines the end value
  5545. * @param amount defines the gradient factor
  5546. * @param result defines the Color3 object where to store the result
  5547. */
  5548. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5549. /**
  5550. * Returns a Color3 value containing a red color
  5551. * @returns a new Color3 object
  5552. */
  5553. static Red(): Color3;
  5554. /**
  5555. * Returns a Color3 value containing a green color
  5556. * @returns a new Color3 object
  5557. */
  5558. static Green(): Color3;
  5559. /**
  5560. * Returns a Color3 value containing a blue color
  5561. * @returns a new Color3 object
  5562. */
  5563. static Blue(): Color3;
  5564. /**
  5565. * Returns a Color3 value containing a black color
  5566. * @returns a new Color3 object
  5567. */
  5568. static Black(): Color3;
  5569. /**
  5570. * Gets a Color3 value containing a black color that must not be updated
  5571. */
  5572. static get BlackReadOnly(): DeepImmutable<Color3>;
  5573. /**
  5574. * Returns a Color3 value containing a white color
  5575. * @returns a new Color3 object
  5576. */
  5577. static White(): Color3;
  5578. /**
  5579. * Returns a Color3 value containing a purple color
  5580. * @returns a new Color3 object
  5581. */
  5582. static Purple(): Color3;
  5583. /**
  5584. * Returns a Color3 value containing a magenta color
  5585. * @returns a new Color3 object
  5586. */
  5587. static Magenta(): Color3;
  5588. /**
  5589. * Returns a Color3 value containing a yellow color
  5590. * @returns a new Color3 object
  5591. */
  5592. static Yellow(): Color3;
  5593. /**
  5594. * Returns a Color3 value containing a gray color
  5595. * @returns a new Color3 object
  5596. */
  5597. static Gray(): Color3;
  5598. /**
  5599. * Returns a Color3 value containing a teal color
  5600. * @returns a new Color3 object
  5601. */
  5602. static Teal(): Color3;
  5603. /**
  5604. * Returns a Color3 value containing a random color
  5605. * @returns a new Color3 object
  5606. */
  5607. static Random(): Color3;
  5608. }
  5609. /**
  5610. * Class used to hold a RBGA color
  5611. */
  5612. export class Color4 {
  5613. /**
  5614. * Defines the red component (between 0 and 1, default is 0)
  5615. */
  5616. r: number;
  5617. /**
  5618. * Defines the green component (between 0 and 1, default is 0)
  5619. */
  5620. g: number;
  5621. /**
  5622. * Defines the blue component (between 0 and 1, default is 0)
  5623. */
  5624. b: number;
  5625. /**
  5626. * Defines the alpha component (between 0 and 1, default is 1)
  5627. */
  5628. a: number;
  5629. /**
  5630. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5631. * @param r defines the red component (between 0 and 1, default is 0)
  5632. * @param g defines the green component (between 0 and 1, default is 0)
  5633. * @param b defines the blue component (between 0 and 1, default is 0)
  5634. * @param a defines the alpha component (between 0 and 1, default is 1)
  5635. */
  5636. constructor(
  5637. /**
  5638. * Defines the red component (between 0 and 1, default is 0)
  5639. */
  5640. r?: number,
  5641. /**
  5642. * Defines the green component (between 0 and 1, default is 0)
  5643. */
  5644. g?: number,
  5645. /**
  5646. * Defines the blue component (between 0 and 1, default is 0)
  5647. */
  5648. b?: number,
  5649. /**
  5650. * Defines the alpha component (between 0 and 1, default is 1)
  5651. */
  5652. a?: number);
  5653. /**
  5654. * Adds in place the given Color4 values to the current Color4 object
  5655. * @param right defines the second operand
  5656. * @returns the current updated Color4 object
  5657. */
  5658. addInPlace(right: DeepImmutable<Color4>): Color4;
  5659. /**
  5660. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5661. * @returns the new array
  5662. */
  5663. asArray(): number[];
  5664. /**
  5665. * Stores from the starting index in the given array the Color4 successive values
  5666. * @param array defines the array where to store the r,g,b components
  5667. * @param index defines an optional index in the target array to define where to start storing values
  5668. * @returns the current Color4 object
  5669. */
  5670. toArray(array: number[], index?: number): Color4;
  5671. /**
  5672. * Determines equality between Color4 objects
  5673. * @param otherColor defines the second operand
  5674. * @returns true if the rgba values are equal to the given ones
  5675. */
  5676. equals(otherColor: DeepImmutable<Color4>): boolean;
  5677. /**
  5678. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5679. * @param right defines the second operand
  5680. * @returns a new Color4 object
  5681. */
  5682. add(right: DeepImmutable<Color4>): Color4;
  5683. /**
  5684. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5685. * @param right defines the second operand
  5686. * @returns a new Color4 object
  5687. */
  5688. subtract(right: DeepImmutable<Color4>): Color4;
  5689. /**
  5690. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5691. * @param right defines the second operand
  5692. * @param result defines the Color4 object where to store the result
  5693. * @returns the current Color4 object
  5694. */
  5695. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5696. /**
  5697. * Creates a new Color4 with the current Color4 values multiplied by scale
  5698. * @param scale defines the scaling factor to apply
  5699. * @returns a new Color4 object
  5700. */
  5701. scale(scale: number): Color4;
  5702. /**
  5703. * Multiplies the current Color4 values by scale and stores the result in "result"
  5704. * @param scale defines the scaling factor to apply
  5705. * @param result defines the Color4 object where to store the result
  5706. * @returns the current unmodified Color4
  5707. */
  5708. scaleToRef(scale: number, result: Color4): Color4;
  5709. /**
  5710. * Scale the current Color4 values by a factor and add the result to a given Color4
  5711. * @param scale defines the scale factor
  5712. * @param result defines the Color4 object where to store the result
  5713. * @returns the unmodified current Color4
  5714. */
  5715. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5716. /**
  5717. * Clamps the rgb values by the min and max values and stores the result into "result"
  5718. * @param min defines minimum clamping value (default is 0)
  5719. * @param max defines maximum clamping value (default is 1)
  5720. * @param result defines color to store the result into.
  5721. * @returns the cuurent Color4
  5722. */
  5723. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5724. /**
  5725. * Multipy an Color4 value by another and return a new Color4 object
  5726. * @param color defines the Color4 value to multiply by
  5727. * @returns a new Color4 object
  5728. */
  5729. multiply(color: Color4): Color4;
  5730. /**
  5731. * Multipy a Color4 value by another and push the result in a reference value
  5732. * @param color defines the Color4 value to multiply by
  5733. * @param result defines the Color4 to fill the result in
  5734. * @returns the result Color4
  5735. */
  5736. multiplyToRef(color: Color4, result: Color4): Color4;
  5737. /**
  5738. * Creates a string with the Color4 current values
  5739. * @returns the string representation of the Color4 object
  5740. */
  5741. toString(): string;
  5742. /**
  5743. * Returns the string "Color4"
  5744. * @returns "Color4"
  5745. */
  5746. getClassName(): string;
  5747. /**
  5748. * Compute the Color4 hash code
  5749. * @returns an unique number that can be used to hash Color4 objects
  5750. */
  5751. getHashCode(): number;
  5752. /**
  5753. * Creates a new Color4 copied from the current one
  5754. * @returns a new Color4 object
  5755. */
  5756. clone(): Color4;
  5757. /**
  5758. * Copies the given Color4 values into the current one
  5759. * @param source defines the source Color4 object
  5760. * @returns the current updated Color4 object
  5761. */
  5762. copyFrom(source: Color4): Color4;
  5763. /**
  5764. * Copies the given float values into the current one
  5765. * @param r defines the red component to read from
  5766. * @param g defines the green component to read from
  5767. * @param b defines the blue component to read from
  5768. * @param a defines the alpha component to read from
  5769. * @returns the current updated Color4 object
  5770. */
  5771. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5772. /**
  5773. * Copies the given float values into the current one
  5774. * @param r defines the red component to read from
  5775. * @param g defines the green component to read from
  5776. * @param b defines the blue component to read from
  5777. * @param a defines the alpha component to read from
  5778. * @returns the current updated Color4 object
  5779. */
  5780. set(r: number, g: number, b: number, a: number): Color4;
  5781. /**
  5782. * Compute the Color4 hexadecimal code as a string
  5783. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5784. * @returns a string containing the hexadecimal representation of the Color4 object
  5785. */
  5786. toHexString(returnAsColor3?: boolean): string;
  5787. /**
  5788. * Computes a new Color4 converted from the current one to linear space
  5789. * @returns a new Color4 object
  5790. */
  5791. toLinearSpace(): Color4;
  5792. /**
  5793. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5794. * @param convertedColor defines the Color4 object where to store the linear space version
  5795. * @returns the unmodified Color4
  5796. */
  5797. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5798. /**
  5799. * Computes a new Color4 converted from the current one to gamma space
  5800. * @returns a new Color4 object
  5801. */
  5802. toGammaSpace(): Color4;
  5803. /**
  5804. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5805. * @param convertedColor defines the Color4 object where to store the gamma space version
  5806. * @returns the unmodified Color4
  5807. */
  5808. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5809. /**
  5810. * Creates a new Color4 from the string containing valid hexadecimal values
  5811. * @param hex defines a string containing valid hexadecimal values
  5812. * @returns a new Color4 object
  5813. */
  5814. static FromHexString(hex: string): Color4;
  5815. /**
  5816. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5817. * @param left defines the start value
  5818. * @param right defines the end value
  5819. * @param amount defines the gradient factor
  5820. * @returns a new Color4 object
  5821. */
  5822. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5823. /**
  5824. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5825. * @param left defines the start value
  5826. * @param right defines the end value
  5827. * @param amount defines the gradient factor
  5828. * @param result defines the Color4 object where to store data
  5829. */
  5830. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5831. /**
  5832. * Creates a new Color4 from a Color3 and an alpha value
  5833. * @param color3 defines the source Color3 to read from
  5834. * @param alpha defines the alpha component (1.0 by default)
  5835. * @returns a new Color4 object
  5836. */
  5837. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5838. /**
  5839. * Creates a new Color4 from the starting index element of the given array
  5840. * @param array defines the source array to read from
  5841. * @param offset defines the offset in the source array
  5842. * @returns a new Color4 object
  5843. */
  5844. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5845. /**
  5846. * Creates a new Color3 from integer values (< 256)
  5847. * @param r defines the red component to read from (value between 0 and 255)
  5848. * @param g defines the green component to read from (value between 0 and 255)
  5849. * @param b defines the blue component to read from (value between 0 and 255)
  5850. * @param a defines the alpha component to read from (value between 0 and 255)
  5851. * @returns a new Color3 object
  5852. */
  5853. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5854. /**
  5855. * Check the content of a given array and convert it to an array containing RGBA data
  5856. * If the original array was already containing count * 4 values then it is returned directly
  5857. * @param colors defines the array to check
  5858. * @param count defines the number of RGBA data to expect
  5859. * @returns an array containing count * 4 values (RGBA)
  5860. */
  5861. static CheckColors4(colors: number[], count: number): number[];
  5862. }
  5863. /**
  5864. * @hidden
  5865. */
  5866. export class TmpColors {
  5867. static Color3: Color3[];
  5868. static Color4: Color4[];
  5869. }
  5870. }
  5871. declare module BABYLON {
  5872. /**
  5873. * Defines an interface which represents an animation key frame
  5874. */
  5875. export interface IAnimationKey {
  5876. /**
  5877. * Frame of the key frame
  5878. */
  5879. frame: number;
  5880. /**
  5881. * Value at the specifies key frame
  5882. */
  5883. value: any;
  5884. /**
  5885. * The input tangent for the cubic hermite spline
  5886. */
  5887. inTangent?: any;
  5888. /**
  5889. * The output tangent for the cubic hermite spline
  5890. */
  5891. outTangent?: any;
  5892. /**
  5893. * The animation interpolation type
  5894. */
  5895. interpolation?: AnimationKeyInterpolation;
  5896. }
  5897. /**
  5898. * Enum for the animation key frame interpolation type
  5899. */
  5900. export enum AnimationKeyInterpolation {
  5901. /**
  5902. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5903. */
  5904. STEP = 1
  5905. }
  5906. }
  5907. declare module BABYLON {
  5908. /**
  5909. * Represents the range of an animation
  5910. */
  5911. export class AnimationRange {
  5912. /**The name of the animation range**/
  5913. name: string;
  5914. /**The starting frame of the animation */
  5915. from: number;
  5916. /**The ending frame of the animation*/
  5917. to: number;
  5918. /**
  5919. * Initializes the range of an animation
  5920. * @param name The name of the animation range
  5921. * @param from The starting frame of the animation
  5922. * @param to The ending frame of the animation
  5923. */
  5924. constructor(
  5925. /**The name of the animation range**/
  5926. name: string,
  5927. /**The starting frame of the animation */
  5928. from: number,
  5929. /**The ending frame of the animation*/
  5930. to: number);
  5931. /**
  5932. * Makes a copy of the animation range
  5933. * @returns A copy of the animation range
  5934. */
  5935. clone(): AnimationRange;
  5936. }
  5937. }
  5938. declare module BABYLON {
  5939. /**
  5940. * Composed of a frame, and an action function
  5941. */
  5942. export class AnimationEvent {
  5943. /** The frame for which the event is triggered **/
  5944. frame: number;
  5945. /** The event to perform when triggered **/
  5946. action: (currentFrame: number) => void;
  5947. /** Specifies if the event should be triggered only once**/
  5948. onlyOnce?: boolean | undefined;
  5949. /**
  5950. * Specifies if the animation event is done
  5951. */
  5952. isDone: boolean;
  5953. /**
  5954. * Initializes the animation event
  5955. * @param frame The frame for which the event is triggered
  5956. * @param action The event to perform when triggered
  5957. * @param onlyOnce Specifies if the event should be triggered only once
  5958. */
  5959. constructor(
  5960. /** The frame for which the event is triggered **/
  5961. frame: number,
  5962. /** The event to perform when triggered **/
  5963. action: (currentFrame: number) => void,
  5964. /** Specifies if the event should be triggered only once**/
  5965. onlyOnce?: boolean | undefined);
  5966. /** @hidden */
  5967. _clone(): AnimationEvent;
  5968. }
  5969. }
  5970. declare module BABYLON {
  5971. /**
  5972. * Interface used to define a behavior
  5973. */
  5974. export interface Behavior<T> {
  5975. /** gets or sets behavior's name */
  5976. name: string;
  5977. /**
  5978. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5979. */
  5980. init(): void;
  5981. /**
  5982. * Called when the behavior is attached to a target
  5983. * @param target defines the target where the behavior is attached to
  5984. */
  5985. attach(target: T): void;
  5986. /**
  5987. * Called when the behavior is detached from its target
  5988. */
  5989. detach(): void;
  5990. }
  5991. /**
  5992. * Interface implemented by classes supporting behaviors
  5993. */
  5994. export interface IBehaviorAware<T> {
  5995. /**
  5996. * Attach a behavior
  5997. * @param behavior defines the behavior to attach
  5998. * @returns the current host
  5999. */
  6000. addBehavior(behavior: Behavior<T>): T;
  6001. /**
  6002. * Remove a behavior from the current object
  6003. * @param behavior defines the behavior to detach
  6004. * @returns the current host
  6005. */
  6006. removeBehavior(behavior: Behavior<T>): T;
  6007. /**
  6008. * Gets a behavior using its name to search
  6009. * @param name defines the name to search
  6010. * @returns the behavior or null if not found
  6011. */
  6012. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6013. }
  6014. }
  6015. declare module BABYLON {
  6016. /**
  6017. * Defines an array and its length.
  6018. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6019. */
  6020. export interface ISmartArrayLike<T> {
  6021. /**
  6022. * The data of the array.
  6023. */
  6024. data: Array<T>;
  6025. /**
  6026. * The active length of the array.
  6027. */
  6028. length: number;
  6029. }
  6030. /**
  6031. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6032. */
  6033. export class SmartArray<T> implements ISmartArrayLike<T> {
  6034. /**
  6035. * The full set of data from the array.
  6036. */
  6037. data: Array<T>;
  6038. /**
  6039. * The active length of the array.
  6040. */
  6041. length: number;
  6042. protected _id: number;
  6043. /**
  6044. * Instantiates a Smart Array.
  6045. * @param capacity defines the default capacity of the array.
  6046. */
  6047. constructor(capacity: number);
  6048. /**
  6049. * Pushes a value at the end of the active data.
  6050. * @param value defines the object to push in the array.
  6051. */
  6052. push(value: T): void;
  6053. /**
  6054. * Iterates over the active data and apply the lambda to them.
  6055. * @param func defines the action to apply on each value.
  6056. */
  6057. forEach(func: (content: T) => void): void;
  6058. /**
  6059. * Sorts the full sets of data.
  6060. * @param compareFn defines the comparison function to apply.
  6061. */
  6062. sort(compareFn: (a: T, b: T) => number): void;
  6063. /**
  6064. * Resets the active data to an empty array.
  6065. */
  6066. reset(): void;
  6067. /**
  6068. * Releases all the data from the array as well as the array.
  6069. */
  6070. dispose(): void;
  6071. /**
  6072. * Concats the active data with a given array.
  6073. * @param array defines the data to concatenate with.
  6074. */
  6075. concat(array: any): void;
  6076. /**
  6077. * Returns the position of a value in the active data.
  6078. * @param value defines the value to find the index for
  6079. * @returns the index if found in the active data otherwise -1
  6080. */
  6081. indexOf(value: T): number;
  6082. /**
  6083. * Returns whether an element is part of the active data.
  6084. * @param value defines the value to look for
  6085. * @returns true if found in the active data otherwise false
  6086. */
  6087. contains(value: T): boolean;
  6088. private static _GlobalId;
  6089. }
  6090. /**
  6091. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6092. * The data in this array can only be present once
  6093. */
  6094. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6095. private _duplicateId;
  6096. /**
  6097. * Pushes a value at the end of the active data.
  6098. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6099. * @param value defines the object to push in the array.
  6100. */
  6101. push(value: T): void;
  6102. /**
  6103. * Pushes a value at the end of the active data.
  6104. * If the data is already present, it won t be added again
  6105. * @param value defines the object to push in the array.
  6106. * @returns true if added false if it was already present
  6107. */
  6108. pushNoDuplicate(value: T): boolean;
  6109. /**
  6110. * Resets the active data to an empty array.
  6111. */
  6112. reset(): void;
  6113. /**
  6114. * Concats the active data with a given array.
  6115. * This ensures no dupplicate will be present in the result.
  6116. * @param array defines the data to concatenate with.
  6117. */
  6118. concatWithNoDuplicate(array: any): void;
  6119. }
  6120. }
  6121. declare module BABYLON {
  6122. /**
  6123. * @ignore
  6124. * This is a list of all the different input types that are available in the application.
  6125. * Fo instance: ArcRotateCameraGamepadInput...
  6126. */
  6127. export var CameraInputTypes: {};
  6128. /**
  6129. * This is the contract to implement in order to create a new input class.
  6130. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6131. */
  6132. export interface ICameraInput<TCamera extends Camera> {
  6133. /**
  6134. * Defines the camera the input is attached to.
  6135. */
  6136. camera: Nullable<TCamera>;
  6137. /**
  6138. * Gets the class name of the current intput.
  6139. * @returns the class name
  6140. */
  6141. getClassName(): string;
  6142. /**
  6143. * Get the friendly name associated with the input class.
  6144. * @returns the input friendly name
  6145. */
  6146. getSimpleName(): string;
  6147. /**
  6148. * Attach the input controls to a specific dom element to get the input from.
  6149. * @param element Defines the element the controls should be listened from
  6150. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6151. */
  6152. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6153. /**
  6154. * Detach the current controls from the specified dom element.
  6155. * @param element Defines the element to stop listening the inputs from
  6156. */
  6157. detachControl(element: Nullable<HTMLElement>): void;
  6158. /**
  6159. * Update the current camera state depending on the inputs that have been used this frame.
  6160. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6161. */
  6162. checkInputs?: () => void;
  6163. }
  6164. /**
  6165. * Represents a map of input types to input instance or input index to input instance.
  6166. */
  6167. export interface CameraInputsMap<TCamera extends Camera> {
  6168. /**
  6169. * Accessor to the input by input type.
  6170. */
  6171. [name: string]: ICameraInput<TCamera>;
  6172. /**
  6173. * Accessor to the input by input index.
  6174. */
  6175. [idx: number]: ICameraInput<TCamera>;
  6176. }
  6177. /**
  6178. * This represents the input manager used within a camera.
  6179. * It helps dealing with all the different kind of input attached to a camera.
  6180. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6181. */
  6182. export class CameraInputsManager<TCamera extends Camera> {
  6183. /**
  6184. * Defines the list of inputs attahed to the camera.
  6185. */
  6186. attached: CameraInputsMap<TCamera>;
  6187. /**
  6188. * Defines the dom element the camera is collecting inputs from.
  6189. * This is null if the controls have not been attached.
  6190. */
  6191. attachedElement: Nullable<HTMLElement>;
  6192. /**
  6193. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6194. */
  6195. noPreventDefault: boolean;
  6196. /**
  6197. * Defined the camera the input manager belongs to.
  6198. */
  6199. camera: TCamera;
  6200. /**
  6201. * Update the current camera state depending on the inputs that have been used this frame.
  6202. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6203. */
  6204. checkInputs: () => void;
  6205. /**
  6206. * Instantiate a new Camera Input Manager.
  6207. * @param camera Defines the camera the input manager blongs to
  6208. */
  6209. constructor(camera: TCamera);
  6210. /**
  6211. * Add an input method to a camera
  6212. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6213. * @param input camera input method
  6214. */
  6215. add(input: ICameraInput<TCamera>): void;
  6216. /**
  6217. * Remove a specific input method from a camera
  6218. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6219. * @param inputToRemove camera input method
  6220. */
  6221. remove(inputToRemove: ICameraInput<TCamera>): void;
  6222. /**
  6223. * Remove a specific input type from a camera
  6224. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6225. * @param inputType the type of the input to remove
  6226. */
  6227. removeByType(inputType: string): void;
  6228. private _addCheckInputs;
  6229. /**
  6230. * Attach the input controls to the currently attached dom element to listen the events from.
  6231. * @param input Defines the input to attach
  6232. */
  6233. attachInput(input: ICameraInput<TCamera>): void;
  6234. /**
  6235. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6236. * @param element Defines the dom element to collect the events from
  6237. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6238. */
  6239. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6240. /**
  6241. * Detach the current manager inputs controls from a specific dom element.
  6242. * @param element Defines the dom element to collect the events from
  6243. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6244. */
  6245. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6246. /**
  6247. * Rebuild the dynamic inputCheck function from the current list of
  6248. * defined inputs in the manager.
  6249. */
  6250. rebuildInputCheck(): void;
  6251. /**
  6252. * Remove all attached input methods from a camera
  6253. */
  6254. clear(): void;
  6255. /**
  6256. * Serialize the current input manager attached to a camera.
  6257. * This ensures than once parsed,
  6258. * the input associated to the camera will be identical to the current ones
  6259. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6260. */
  6261. serialize(serializedCamera: any): void;
  6262. /**
  6263. * Parses an input manager serialized JSON to restore the previous list of inputs
  6264. * and states associated to a camera.
  6265. * @param parsedCamera Defines the JSON to parse
  6266. */
  6267. parse(parsedCamera: any): void;
  6268. }
  6269. }
  6270. declare module BABYLON {
  6271. /**
  6272. * Class used to store data that will be store in GPU memory
  6273. */
  6274. export class Buffer {
  6275. private _engine;
  6276. private _buffer;
  6277. /** @hidden */
  6278. _data: Nullable<DataArray>;
  6279. private _updatable;
  6280. private _instanced;
  6281. private _divisor;
  6282. /**
  6283. * Gets the byte stride.
  6284. */
  6285. readonly byteStride: number;
  6286. /**
  6287. * Constructor
  6288. * @param engine the engine
  6289. * @param data the data to use for this buffer
  6290. * @param updatable whether the data is updatable
  6291. * @param stride the stride (optional)
  6292. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6293. * @param instanced whether the buffer is instanced (optional)
  6294. * @param useBytes set to true if the stride in in bytes (optional)
  6295. * @param divisor sets an optional divisor for instances (1 by default)
  6296. */
  6297. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6298. /**
  6299. * Create a new VertexBuffer based on the current buffer
  6300. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6301. * @param offset defines offset in the buffer (0 by default)
  6302. * @param size defines the size in floats of attributes (position is 3 for instance)
  6303. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6304. * @param instanced defines if the vertex buffer contains indexed data
  6305. * @param useBytes defines if the offset and stride are in bytes *
  6306. * @param divisor sets an optional divisor for instances (1 by default)
  6307. * @returns the new vertex buffer
  6308. */
  6309. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6310. /**
  6311. * Gets a boolean indicating if the Buffer is updatable?
  6312. * @returns true if the buffer is updatable
  6313. */
  6314. isUpdatable(): boolean;
  6315. /**
  6316. * Gets current buffer's data
  6317. * @returns a DataArray or null
  6318. */
  6319. getData(): Nullable<DataArray>;
  6320. /**
  6321. * Gets underlying native buffer
  6322. * @returns underlying native buffer
  6323. */
  6324. getBuffer(): Nullable<DataBuffer>;
  6325. /**
  6326. * Gets the stride in float32 units (i.e. byte stride / 4).
  6327. * May not be an integer if the byte stride is not divisible by 4.
  6328. * @returns the stride in float32 units
  6329. * @deprecated Please use byteStride instead.
  6330. */
  6331. getStrideSize(): number;
  6332. /**
  6333. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6334. * @param data defines the data to store
  6335. */
  6336. create(data?: Nullable<DataArray>): void;
  6337. /** @hidden */
  6338. _rebuild(): void;
  6339. /**
  6340. * Update current buffer data
  6341. * @param data defines the data to store
  6342. */
  6343. update(data: DataArray): void;
  6344. /**
  6345. * Updates the data directly.
  6346. * @param data the new data
  6347. * @param offset the new offset
  6348. * @param vertexCount the vertex count (optional)
  6349. * @param useBytes set to true if the offset is in bytes
  6350. */
  6351. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6352. /**
  6353. * Release all resources
  6354. */
  6355. dispose(): void;
  6356. }
  6357. /**
  6358. * Specialized buffer used to store vertex data
  6359. */
  6360. export class VertexBuffer {
  6361. /** @hidden */
  6362. _buffer: Buffer;
  6363. private _kind;
  6364. private _size;
  6365. private _ownsBuffer;
  6366. private _instanced;
  6367. private _instanceDivisor;
  6368. /**
  6369. * The byte type.
  6370. */
  6371. static readonly BYTE: number;
  6372. /**
  6373. * The unsigned byte type.
  6374. */
  6375. static readonly UNSIGNED_BYTE: number;
  6376. /**
  6377. * The short type.
  6378. */
  6379. static readonly SHORT: number;
  6380. /**
  6381. * The unsigned short type.
  6382. */
  6383. static readonly UNSIGNED_SHORT: number;
  6384. /**
  6385. * The integer type.
  6386. */
  6387. static readonly INT: number;
  6388. /**
  6389. * The unsigned integer type.
  6390. */
  6391. static readonly UNSIGNED_INT: number;
  6392. /**
  6393. * The float type.
  6394. */
  6395. static readonly FLOAT: number;
  6396. /**
  6397. * Gets or sets the instance divisor when in instanced mode
  6398. */
  6399. get instanceDivisor(): number;
  6400. set instanceDivisor(value: number);
  6401. /**
  6402. * Gets the byte stride.
  6403. */
  6404. readonly byteStride: number;
  6405. /**
  6406. * Gets the byte offset.
  6407. */
  6408. readonly byteOffset: number;
  6409. /**
  6410. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6411. */
  6412. readonly normalized: boolean;
  6413. /**
  6414. * Gets the data type of each component in the array.
  6415. */
  6416. readonly type: number;
  6417. /**
  6418. * Constructor
  6419. * @param engine the engine
  6420. * @param data the data to use for this vertex buffer
  6421. * @param kind the vertex buffer kind
  6422. * @param updatable whether the data is updatable
  6423. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6424. * @param stride the stride (optional)
  6425. * @param instanced whether the buffer is instanced (optional)
  6426. * @param offset the offset of the data (optional)
  6427. * @param size the number of components (optional)
  6428. * @param type the type of the component (optional)
  6429. * @param normalized whether the data contains normalized data (optional)
  6430. * @param useBytes set to true if stride and offset are in bytes (optional)
  6431. * @param divisor defines the instance divisor to use (1 by default)
  6432. */
  6433. 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);
  6434. /** @hidden */
  6435. _rebuild(): void;
  6436. /**
  6437. * Returns the kind of the VertexBuffer (string)
  6438. * @returns a string
  6439. */
  6440. getKind(): string;
  6441. /**
  6442. * Gets a boolean indicating if the VertexBuffer is updatable?
  6443. * @returns true if the buffer is updatable
  6444. */
  6445. isUpdatable(): boolean;
  6446. /**
  6447. * Gets current buffer's data
  6448. * @returns a DataArray or null
  6449. */
  6450. getData(): Nullable<DataArray>;
  6451. /**
  6452. * Gets underlying native buffer
  6453. * @returns underlying native buffer
  6454. */
  6455. getBuffer(): Nullable<DataBuffer>;
  6456. /**
  6457. * Gets the stride in float32 units (i.e. byte stride / 4).
  6458. * May not be an integer if the byte stride is not divisible by 4.
  6459. * @returns the stride in float32 units
  6460. * @deprecated Please use byteStride instead.
  6461. */
  6462. getStrideSize(): number;
  6463. /**
  6464. * Returns the offset as a multiple of the type byte length.
  6465. * @returns the offset in bytes
  6466. * @deprecated Please use byteOffset instead.
  6467. */
  6468. getOffset(): number;
  6469. /**
  6470. * Returns the number of components per vertex attribute (integer)
  6471. * @returns the size in float
  6472. */
  6473. getSize(): number;
  6474. /**
  6475. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6476. * @returns true if this buffer is instanced
  6477. */
  6478. getIsInstanced(): boolean;
  6479. /**
  6480. * Returns the instancing divisor, zero for non-instanced (integer).
  6481. * @returns a number
  6482. */
  6483. getInstanceDivisor(): number;
  6484. /**
  6485. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6486. * @param data defines the data to store
  6487. */
  6488. create(data?: DataArray): void;
  6489. /**
  6490. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6491. * This function will create a new buffer if the current one is not updatable
  6492. * @param data defines the data to store
  6493. */
  6494. update(data: DataArray): void;
  6495. /**
  6496. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6497. * Returns the directly updated WebGLBuffer.
  6498. * @param data the new data
  6499. * @param offset the new offset
  6500. * @param useBytes set to true if the offset is in bytes
  6501. */
  6502. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6503. /**
  6504. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6505. */
  6506. dispose(): void;
  6507. /**
  6508. * Enumerates each value of this vertex buffer as numbers.
  6509. * @param count the number of values to enumerate
  6510. * @param callback the callback function called for each value
  6511. */
  6512. forEach(count: number, callback: (value: number, index: number) => void): void;
  6513. /**
  6514. * Positions
  6515. */
  6516. static readonly PositionKind: string;
  6517. /**
  6518. * Normals
  6519. */
  6520. static readonly NormalKind: string;
  6521. /**
  6522. * Tangents
  6523. */
  6524. static readonly TangentKind: string;
  6525. /**
  6526. * Texture coordinates
  6527. */
  6528. static readonly UVKind: string;
  6529. /**
  6530. * Texture coordinates 2
  6531. */
  6532. static readonly UV2Kind: string;
  6533. /**
  6534. * Texture coordinates 3
  6535. */
  6536. static readonly UV3Kind: string;
  6537. /**
  6538. * Texture coordinates 4
  6539. */
  6540. static readonly UV4Kind: string;
  6541. /**
  6542. * Texture coordinates 5
  6543. */
  6544. static readonly UV5Kind: string;
  6545. /**
  6546. * Texture coordinates 6
  6547. */
  6548. static readonly UV6Kind: string;
  6549. /**
  6550. * Colors
  6551. */
  6552. static readonly ColorKind: string;
  6553. /**
  6554. * Matrix indices (for bones)
  6555. */
  6556. static readonly MatricesIndicesKind: string;
  6557. /**
  6558. * Matrix weights (for bones)
  6559. */
  6560. static readonly MatricesWeightsKind: string;
  6561. /**
  6562. * Additional matrix indices (for bones)
  6563. */
  6564. static readonly MatricesIndicesExtraKind: string;
  6565. /**
  6566. * Additional matrix weights (for bones)
  6567. */
  6568. static readonly MatricesWeightsExtraKind: string;
  6569. /**
  6570. * Deduces the stride given a kind.
  6571. * @param kind The kind string to deduce
  6572. * @returns The deduced stride
  6573. */
  6574. static DeduceStride(kind: string): number;
  6575. /**
  6576. * Gets the byte length of the given type.
  6577. * @param type the type
  6578. * @returns the number of bytes
  6579. */
  6580. static GetTypeByteLength(type: number): number;
  6581. /**
  6582. * Enumerates each value of the given parameters as numbers.
  6583. * @param data the data to enumerate
  6584. * @param byteOffset the byte offset of the data
  6585. * @param byteStride the byte stride of the data
  6586. * @param componentCount the number of components per element
  6587. * @param componentType the type of the component
  6588. * @param count the number of values to enumerate
  6589. * @param normalized whether the data is normalized
  6590. * @param callback the callback function called for each value
  6591. */
  6592. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6593. private static _GetFloatValue;
  6594. }
  6595. }
  6596. declare module BABYLON {
  6597. /**
  6598. * @hidden
  6599. */
  6600. export class IntersectionInfo {
  6601. bu: Nullable<number>;
  6602. bv: Nullable<number>;
  6603. distance: number;
  6604. faceId: number;
  6605. subMeshId: number;
  6606. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6607. }
  6608. }
  6609. declare module BABYLON {
  6610. /**
  6611. * Represens a plane by the equation ax + by + cz + d = 0
  6612. */
  6613. export class Plane {
  6614. private static _TmpMatrix;
  6615. /**
  6616. * Normal of the plane (a,b,c)
  6617. */
  6618. normal: Vector3;
  6619. /**
  6620. * d component of the plane
  6621. */
  6622. d: number;
  6623. /**
  6624. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6625. * @param a a component of the plane
  6626. * @param b b component of the plane
  6627. * @param c c component of the plane
  6628. * @param d d component of the plane
  6629. */
  6630. constructor(a: number, b: number, c: number, d: number);
  6631. /**
  6632. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6633. */
  6634. asArray(): number[];
  6635. /**
  6636. * @returns a new plane copied from the current Plane.
  6637. */
  6638. clone(): Plane;
  6639. /**
  6640. * @returns the string "Plane".
  6641. */
  6642. getClassName(): string;
  6643. /**
  6644. * @returns the Plane hash code.
  6645. */
  6646. getHashCode(): number;
  6647. /**
  6648. * Normalize the current Plane in place.
  6649. * @returns the updated Plane.
  6650. */
  6651. normalize(): Plane;
  6652. /**
  6653. * Applies a transformation the plane and returns the result
  6654. * @param transformation the transformation matrix to be applied to the plane
  6655. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6656. */
  6657. transform(transformation: DeepImmutable<Matrix>): Plane;
  6658. /**
  6659. * Calcualtte the dot product between the point and the plane normal
  6660. * @param point point to calculate the dot product with
  6661. * @returns the dot product (float) of the point coordinates and the plane normal.
  6662. */
  6663. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6664. /**
  6665. * Updates the current Plane from the plane defined by the three given points.
  6666. * @param point1 one of the points used to contruct the plane
  6667. * @param point2 one of the points used to contruct the plane
  6668. * @param point3 one of the points used to contruct the plane
  6669. * @returns the updated Plane.
  6670. */
  6671. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6672. /**
  6673. * Checks if the plane is facing a given direction
  6674. * @param direction the direction to check if the plane is facing
  6675. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6676. * @returns True is the vector "direction" is the same side than the plane normal.
  6677. */
  6678. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6679. /**
  6680. * Calculates the distance to a point
  6681. * @param point point to calculate distance to
  6682. * @returns the signed distance (float) from the given point to the Plane.
  6683. */
  6684. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6685. /**
  6686. * Creates a plane from an array
  6687. * @param array the array to create a plane from
  6688. * @returns a new Plane from the given array.
  6689. */
  6690. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6691. /**
  6692. * Creates a plane from three points
  6693. * @param point1 point used to create the plane
  6694. * @param point2 point used to create the plane
  6695. * @param point3 point used to create the plane
  6696. * @returns a new Plane defined by the three given points.
  6697. */
  6698. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6699. /**
  6700. * Creates a plane from an origin point and a normal
  6701. * @param origin origin of the plane to be constructed
  6702. * @param normal normal of the plane to be constructed
  6703. * @returns a new Plane the normal vector to this plane at the given origin point.
  6704. * Note : the vector "normal" is updated because normalized.
  6705. */
  6706. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6707. /**
  6708. * Calculates the distance from a plane and a point
  6709. * @param origin origin of the plane to be constructed
  6710. * @param normal normal of the plane to be constructed
  6711. * @param point point to calculate distance to
  6712. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6713. */
  6714. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6715. }
  6716. }
  6717. declare module BABYLON {
  6718. /**
  6719. * Class used to store bounding sphere information
  6720. */
  6721. export class BoundingSphere {
  6722. /**
  6723. * Gets the center of the bounding sphere in local space
  6724. */
  6725. readonly center: Vector3;
  6726. /**
  6727. * Radius of the bounding sphere in local space
  6728. */
  6729. radius: number;
  6730. /**
  6731. * Gets the center of the bounding sphere in world space
  6732. */
  6733. readonly centerWorld: Vector3;
  6734. /**
  6735. * Radius of the bounding sphere in world space
  6736. */
  6737. radiusWorld: number;
  6738. /**
  6739. * Gets the minimum vector in local space
  6740. */
  6741. readonly minimum: Vector3;
  6742. /**
  6743. * Gets the maximum vector in local space
  6744. */
  6745. readonly maximum: Vector3;
  6746. private _worldMatrix;
  6747. private static readonly TmpVector3;
  6748. /**
  6749. * Creates a new bounding sphere
  6750. * @param min defines the minimum vector (in local space)
  6751. * @param max defines the maximum vector (in local space)
  6752. * @param worldMatrix defines the new world matrix
  6753. */
  6754. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6755. /**
  6756. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6757. * @param min defines the new minimum vector (in local space)
  6758. * @param max defines the new maximum vector (in local space)
  6759. * @param worldMatrix defines the new world matrix
  6760. */
  6761. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6762. /**
  6763. * Scale the current bounding sphere by applying a scale factor
  6764. * @param factor defines the scale factor to apply
  6765. * @returns the current bounding box
  6766. */
  6767. scale(factor: number): BoundingSphere;
  6768. /**
  6769. * Gets the world matrix of the bounding box
  6770. * @returns a matrix
  6771. */
  6772. getWorldMatrix(): DeepImmutable<Matrix>;
  6773. /** @hidden */
  6774. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6775. /**
  6776. * Tests if the bounding sphere is intersecting the frustum planes
  6777. * @param frustumPlanes defines the frustum planes to test
  6778. * @returns true if there is an intersection
  6779. */
  6780. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6781. /**
  6782. * Tests if the bounding sphere center is in between the frustum planes.
  6783. * Used for optimistic fast inclusion.
  6784. * @param frustumPlanes defines the frustum planes to test
  6785. * @returns true if the sphere center is in between the frustum planes
  6786. */
  6787. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6788. /**
  6789. * Tests if a point is inside the bounding sphere
  6790. * @param point defines the point to test
  6791. * @returns true if the point is inside the bounding sphere
  6792. */
  6793. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6794. /**
  6795. * Checks if two sphere intersct
  6796. * @param sphere0 sphere 0
  6797. * @param sphere1 sphere 1
  6798. * @returns true if the speres intersect
  6799. */
  6800. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6801. }
  6802. }
  6803. declare module BABYLON {
  6804. /**
  6805. * Class used to store bounding box information
  6806. */
  6807. export class BoundingBox implements ICullable {
  6808. /**
  6809. * Gets the 8 vectors representing the bounding box in local space
  6810. */
  6811. readonly vectors: Vector3[];
  6812. /**
  6813. * Gets the center of the bounding box in local space
  6814. */
  6815. readonly center: Vector3;
  6816. /**
  6817. * Gets the center of the bounding box in world space
  6818. */
  6819. readonly centerWorld: Vector3;
  6820. /**
  6821. * Gets the extend size in local space
  6822. */
  6823. readonly extendSize: Vector3;
  6824. /**
  6825. * Gets the extend size in world space
  6826. */
  6827. readonly extendSizeWorld: Vector3;
  6828. /**
  6829. * Gets the OBB (object bounding box) directions
  6830. */
  6831. readonly directions: Vector3[];
  6832. /**
  6833. * Gets the 8 vectors representing the bounding box in world space
  6834. */
  6835. readonly vectorsWorld: Vector3[];
  6836. /**
  6837. * Gets the minimum vector in world space
  6838. */
  6839. readonly minimumWorld: Vector3;
  6840. /**
  6841. * Gets the maximum vector in world space
  6842. */
  6843. readonly maximumWorld: Vector3;
  6844. /**
  6845. * Gets the minimum vector in local space
  6846. */
  6847. readonly minimum: Vector3;
  6848. /**
  6849. * Gets the maximum vector in local space
  6850. */
  6851. readonly maximum: Vector3;
  6852. private _worldMatrix;
  6853. private static readonly TmpVector3;
  6854. /**
  6855. * @hidden
  6856. */
  6857. _tag: number;
  6858. /**
  6859. * Creates a new bounding box
  6860. * @param min defines the minimum vector (in local space)
  6861. * @param max defines the maximum vector (in local space)
  6862. * @param worldMatrix defines the new world matrix
  6863. */
  6864. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6865. /**
  6866. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6867. * @param min defines the new minimum vector (in local space)
  6868. * @param max defines the new maximum vector (in local space)
  6869. * @param worldMatrix defines the new world matrix
  6870. */
  6871. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6872. /**
  6873. * Scale the current bounding box by applying a scale factor
  6874. * @param factor defines the scale factor to apply
  6875. * @returns the current bounding box
  6876. */
  6877. scale(factor: number): BoundingBox;
  6878. /**
  6879. * Gets the world matrix of the bounding box
  6880. * @returns a matrix
  6881. */
  6882. getWorldMatrix(): DeepImmutable<Matrix>;
  6883. /** @hidden */
  6884. _update(world: DeepImmutable<Matrix>): void;
  6885. /**
  6886. * Tests if the bounding box is intersecting the frustum planes
  6887. * @param frustumPlanes defines the frustum planes to test
  6888. * @returns true if there is an intersection
  6889. */
  6890. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6891. /**
  6892. * Tests if the bounding box is entirely inside the frustum planes
  6893. * @param frustumPlanes defines the frustum planes to test
  6894. * @returns true if there is an inclusion
  6895. */
  6896. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6897. /**
  6898. * Tests if a point is inside the bounding box
  6899. * @param point defines the point to test
  6900. * @returns true if the point is inside the bounding box
  6901. */
  6902. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6903. /**
  6904. * Tests if the bounding box intersects with a bounding sphere
  6905. * @param sphere defines the sphere to test
  6906. * @returns true if there is an intersection
  6907. */
  6908. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6909. /**
  6910. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6911. * @param min defines the min vector to use
  6912. * @param max defines the max vector to use
  6913. * @returns true if there is an intersection
  6914. */
  6915. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6916. /**
  6917. * Tests if two bounding boxes are intersections
  6918. * @param box0 defines the first box to test
  6919. * @param box1 defines the second box to test
  6920. * @returns true if there is an intersection
  6921. */
  6922. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6923. /**
  6924. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6925. * @param minPoint defines the minimum vector of the bounding box
  6926. * @param maxPoint defines the maximum vector of the bounding box
  6927. * @param sphereCenter defines the sphere center
  6928. * @param sphereRadius defines the sphere radius
  6929. * @returns true if there is an intersection
  6930. */
  6931. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6932. /**
  6933. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6934. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6935. * @param frustumPlanes defines the frustum planes to test
  6936. * @return true if there is an inclusion
  6937. */
  6938. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6939. /**
  6940. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6941. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6942. * @param frustumPlanes defines the frustum planes to test
  6943. * @return true if there is an intersection
  6944. */
  6945. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6946. }
  6947. }
  6948. declare module BABYLON {
  6949. /** @hidden */
  6950. export class Collider {
  6951. /** Define if a collision was found */
  6952. collisionFound: boolean;
  6953. /**
  6954. * Define last intersection point in local space
  6955. */
  6956. intersectionPoint: Vector3;
  6957. /**
  6958. * Define last collided mesh
  6959. */
  6960. collidedMesh: Nullable<AbstractMesh>;
  6961. private _collisionPoint;
  6962. private _planeIntersectionPoint;
  6963. private _tempVector;
  6964. private _tempVector2;
  6965. private _tempVector3;
  6966. private _tempVector4;
  6967. private _edge;
  6968. private _baseToVertex;
  6969. private _destinationPoint;
  6970. private _slidePlaneNormal;
  6971. private _displacementVector;
  6972. /** @hidden */
  6973. _radius: Vector3;
  6974. /** @hidden */
  6975. _retry: number;
  6976. private _velocity;
  6977. private _basePoint;
  6978. private _epsilon;
  6979. /** @hidden */
  6980. _velocityWorldLength: number;
  6981. /** @hidden */
  6982. _basePointWorld: Vector3;
  6983. private _velocityWorld;
  6984. private _normalizedVelocity;
  6985. /** @hidden */
  6986. _initialVelocity: Vector3;
  6987. /** @hidden */
  6988. _initialPosition: Vector3;
  6989. private _nearestDistance;
  6990. private _collisionMask;
  6991. get collisionMask(): number;
  6992. set collisionMask(mask: number);
  6993. /**
  6994. * Gets the plane normal used to compute the sliding response (in local space)
  6995. */
  6996. get slidePlaneNormal(): Vector3;
  6997. /** @hidden */
  6998. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6999. /** @hidden */
  7000. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7001. /** @hidden */
  7002. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7003. /** @hidden */
  7004. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7005. /** @hidden */
  7006. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7007. /** @hidden */
  7008. _getResponse(pos: Vector3, vel: Vector3): void;
  7009. }
  7010. }
  7011. declare module BABYLON {
  7012. /**
  7013. * Interface for cullable objects
  7014. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7015. */
  7016. export interface ICullable {
  7017. /**
  7018. * Checks if the object or part of the object is in the frustum
  7019. * @param frustumPlanes Camera near/planes
  7020. * @returns true if the object is in frustum otherwise false
  7021. */
  7022. isInFrustum(frustumPlanes: Plane[]): boolean;
  7023. /**
  7024. * Checks if a cullable object (mesh...) is in the camera frustum
  7025. * Unlike isInFrustum this cheks the full bounding box
  7026. * @param frustumPlanes Camera near/planes
  7027. * @returns true if the object is in frustum otherwise false
  7028. */
  7029. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7030. }
  7031. /**
  7032. * Info for a bounding data of a mesh
  7033. */
  7034. export class BoundingInfo implements ICullable {
  7035. /**
  7036. * Bounding box for the mesh
  7037. */
  7038. readonly boundingBox: BoundingBox;
  7039. /**
  7040. * Bounding sphere for the mesh
  7041. */
  7042. readonly boundingSphere: BoundingSphere;
  7043. private _isLocked;
  7044. private static readonly TmpVector3;
  7045. /**
  7046. * Constructs bounding info
  7047. * @param minimum min vector of the bounding box/sphere
  7048. * @param maximum max vector of the bounding box/sphere
  7049. * @param worldMatrix defines the new world matrix
  7050. */
  7051. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7052. /**
  7053. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7054. * @param min defines the new minimum vector (in local space)
  7055. * @param max defines the new maximum vector (in local space)
  7056. * @param worldMatrix defines the new world matrix
  7057. */
  7058. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7059. /**
  7060. * min vector of the bounding box/sphere
  7061. */
  7062. get minimum(): Vector3;
  7063. /**
  7064. * max vector of the bounding box/sphere
  7065. */
  7066. get maximum(): Vector3;
  7067. /**
  7068. * If the info is locked and won't be updated to avoid perf overhead
  7069. */
  7070. get isLocked(): boolean;
  7071. set isLocked(value: boolean);
  7072. /**
  7073. * Updates the bounding sphere and box
  7074. * @param world world matrix to be used to update
  7075. */
  7076. update(world: DeepImmutable<Matrix>): void;
  7077. /**
  7078. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7079. * @param center New center of the bounding info
  7080. * @param extend New extend of the bounding info
  7081. * @returns the current bounding info
  7082. */
  7083. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7084. /**
  7085. * Scale the current bounding info by applying a scale factor
  7086. * @param factor defines the scale factor to apply
  7087. * @returns the current bounding info
  7088. */
  7089. scale(factor: number): BoundingInfo;
  7090. /**
  7091. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7092. * @param frustumPlanes defines the frustum to test
  7093. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7094. * @returns true if the bounding info is in the frustum planes
  7095. */
  7096. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7097. /**
  7098. * Gets the world distance between the min and max points of the bounding box
  7099. */
  7100. get diagonalLength(): number;
  7101. /**
  7102. * Checks if a cullable object (mesh...) is in the camera frustum
  7103. * Unlike isInFrustum this cheks the full bounding box
  7104. * @param frustumPlanes Camera near/planes
  7105. * @returns true if the object is in frustum otherwise false
  7106. */
  7107. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7108. /** @hidden */
  7109. _checkCollision(collider: Collider): boolean;
  7110. /**
  7111. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7112. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7113. * @param point the point to check intersection with
  7114. * @returns if the point intersects
  7115. */
  7116. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7117. /**
  7118. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7119. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7120. * @param boundingInfo the bounding info to check intersection with
  7121. * @param precise if the intersection should be done using OBB
  7122. * @returns if the bounding info intersects
  7123. */
  7124. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7125. }
  7126. }
  7127. declare module BABYLON {
  7128. /**
  7129. * Extracts minimum and maximum values from a list of indexed positions
  7130. * @param positions defines the positions to use
  7131. * @param indices defines the indices to the positions
  7132. * @param indexStart defines the start index
  7133. * @param indexCount defines the end index
  7134. * @param bias defines bias value to add to the result
  7135. * @return minimum and maximum values
  7136. */
  7137. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7138. minimum: Vector3;
  7139. maximum: Vector3;
  7140. };
  7141. /**
  7142. * Extracts minimum and maximum values from a list of positions
  7143. * @param positions defines the positions to use
  7144. * @param start defines the start index in the positions array
  7145. * @param count defines the number of positions to handle
  7146. * @param bias defines bias value to add to the result
  7147. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7148. * @return minimum and maximum values
  7149. */
  7150. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7151. minimum: Vector3;
  7152. maximum: Vector3;
  7153. };
  7154. }
  7155. declare module BABYLON {
  7156. /** @hidden */
  7157. export class WebGLDataBuffer extends DataBuffer {
  7158. private _buffer;
  7159. constructor(resource: WebGLBuffer);
  7160. get underlyingResource(): any;
  7161. }
  7162. }
  7163. declare module BABYLON {
  7164. /** @hidden */
  7165. export class WebGLPipelineContext implements IPipelineContext {
  7166. engine: ThinEngine;
  7167. program: Nullable<WebGLProgram>;
  7168. context?: WebGLRenderingContext;
  7169. vertexShader?: WebGLShader;
  7170. fragmentShader?: WebGLShader;
  7171. isParallelCompiled: boolean;
  7172. onCompiled?: () => void;
  7173. transformFeedback?: WebGLTransformFeedback | null;
  7174. vertexCompilationError: Nullable<string>;
  7175. fragmentCompilationError: Nullable<string>;
  7176. programLinkError: Nullable<string>;
  7177. programValidationError: Nullable<string>;
  7178. get isAsync(): boolean;
  7179. get isReady(): boolean;
  7180. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7181. _getVertexShaderCode(): string | null;
  7182. _getFragmentShaderCode(): string | null;
  7183. }
  7184. }
  7185. declare module BABYLON {
  7186. interface ThinEngine {
  7187. /**
  7188. * Create an uniform buffer
  7189. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7190. * @param elements defines the content of the uniform buffer
  7191. * @returns the webGL uniform buffer
  7192. */
  7193. createUniformBuffer(elements: FloatArray): DataBuffer;
  7194. /**
  7195. * Create a dynamic uniform buffer
  7196. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7197. * @param elements defines the content of the uniform buffer
  7198. * @returns the webGL uniform buffer
  7199. */
  7200. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7201. /**
  7202. * Update an existing uniform buffer
  7203. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7204. * @param uniformBuffer defines the target uniform buffer
  7205. * @param elements defines the content to update
  7206. * @param offset defines the offset in the uniform buffer where update should start
  7207. * @param count defines the size of the data to update
  7208. */
  7209. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7210. /**
  7211. * Bind an uniform buffer to the current webGL context
  7212. * @param buffer defines the buffer to bind
  7213. */
  7214. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7215. /**
  7216. * Bind a buffer to the current webGL context at a given location
  7217. * @param buffer defines the buffer to bind
  7218. * @param location defines the index where to bind the buffer
  7219. */
  7220. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7221. /**
  7222. * Bind a specific block at a given index in a specific shader program
  7223. * @param pipelineContext defines the pipeline context to use
  7224. * @param blockName defines the block name
  7225. * @param index defines the index where to bind the block
  7226. */
  7227. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7228. }
  7229. }
  7230. declare module BABYLON {
  7231. /**
  7232. * Uniform buffer objects.
  7233. *
  7234. * Handles blocks of uniform on the GPU.
  7235. *
  7236. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7237. *
  7238. * For more information, please refer to :
  7239. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7240. */
  7241. export class UniformBuffer {
  7242. private _engine;
  7243. private _buffer;
  7244. private _data;
  7245. private _bufferData;
  7246. private _dynamic?;
  7247. private _uniformLocations;
  7248. private _uniformSizes;
  7249. private _uniformLocationPointer;
  7250. private _needSync;
  7251. private _noUBO;
  7252. private _currentEffect;
  7253. /** @hidden */
  7254. _alreadyBound: boolean;
  7255. private static _MAX_UNIFORM_SIZE;
  7256. private static _tempBuffer;
  7257. /**
  7258. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7259. * This is dynamic to allow compat with webgl 1 and 2.
  7260. * You will need to pass the name of the uniform as well as the value.
  7261. */
  7262. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7263. /**
  7264. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7265. * This is dynamic to allow compat with webgl 1 and 2.
  7266. * You will need to pass the name of the uniform as well as the value.
  7267. */
  7268. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7269. /**
  7270. * Lambda to Update a single float in a uniform buffer.
  7271. * This is dynamic to allow compat with webgl 1 and 2.
  7272. * You will need to pass the name of the uniform as well as the value.
  7273. */
  7274. updateFloat: (name: string, x: number) => void;
  7275. /**
  7276. * Lambda to Update a vec2 of float in a uniform buffer.
  7277. * This is dynamic to allow compat with webgl 1 and 2.
  7278. * You will need to pass the name of the uniform as well as the value.
  7279. */
  7280. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7281. /**
  7282. * Lambda to Update a vec3 of float in a uniform buffer.
  7283. * This is dynamic to allow compat with webgl 1 and 2.
  7284. * You will need to pass the name of the uniform as well as the value.
  7285. */
  7286. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7287. /**
  7288. * Lambda to Update a vec4 of float in a uniform buffer.
  7289. * This is dynamic to allow compat with webgl 1 and 2.
  7290. * You will need to pass the name of the uniform as well as the value.
  7291. */
  7292. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7293. /**
  7294. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7295. * This is dynamic to allow compat with webgl 1 and 2.
  7296. * You will need to pass the name of the uniform as well as the value.
  7297. */
  7298. updateMatrix: (name: string, mat: Matrix) => void;
  7299. /**
  7300. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7301. * This is dynamic to allow compat with webgl 1 and 2.
  7302. * You will need to pass the name of the uniform as well as the value.
  7303. */
  7304. updateVector3: (name: string, vector: Vector3) => void;
  7305. /**
  7306. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7307. * This is dynamic to allow compat with webgl 1 and 2.
  7308. * You will need to pass the name of the uniform as well as the value.
  7309. */
  7310. updateVector4: (name: string, vector: Vector4) => void;
  7311. /**
  7312. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7313. * This is dynamic to allow compat with webgl 1 and 2.
  7314. * You will need to pass the name of the uniform as well as the value.
  7315. */
  7316. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7317. /**
  7318. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7319. * This is dynamic to allow compat with webgl 1 and 2.
  7320. * You will need to pass the name of the uniform as well as the value.
  7321. */
  7322. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7323. /**
  7324. * Instantiates a new Uniform buffer objects.
  7325. *
  7326. * Handles blocks of uniform on the GPU.
  7327. *
  7328. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7329. *
  7330. * For more information, please refer to :
  7331. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7332. * @param engine Define the engine the buffer is associated with
  7333. * @param data Define the data contained in the buffer
  7334. * @param dynamic Define if the buffer is updatable
  7335. */
  7336. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7337. /**
  7338. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7339. * or just falling back on setUniformXXX calls.
  7340. */
  7341. get useUbo(): boolean;
  7342. /**
  7343. * Indicates if the WebGL underlying uniform buffer is in sync
  7344. * with the javascript cache data.
  7345. */
  7346. get isSync(): boolean;
  7347. /**
  7348. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7349. * Also, a dynamic UniformBuffer will disable cache verification and always
  7350. * update the underlying WebGL uniform buffer to the GPU.
  7351. * @returns if Dynamic, otherwise false
  7352. */
  7353. isDynamic(): boolean;
  7354. /**
  7355. * The data cache on JS side.
  7356. * @returns the underlying data as a float array
  7357. */
  7358. getData(): Float32Array;
  7359. /**
  7360. * The underlying WebGL Uniform buffer.
  7361. * @returns the webgl buffer
  7362. */
  7363. getBuffer(): Nullable<DataBuffer>;
  7364. /**
  7365. * std140 layout specifies how to align data within an UBO structure.
  7366. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7367. * for specs.
  7368. */
  7369. private _fillAlignment;
  7370. /**
  7371. * Adds an uniform in the buffer.
  7372. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7373. * for the layout to be correct !
  7374. * @param name Name of the uniform, as used in the uniform block in the shader.
  7375. * @param size Data size, or data directly.
  7376. */
  7377. addUniform(name: string, size: number | number[]): void;
  7378. /**
  7379. * Adds a Matrix 4x4 to the uniform buffer.
  7380. * @param name Name of the uniform, as used in the uniform block in the shader.
  7381. * @param mat A 4x4 matrix.
  7382. */
  7383. addMatrix(name: string, mat: Matrix): void;
  7384. /**
  7385. * Adds a vec2 to the uniform buffer.
  7386. * @param name Name of the uniform, as used in the uniform block in the shader.
  7387. * @param x Define the x component value of the vec2
  7388. * @param y Define the y component value of the vec2
  7389. */
  7390. addFloat2(name: string, x: number, y: number): void;
  7391. /**
  7392. * Adds a vec3 to the uniform buffer.
  7393. * @param name Name of the uniform, as used in the uniform block in the shader.
  7394. * @param x Define the x component value of the vec3
  7395. * @param y Define the y component value of the vec3
  7396. * @param z Define the z component value of the vec3
  7397. */
  7398. addFloat3(name: string, x: number, y: number, z: number): void;
  7399. /**
  7400. * Adds a vec3 to the uniform buffer.
  7401. * @param name Name of the uniform, as used in the uniform block in the shader.
  7402. * @param color Define the vec3 from a Color
  7403. */
  7404. addColor3(name: string, color: Color3): void;
  7405. /**
  7406. * Adds a vec4 to the uniform buffer.
  7407. * @param name Name of the uniform, as used in the uniform block in the shader.
  7408. * @param color Define the rgb components from a Color
  7409. * @param alpha Define the a component of the vec4
  7410. */
  7411. addColor4(name: string, color: Color3, alpha: number): void;
  7412. /**
  7413. * Adds a vec3 to the uniform buffer.
  7414. * @param name Name of the uniform, as used in the uniform block in the shader.
  7415. * @param vector Define the vec3 components from a Vector
  7416. */
  7417. addVector3(name: string, vector: Vector3): void;
  7418. /**
  7419. * Adds a Matrix 3x3 to the uniform buffer.
  7420. * @param name Name of the uniform, as used in the uniform block in the shader.
  7421. */
  7422. addMatrix3x3(name: string): void;
  7423. /**
  7424. * Adds a Matrix 2x2 to the uniform buffer.
  7425. * @param name Name of the uniform, as used in the uniform block in the shader.
  7426. */
  7427. addMatrix2x2(name: string): void;
  7428. /**
  7429. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7430. */
  7431. create(): void;
  7432. /** @hidden */
  7433. _rebuild(): void;
  7434. /**
  7435. * Updates the WebGL Uniform Buffer on the GPU.
  7436. * If the `dynamic` flag is set to true, no cache comparison is done.
  7437. * Otherwise, the buffer will be updated only if the cache differs.
  7438. */
  7439. update(): void;
  7440. /**
  7441. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7442. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7443. * @param data Define the flattened data
  7444. * @param size Define the size of the data.
  7445. */
  7446. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7447. private _valueCache;
  7448. private _cacheMatrix;
  7449. private _updateMatrix3x3ForUniform;
  7450. private _updateMatrix3x3ForEffect;
  7451. private _updateMatrix2x2ForEffect;
  7452. private _updateMatrix2x2ForUniform;
  7453. private _updateFloatForEffect;
  7454. private _updateFloatForUniform;
  7455. private _updateFloat2ForEffect;
  7456. private _updateFloat2ForUniform;
  7457. private _updateFloat3ForEffect;
  7458. private _updateFloat3ForUniform;
  7459. private _updateFloat4ForEffect;
  7460. private _updateFloat4ForUniform;
  7461. private _updateMatrixForEffect;
  7462. private _updateMatrixForUniform;
  7463. private _updateVector3ForEffect;
  7464. private _updateVector3ForUniform;
  7465. private _updateVector4ForEffect;
  7466. private _updateVector4ForUniform;
  7467. private _updateColor3ForEffect;
  7468. private _updateColor3ForUniform;
  7469. private _updateColor4ForEffect;
  7470. private _updateColor4ForUniform;
  7471. /**
  7472. * Sets a sampler uniform on the effect.
  7473. * @param name Define the name of the sampler.
  7474. * @param texture Define the texture to set in the sampler
  7475. */
  7476. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7477. /**
  7478. * Directly updates the value of the uniform in the cache AND on the GPU.
  7479. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7480. * @param data Define the flattened data
  7481. */
  7482. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7483. /**
  7484. * Binds this uniform buffer to an effect.
  7485. * @param effect Define the effect to bind the buffer to
  7486. * @param name Name of the uniform block in the shader.
  7487. */
  7488. bindToEffect(effect: Effect, name: string): void;
  7489. /**
  7490. * Disposes the uniform buffer.
  7491. */
  7492. dispose(): void;
  7493. }
  7494. }
  7495. declare module BABYLON {
  7496. /**
  7497. * Enum that determines the text-wrapping mode to use.
  7498. */
  7499. export enum InspectableType {
  7500. /**
  7501. * Checkbox for booleans
  7502. */
  7503. Checkbox = 0,
  7504. /**
  7505. * Sliders for numbers
  7506. */
  7507. Slider = 1,
  7508. /**
  7509. * Vector3
  7510. */
  7511. Vector3 = 2,
  7512. /**
  7513. * Quaternions
  7514. */
  7515. Quaternion = 3,
  7516. /**
  7517. * Color3
  7518. */
  7519. Color3 = 4,
  7520. /**
  7521. * String
  7522. */
  7523. String = 5
  7524. }
  7525. /**
  7526. * Interface used to define custom inspectable properties.
  7527. * This interface is used by the inspector to display custom property grids
  7528. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7529. */
  7530. export interface IInspectable {
  7531. /**
  7532. * Gets the label to display
  7533. */
  7534. label: string;
  7535. /**
  7536. * Gets the name of the property to edit
  7537. */
  7538. propertyName: string;
  7539. /**
  7540. * Gets the type of the editor to use
  7541. */
  7542. type: InspectableType;
  7543. /**
  7544. * Gets the minimum value of the property when using in "slider" mode
  7545. */
  7546. min?: number;
  7547. /**
  7548. * Gets the maximum value of the property when using in "slider" mode
  7549. */
  7550. max?: number;
  7551. /**
  7552. * Gets the setp to use when using in "slider" mode
  7553. */
  7554. step?: number;
  7555. }
  7556. }
  7557. declare module BABYLON {
  7558. /**
  7559. * Class used to provide helper for timing
  7560. */
  7561. export class TimingTools {
  7562. /**
  7563. * Polyfill for setImmediate
  7564. * @param action defines the action to execute after the current execution block
  7565. */
  7566. static SetImmediate(action: () => void): void;
  7567. }
  7568. }
  7569. declare module BABYLON {
  7570. /**
  7571. * Class used to enable instatition of objects by class name
  7572. */
  7573. export class InstantiationTools {
  7574. /**
  7575. * Use this object to register external classes like custom textures or material
  7576. * to allow the laoders to instantiate them
  7577. */
  7578. static RegisteredExternalClasses: {
  7579. [key: string]: Object;
  7580. };
  7581. /**
  7582. * Tries to instantiate a new object from a given class name
  7583. * @param className defines the class name to instantiate
  7584. * @returns the new object or null if the system was not able to do the instantiation
  7585. */
  7586. static Instantiate(className: string): any;
  7587. }
  7588. }
  7589. declare module BABYLON {
  7590. /**
  7591. * Define options used to create a depth texture
  7592. */
  7593. export class DepthTextureCreationOptions {
  7594. /** Specifies whether or not a stencil should be allocated in the texture */
  7595. generateStencil?: boolean;
  7596. /** Specifies whether or not bilinear filtering is enable on the texture */
  7597. bilinearFiltering?: boolean;
  7598. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7599. comparisonFunction?: number;
  7600. /** Specifies if the created texture is a cube texture */
  7601. isCube?: boolean;
  7602. }
  7603. }
  7604. declare module BABYLON {
  7605. interface ThinEngine {
  7606. /**
  7607. * Creates a depth stencil cube texture.
  7608. * This is only available in WebGL 2.
  7609. * @param size The size of face edge in the cube texture.
  7610. * @param options The options defining the cube texture.
  7611. * @returns The cube texture
  7612. */
  7613. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7614. /**
  7615. * Creates a cube texture
  7616. * @param rootUrl defines the url where the files to load is located
  7617. * @param scene defines the current scene
  7618. * @param files defines the list of files to load (1 per face)
  7619. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7620. * @param onLoad defines an optional callback raised when the texture is loaded
  7621. * @param onError defines an optional callback raised if there is an issue to load the texture
  7622. * @param format defines the format of the data
  7623. * @param forcedExtension defines the extension to use to pick the right loader
  7624. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7625. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7626. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7627. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7628. * @returns the cube texture as an InternalTexture
  7629. */
  7630. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7631. /**
  7632. * Creates a cube texture
  7633. * @param rootUrl defines the url where the files to load is located
  7634. * @param scene defines the current scene
  7635. * @param files defines the list of files to load (1 per face)
  7636. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7637. * @param onLoad defines an optional callback raised when the texture is loaded
  7638. * @param onError defines an optional callback raised if there is an issue to load the texture
  7639. * @param format defines the format of the data
  7640. * @param forcedExtension defines the extension to use to pick the right loader
  7641. * @returns the cube texture as an InternalTexture
  7642. */
  7643. 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;
  7644. /**
  7645. * Creates a cube texture
  7646. * @param rootUrl defines the url where the files to load is located
  7647. * @param scene defines the current scene
  7648. * @param files defines the list of files to load (1 per face)
  7649. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7650. * @param onLoad defines an optional callback raised when the texture is loaded
  7651. * @param onError defines an optional callback raised if there is an issue to load the texture
  7652. * @param format defines the format of the data
  7653. * @param forcedExtension defines the extension to use to pick the right loader
  7654. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7655. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7656. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7657. * @returns the cube texture as an InternalTexture
  7658. */
  7659. 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;
  7660. /** @hidden */
  7661. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7662. /** @hidden */
  7663. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7664. /** @hidden */
  7665. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7666. /** @hidden */
  7667. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7668. /**
  7669. * @hidden
  7670. */
  7671. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7672. }
  7673. }
  7674. declare module BABYLON {
  7675. /**
  7676. * Class for creating a cube texture
  7677. */
  7678. export class CubeTexture extends BaseTexture {
  7679. private _delayedOnLoad;
  7680. /**
  7681. * Observable triggered once the texture has been loaded.
  7682. */
  7683. onLoadObservable: Observable<CubeTexture>;
  7684. /**
  7685. * The url of the texture
  7686. */
  7687. url: string;
  7688. /**
  7689. * Gets or sets the center of the bounding box associated with the cube texture.
  7690. * It must define where the camera used to render the texture was set
  7691. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7692. */
  7693. boundingBoxPosition: Vector3;
  7694. private _boundingBoxSize;
  7695. /**
  7696. * Gets or sets the size of the bounding box associated with the cube texture
  7697. * When defined, the cubemap will switch to local mode
  7698. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7699. * @example https://www.babylonjs-playground.com/#RNASML
  7700. */
  7701. set boundingBoxSize(value: Vector3);
  7702. /**
  7703. * Returns the bounding box size
  7704. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7705. */
  7706. get boundingBoxSize(): Vector3;
  7707. protected _rotationY: number;
  7708. /**
  7709. * Sets texture matrix rotation angle around Y axis in radians.
  7710. */
  7711. set rotationY(value: number);
  7712. /**
  7713. * Gets texture matrix rotation angle around Y axis radians.
  7714. */
  7715. get rotationY(): number;
  7716. /**
  7717. * Are mip maps generated for this texture or not.
  7718. */
  7719. get noMipmap(): boolean;
  7720. private _noMipmap;
  7721. private _files;
  7722. protected _forcedExtension: Nullable<string>;
  7723. private _extensions;
  7724. private _textureMatrix;
  7725. private _format;
  7726. private _createPolynomials;
  7727. /** @hidden */
  7728. _prefiltered: boolean;
  7729. /**
  7730. * Creates a cube texture from an array of image urls
  7731. * @param files defines an array of image urls
  7732. * @param scene defines the hosting scene
  7733. * @param noMipmap specifies if mip maps are not used
  7734. * @returns a cube texture
  7735. */
  7736. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7737. /**
  7738. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7739. * @param url defines the url of the prefiltered texture
  7740. * @param scene defines the scene the texture is attached to
  7741. * @param forcedExtension defines the extension of the file if different from the url
  7742. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7743. * @return the prefiltered texture
  7744. */
  7745. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7746. /**
  7747. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7748. * as prefiltered data.
  7749. * @param rootUrl defines the url of the texture or the root name of the six images
  7750. * @param scene defines the scene the texture is attached to
  7751. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7752. * @param noMipmap defines if mipmaps should be created or not
  7753. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7754. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7755. * @param onError defines a callback triggered in case of error during load
  7756. * @param format defines the internal format to use for the texture once loaded
  7757. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7758. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7759. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7760. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7761. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7762. * @return the cube texture
  7763. */
  7764. 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);
  7765. /**
  7766. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7767. */
  7768. get isPrefiltered(): boolean;
  7769. /**
  7770. * Get the current class name of the texture useful for serialization or dynamic coding.
  7771. * @returns "CubeTexture"
  7772. */
  7773. getClassName(): string;
  7774. /**
  7775. * Update the url (and optional buffer) of this texture if url was null during construction.
  7776. * @param url the url of the texture
  7777. * @param forcedExtension defines the extension to use
  7778. * @param onLoad callback called when the texture is loaded (defaults to null)
  7779. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7780. */
  7781. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7782. /**
  7783. * Delays loading of the cube texture
  7784. * @param forcedExtension defines the extension to use
  7785. */
  7786. delayLoad(forcedExtension?: string): void;
  7787. /**
  7788. * Returns the reflection texture matrix
  7789. * @returns the reflection texture matrix
  7790. */
  7791. getReflectionTextureMatrix(): Matrix;
  7792. /**
  7793. * Sets the reflection texture matrix
  7794. * @param value Reflection texture matrix
  7795. */
  7796. setReflectionTextureMatrix(value: Matrix): void;
  7797. /**
  7798. * Parses text to create a cube texture
  7799. * @param parsedTexture define the serialized text to read from
  7800. * @param scene defines the hosting scene
  7801. * @param rootUrl defines the root url of the cube texture
  7802. * @returns a cube texture
  7803. */
  7804. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7805. /**
  7806. * Makes a clone, or deep copy, of the cube texture
  7807. * @returns a new cube texture
  7808. */
  7809. clone(): CubeTexture;
  7810. }
  7811. }
  7812. declare module BABYLON {
  7813. /**
  7814. * Manages the defines for the Material
  7815. */
  7816. export class MaterialDefines {
  7817. /** @hidden */
  7818. protected _keys: string[];
  7819. private _isDirty;
  7820. /** @hidden */
  7821. _renderId: number;
  7822. /** @hidden */
  7823. _areLightsDirty: boolean;
  7824. /** @hidden */
  7825. _areLightsDisposed: boolean;
  7826. /** @hidden */
  7827. _areAttributesDirty: boolean;
  7828. /** @hidden */
  7829. _areTexturesDirty: boolean;
  7830. /** @hidden */
  7831. _areFresnelDirty: boolean;
  7832. /** @hidden */
  7833. _areMiscDirty: boolean;
  7834. /** @hidden */
  7835. _areImageProcessingDirty: boolean;
  7836. /** @hidden */
  7837. _normals: boolean;
  7838. /** @hidden */
  7839. _uvs: boolean;
  7840. /** @hidden */
  7841. _needNormals: boolean;
  7842. /** @hidden */
  7843. _needUVs: boolean;
  7844. [id: string]: any;
  7845. /**
  7846. * Specifies if the material needs to be re-calculated
  7847. */
  7848. get isDirty(): boolean;
  7849. /**
  7850. * Marks the material to indicate that it has been re-calculated
  7851. */
  7852. markAsProcessed(): void;
  7853. /**
  7854. * Marks the material to indicate that it needs to be re-calculated
  7855. */
  7856. markAsUnprocessed(): void;
  7857. /**
  7858. * Marks the material to indicate all of its defines need to be re-calculated
  7859. */
  7860. markAllAsDirty(): void;
  7861. /**
  7862. * Marks the material to indicate that image processing needs to be re-calculated
  7863. */
  7864. markAsImageProcessingDirty(): void;
  7865. /**
  7866. * Marks the material to indicate the lights need to be re-calculated
  7867. * @param disposed Defines whether the light is dirty due to dispose or not
  7868. */
  7869. markAsLightDirty(disposed?: boolean): void;
  7870. /**
  7871. * Marks the attribute state as changed
  7872. */
  7873. markAsAttributesDirty(): void;
  7874. /**
  7875. * Marks the texture state as changed
  7876. */
  7877. markAsTexturesDirty(): void;
  7878. /**
  7879. * Marks the fresnel state as changed
  7880. */
  7881. markAsFresnelDirty(): void;
  7882. /**
  7883. * Marks the misc state as changed
  7884. */
  7885. markAsMiscDirty(): void;
  7886. /**
  7887. * Rebuilds the material defines
  7888. */
  7889. rebuild(): void;
  7890. /**
  7891. * Specifies if two material defines are equal
  7892. * @param other - A material define instance to compare to
  7893. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7894. */
  7895. isEqual(other: MaterialDefines): boolean;
  7896. /**
  7897. * Clones this instance's defines to another instance
  7898. * @param other - material defines to clone values to
  7899. */
  7900. cloneTo(other: MaterialDefines): void;
  7901. /**
  7902. * Resets the material define values
  7903. */
  7904. reset(): void;
  7905. /**
  7906. * Converts the material define values to a string
  7907. * @returns - String of material define information
  7908. */
  7909. toString(): string;
  7910. }
  7911. }
  7912. declare module BABYLON {
  7913. /**
  7914. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7915. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7916. * 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;
  7917. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7918. */
  7919. export class ColorCurves {
  7920. private _dirty;
  7921. private _tempColor;
  7922. private _globalCurve;
  7923. private _highlightsCurve;
  7924. private _midtonesCurve;
  7925. private _shadowsCurve;
  7926. private _positiveCurve;
  7927. private _negativeCurve;
  7928. private _globalHue;
  7929. private _globalDensity;
  7930. private _globalSaturation;
  7931. private _globalExposure;
  7932. /**
  7933. * Gets the global Hue value.
  7934. * 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).
  7935. */
  7936. get globalHue(): number;
  7937. /**
  7938. * Sets the global Hue value.
  7939. * 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).
  7940. */
  7941. set globalHue(value: number);
  7942. /**
  7943. * Gets the global Density value.
  7944. * 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.
  7945. * Values less than zero provide a filter of opposite hue.
  7946. */
  7947. get globalDensity(): number;
  7948. /**
  7949. * Sets the global Density value.
  7950. * 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.
  7951. * Values less than zero provide a filter of opposite hue.
  7952. */
  7953. set globalDensity(value: number);
  7954. /**
  7955. * Gets the global Saturation value.
  7956. * 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.
  7957. */
  7958. get globalSaturation(): number;
  7959. /**
  7960. * Sets the global Saturation value.
  7961. * 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.
  7962. */
  7963. set globalSaturation(value: number);
  7964. /**
  7965. * Gets the global Exposure value.
  7966. * 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.
  7967. */
  7968. get globalExposure(): number;
  7969. /**
  7970. * Sets the global Exposure value.
  7971. * 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.
  7972. */
  7973. set globalExposure(value: number);
  7974. private _highlightsHue;
  7975. private _highlightsDensity;
  7976. private _highlightsSaturation;
  7977. private _highlightsExposure;
  7978. /**
  7979. * Gets the highlights Hue value.
  7980. * 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).
  7981. */
  7982. get highlightsHue(): number;
  7983. /**
  7984. * Sets the highlights Hue value.
  7985. * 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).
  7986. */
  7987. set highlightsHue(value: number);
  7988. /**
  7989. * Gets the highlights Density value.
  7990. * 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.
  7991. * Values less than zero provide a filter of opposite hue.
  7992. */
  7993. get highlightsDensity(): number;
  7994. /**
  7995. * Sets the highlights Density value.
  7996. * 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.
  7997. * Values less than zero provide a filter of opposite hue.
  7998. */
  7999. set highlightsDensity(value: number);
  8000. /**
  8001. * Gets the highlights Saturation value.
  8002. * 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.
  8003. */
  8004. get highlightsSaturation(): number;
  8005. /**
  8006. * Sets the highlights Saturation value.
  8007. * 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.
  8008. */
  8009. set highlightsSaturation(value: number);
  8010. /**
  8011. * Gets the highlights Exposure 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 exposure and negative values decrease exposure.
  8013. */
  8014. get highlightsExposure(): number;
  8015. /**
  8016. * Sets the highlights Exposure value.
  8017. * 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.
  8018. */
  8019. set highlightsExposure(value: number);
  8020. private _midtonesHue;
  8021. private _midtonesDensity;
  8022. private _midtonesSaturation;
  8023. private _midtonesExposure;
  8024. /**
  8025. * Gets the midtones Hue value.
  8026. * 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).
  8027. */
  8028. get midtonesHue(): number;
  8029. /**
  8030. * Sets the midtones Hue value.
  8031. * 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).
  8032. */
  8033. set midtonesHue(value: number);
  8034. /**
  8035. * Gets the midtones Density value.
  8036. * 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.
  8037. * Values less than zero provide a filter of opposite hue.
  8038. */
  8039. get midtonesDensity(): number;
  8040. /**
  8041. * Sets the midtones Density value.
  8042. * 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.
  8043. * Values less than zero provide a filter of opposite hue.
  8044. */
  8045. set midtonesDensity(value: number);
  8046. /**
  8047. * Gets the midtones Saturation value.
  8048. * 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.
  8049. */
  8050. get midtonesSaturation(): number;
  8051. /**
  8052. * Sets the midtones Saturation value.
  8053. * 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.
  8054. */
  8055. set midtonesSaturation(value: number);
  8056. /**
  8057. * Gets the midtones Exposure value.
  8058. * 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.
  8059. */
  8060. get midtonesExposure(): number;
  8061. /**
  8062. * Sets the midtones Exposure value.
  8063. * 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.
  8064. */
  8065. set midtonesExposure(value: number);
  8066. private _shadowsHue;
  8067. private _shadowsDensity;
  8068. private _shadowsSaturation;
  8069. private _shadowsExposure;
  8070. /**
  8071. * Gets the shadows Hue value.
  8072. * 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).
  8073. */
  8074. get shadowsHue(): number;
  8075. /**
  8076. * Sets the shadows Hue value.
  8077. * 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).
  8078. */
  8079. set shadowsHue(value: number);
  8080. /**
  8081. * Gets the shadows Density value.
  8082. * 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.
  8083. * Values less than zero provide a filter of opposite hue.
  8084. */
  8085. get shadowsDensity(): number;
  8086. /**
  8087. * Sets the shadows Density value.
  8088. * 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.
  8089. * Values less than zero provide a filter of opposite hue.
  8090. */
  8091. set shadowsDensity(value: number);
  8092. /**
  8093. * Gets the shadows Saturation value.
  8094. * 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.
  8095. */
  8096. get shadowsSaturation(): number;
  8097. /**
  8098. * Sets the shadows Saturation value.
  8099. * 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.
  8100. */
  8101. set shadowsSaturation(value: number);
  8102. /**
  8103. * Gets the shadows Exposure value.
  8104. * 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.
  8105. */
  8106. get shadowsExposure(): number;
  8107. /**
  8108. * Sets the shadows Exposure value.
  8109. * 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.
  8110. */
  8111. set shadowsExposure(value: number);
  8112. /**
  8113. * Returns the class name
  8114. * @returns The class name
  8115. */
  8116. getClassName(): string;
  8117. /**
  8118. * Binds the color curves to the shader.
  8119. * @param colorCurves The color curve to bind
  8120. * @param effect The effect to bind to
  8121. * @param positiveUniform The positive uniform shader parameter
  8122. * @param neutralUniform The neutral uniform shader parameter
  8123. * @param negativeUniform The negative uniform shader parameter
  8124. */
  8125. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8126. /**
  8127. * Prepare the list of uniforms associated with the ColorCurves effects.
  8128. * @param uniformsList The list of uniforms used in the effect
  8129. */
  8130. static PrepareUniforms(uniformsList: string[]): void;
  8131. /**
  8132. * Returns color grading data based on a hue, density, saturation and exposure value.
  8133. * @param filterHue The hue of the color filter.
  8134. * @param filterDensity The density of the color filter.
  8135. * @param saturation The saturation.
  8136. * @param exposure The exposure.
  8137. * @param result The result data container.
  8138. */
  8139. private getColorGradingDataToRef;
  8140. /**
  8141. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8142. * @param value The input slider value in range [-100,100].
  8143. * @returns Adjusted value.
  8144. */
  8145. private static applyColorGradingSliderNonlinear;
  8146. /**
  8147. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8148. * @param hue The hue (H) input.
  8149. * @param saturation The saturation (S) input.
  8150. * @param brightness The brightness (B) input.
  8151. * @result An RGBA color represented as Vector4.
  8152. */
  8153. private static fromHSBToRef;
  8154. /**
  8155. * Returns a value clamped between min and max
  8156. * @param value The value to clamp
  8157. * @param min The minimum of value
  8158. * @param max The maximum of value
  8159. * @returns The clamped value.
  8160. */
  8161. private static clamp;
  8162. /**
  8163. * Clones the current color curve instance.
  8164. * @return The cloned curves
  8165. */
  8166. clone(): ColorCurves;
  8167. /**
  8168. * Serializes the current color curve instance to a json representation.
  8169. * @return a JSON representation
  8170. */
  8171. serialize(): any;
  8172. /**
  8173. * Parses the color curve from a json representation.
  8174. * @param source the JSON source to parse
  8175. * @return The parsed curves
  8176. */
  8177. static Parse(source: any): ColorCurves;
  8178. }
  8179. }
  8180. declare module BABYLON {
  8181. /**
  8182. * Interface to follow in your material defines to integrate easily the
  8183. * Image proccessing functions.
  8184. * @hidden
  8185. */
  8186. export interface IImageProcessingConfigurationDefines {
  8187. IMAGEPROCESSING: boolean;
  8188. VIGNETTE: boolean;
  8189. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8190. VIGNETTEBLENDMODEOPAQUE: boolean;
  8191. TONEMAPPING: boolean;
  8192. TONEMAPPING_ACES: boolean;
  8193. CONTRAST: boolean;
  8194. EXPOSURE: boolean;
  8195. COLORCURVES: boolean;
  8196. COLORGRADING: boolean;
  8197. COLORGRADING3D: boolean;
  8198. SAMPLER3DGREENDEPTH: boolean;
  8199. SAMPLER3DBGRMAP: boolean;
  8200. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8201. }
  8202. /**
  8203. * @hidden
  8204. */
  8205. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8206. IMAGEPROCESSING: boolean;
  8207. VIGNETTE: boolean;
  8208. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8209. VIGNETTEBLENDMODEOPAQUE: boolean;
  8210. TONEMAPPING: boolean;
  8211. TONEMAPPING_ACES: boolean;
  8212. CONTRAST: boolean;
  8213. COLORCURVES: boolean;
  8214. COLORGRADING: boolean;
  8215. COLORGRADING3D: boolean;
  8216. SAMPLER3DGREENDEPTH: boolean;
  8217. SAMPLER3DBGRMAP: boolean;
  8218. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8219. EXPOSURE: boolean;
  8220. constructor();
  8221. }
  8222. /**
  8223. * This groups together the common properties used for image processing either in direct forward pass
  8224. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8225. * or not.
  8226. */
  8227. export class ImageProcessingConfiguration {
  8228. /**
  8229. * Default tone mapping applied in BabylonJS.
  8230. */
  8231. static readonly TONEMAPPING_STANDARD: number;
  8232. /**
  8233. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8234. * to other engines rendering to increase portability.
  8235. */
  8236. static readonly TONEMAPPING_ACES: number;
  8237. /**
  8238. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8239. */
  8240. colorCurves: Nullable<ColorCurves>;
  8241. private _colorCurvesEnabled;
  8242. /**
  8243. * Gets wether the color curves effect is enabled.
  8244. */
  8245. get colorCurvesEnabled(): boolean;
  8246. /**
  8247. * Sets wether the color curves effect is enabled.
  8248. */
  8249. set colorCurvesEnabled(value: boolean);
  8250. private _colorGradingTexture;
  8251. /**
  8252. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8253. */
  8254. get colorGradingTexture(): Nullable<BaseTexture>;
  8255. /**
  8256. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8257. */
  8258. set colorGradingTexture(value: Nullable<BaseTexture>);
  8259. private _colorGradingEnabled;
  8260. /**
  8261. * Gets wether the color grading effect is enabled.
  8262. */
  8263. get colorGradingEnabled(): boolean;
  8264. /**
  8265. * Sets wether the color grading effect is enabled.
  8266. */
  8267. set colorGradingEnabled(value: boolean);
  8268. private _colorGradingWithGreenDepth;
  8269. /**
  8270. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8271. */
  8272. get colorGradingWithGreenDepth(): boolean;
  8273. /**
  8274. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8275. */
  8276. set colorGradingWithGreenDepth(value: boolean);
  8277. private _colorGradingBGR;
  8278. /**
  8279. * Gets wether the color grading texture contains BGR values.
  8280. */
  8281. get colorGradingBGR(): boolean;
  8282. /**
  8283. * Sets wether the color grading texture contains BGR values.
  8284. */
  8285. set colorGradingBGR(value: boolean);
  8286. /** @hidden */
  8287. _exposure: number;
  8288. /**
  8289. * Gets the Exposure used in the effect.
  8290. */
  8291. get exposure(): number;
  8292. /**
  8293. * Sets the Exposure used in the effect.
  8294. */
  8295. set exposure(value: number);
  8296. private _toneMappingEnabled;
  8297. /**
  8298. * Gets wether the tone mapping effect is enabled.
  8299. */
  8300. get toneMappingEnabled(): boolean;
  8301. /**
  8302. * Sets wether the tone mapping effect is enabled.
  8303. */
  8304. set toneMappingEnabled(value: boolean);
  8305. private _toneMappingType;
  8306. /**
  8307. * Gets the type of tone mapping effect.
  8308. */
  8309. get toneMappingType(): number;
  8310. /**
  8311. * Sets the type of tone mapping effect used in BabylonJS.
  8312. */
  8313. set toneMappingType(value: number);
  8314. protected _contrast: number;
  8315. /**
  8316. * Gets the contrast used in the effect.
  8317. */
  8318. get contrast(): number;
  8319. /**
  8320. * Sets the contrast used in the effect.
  8321. */
  8322. set contrast(value: number);
  8323. /**
  8324. * Vignette stretch size.
  8325. */
  8326. vignetteStretch: number;
  8327. /**
  8328. * Vignette centre X Offset.
  8329. */
  8330. vignetteCentreX: number;
  8331. /**
  8332. * Vignette centre Y Offset.
  8333. */
  8334. vignetteCentreY: number;
  8335. /**
  8336. * Vignette weight or intensity of the vignette effect.
  8337. */
  8338. vignetteWeight: number;
  8339. /**
  8340. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8341. * if vignetteEnabled is set to true.
  8342. */
  8343. vignetteColor: Color4;
  8344. /**
  8345. * Camera field of view used by the Vignette effect.
  8346. */
  8347. vignetteCameraFov: number;
  8348. private _vignetteBlendMode;
  8349. /**
  8350. * Gets the vignette blend mode allowing different kind of effect.
  8351. */
  8352. get vignetteBlendMode(): number;
  8353. /**
  8354. * Sets the vignette blend mode allowing different kind of effect.
  8355. */
  8356. set vignetteBlendMode(value: number);
  8357. private _vignetteEnabled;
  8358. /**
  8359. * Gets wether the vignette effect is enabled.
  8360. */
  8361. get vignetteEnabled(): boolean;
  8362. /**
  8363. * Sets wether the vignette effect is enabled.
  8364. */
  8365. set vignetteEnabled(value: boolean);
  8366. private _applyByPostProcess;
  8367. /**
  8368. * Gets wether the image processing is applied through a post process or not.
  8369. */
  8370. get applyByPostProcess(): boolean;
  8371. /**
  8372. * Sets wether the image processing is applied through a post process or not.
  8373. */
  8374. set applyByPostProcess(value: boolean);
  8375. private _isEnabled;
  8376. /**
  8377. * Gets wether the image processing is enabled or not.
  8378. */
  8379. get isEnabled(): boolean;
  8380. /**
  8381. * Sets wether the image processing is enabled or not.
  8382. */
  8383. set isEnabled(value: boolean);
  8384. /**
  8385. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8386. */
  8387. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8388. /**
  8389. * Method called each time the image processing information changes requires to recompile the effect.
  8390. */
  8391. protected _updateParameters(): void;
  8392. /**
  8393. * Gets the current class name.
  8394. * @return "ImageProcessingConfiguration"
  8395. */
  8396. getClassName(): string;
  8397. /**
  8398. * Prepare the list of uniforms associated with the Image Processing effects.
  8399. * @param uniforms The list of uniforms used in the effect
  8400. * @param defines the list of defines currently in use
  8401. */
  8402. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8403. /**
  8404. * Prepare the list of samplers associated with the Image Processing effects.
  8405. * @param samplersList The list of uniforms used in the effect
  8406. * @param defines the list of defines currently in use
  8407. */
  8408. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8409. /**
  8410. * Prepare the list of defines associated to the shader.
  8411. * @param defines the list of defines to complete
  8412. * @param forPostProcess Define if we are currently in post process mode or not
  8413. */
  8414. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8415. /**
  8416. * Returns true if all the image processing information are ready.
  8417. * @returns True if ready, otherwise, false
  8418. */
  8419. isReady(): boolean;
  8420. /**
  8421. * Binds the image processing to the shader.
  8422. * @param effect The effect to bind to
  8423. * @param overrideAspectRatio Override the aspect ratio of the effect
  8424. */
  8425. bind(effect: Effect, overrideAspectRatio?: number): void;
  8426. /**
  8427. * Clones the current image processing instance.
  8428. * @return The cloned image processing
  8429. */
  8430. clone(): ImageProcessingConfiguration;
  8431. /**
  8432. * Serializes the current image processing instance to a json representation.
  8433. * @return a JSON representation
  8434. */
  8435. serialize(): any;
  8436. /**
  8437. * Parses the image processing from a json representation.
  8438. * @param source the JSON source to parse
  8439. * @return The parsed image processing
  8440. */
  8441. static Parse(source: any): ImageProcessingConfiguration;
  8442. private static _VIGNETTEMODE_MULTIPLY;
  8443. private static _VIGNETTEMODE_OPAQUE;
  8444. /**
  8445. * Used to apply the vignette as a mix with the pixel color.
  8446. */
  8447. static get VIGNETTEMODE_MULTIPLY(): number;
  8448. /**
  8449. * Used to apply the vignette as a replacement of the pixel color.
  8450. */
  8451. static get VIGNETTEMODE_OPAQUE(): number;
  8452. }
  8453. }
  8454. declare module BABYLON {
  8455. /** @hidden */
  8456. export var postprocessVertexShader: {
  8457. name: string;
  8458. shader: string;
  8459. };
  8460. }
  8461. declare module BABYLON {
  8462. interface ThinEngine {
  8463. /**
  8464. * Creates a new render target texture
  8465. * @param size defines the size of the texture
  8466. * @param options defines the options used to create the texture
  8467. * @returns a new render target texture stored in an InternalTexture
  8468. */
  8469. createRenderTargetTexture(size: number | {
  8470. width: number;
  8471. height: number;
  8472. layers?: number;
  8473. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8474. /**
  8475. * Creates a depth stencil texture.
  8476. * This is only available in WebGL 2 or with the depth texture extension available.
  8477. * @param size The size of face edge in the texture.
  8478. * @param options The options defining the texture.
  8479. * @returns The texture
  8480. */
  8481. createDepthStencilTexture(size: number | {
  8482. width: number;
  8483. height: number;
  8484. layers?: number;
  8485. }, options: DepthTextureCreationOptions): InternalTexture;
  8486. /** @hidden */
  8487. _createDepthStencilTexture(size: number | {
  8488. width: number;
  8489. height: number;
  8490. layers?: number;
  8491. }, options: DepthTextureCreationOptions): InternalTexture;
  8492. }
  8493. }
  8494. declare module BABYLON {
  8495. /** Defines supported spaces */
  8496. export enum Space {
  8497. /** Local (object) space */
  8498. LOCAL = 0,
  8499. /** World space */
  8500. WORLD = 1,
  8501. /** Bone space */
  8502. BONE = 2
  8503. }
  8504. /** Defines the 3 main axes */
  8505. export class Axis {
  8506. /** X axis */
  8507. static X: Vector3;
  8508. /** Y axis */
  8509. static Y: Vector3;
  8510. /** Z axis */
  8511. static Z: Vector3;
  8512. }
  8513. }
  8514. declare module BABYLON {
  8515. /**
  8516. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8517. * This is the base of the follow, arc rotate cameras and Free camera
  8518. * @see http://doc.babylonjs.com/features/cameras
  8519. */
  8520. export class TargetCamera extends Camera {
  8521. private static _RigCamTransformMatrix;
  8522. private static _TargetTransformMatrix;
  8523. private static _TargetFocalPoint;
  8524. /**
  8525. * Define the current direction the camera is moving to
  8526. */
  8527. cameraDirection: Vector3;
  8528. /**
  8529. * Define the current rotation the camera is rotating to
  8530. */
  8531. cameraRotation: Vector2;
  8532. /**
  8533. * When set, the up vector of the camera will be updated by the rotation of the camera
  8534. */
  8535. updateUpVectorFromRotation: boolean;
  8536. private _tmpQuaternion;
  8537. /**
  8538. * Define the current rotation of the camera
  8539. */
  8540. rotation: Vector3;
  8541. /**
  8542. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8543. */
  8544. rotationQuaternion: Quaternion;
  8545. /**
  8546. * Define the current speed of the camera
  8547. */
  8548. speed: number;
  8549. /**
  8550. * Add constraint to the camera to prevent it to move freely in all directions and
  8551. * around all axis.
  8552. */
  8553. noRotationConstraint: boolean;
  8554. /**
  8555. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8556. * panning
  8557. */
  8558. invertRotation: boolean;
  8559. /**
  8560. * Speed multiplier for inverse camera panning
  8561. */
  8562. inverseRotationSpeed: number;
  8563. /**
  8564. * Define the current target of the camera as an object or a position.
  8565. */
  8566. lockedTarget: any;
  8567. /** @hidden */
  8568. _currentTarget: Vector3;
  8569. /** @hidden */
  8570. _initialFocalDistance: number;
  8571. /** @hidden */
  8572. _viewMatrix: Matrix;
  8573. /** @hidden */
  8574. _camMatrix: Matrix;
  8575. /** @hidden */
  8576. _cameraTransformMatrix: Matrix;
  8577. /** @hidden */
  8578. _cameraRotationMatrix: Matrix;
  8579. /** @hidden */
  8580. _referencePoint: Vector3;
  8581. /** @hidden */
  8582. _transformedReferencePoint: Vector3;
  8583. protected _globalCurrentTarget: Vector3;
  8584. protected _globalCurrentUpVector: Vector3;
  8585. /** @hidden */
  8586. _reset: () => void;
  8587. private _defaultUp;
  8588. /**
  8589. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8590. * This is the base of the follow, arc rotate cameras and Free camera
  8591. * @see http://doc.babylonjs.com/features/cameras
  8592. * @param name Defines the name of the camera in the scene
  8593. * @param position Defines the start position of the camera in the scene
  8594. * @param scene Defines the scene the camera belongs to
  8595. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8596. */
  8597. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8598. /**
  8599. * Gets the position in front of the camera at a given distance.
  8600. * @param distance The distance from the camera we want the position to be
  8601. * @returns the position
  8602. */
  8603. getFrontPosition(distance: number): Vector3;
  8604. /** @hidden */
  8605. _getLockedTargetPosition(): Nullable<Vector3>;
  8606. private _storedPosition;
  8607. private _storedRotation;
  8608. private _storedRotationQuaternion;
  8609. /**
  8610. * Store current camera state of the camera (fov, position, rotation, etc..)
  8611. * @returns the camera
  8612. */
  8613. storeState(): Camera;
  8614. /**
  8615. * Restored camera state. You must call storeState() first
  8616. * @returns whether it was successful or not
  8617. * @hidden
  8618. */
  8619. _restoreStateValues(): boolean;
  8620. /** @hidden */
  8621. _initCache(): void;
  8622. /** @hidden */
  8623. _updateCache(ignoreParentClass?: boolean): void;
  8624. /** @hidden */
  8625. _isSynchronizedViewMatrix(): boolean;
  8626. /** @hidden */
  8627. _computeLocalCameraSpeed(): number;
  8628. /**
  8629. * Defines the target the camera should look at.
  8630. * @param target Defines the new target as a Vector or a mesh
  8631. */
  8632. setTarget(target: Vector3): void;
  8633. /**
  8634. * Return the current target position of the camera. This value is expressed in local space.
  8635. * @returns the target position
  8636. */
  8637. getTarget(): Vector3;
  8638. /** @hidden */
  8639. _decideIfNeedsToMove(): boolean;
  8640. /** @hidden */
  8641. _updatePosition(): void;
  8642. /** @hidden */
  8643. _checkInputs(): void;
  8644. protected _updateCameraRotationMatrix(): void;
  8645. /**
  8646. * 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)
  8647. * @returns the current camera
  8648. */
  8649. private _rotateUpVectorWithCameraRotationMatrix;
  8650. private _cachedRotationZ;
  8651. private _cachedQuaternionRotationZ;
  8652. /** @hidden */
  8653. _getViewMatrix(): Matrix;
  8654. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8655. /**
  8656. * @hidden
  8657. */
  8658. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8659. /**
  8660. * @hidden
  8661. */
  8662. _updateRigCameras(): void;
  8663. private _getRigCamPositionAndTarget;
  8664. /**
  8665. * Gets the current object class name.
  8666. * @return the class name
  8667. */
  8668. getClassName(): string;
  8669. }
  8670. }
  8671. declare module BABYLON {
  8672. /**
  8673. * Gather the list of keyboard event types as constants.
  8674. */
  8675. export class KeyboardEventTypes {
  8676. /**
  8677. * The keydown event is fired when a key becomes active (pressed).
  8678. */
  8679. static readonly KEYDOWN: number;
  8680. /**
  8681. * The keyup event is fired when a key has been released.
  8682. */
  8683. static readonly KEYUP: number;
  8684. }
  8685. /**
  8686. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8687. */
  8688. export class KeyboardInfo {
  8689. /**
  8690. * Defines the type of event (KeyboardEventTypes)
  8691. */
  8692. type: number;
  8693. /**
  8694. * Defines the related dom event
  8695. */
  8696. event: KeyboardEvent;
  8697. /**
  8698. * Instantiates a new keyboard info.
  8699. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8700. * @param type Defines the type of event (KeyboardEventTypes)
  8701. * @param event Defines the related dom event
  8702. */
  8703. constructor(
  8704. /**
  8705. * Defines the type of event (KeyboardEventTypes)
  8706. */
  8707. type: number,
  8708. /**
  8709. * Defines the related dom event
  8710. */
  8711. event: KeyboardEvent);
  8712. }
  8713. /**
  8714. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8715. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8716. */
  8717. export class KeyboardInfoPre extends KeyboardInfo {
  8718. /**
  8719. * Defines the type of event (KeyboardEventTypes)
  8720. */
  8721. type: number;
  8722. /**
  8723. * Defines the related dom event
  8724. */
  8725. event: KeyboardEvent;
  8726. /**
  8727. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8728. */
  8729. skipOnPointerObservable: boolean;
  8730. /**
  8731. * Instantiates a new keyboard pre info.
  8732. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8733. * @param type Defines the type of event (KeyboardEventTypes)
  8734. * @param event Defines the related dom event
  8735. */
  8736. constructor(
  8737. /**
  8738. * Defines the type of event (KeyboardEventTypes)
  8739. */
  8740. type: number,
  8741. /**
  8742. * Defines the related dom event
  8743. */
  8744. event: KeyboardEvent);
  8745. }
  8746. }
  8747. declare module BABYLON {
  8748. /**
  8749. * Manage the keyboard inputs to control the movement of a free camera.
  8750. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8751. */
  8752. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8753. /**
  8754. * Defines the camera the input is attached to.
  8755. */
  8756. camera: FreeCamera;
  8757. /**
  8758. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8759. */
  8760. keysUp: number[];
  8761. /**
  8762. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8763. */
  8764. keysUpward: number[];
  8765. /**
  8766. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8767. */
  8768. keysDown: number[];
  8769. /**
  8770. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8771. */
  8772. keysDownward: number[];
  8773. /**
  8774. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8775. */
  8776. keysLeft: number[];
  8777. /**
  8778. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8779. */
  8780. keysRight: number[];
  8781. private _keys;
  8782. private _onCanvasBlurObserver;
  8783. private _onKeyboardObserver;
  8784. private _engine;
  8785. private _scene;
  8786. /**
  8787. * Attach the input controls to a specific dom element to get the input from.
  8788. * @param element Defines the element the controls should be listened from
  8789. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8790. */
  8791. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8792. /**
  8793. * Detach the current controls from the specified dom element.
  8794. * @param element Defines the element to stop listening the inputs from
  8795. */
  8796. detachControl(element: Nullable<HTMLElement>): void;
  8797. /**
  8798. * Update the current camera state depending on the inputs that have been used this frame.
  8799. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8800. */
  8801. checkInputs(): void;
  8802. /**
  8803. * Gets the class name of the current intput.
  8804. * @returns the class name
  8805. */
  8806. getClassName(): string;
  8807. /** @hidden */
  8808. _onLostFocus(): void;
  8809. /**
  8810. * Get the friendly name associated with the input class.
  8811. * @returns the input friendly name
  8812. */
  8813. getSimpleName(): string;
  8814. }
  8815. }
  8816. declare module BABYLON {
  8817. /**
  8818. * Interface describing all the common properties and methods a shadow light needs to implement.
  8819. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8820. * as well as binding the different shadow properties to the effects.
  8821. */
  8822. export interface IShadowLight extends Light {
  8823. /**
  8824. * The light id in the scene (used in scene.findLighById for instance)
  8825. */
  8826. id: string;
  8827. /**
  8828. * The position the shdow will be casted from.
  8829. */
  8830. position: Vector3;
  8831. /**
  8832. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8833. */
  8834. direction: Vector3;
  8835. /**
  8836. * The transformed position. Position of the light in world space taking parenting in account.
  8837. */
  8838. transformedPosition: Vector3;
  8839. /**
  8840. * The transformed direction. Direction of the light in world space taking parenting in account.
  8841. */
  8842. transformedDirection: Vector3;
  8843. /**
  8844. * The friendly name of the light in the scene.
  8845. */
  8846. name: string;
  8847. /**
  8848. * Defines the shadow projection clipping minimum z value.
  8849. */
  8850. shadowMinZ: number;
  8851. /**
  8852. * Defines the shadow projection clipping maximum z value.
  8853. */
  8854. shadowMaxZ: number;
  8855. /**
  8856. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8857. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8858. */
  8859. computeTransformedInformation(): boolean;
  8860. /**
  8861. * Gets the scene the light belongs to.
  8862. * @returns The scene
  8863. */
  8864. getScene(): Scene;
  8865. /**
  8866. * Callback defining a custom Projection Matrix Builder.
  8867. * This can be used to override the default projection matrix computation.
  8868. */
  8869. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8870. /**
  8871. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8872. * @param matrix The materix to updated with the projection information
  8873. * @param viewMatrix The transform matrix of the light
  8874. * @param renderList The list of mesh to render in the map
  8875. * @returns The current light
  8876. */
  8877. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8878. /**
  8879. * Gets the current depth scale used in ESM.
  8880. * @returns The scale
  8881. */
  8882. getDepthScale(): number;
  8883. /**
  8884. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8885. * @returns true if a cube texture needs to be use
  8886. */
  8887. needCube(): boolean;
  8888. /**
  8889. * Detects if the projection matrix requires to be recomputed this frame.
  8890. * @returns true if it requires to be recomputed otherwise, false.
  8891. */
  8892. needProjectionMatrixCompute(): boolean;
  8893. /**
  8894. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8895. */
  8896. forceProjectionMatrixCompute(): void;
  8897. /**
  8898. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8899. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8900. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8901. */
  8902. getShadowDirection(faceIndex?: number): Vector3;
  8903. /**
  8904. * Gets the minZ used for shadow according to both the scene and the light.
  8905. * @param activeCamera The camera we are returning the min for
  8906. * @returns the depth min z
  8907. */
  8908. getDepthMinZ(activeCamera: Camera): number;
  8909. /**
  8910. * Gets the maxZ used for shadow according to both the scene and the light.
  8911. * @param activeCamera The camera we are returning the max for
  8912. * @returns the depth max z
  8913. */
  8914. getDepthMaxZ(activeCamera: Camera): number;
  8915. }
  8916. /**
  8917. * Base implementation IShadowLight
  8918. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8919. */
  8920. export abstract class ShadowLight extends Light implements IShadowLight {
  8921. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8922. protected _position: Vector3;
  8923. protected _setPosition(value: Vector3): void;
  8924. /**
  8925. * Sets the position the shadow will be casted from. Also use as the light position for both
  8926. * point and spot lights.
  8927. */
  8928. get position(): Vector3;
  8929. /**
  8930. * Sets the position the shadow will be casted from. Also use as the light position for both
  8931. * point and spot lights.
  8932. */
  8933. set position(value: Vector3);
  8934. protected _direction: Vector3;
  8935. protected _setDirection(value: Vector3): void;
  8936. /**
  8937. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8938. * Also use as the light direction on spot and directional lights.
  8939. */
  8940. get direction(): Vector3;
  8941. /**
  8942. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8943. * Also use as the light direction on spot and directional lights.
  8944. */
  8945. set direction(value: Vector3);
  8946. protected _shadowMinZ: number;
  8947. /**
  8948. * Gets the shadow projection clipping minimum z value.
  8949. */
  8950. get shadowMinZ(): number;
  8951. /**
  8952. * Sets the shadow projection clipping minimum z value.
  8953. */
  8954. set shadowMinZ(value: number);
  8955. protected _shadowMaxZ: number;
  8956. /**
  8957. * Sets the shadow projection clipping maximum z value.
  8958. */
  8959. get shadowMaxZ(): number;
  8960. /**
  8961. * Gets the shadow projection clipping maximum z value.
  8962. */
  8963. set shadowMaxZ(value: number);
  8964. /**
  8965. * Callback defining a custom Projection Matrix Builder.
  8966. * This can be used to override the default projection matrix computation.
  8967. */
  8968. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8969. /**
  8970. * The transformed position. Position of the light in world space taking parenting in account.
  8971. */
  8972. transformedPosition: Vector3;
  8973. /**
  8974. * The transformed direction. Direction of the light in world space taking parenting in account.
  8975. */
  8976. transformedDirection: Vector3;
  8977. private _needProjectionMatrixCompute;
  8978. /**
  8979. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8980. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8981. */
  8982. computeTransformedInformation(): boolean;
  8983. /**
  8984. * Return the depth scale used for the shadow map.
  8985. * @returns the depth scale.
  8986. */
  8987. getDepthScale(): number;
  8988. /**
  8989. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8990. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8991. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8992. */
  8993. getShadowDirection(faceIndex?: number): Vector3;
  8994. /**
  8995. * Returns the ShadowLight absolute position in the World.
  8996. * @returns the position vector in world space
  8997. */
  8998. getAbsolutePosition(): Vector3;
  8999. /**
  9000. * Sets the ShadowLight direction toward the passed target.
  9001. * @param target The point to target in local space
  9002. * @returns the updated ShadowLight direction
  9003. */
  9004. setDirectionToTarget(target: Vector3): Vector3;
  9005. /**
  9006. * Returns the light rotation in euler definition.
  9007. * @returns the x y z rotation in local space.
  9008. */
  9009. getRotation(): Vector3;
  9010. /**
  9011. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9012. * @returns true if a cube texture needs to be use
  9013. */
  9014. needCube(): boolean;
  9015. /**
  9016. * Detects if the projection matrix requires to be recomputed this frame.
  9017. * @returns true if it requires to be recomputed otherwise, false.
  9018. */
  9019. needProjectionMatrixCompute(): boolean;
  9020. /**
  9021. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9022. */
  9023. forceProjectionMatrixCompute(): void;
  9024. /** @hidden */
  9025. _initCache(): void;
  9026. /** @hidden */
  9027. _isSynchronized(): boolean;
  9028. /**
  9029. * Computes the world matrix of the node
  9030. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9031. * @returns the world matrix
  9032. */
  9033. computeWorldMatrix(force?: boolean): Matrix;
  9034. /**
  9035. * Gets the minZ used for shadow according to both the scene and the light.
  9036. * @param activeCamera The camera we are returning the min for
  9037. * @returns the depth min z
  9038. */
  9039. getDepthMinZ(activeCamera: Camera): number;
  9040. /**
  9041. * Gets the maxZ used for shadow according to both the scene and the light.
  9042. * @param activeCamera The camera we are returning the max for
  9043. * @returns the depth max z
  9044. */
  9045. getDepthMaxZ(activeCamera: Camera): number;
  9046. /**
  9047. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9048. * @param matrix The materix to updated with the projection information
  9049. * @param viewMatrix The transform matrix of the light
  9050. * @param renderList The list of mesh to render in the map
  9051. * @returns The current light
  9052. */
  9053. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9054. }
  9055. }
  9056. declare module BABYLON {
  9057. /**
  9058. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9059. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9060. */
  9061. export class EffectFallbacks implements IEffectFallbacks {
  9062. private _defines;
  9063. private _currentRank;
  9064. private _maxRank;
  9065. private _mesh;
  9066. /**
  9067. * Removes the fallback from the bound mesh.
  9068. */
  9069. unBindMesh(): void;
  9070. /**
  9071. * Adds a fallback on the specified property.
  9072. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9073. * @param define The name of the define in the shader
  9074. */
  9075. addFallback(rank: number, define: string): void;
  9076. /**
  9077. * Sets the mesh to use CPU skinning when needing to fallback.
  9078. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9079. * @param mesh The mesh to use the fallbacks.
  9080. */
  9081. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9082. /**
  9083. * Checks to see if more fallbacks are still availible.
  9084. */
  9085. get hasMoreFallbacks(): boolean;
  9086. /**
  9087. * Removes the defines that should be removed when falling back.
  9088. * @param currentDefines defines the current define statements for the shader.
  9089. * @param effect defines the current effect we try to compile
  9090. * @returns The resulting defines with defines of the current rank removed.
  9091. */
  9092. reduce(currentDefines: string, effect: Effect): string;
  9093. }
  9094. }
  9095. declare module BABYLON {
  9096. /**
  9097. * "Static Class" containing the most commonly used helper while dealing with material for
  9098. * rendering purpose.
  9099. *
  9100. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9101. *
  9102. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9103. */
  9104. export class MaterialHelper {
  9105. /**
  9106. * Bind the current view position to an effect.
  9107. * @param effect The effect to be bound
  9108. * @param scene The scene the eyes position is used from
  9109. */
  9110. static BindEyePosition(effect: Effect, scene: Scene): void;
  9111. /**
  9112. * Helps preparing the defines values about the UVs in used in the effect.
  9113. * UVs are shared as much as we can accross channels in the shaders.
  9114. * @param texture The texture we are preparing the UVs for
  9115. * @param defines The defines to update
  9116. * @param key The channel key "diffuse", "specular"... used in the shader
  9117. */
  9118. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9119. /**
  9120. * Binds a texture matrix value to its corrsponding uniform
  9121. * @param texture The texture to bind the matrix for
  9122. * @param uniformBuffer The uniform buffer receivin the data
  9123. * @param key The channel key "diffuse", "specular"... used in the shader
  9124. */
  9125. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9126. /**
  9127. * Gets the current status of the fog (should it be enabled?)
  9128. * @param mesh defines the mesh to evaluate for fog support
  9129. * @param scene defines the hosting scene
  9130. * @returns true if fog must be enabled
  9131. */
  9132. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9133. /**
  9134. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9135. * @param mesh defines the current mesh
  9136. * @param scene defines the current scene
  9137. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9138. * @param pointsCloud defines if point cloud rendering has to be turned on
  9139. * @param fogEnabled defines if fog has to be turned on
  9140. * @param alphaTest defines if alpha testing has to be turned on
  9141. * @param defines defines the current list of defines
  9142. */
  9143. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9144. /**
  9145. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9146. * @param scene defines the current scene
  9147. * @param engine defines the current engine
  9148. * @param defines specifies the list of active defines
  9149. * @param useInstances defines if instances have to be turned on
  9150. * @param useClipPlane defines if clip plane have to be turned on
  9151. */
  9152. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9153. /**
  9154. * Prepares the defines for bones
  9155. * @param mesh The mesh containing the geometry data we will draw
  9156. * @param defines The defines to update
  9157. */
  9158. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9159. /**
  9160. * Prepares the defines for morph targets
  9161. * @param mesh The mesh containing the geometry data we will draw
  9162. * @param defines The defines to update
  9163. */
  9164. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9165. /**
  9166. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9167. * @param mesh The mesh containing the geometry data we will draw
  9168. * @param defines The defines to update
  9169. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9170. * @param useBones Precise whether bones should be used or not (override mesh info)
  9171. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9172. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9173. * @returns false if defines are considered not dirty and have not been checked
  9174. */
  9175. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9176. /**
  9177. * Prepares the defines related to multiview
  9178. * @param scene The scene we are intending to draw
  9179. * @param defines The defines to update
  9180. */
  9181. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9182. /**
  9183. * Prepares the defines related to the light information passed in parameter
  9184. * @param scene The scene we are intending to draw
  9185. * @param mesh The mesh the effect is compiling for
  9186. * @param light The light the effect is compiling for
  9187. * @param lightIndex The index of the light
  9188. * @param defines The defines to update
  9189. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9190. * @param state Defines the current state regarding what is needed (normals, etc...)
  9191. */
  9192. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9193. needNormals: boolean;
  9194. needRebuild: boolean;
  9195. shadowEnabled: boolean;
  9196. specularEnabled: boolean;
  9197. lightmapMode: boolean;
  9198. }): void;
  9199. /**
  9200. * Prepares the defines related to the light information passed in parameter
  9201. * @param scene The scene we are intending to draw
  9202. * @param mesh The mesh the effect is compiling for
  9203. * @param defines The defines to update
  9204. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9205. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9206. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9207. * @returns true if normals will be required for the rest of the effect
  9208. */
  9209. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9210. /**
  9211. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9212. * @param lightIndex defines the light index
  9213. * @param uniformsList The uniform list
  9214. * @param samplersList The sampler list
  9215. * @param projectedLightTexture defines if projected texture must be used
  9216. * @param uniformBuffersList defines an optional list of uniform buffers
  9217. */
  9218. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9219. /**
  9220. * Prepares the uniforms and samplers list to be used in the effect
  9221. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9222. * @param samplersList The sampler list
  9223. * @param defines The defines helping in the list generation
  9224. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9225. */
  9226. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9227. /**
  9228. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9229. * @param defines The defines to update while falling back
  9230. * @param fallbacks The authorized effect fallbacks
  9231. * @param maxSimultaneousLights The maximum number of lights allowed
  9232. * @param rank the current rank of the Effect
  9233. * @returns The newly affected rank
  9234. */
  9235. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9236. private static _TmpMorphInfluencers;
  9237. /**
  9238. * Prepares the list of attributes required for morph targets according to the effect defines.
  9239. * @param attribs The current list of supported attribs
  9240. * @param mesh The mesh to prepare the morph targets attributes for
  9241. * @param influencers The number of influencers
  9242. */
  9243. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9244. /**
  9245. * Prepares the list of attributes required for morph targets according to the effect defines.
  9246. * @param attribs The current list of supported attribs
  9247. * @param mesh The mesh to prepare the morph targets attributes for
  9248. * @param defines The current Defines of the effect
  9249. */
  9250. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9251. /**
  9252. * Prepares the list of attributes required for bones according to the effect defines.
  9253. * @param attribs The current list of supported attribs
  9254. * @param mesh The mesh to prepare the bones attributes for
  9255. * @param defines The current Defines of the effect
  9256. * @param fallbacks The current efffect fallback strategy
  9257. */
  9258. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9259. /**
  9260. * Check and prepare the list of attributes required for instances according to the effect defines.
  9261. * @param attribs The current list of supported attribs
  9262. * @param defines The current MaterialDefines of the effect
  9263. */
  9264. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9265. /**
  9266. * Add the list of attributes required for instances to the attribs array.
  9267. * @param attribs The current list of supported attribs
  9268. */
  9269. static PushAttributesForInstances(attribs: string[]): void;
  9270. /**
  9271. * Binds the light information to the effect.
  9272. * @param light The light containing the generator
  9273. * @param effect The effect we are binding the data to
  9274. * @param lightIndex The light index in the effect used to render
  9275. */
  9276. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9277. /**
  9278. * Binds the lights information from the scene to the effect for the given mesh.
  9279. * @param light Light to bind
  9280. * @param lightIndex Light index
  9281. * @param scene The scene where the light belongs to
  9282. * @param effect The effect we are binding the data to
  9283. * @param useSpecular Defines if specular is supported
  9284. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9285. */
  9286. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9287. /**
  9288. * Binds the lights information from the scene to the effect for the given mesh.
  9289. * @param scene The scene the lights belongs to
  9290. * @param mesh The mesh we are binding the information to render
  9291. * @param effect The effect we are binding the data to
  9292. * @param defines The generated defines for the effect
  9293. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9294. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9295. */
  9296. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9297. private static _tempFogColor;
  9298. /**
  9299. * Binds the fog information from the scene to the effect for the given mesh.
  9300. * @param scene The scene the lights belongs to
  9301. * @param mesh The mesh we are binding the information to render
  9302. * @param effect The effect we are binding the data to
  9303. * @param linearSpace Defines if the fog effect is applied in linear space
  9304. */
  9305. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9306. /**
  9307. * Binds the bones information from the mesh to the effect.
  9308. * @param mesh The mesh we are binding the information to render
  9309. * @param effect The effect we are binding the data to
  9310. */
  9311. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9312. /**
  9313. * Binds the morph targets information from the mesh to the effect.
  9314. * @param abstractMesh The mesh we are binding the information to render
  9315. * @param effect The effect we are binding the data to
  9316. */
  9317. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9318. /**
  9319. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9320. * @param defines The generated defines used in the effect
  9321. * @param effect The effect we are binding the data to
  9322. * @param scene The scene we are willing to render with logarithmic scale for
  9323. */
  9324. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9325. /**
  9326. * Binds the clip plane information from the scene to the effect.
  9327. * @param scene The scene the clip plane information are extracted from
  9328. * @param effect The effect we are binding the data to
  9329. */
  9330. static BindClipPlane(effect: Effect, scene: Scene): void;
  9331. }
  9332. }
  9333. declare module BABYLON {
  9334. /** @hidden */
  9335. export var packingFunctions: {
  9336. name: string;
  9337. shader: string;
  9338. };
  9339. }
  9340. declare module BABYLON {
  9341. /** @hidden */
  9342. export var clipPlaneFragmentDeclaration: {
  9343. name: string;
  9344. shader: string;
  9345. };
  9346. }
  9347. declare module BABYLON {
  9348. /** @hidden */
  9349. export var clipPlaneFragment: {
  9350. name: string;
  9351. shader: string;
  9352. };
  9353. }
  9354. declare module BABYLON {
  9355. /** @hidden */
  9356. export var shadowMapPixelShader: {
  9357. name: string;
  9358. shader: string;
  9359. };
  9360. }
  9361. declare module BABYLON {
  9362. /** @hidden */
  9363. export var bonesDeclaration: {
  9364. name: string;
  9365. shader: string;
  9366. };
  9367. }
  9368. declare module BABYLON {
  9369. /** @hidden */
  9370. export var morphTargetsVertexGlobalDeclaration: {
  9371. name: string;
  9372. shader: string;
  9373. };
  9374. }
  9375. declare module BABYLON {
  9376. /** @hidden */
  9377. export var morphTargetsVertexDeclaration: {
  9378. name: string;
  9379. shader: string;
  9380. };
  9381. }
  9382. declare module BABYLON {
  9383. /** @hidden */
  9384. export var instancesDeclaration: {
  9385. name: string;
  9386. shader: string;
  9387. };
  9388. }
  9389. declare module BABYLON {
  9390. /** @hidden */
  9391. export var helperFunctions: {
  9392. name: string;
  9393. shader: string;
  9394. };
  9395. }
  9396. declare module BABYLON {
  9397. /** @hidden */
  9398. export var clipPlaneVertexDeclaration: {
  9399. name: string;
  9400. shader: string;
  9401. };
  9402. }
  9403. declare module BABYLON {
  9404. /** @hidden */
  9405. export var morphTargetsVertex: {
  9406. name: string;
  9407. shader: string;
  9408. };
  9409. }
  9410. declare module BABYLON {
  9411. /** @hidden */
  9412. export var instancesVertex: {
  9413. name: string;
  9414. shader: string;
  9415. };
  9416. }
  9417. declare module BABYLON {
  9418. /** @hidden */
  9419. export var bonesVertex: {
  9420. name: string;
  9421. shader: string;
  9422. };
  9423. }
  9424. declare module BABYLON {
  9425. /** @hidden */
  9426. export var clipPlaneVertex: {
  9427. name: string;
  9428. shader: string;
  9429. };
  9430. }
  9431. declare module BABYLON {
  9432. /** @hidden */
  9433. export var shadowMapVertexShader: {
  9434. name: string;
  9435. shader: string;
  9436. };
  9437. }
  9438. declare module BABYLON {
  9439. /** @hidden */
  9440. export var depthBoxBlurPixelShader: {
  9441. name: string;
  9442. shader: string;
  9443. };
  9444. }
  9445. declare module BABYLON {
  9446. /**
  9447. * Class representing a ray with position and direction
  9448. */
  9449. export class Ray {
  9450. /** origin point */
  9451. origin: Vector3;
  9452. /** direction */
  9453. direction: Vector3;
  9454. /** length of the ray */
  9455. length: number;
  9456. private static readonly TmpVector3;
  9457. private _tmpRay;
  9458. /**
  9459. * Creates a new ray
  9460. * @param origin origin point
  9461. * @param direction direction
  9462. * @param length length of the ray
  9463. */
  9464. constructor(
  9465. /** origin point */
  9466. origin: Vector3,
  9467. /** direction */
  9468. direction: Vector3,
  9469. /** length of the ray */
  9470. length?: number);
  9471. /**
  9472. * Checks if the ray intersects a box
  9473. * @param minimum bound of the box
  9474. * @param maximum bound of the box
  9475. * @param intersectionTreshold extra extend to be added to the box in all direction
  9476. * @returns if the box was hit
  9477. */
  9478. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9479. /**
  9480. * Checks if the ray intersects a box
  9481. * @param box the bounding box to check
  9482. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9483. * @returns if the box was hit
  9484. */
  9485. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9486. /**
  9487. * If the ray hits a sphere
  9488. * @param sphere the bounding sphere to check
  9489. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9490. * @returns true if it hits the sphere
  9491. */
  9492. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9493. /**
  9494. * If the ray hits a triange
  9495. * @param vertex0 triangle vertex
  9496. * @param vertex1 triangle vertex
  9497. * @param vertex2 triangle vertex
  9498. * @returns intersection information if hit
  9499. */
  9500. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9501. /**
  9502. * Checks if ray intersects a plane
  9503. * @param plane the plane to check
  9504. * @returns the distance away it was hit
  9505. */
  9506. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9507. /**
  9508. * Calculate the intercept of a ray on a given axis
  9509. * @param axis to check 'x' | 'y' | 'z'
  9510. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9511. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9512. */
  9513. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9514. /**
  9515. * Checks if ray intersects a mesh
  9516. * @param mesh the mesh to check
  9517. * @param fastCheck if only the bounding box should checked
  9518. * @returns picking info of the intersecton
  9519. */
  9520. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9521. /**
  9522. * Checks if ray intersects a mesh
  9523. * @param meshes the meshes to check
  9524. * @param fastCheck if only the bounding box should checked
  9525. * @param results array to store result in
  9526. * @returns Array of picking infos
  9527. */
  9528. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9529. private _comparePickingInfo;
  9530. private static smallnum;
  9531. private static rayl;
  9532. /**
  9533. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9534. * @param sega the first point of the segment to test the intersection against
  9535. * @param segb the second point of the segment to test the intersection against
  9536. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9537. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9538. */
  9539. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9540. /**
  9541. * Update the ray from viewport position
  9542. * @param x position
  9543. * @param y y position
  9544. * @param viewportWidth viewport width
  9545. * @param viewportHeight viewport height
  9546. * @param world world matrix
  9547. * @param view view matrix
  9548. * @param projection projection matrix
  9549. * @returns this ray updated
  9550. */
  9551. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9552. /**
  9553. * Creates a ray with origin and direction of 0,0,0
  9554. * @returns the new ray
  9555. */
  9556. static Zero(): Ray;
  9557. /**
  9558. * Creates a new ray from screen space and viewport
  9559. * @param x position
  9560. * @param y y position
  9561. * @param viewportWidth viewport width
  9562. * @param viewportHeight viewport height
  9563. * @param world world matrix
  9564. * @param view view matrix
  9565. * @param projection projection matrix
  9566. * @returns new ray
  9567. */
  9568. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9569. /**
  9570. * 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
  9571. * transformed to the given world matrix.
  9572. * @param origin The origin point
  9573. * @param end The end point
  9574. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9575. * @returns the new ray
  9576. */
  9577. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9578. /**
  9579. * Transforms a ray by a matrix
  9580. * @param ray ray to transform
  9581. * @param matrix matrix to apply
  9582. * @returns the resulting new ray
  9583. */
  9584. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9585. /**
  9586. * Transforms a ray by a matrix
  9587. * @param ray ray to transform
  9588. * @param matrix matrix to apply
  9589. * @param result ray to store result in
  9590. */
  9591. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9592. /**
  9593. * Unproject a ray from screen space to object space
  9594. * @param sourceX defines the screen space x coordinate to use
  9595. * @param sourceY defines the screen space y coordinate to use
  9596. * @param viewportWidth defines the current width of the viewport
  9597. * @param viewportHeight defines the current height of the viewport
  9598. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9599. * @param view defines the view matrix to use
  9600. * @param projection defines the projection matrix to use
  9601. */
  9602. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9603. }
  9604. /**
  9605. * Type used to define predicate used to select faces when a mesh intersection is detected
  9606. */
  9607. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9608. interface Scene {
  9609. /** @hidden */
  9610. _tempPickingRay: Nullable<Ray>;
  9611. /** @hidden */
  9612. _cachedRayForTransform: Ray;
  9613. /** @hidden */
  9614. _pickWithRayInverseMatrix: Matrix;
  9615. /** @hidden */
  9616. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9617. /** @hidden */
  9618. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9619. }
  9620. }
  9621. declare module BABYLON {
  9622. /**
  9623. * Groups all the scene component constants in one place to ease maintenance.
  9624. * @hidden
  9625. */
  9626. export class SceneComponentConstants {
  9627. static readonly NAME_EFFECTLAYER: string;
  9628. static readonly NAME_LAYER: string;
  9629. static readonly NAME_LENSFLARESYSTEM: string;
  9630. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9631. static readonly NAME_PARTICLESYSTEM: string;
  9632. static readonly NAME_GAMEPAD: string;
  9633. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9634. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9635. static readonly NAME_DEPTHRENDERER: string;
  9636. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9637. static readonly NAME_SPRITE: string;
  9638. static readonly NAME_OUTLINERENDERER: string;
  9639. static readonly NAME_PROCEDURALTEXTURE: string;
  9640. static readonly NAME_SHADOWGENERATOR: string;
  9641. static readonly NAME_OCTREE: string;
  9642. static readonly NAME_PHYSICSENGINE: string;
  9643. static readonly NAME_AUDIO: string;
  9644. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9645. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9646. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9647. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9648. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9649. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9650. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9651. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9652. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9653. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9654. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9655. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9656. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9657. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9658. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9659. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9660. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9661. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9662. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9663. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9664. static readonly STEP_AFTERRENDER_AUDIO: number;
  9665. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9666. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9667. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9668. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9669. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9670. static readonly STEP_POINTERMOVE_SPRITE: number;
  9671. static readonly STEP_POINTERDOWN_SPRITE: number;
  9672. static readonly STEP_POINTERUP_SPRITE: number;
  9673. }
  9674. /**
  9675. * This represents a scene component.
  9676. *
  9677. * This is used to decouple the dependency the scene is having on the different workloads like
  9678. * layers, post processes...
  9679. */
  9680. export interface ISceneComponent {
  9681. /**
  9682. * The name of the component. Each component must have a unique name.
  9683. */
  9684. name: string;
  9685. /**
  9686. * The scene the component belongs to.
  9687. */
  9688. scene: Scene;
  9689. /**
  9690. * Register the component to one instance of a scene.
  9691. */
  9692. register(): void;
  9693. /**
  9694. * Rebuilds the elements related to this component in case of
  9695. * context lost for instance.
  9696. */
  9697. rebuild(): void;
  9698. /**
  9699. * Disposes the component and the associated ressources.
  9700. */
  9701. dispose(): void;
  9702. }
  9703. /**
  9704. * This represents a SERIALIZABLE scene component.
  9705. *
  9706. * This extends Scene Component to add Serialization methods on top.
  9707. */
  9708. export interface ISceneSerializableComponent extends ISceneComponent {
  9709. /**
  9710. * Adds all the elements from the container to the scene
  9711. * @param container the container holding the elements
  9712. */
  9713. addFromContainer(container: AbstractScene): void;
  9714. /**
  9715. * Removes all the elements in the container from the scene
  9716. * @param container contains the elements to remove
  9717. * @param dispose if the removed element should be disposed (default: false)
  9718. */
  9719. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9720. /**
  9721. * Serializes the component data to the specified json object
  9722. * @param serializationObject The object to serialize to
  9723. */
  9724. serialize(serializationObject: any): void;
  9725. }
  9726. /**
  9727. * Strong typing of a Mesh related stage step action
  9728. */
  9729. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9730. /**
  9731. * Strong typing of a Evaluate Sub Mesh related stage step action
  9732. */
  9733. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9734. /**
  9735. * Strong typing of a Active Mesh related stage step action
  9736. */
  9737. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9738. /**
  9739. * Strong typing of a Camera related stage step action
  9740. */
  9741. export type CameraStageAction = (camera: Camera) => void;
  9742. /**
  9743. * Strong typing of a Camera Frame buffer related stage step action
  9744. */
  9745. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9746. /**
  9747. * Strong typing of a Render Target related stage step action
  9748. */
  9749. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9750. /**
  9751. * Strong typing of a RenderingGroup related stage step action
  9752. */
  9753. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9754. /**
  9755. * Strong typing of a Mesh Render related stage step action
  9756. */
  9757. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9758. /**
  9759. * Strong typing of a simple stage step action
  9760. */
  9761. export type SimpleStageAction = () => void;
  9762. /**
  9763. * Strong typing of a render target action.
  9764. */
  9765. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9766. /**
  9767. * Strong typing of a pointer move action.
  9768. */
  9769. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9770. /**
  9771. * Strong typing of a pointer up/down action.
  9772. */
  9773. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9774. /**
  9775. * Representation of a stage in the scene (Basically a list of ordered steps)
  9776. * @hidden
  9777. */
  9778. export class Stage<T extends Function> extends Array<{
  9779. index: number;
  9780. component: ISceneComponent;
  9781. action: T;
  9782. }> {
  9783. /**
  9784. * Hide ctor from the rest of the world.
  9785. * @param items The items to add.
  9786. */
  9787. private constructor();
  9788. /**
  9789. * Creates a new Stage.
  9790. * @returns A new instance of a Stage
  9791. */
  9792. static Create<T extends Function>(): Stage<T>;
  9793. /**
  9794. * Registers a step in an ordered way in the targeted stage.
  9795. * @param index Defines the position to register the step in
  9796. * @param component Defines the component attached to the step
  9797. * @param action Defines the action to launch during the step
  9798. */
  9799. registerStep(index: number, component: ISceneComponent, action: T): void;
  9800. /**
  9801. * Clears all the steps from the stage.
  9802. */
  9803. clear(): void;
  9804. }
  9805. }
  9806. declare module BABYLON {
  9807. interface Scene {
  9808. /** @hidden */
  9809. _pointerOverSprite: Nullable<Sprite>;
  9810. /** @hidden */
  9811. _pickedDownSprite: Nullable<Sprite>;
  9812. /** @hidden */
  9813. _tempSpritePickingRay: Nullable<Ray>;
  9814. /**
  9815. * All of the sprite managers added to this scene
  9816. * @see http://doc.babylonjs.com/babylon101/sprites
  9817. */
  9818. spriteManagers: Array<ISpriteManager>;
  9819. /**
  9820. * An event triggered when sprites rendering is about to start
  9821. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9822. */
  9823. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9824. /**
  9825. * An event triggered when sprites rendering is done
  9826. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9827. */
  9828. onAfterSpritesRenderingObservable: Observable<Scene>;
  9829. /** @hidden */
  9830. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9831. /** Launch a ray to try to pick a sprite in the scene
  9832. * @param x position on screen
  9833. * @param y position on screen
  9834. * @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
  9835. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9836. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9837. * @returns a PickingInfo
  9838. */
  9839. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9840. /** Use the given ray to pick a sprite in the scene
  9841. * @param ray The ray (in world space) to use to pick meshes
  9842. * @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
  9843. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9844. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9845. * @returns a PickingInfo
  9846. */
  9847. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9848. /** @hidden */
  9849. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9850. /** Launch a ray to try to pick sprites in the scene
  9851. * @param x position on screen
  9852. * @param y position on screen
  9853. * @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
  9854. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9855. * @returns a PickingInfo array
  9856. */
  9857. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9858. /** Use the given ray to pick sprites in the scene
  9859. * @param ray The ray (in world space) to use to pick meshes
  9860. * @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
  9861. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9862. * @returns a PickingInfo array
  9863. */
  9864. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9865. /**
  9866. * Force the sprite under the pointer
  9867. * @param sprite defines the sprite to use
  9868. */
  9869. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9870. /**
  9871. * Gets the sprite under the pointer
  9872. * @returns a Sprite or null if no sprite is under the pointer
  9873. */
  9874. getPointerOverSprite(): Nullable<Sprite>;
  9875. }
  9876. /**
  9877. * Defines the sprite scene component responsible to manage sprites
  9878. * in a given scene.
  9879. */
  9880. export class SpriteSceneComponent implements ISceneComponent {
  9881. /**
  9882. * The component name helpfull to identify the component in the list of scene components.
  9883. */
  9884. readonly name: string;
  9885. /**
  9886. * The scene the component belongs to.
  9887. */
  9888. scene: Scene;
  9889. /** @hidden */
  9890. private _spritePredicate;
  9891. /**
  9892. * Creates a new instance of the component for the given scene
  9893. * @param scene Defines the scene to register the component in
  9894. */
  9895. constructor(scene: Scene);
  9896. /**
  9897. * Registers the component in a given scene
  9898. */
  9899. register(): void;
  9900. /**
  9901. * Rebuilds the elements related to this component in case of
  9902. * context lost for instance.
  9903. */
  9904. rebuild(): void;
  9905. /**
  9906. * Disposes the component and the associated ressources.
  9907. */
  9908. dispose(): void;
  9909. private _pickSpriteButKeepRay;
  9910. private _pointerMove;
  9911. private _pointerDown;
  9912. private _pointerUp;
  9913. }
  9914. }
  9915. declare module BABYLON {
  9916. /** @hidden */
  9917. export var fogFragmentDeclaration: {
  9918. name: string;
  9919. shader: string;
  9920. };
  9921. }
  9922. declare module BABYLON {
  9923. /** @hidden */
  9924. export var fogFragment: {
  9925. name: string;
  9926. shader: string;
  9927. };
  9928. }
  9929. declare module BABYLON {
  9930. /** @hidden */
  9931. export var spritesPixelShader: {
  9932. name: string;
  9933. shader: string;
  9934. };
  9935. }
  9936. declare module BABYLON {
  9937. /** @hidden */
  9938. export var fogVertexDeclaration: {
  9939. name: string;
  9940. shader: string;
  9941. };
  9942. }
  9943. declare module BABYLON {
  9944. /** @hidden */
  9945. export var spritesVertexShader: {
  9946. name: string;
  9947. shader: string;
  9948. };
  9949. }
  9950. declare module BABYLON {
  9951. /**
  9952. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9953. */
  9954. export interface ISpriteManager extends IDisposable {
  9955. /**
  9956. * Restricts the camera to viewing objects with the same layerMask.
  9957. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  9958. */
  9959. layerMask: number;
  9960. /**
  9961. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  9962. */
  9963. isPickable: boolean;
  9964. /**
  9965. * Specifies the rendering group id for this mesh (0 by default)
  9966. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  9967. */
  9968. renderingGroupId: number;
  9969. /**
  9970. * Defines the list of sprites managed by the manager.
  9971. */
  9972. sprites: Array<Sprite>;
  9973. /**
  9974. * Tests the intersection of a sprite with a specific ray.
  9975. * @param ray The ray we are sending to test the collision
  9976. * @param camera The camera space we are sending rays in
  9977. * @param predicate A predicate allowing excluding sprites from the list of object to test
  9978. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  9979. * @returns picking info or null.
  9980. */
  9981. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  9982. /**
  9983. * Intersects the sprites with a ray
  9984. * @param ray defines the ray to intersect with
  9985. * @param camera defines the current active camera
  9986. * @param predicate defines a predicate used to select candidate sprites
  9987. * @returns null if no hit or a PickingInfo array
  9988. */
  9989. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  9990. /**
  9991. * Renders the list of sprites on screen.
  9992. */
  9993. render(): void;
  9994. }
  9995. /**
  9996. * Class used to manage multiple sprites on the same spritesheet
  9997. * @see http://doc.babylonjs.com/babylon101/sprites
  9998. */
  9999. export class SpriteManager implements ISpriteManager {
  10000. /** defines the manager's name */
  10001. name: string;
  10002. /** Gets the list of sprites */
  10003. sprites: Sprite[];
  10004. /** Gets or sets the rendering group id (0 by default) */
  10005. renderingGroupId: number;
  10006. /** Gets or sets camera layer mask */
  10007. layerMask: number;
  10008. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10009. fogEnabled: boolean;
  10010. /** Gets or sets a boolean indicating if the sprites are pickable */
  10011. isPickable: boolean;
  10012. /** Defines the default width of a cell in the spritesheet */
  10013. cellWidth: number;
  10014. /** Defines the default height of a cell in the spritesheet */
  10015. cellHeight: number;
  10016. /** Associative array from JSON sprite data file */
  10017. private _cellData;
  10018. /** Array of sprite names from JSON sprite data file */
  10019. private _spriteMap;
  10020. /** True when packed cell data from JSON file is ready*/
  10021. private _packedAndReady;
  10022. /**
  10023. * An event triggered when the manager is disposed.
  10024. */
  10025. onDisposeObservable: Observable<SpriteManager>;
  10026. private _onDisposeObserver;
  10027. /**
  10028. * Callback called when the manager is disposed
  10029. */
  10030. set onDispose(callback: () => void);
  10031. private _capacity;
  10032. private _fromPacked;
  10033. private _spriteTexture;
  10034. private _epsilon;
  10035. private _scene;
  10036. private _vertexData;
  10037. private _buffer;
  10038. private _vertexBuffers;
  10039. private _indexBuffer;
  10040. private _effectBase;
  10041. private _effectFog;
  10042. /**
  10043. * Gets or sets the spritesheet texture
  10044. */
  10045. get texture(): Texture;
  10046. set texture(value: Texture);
  10047. private _blendMode;
  10048. /**
  10049. * Blend mode use to render the particle, it can be any of
  10050. * the static Constants.ALPHA_x properties provided in this class.
  10051. * Default value is Constants.ALPHA_COMBINE
  10052. */
  10053. get blendMode(): number;
  10054. set blendMode(blendMode: number);
  10055. /** Disables writing to the depth buffer when rendering the sprites.
  10056. * It can be handy to disable depth writing when using textures without alpha channel
  10057. * and setting some specific blend modes.
  10058. */
  10059. disableDepthWrite: boolean;
  10060. /**
  10061. * Creates a new sprite manager
  10062. * @param name defines the manager's name
  10063. * @param imgUrl defines the sprite sheet url
  10064. * @param capacity defines the maximum allowed number of sprites
  10065. * @param cellSize defines the size of a sprite cell
  10066. * @param scene defines the hosting scene
  10067. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10068. * @param samplingMode defines the smapling mode to use with spritesheet
  10069. * @param fromPacked set to false; do not alter
  10070. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10071. */
  10072. constructor(
  10073. /** defines the manager's name */
  10074. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10075. private _makePacked;
  10076. private _appendSpriteVertex;
  10077. /**
  10078. * Intersects the sprites with a ray
  10079. * @param ray defines the ray to intersect with
  10080. * @param camera defines the current active camera
  10081. * @param predicate defines a predicate used to select candidate sprites
  10082. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10083. * @returns null if no hit or a PickingInfo
  10084. */
  10085. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10086. /**
  10087. * Intersects the sprites with a ray
  10088. * @param ray defines the ray to intersect with
  10089. * @param camera defines the current active camera
  10090. * @param predicate defines a predicate used to select candidate sprites
  10091. * @returns null if no hit or a PickingInfo array
  10092. */
  10093. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10094. /**
  10095. * Render all child sprites
  10096. */
  10097. render(): void;
  10098. /**
  10099. * Release associated resources
  10100. */
  10101. dispose(): void;
  10102. }
  10103. }
  10104. declare module BABYLON {
  10105. /** Interface used by value gradients (color, factor, ...) */
  10106. export interface IValueGradient {
  10107. /**
  10108. * Gets or sets the gradient value (between 0 and 1)
  10109. */
  10110. gradient: number;
  10111. }
  10112. /** Class used to store color4 gradient */
  10113. export class ColorGradient implements IValueGradient {
  10114. /**
  10115. * Gets or sets the gradient value (between 0 and 1)
  10116. */
  10117. gradient: number;
  10118. /**
  10119. * Gets or sets first associated color
  10120. */
  10121. color1: Color4;
  10122. /**
  10123. * Gets or sets second associated color
  10124. */
  10125. color2?: Color4 | undefined;
  10126. /**
  10127. * Creates a new color4 gradient
  10128. * @param gradient gets or sets the gradient value (between 0 and 1)
  10129. * @param color1 gets or sets first associated color
  10130. * @param color2 gets or sets first second color
  10131. */
  10132. constructor(
  10133. /**
  10134. * Gets or sets the gradient value (between 0 and 1)
  10135. */
  10136. gradient: number,
  10137. /**
  10138. * Gets or sets first associated color
  10139. */
  10140. color1: Color4,
  10141. /**
  10142. * Gets or sets second associated color
  10143. */
  10144. color2?: Color4 | undefined);
  10145. /**
  10146. * Will get a color picked randomly between color1 and color2.
  10147. * If color2 is undefined then color1 will be used
  10148. * @param result defines the target Color4 to store the result in
  10149. */
  10150. getColorToRef(result: Color4): void;
  10151. }
  10152. /** Class used to store color 3 gradient */
  10153. export class Color3Gradient implements IValueGradient {
  10154. /**
  10155. * Gets or sets the gradient value (between 0 and 1)
  10156. */
  10157. gradient: number;
  10158. /**
  10159. * Gets or sets the associated color
  10160. */
  10161. color: Color3;
  10162. /**
  10163. * Creates a new color3 gradient
  10164. * @param gradient gets or sets the gradient value (between 0 and 1)
  10165. * @param color gets or sets associated color
  10166. */
  10167. constructor(
  10168. /**
  10169. * Gets or sets the gradient value (between 0 and 1)
  10170. */
  10171. gradient: number,
  10172. /**
  10173. * Gets or sets the associated color
  10174. */
  10175. color: Color3);
  10176. }
  10177. /** Class used to store factor gradient */
  10178. export class FactorGradient implements IValueGradient {
  10179. /**
  10180. * Gets or sets the gradient value (between 0 and 1)
  10181. */
  10182. gradient: number;
  10183. /**
  10184. * Gets or sets first associated factor
  10185. */
  10186. factor1: number;
  10187. /**
  10188. * Gets or sets second associated factor
  10189. */
  10190. factor2?: number | undefined;
  10191. /**
  10192. * Creates a new factor gradient
  10193. * @param gradient gets or sets the gradient value (between 0 and 1)
  10194. * @param factor1 gets or sets first associated factor
  10195. * @param factor2 gets or sets second associated factor
  10196. */
  10197. constructor(
  10198. /**
  10199. * Gets or sets the gradient value (between 0 and 1)
  10200. */
  10201. gradient: number,
  10202. /**
  10203. * Gets or sets first associated factor
  10204. */
  10205. factor1: number,
  10206. /**
  10207. * Gets or sets second associated factor
  10208. */
  10209. factor2?: number | undefined);
  10210. /**
  10211. * Will get a number picked randomly between factor1 and factor2.
  10212. * If factor2 is undefined then factor1 will be used
  10213. * @returns the picked number
  10214. */
  10215. getFactor(): number;
  10216. }
  10217. /**
  10218. * Helper used to simplify some generic gradient tasks
  10219. */
  10220. export class GradientHelper {
  10221. /**
  10222. * Gets the current gradient from an array of IValueGradient
  10223. * @param ratio defines the current ratio to get
  10224. * @param gradients defines the array of IValueGradient
  10225. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10226. */
  10227. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10228. }
  10229. }
  10230. declare module BABYLON {
  10231. /**
  10232. * Interface for the size containing width and height
  10233. */
  10234. export interface ISize {
  10235. /**
  10236. * Width
  10237. */
  10238. width: number;
  10239. /**
  10240. * Heighht
  10241. */
  10242. height: number;
  10243. }
  10244. /**
  10245. * Size containing widht and height
  10246. */
  10247. export class Size implements ISize {
  10248. /**
  10249. * Width
  10250. */
  10251. width: number;
  10252. /**
  10253. * Height
  10254. */
  10255. height: number;
  10256. /**
  10257. * Creates a Size object from the given width and height (floats).
  10258. * @param width width of the new size
  10259. * @param height height of the new size
  10260. */
  10261. constructor(width: number, height: number);
  10262. /**
  10263. * Returns a string with the Size width and height
  10264. * @returns a string with the Size width and height
  10265. */
  10266. toString(): string;
  10267. /**
  10268. * "Size"
  10269. * @returns the string "Size"
  10270. */
  10271. getClassName(): string;
  10272. /**
  10273. * Returns the Size hash code.
  10274. * @returns a hash code for a unique width and height
  10275. */
  10276. getHashCode(): number;
  10277. /**
  10278. * Updates the current size from the given one.
  10279. * @param src the given size
  10280. */
  10281. copyFrom(src: Size): void;
  10282. /**
  10283. * Updates in place the current Size from the given floats.
  10284. * @param width width of the new size
  10285. * @param height height of the new size
  10286. * @returns the updated Size.
  10287. */
  10288. copyFromFloats(width: number, height: number): Size;
  10289. /**
  10290. * Updates in place the current Size from the given floats.
  10291. * @param width width to set
  10292. * @param height height to set
  10293. * @returns the updated Size.
  10294. */
  10295. set(width: number, height: number): Size;
  10296. /**
  10297. * Multiplies the width and height by numbers
  10298. * @param w factor to multiple the width by
  10299. * @param h factor to multiple the height by
  10300. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10301. */
  10302. multiplyByFloats(w: number, h: number): Size;
  10303. /**
  10304. * Clones the size
  10305. * @returns a new Size copied from the given one.
  10306. */
  10307. clone(): Size;
  10308. /**
  10309. * True if the current Size and the given one width and height are strictly equal.
  10310. * @param other the other size to compare against
  10311. * @returns True if the current Size and the given one width and height are strictly equal.
  10312. */
  10313. equals(other: Size): boolean;
  10314. /**
  10315. * The surface of the Size : width * height (float).
  10316. */
  10317. get surface(): number;
  10318. /**
  10319. * Create a new size of zero
  10320. * @returns a new Size set to (0.0, 0.0)
  10321. */
  10322. static Zero(): Size;
  10323. /**
  10324. * Sums the width and height of two sizes
  10325. * @param otherSize size to add to this size
  10326. * @returns a new Size set as the addition result of the current Size and the given one.
  10327. */
  10328. add(otherSize: Size): Size;
  10329. /**
  10330. * Subtracts the width and height of two
  10331. * @param otherSize size to subtract to this size
  10332. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10333. */
  10334. subtract(otherSize: Size): Size;
  10335. /**
  10336. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10337. * @param start starting size to lerp between
  10338. * @param end end size to lerp between
  10339. * @param amount amount to lerp between the start and end values
  10340. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10341. */
  10342. static Lerp(start: Size, end: Size, amount: number): Size;
  10343. }
  10344. }
  10345. declare module BABYLON {
  10346. interface ThinEngine {
  10347. /**
  10348. * Creates a dynamic texture
  10349. * @param width defines the width of the texture
  10350. * @param height defines the height of the texture
  10351. * @param generateMipMaps defines if the engine should generate the mip levels
  10352. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10353. * @returns the dynamic texture inside an InternalTexture
  10354. */
  10355. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10356. /**
  10357. * Update the content of a dynamic texture
  10358. * @param texture defines the texture to update
  10359. * @param canvas defines the canvas containing the source
  10360. * @param invertY defines if data must be stored with Y axis inverted
  10361. * @param premulAlpha defines if alpha is stored as premultiplied
  10362. * @param format defines the format of the data
  10363. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10364. */
  10365. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10366. }
  10367. }
  10368. declare module BABYLON {
  10369. /**
  10370. * Helper class used to generate a canvas to manipulate images
  10371. */
  10372. export class CanvasGenerator {
  10373. /**
  10374. * Create a new canvas (or offscreen canvas depending on the context)
  10375. * @param width defines the expected width
  10376. * @param height defines the expected height
  10377. * @return a new canvas or offscreen canvas
  10378. */
  10379. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10380. }
  10381. }
  10382. declare module BABYLON {
  10383. /**
  10384. * A class extending Texture allowing drawing on a texture
  10385. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10386. */
  10387. export class DynamicTexture extends Texture {
  10388. private _generateMipMaps;
  10389. private _canvas;
  10390. private _context;
  10391. private _engine;
  10392. /**
  10393. * Creates a DynamicTexture
  10394. * @param name defines the name of the texture
  10395. * @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
  10396. * @param scene defines the scene where you want the texture
  10397. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10398. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10399. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10400. */
  10401. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10402. /**
  10403. * Get the current class name of the texture useful for serialization or dynamic coding.
  10404. * @returns "DynamicTexture"
  10405. */
  10406. getClassName(): string;
  10407. /**
  10408. * Gets the current state of canRescale
  10409. */
  10410. get canRescale(): boolean;
  10411. private _recreate;
  10412. /**
  10413. * Scales the texture
  10414. * @param ratio the scale factor to apply to both width and height
  10415. */
  10416. scale(ratio: number): void;
  10417. /**
  10418. * Resizes the texture
  10419. * @param width the new width
  10420. * @param height the new height
  10421. */
  10422. scaleTo(width: number, height: number): void;
  10423. /**
  10424. * Gets the context of the canvas used by the texture
  10425. * @returns the canvas context of the dynamic texture
  10426. */
  10427. getContext(): CanvasRenderingContext2D;
  10428. /**
  10429. * Clears the texture
  10430. */
  10431. clear(): void;
  10432. /**
  10433. * Updates the texture
  10434. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10435. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10436. */
  10437. update(invertY?: boolean, premulAlpha?: boolean): void;
  10438. /**
  10439. * Draws text onto the texture
  10440. * @param text defines the text to be drawn
  10441. * @param x defines the placement of the text from the left
  10442. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10443. * @param font defines the font to be used with font-style, font-size, font-name
  10444. * @param color defines the color used for the text
  10445. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10446. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10447. * @param update defines whether texture is immediately update (default is true)
  10448. */
  10449. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10450. /**
  10451. * Clones the texture
  10452. * @returns the clone of the texture.
  10453. */
  10454. clone(): DynamicTexture;
  10455. /**
  10456. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10457. * @returns a serialized dynamic texture object
  10458. */
  10459. serialize(): any;
  10460. /** @hidden */
  10461. _rebuild(): void;
  10462. }
  10463. }
  10464. declare module BABYLON {
  10465. interface Engine {
  10466. /**
  10467. * Creates a raw texture
  10468. * @param data defines the data to store in the texture
  10469. * @param width defines the width of the texture
  10470. * @param height defines the height of the texture
  10471. * @param format defines the format of the data
  10472. * @param generateMipMaps defines if the engine should generate the mip levels
  10473. * @param invertY defines if data must be stored with Y axis inverted
  10474. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10475. * @param compression defines the compression used (null by default)
  10476. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10477. * @returns the raw texture inside an InternalTexture
  10478. */
  10479. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10480. /**
  10481. * Update a raw texture
  10482. * @param texture defines the texture to update
  10483. * @param data defines the data to store in the texture
  10484. * @param format defines the format of the data
  10485. * @param invertY defines if data must be stored with Y axis inverted
  10486. */
  10487. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10488. /**
  10489. * Update a raw texture
  10490. * @param texture defines the texture to update
  10491. * @param data defines the data to store in the texture
  10492. * @param format defines the format of the data
  10493. * @param invertY defines if data must be stored with Y axis inverted
  10494. * @param compression defines the compression used (null by default)
  10495. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10496. */
  10497. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10498. /**
  10499. * Creates a new raw cube texture
  10500. * @param data defines the array of data to use to create each face
  10501. * @param size defines the size of the textures
  10502. * @param format defines the format of the data
  10503. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10504. * @param generateMipMaps defines if the engine should generate the mip levels
  10505. * @param invertY defines if data must be stored with Y axis inverted
  10506. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10507. * @param compression defines the compression used (null by default)
  10508. * @returns the cube texture as an InternalTexture
  10509. */
  10510. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10511. /**
  10512. * Update a raw cube texture
  10513. * @param texture defines the texture to udpdate
  10514. * @param data defines the data to store
  10515. * @param format defines the data format
  10516. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10517. * @param invertY defines if data must be stored with Y axis inverted
  10518. */
  10519. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10520. /**
  10521. * Update a raw cube texture
  10522. * @param texture defines the texture to udpdate
  10523. * @param data defines the data to store
  10524. * @param format defines the data format
  10525. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10526. * @param invertY defines if data must be stored with Y axis inverted
  10527. * @param compression defines the compression used (null by default)
  10528. */
  10529. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10530. /**
  10531. * Update a raw cube texture
  10532. * @param texture defines the texture to udpdate
  10533. * @param data defines the data to store
  10534. * @param format defines the data format
  10535. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10536. * @param invertY defines if data must be stored with Y axis inverted
  10537. * @param compression defines the compression used (null by default)
  10538. * @param level defines which level of the texture to update
  10539. */
  10540. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10541. /**
  10542. * Creates a new raw cube texture from a specified url
  10543. * @param url defines the url where the data is located
  10544. * @param scene defines the current scene
  10545. * @param size defines the size of the textures
  10546. * @param format defines the format of the data
  10547. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10548. * @param noMipmap defines if the engine should avoid generating the mip levels
  10549. * @param callback defines a callback used to extract texture data from loaded data
  10550. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10551. * @param onLoad defines a callback called when texture is loaded
  10552. * @param onError defines a callback called if there is an error
  10553. * @returns the cube texture as an InternalTexture
  10554. */
  10555. 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;
  10556. /**
  10557. * Creates a new raw cube texture from a specified url
  10558. * @param url defines the url where the data is located
  10559. * @param scene defines the current scene
  10560. * @param size defines the size of the textures
  10561. * @param format defines the format of the data
  10562. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10563. * @param noMipmap defines if the engine should avoid generating the mip levels
  10564. * @param callback defines a callback used to extract texture data from loaded data
  10565. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10566. * @param onLoad defines a callback called when texture is loaded
  10567. * @param onError defines a callback called if there is an error
  10568. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10569. * @param invertY defines if data must be stored with Y axis inverted
  10570. * @returns the cube texture as an InternalTexture
  10571. */
  10572. 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;
  10573. /**
  10574. * Creates a new raw 3D texture
  10575. * @param data defines the data used to create the texture
  10576. * @param width defines the width of the texture
  10577. * @param height defines the height of the texture
  10578. * @param depth defines the depth of the texture
  10579. * @param format defines the format of the texture
  10580. * @param generateMipMaps defines if the engine must generate mip levels
  10581. * @param invertY defines if data must be stored with Y axis inverted
  10582. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10583. * @param compression defines the compressed used (can be null)
  10584. * @param textureType defines the compressed used (can be null)
  10585. * @returns a new raw 3D texture (stored in an InternalTexture)
  10586. */
  10587. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10588. /**
  10589. * Update a raw 3D texture
  10590. * @param texture defines the texture to update
  10591. * @param data defines the data to store
  10592. * @param format defines the data format
  10593. * @param invertY defines if data must be stored with Y axis inverted
  10594. */
  10595. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10596. /**
  10597. * Update a raw 3D texture
  10598. * @param texture defines the texture to update
  10599. * @param data defines the data to store
  10600. * @param format defines the data format
  10601. * @param invertY defines if data must be stored with Y axis inverted
  10602. * @param compression defines the used compression (can be null)
  10603. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10604. */
  10605. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10606. /**
  10607. * Creates a new raw 2D array texture
  10608. * @param data defines the data used to create the texture
  10609. * @param width defines the width of the texture
  10610. * @param height defines the height of the texture
  10611. * @param depth defines the number of layers of the texture
  10612. * @param format defines the format of the texture
  10613. * @param generateMipMaps defines if the engine must generate mip levels
  10614. * @param invertY defines if data must be stored with Y axis inverted
  10615. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10616. * @param compression defines the compressed used (can be null)
  10617. * @param textureType defines the compressed used (can be null)
  10618. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10619. */
  10620. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10621. /**
  10622. * Update a raw 2D array texture
  10623. * @param texture defines the texture to update
  10624. * @param data defines the data to store
  10625. * @param format defines the data format
  10626. * @param invertY defines if data must be stored with Y axis inverted
  10627. */
  10628. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10629. /**
  10630. * Update a raw 2D array texture
  10631. * @param texture defines the texture to update
  10632. * @param data defines the data to store
  10633. * @param format defines the data format
  10634. * @param invertY defines if data must be stored with Y axis inverted
  10635. * @param compression defines the used compression (can be null)
  10636. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10637. */
  10638. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10639. }
  10640. }
  10641. declare module BABYLON {
  10642. /**
  10643. * Raw texture can help creating a texture directly from an array of data.
  10644. * This can be super useful if you either get the data from an uncompressed source or
  10645. * if you wish to create your texture pixel by pixel.
  10646. */
  10647. export class RawTexture extends Texture {
  10648. /**
  10649. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10650. */
  10651. format: number;
  10652. private _engine;
  10653. /**
  10654. * Instantiates a new RawTexture.
  10655. * Raw texture can help creating a texture directly from an array of data.
  10656. * This can be super useful if you either get the data from an uncompressed source or
  10657. * if you wish to create your texture pixel by pixel.
  10658. * @param data define the array of data to use to create the texture
  10659. * @param width define the width of the texture
  10660. * @param height define the height of the texture
  10661. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10662. * @param scene define the scene the texture belongs to
  10663. * @param generateMipMaps define whether mip maps should be generated or not
  10664. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10665. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10666. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10667. */
  10668. constructor(data: ArrayBufferView, width: number, height: number,
  10669. /**
  10670. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10671. */
  10672. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10673. /**
  10674. * Updates the texture underlying data.
  10675. * @param data Define the new data of the texture
  10676. */
  10677. update(data: ArrayBufferView): void;
  10678. /**
  10679. * Creates a luminance texture from some data.
  10680. * @param data Define the texture data
  10681. * @param width Define the width of the texture
  10682. * @param height Define the height of the texture
  10683. * @param scene Define the scene the texture belongs to
  10684. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10685. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10686. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10687. * @returns the luminance texture
  10688. */
  10689. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10690. /**
  10691. * Creates a luminance alpha texture from some data.
  10692. * @param data Define the texture data
  10693. * @param width Define the width of the texture
  10694. * @param height Define the height of the texture
  10695. * @param scene Define the scene the texture belongs to
  10696. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10697. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10698. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10699. * @returns the luminance alpha texture
  10700. */
  10701. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10702. /**
  10703. * Creates an alpha texture from some data.
  10704. * @param data Define the texture data
  10705. * @param width Define the width of the texture
  10706. * @param height Define the height of the texture
  10707. * @param scene Define the scene the texture belongs to
  10708. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10709. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10710. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10711. * @returns the alpha texture
  10712. */
  10713. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10714. /**
  10715. * Creates a RGB texture from some data.
  10716. * @param data Define the texture data
  10717. * @param width Define the width of the texture
  10718. * @param height Define the height of the texture
  10719. * @param scene Define the scene the texture belongs to
  10720. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10721. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10722. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10723. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10724. * @returns the RGB alpha texture
  10725. */
  10726. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10727. /**
  10728. * Creates a RGBA texture from some data.
  10729. * @param data Define the texture data
  10730. * @param width Define the width of the texture
  10731. * @param height Define the height of the texture
  10732. * @param scene Define the scene the texture belongs to
  10733. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10734. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10735. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10736. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10737. * @returns the RGBA texture
  10738. */
  10739. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10740. /**
  10741. * Creates a R texture from some data.
  10742. * @param data Define the texture data
  10743. * @param width Define the width of the texture
  10744. * @param height Define the height of the texture
  10745. * @param scene Define the scene the texture belongs to
  10746. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10747. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10748. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10749. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10750. * @returns the R texture
  10751. */
  10752. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10753. }
  10754. }
  10755. declare module BABYLON {
  10756. interface AbstractScene {
  10757. /**
  10758. * The list of procedural textures added to the scene
  10759. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10760. */
  10761. proceduralTextures: Array<ProceduralTexture>;
  10762. }
  10763. /**
  10764. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10765. * in a given scene.
  10766. */
  10767. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10768. /**
  10769. * The component name helpfull to identify the component in the list of scene components.
  10770. */
  10771. readonly name: string;
  10772. /**
  10773. * The scene the component belongs to.
  10774. */
  10775. scene: Scene;
  10776. /**
  10777. * Creates a new instance of the component for the given scene
  10778. * @param scene Defines the scene to register the component in
  10779. */
  10780. constructor(scene: Scene);
  10781. /**
  10782. * Registers the component in a given scene
  10783. */
  10784. register(): void;
  10785. /**
  10786. * Rebuilds the elements related to this component in case of
  10787. * context lost for instance.
  10788. */
  10789. rebuild(): void;
  10790. /**
  10791. * Disposes the component and the associated ressources.
  10792. */
  10793. dispose(): void;
  10794. private _beforeClear;
  10795. }
  10796. }
  10797. declare module BABYLON {
  10798. interface ThinEngine {
  10799. /**
  10800. * Creates a new render target cube texture
  10801. * @param size defines the size of the texture
  10802. * @param options defines the options used to create the texture
  10803. * @returns a new render target cube texture stored in an InternalTexture
  10804. */
  10805. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10806. }
  10807. }
  10808. declare module BABYLON {
  10809. /** @hidden */
  10810. export var proceduralVertexShader: {
  10811. name: string;
  10812. shader: string;
  10813. };
  10814. }
  10815. declare module BABYLON {
  10816. /**
  10817. * 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.
  10818. * This is the base class of any Procedural texture and contains most of the shareable code.
  10819. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10820. */
  10821. export class ProceduralTexture extends Texture {
  10822. isCube: boolean;
  10823. /**
  10824. * Define if the texture is enabled or not (disabled texture will not render)
  10825. */
  10826. isEnabled: boolean;
  10827. /**
  10828. * Define if the texture must be cleared before rendering (default is true)
  10829. */
  10830. autoClear: boolean;
  10831. /**
  10832. * Callback called when the texture is generated
  10833. */
  10834. onGenerated: () => void;
  10835. /**
  10836. * Event raised when the texture is generated
  10837. */
  10838. onGeneratedObservable: Observable<ProceduralTexture>;
  10839. /** @hidden */
  10840. _generateMipMaps: boolean;
  10841. /** @hidden **/
  10842. _effect: Effect;
  10843. /** @hidden */
  10844. _textures: {
  10845. [key: string]: Texture;
  10846. };
  10847. /** @hidden */
  10848. protected _fallbackTexture: Nullable<Texture>;
  10849. private _size;
  10850. private _currentRefreshId;
  10851. private _frameId;
  10852. private _refreshRate;
  10853. private _vertexBuffers;
  10854. private _indexBuffer;
  10855. private _uniforms;
  10856. private _samplers;
  10857. private _fragment;
  10858. private _floats;
  10859. private _ints;
  10860. private _floatsArrays;
  10861. private _colors3;
  10862. private _colors4;
  10863. private _vectors2;
  10864. private _vectors3;
  10865. private _matrices;
  10866. private _fallbackTextureUsed;
  10867. private _engine;
  10868. private _cachedDefines;
  10869. private _contentUpdateId;
  10870. private _contentData;
  10871. /**
  10872. * Instantiates a new procedural texture.
  10873. * 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.
  10874. * This is the base class of any Procedural texture and contains most of the shareable code.
  10875. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10876. * @param name Define the name of the texture
  10877. * @param size Define the size of the texture to create
  10878. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10879. * @param scene Define the scene the texture belongs to
  10880. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10881. * @param generateMipMaps Define if the texture should creates mip maps or not
  10882. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10883. */
  10884. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10885. /**
  10886. * The effect that is created when initializing the post process.
  10887. * @returns The created effect corresponding the the postprocess.
  10888. */
  10889. getEffect(): Effect;
  10890. /**
  10891. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10892. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10893. */
  10894. getContent(): Nullable<ArrayBufferView>;
  10895. private _createIndexBuffer;
  10896. /** @hidden */
  10897. _rebuild(): void;
  10898. /**
  10899. * Resets the texture in order to recreate its associated resources.
  10900. * This can be called in case of context loss
  10901. */
  10902. reset(): void;
  10903. protected _getDefines(): string;
  10904. /**
  10905. * Is the texture ready to be used ? (rendered at least once)
  10906. * @returns true if ready, otherwise, false.
  10907. */
  10908. isReady(): boolean;
  10909. /**
  10910. * Resets the refresh counter of the texture and start bak from scratch.
  10911. * Could be useful to regenerate the texture if it is setup to render only once.
  10912. */
  10913. resetRefreshCounter(): void;
  10914. /**
  10915. * Set the fragment shader to use in order to render the texture.
  10916. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10917. */
  10918. setFragment(fragment: any): void;
  10919. /**
  10920. * Define the refresh rate of the texture or the rendering frequency.
  10921. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10922. */
  10923. get refreshRate(): number;
  10924. set refreshRate(value: number);
  10925. /** @hidden */
  10926. _shouldRender(): boolean;
  10927. /**
  10928. * Get the size the texture is rendering at.
  10929. * @returns the size (texture is always squared)
  10930. */
  10931. getRenderSize(): number;
  10932. /**
  10933. * Resize the texture to new value.
  10934. * @param size Define the new size the texture should have
  10935. * @param generateMipMaps Define whether the new texture should create mip maps
  10936. */
  10937. resize(size: number, generateMipMaps: boolean): void;
  10938. private _checkUniform;
  10939. /**
  10940. * Set a texture in the shader program used to render.
  10941. * @param name Define the name of the uniform samplers as defined in the shader
  10942. * @param texture Define the texture to bind to this sampler
  10943. * @return the texture itself allowing "fluent" like uniform updates
  10944. */
  10945. setTexture(name: string, texture: Texture): ProceduralTexture;
  10946. /**
  10947. * Set a float in the shader.
  10948. * @param name Define the name of the uniform as defined in the shader
  10949. * @param value Define the value to give to the uniform
  10950. * @return the texture itself allowing "fluent" like uniform updates
  10951. */
  10952. setFloat(name: string, value: number): ProceduralTexture;
  10953. /**
  10954. * Set a int in the shader.
  10955. * @param name Define the name of the uniform as defined in the shader
  10956. * @param value Define the value to give to the uniform
  10957. * @return the texture itself allowing "fluent" like uniform updates
  10958. */
  10959. setInt(name: string, value: number): ProceduralTexture;
  10960. /**
  10961. * Set an array of floats in the shader.
  10962. * @param name Define the name of the uniform as defined in the shader
  10963. * @param value Define the value to give to the uniform
  10964. * @return the texture itself allowing "fluent" like uniform updates
  10965. */
  10966. setFloats(name: string, value: number[]): ProceduralTexture;
  10967. /**
  10968. * Set a vec3 in the shader from a Color3.
  10969. * @param name Define the name of the uniform as defined in the shader
  10970. * @param value Define the value to give to the uniform
  10971. * @return the texture itself allowing "fluent" like uniform updates
  10972. */
  10973. setColor3(name: string, value: Color3): ProceduralTexture;
  10974. /**
  10975. * Set a vec4 in the shader from a Color4.
  10976. * @param name Define the name of the uniform as defined in the shader
  10977. * @param value Define the value to give to the uniform
  10978. * @return the texture itself allowing "fluent" like uniform updates
  10979. */
  10980. setColor4(name: string, value: Color4): ProceduralTexture;
  10981. /**
  10982. * Set a vec2 in the shader from a Vector2.
  10983. * @param name Define the name of the uniform as defined in the shader
  10984. * @param value Define the value to give to the uniform
  10985. * @return the texture itself allowing "fluent" like uniform updates
  10986. */
  10987. setVector2(name: string, value: Vector2): ProceduralTexture;
  10988. /**
  10989. * Set a vec3 in the shader from a Vector3.
  10990. * @param name Define the name of the uniform as defined in the shader
  10991. * @param value Define the value to give to the uniform
  10992. * @return the texture itself allowing "fluent" like uniform updates
  10993. */
  10994. setVector3(name: string, value: Vector3): ProceduralTexture;
  10995. /**
  10996. * Set a mat4 in the shader from a MAtrix.
  10997. * @param name Define the name of the uniform as defined in the shader
  10998. * @param value Define the value to give to the uniform
  10999. * @return the texture itself allowing "fluent" like uniform updates
  11000. */
  11001. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11002. /**
  11003. * Render the texture to its associated render target.
  11004. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11005. */
  11006. render(useCameraPostProcess?: boolean): void;
  11007. /**
  11008. * Clone the texture.
  11009. * @returns the cloned texture
  11010. */
  11011. clone(): ProceduralTexture;
  11012. /**
  11013. * Dispose the texture and release its asoociated resources.
  11014. */
  11015. dispose(): void;
  11016. }
  11017. }
  11018. declare module BABYLON {
  11019. /**
  11020. * This represents the base class for particle system in Babylon.
  11021. * 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.
  11022. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11023. * @example https://doc.babylonjs.com/babylon101/particles
  11024. */
  11025. export class BaseParticleSystem {
  11026. /**
  11027. * Source color is added to the destination color without alpha affecting the result
  11028. */
  11029. static BLENDMODE_ONEONE: number;
  11030. /**
  11031. * Blend current color and particle color using particle’s alpha
  11032. */
  11033. static BLENDMODE_STANDARD: number;
  11034. /**
  11035. * Add current color and particle color multiplied by particle’s alpha
  11036. */
  11037. static BLENDMODE_ADD: number;
  11038. /**
  11039. * Multiply current color with particle color
  11040. */
  11041. static BLENDMODE_MULTIPLY: number;
  11042. /**
  11043. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11044. */
  11045. static BLENDMODE_MULTIPLYADD: number;
  11046. /**
  11047. * List of animations used by the particle system.
  11048. */
  11049. animations: Animation[];
  11050. /**
  11051. * Gets or sets the unique id of the particle system
  11052. */
  11053. uniqueId: number;
  11054. /**
  11055. * The id of the Particle system.
  11056. */
  11057. id: string;
  11058. /**
  11059. * The friendly name of the Particle system.
  11060. */
  11061. name: string;
  11062. /**
  11063. * Snippet ID if the particle system was created from the snippet server
  11064. */
  11065. snippetId: string;
  11066. /**
  11067. * The rendering group used by the Particle system to chose when to render.
  11068. */
  11069. renderingGroupId: number;
  11070. /**
  11071. * The emitter represents the Mesh or position we are attaching the particle system to.
  11072. */
  11073. emitter: Nullable<AbstractMesh | Vector3>;
  11074. /**
  11075. * The maximum number of particles to emit per frame
  11076. */
  11077. emitRate: number;
  11078. /**
  11079. * If you want to launch only a few particles at once, that can be done, as well.
  11080. */
  11081. manualEmitCount: number;
  11082. /**
  11083. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11084. */
  11085. updateSpeed: number;
  11086. /**
  11087. * The amount of time the particle system is running (depends of the overall update speed).
  11088. */
  11089. targetStopDuration: number;
  11090. /**
  11091. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11092. */
  11093. disposeOnStop: boolean;
  11094. /**
  11095. * Minimum power of emitting particles.
  11096. */
  11097. minEmitPower: number;
  11098. /**
  11099. * Maximum power of emitting particles.
  11100. */
  11101. maxEmitPower: number;
  11102. /**
  11103. * Minimum life time of emitting particles.
  11104. */
  11105. minLifeTime: number;
  11106. /**
  11107. * Maximum life time of emitting particles.
  11108. */
  11109. maxLifeTime: number;
  11110. /**
  11111. * Minimum Size of emitting particles.
  11112. */
  11113. minSize: number;
  11114. /**
  11115. * Maximum Size of emitting particles.
  11116. */
  11117. maxSize: number;
  11118. /**
  11119. * Minimum scale of emitting particles on X axis.
  11120. */
  11121. minScaleX: number;
  11122. /**
  11123. * Maximum scale of emitting particles on X axis.
  11124. */
  11125. maxScaleX: number;
  11126. /**
  11127. * Minimum scale of emitting particles on Y axis.
  11128. */
  11129. minScaleY: number;
  11130. /**
  11131. * Maximum scale of emitting particles on Y axis.
  11132. */
  11133. maxScaleY: number;
  11134. /**
  11135. * Gets or sets the minimal initial rotation in radians.
  11136. */
  11137. minInitialRotation: number;
  11138. /**
  11139. * Gets or sets the maximal initial rotation in radians.
  11140. */
  11141. maxInitialRotation: number;
  11142. /**
  11143. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11144. */
  11145. minAngularSpeed: number;
  11146. /**
  11147. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11148. */
  11149. maxAngularSpeed: number;
  11150. /**
  11151. * The texture used to render each particle. (this can be a spritesheet)
  11152. */
  11153. particleTexture: Nullable<Texture>;
  11154. /**
  11155. * The layer mask we are rendering the particles through.
  11156. */
  11157. layerMask: number;
  11158. /**
  11159. * This can help using your own shader to render the particle system.
  11160. * The according effect will be created
  11161. */
  11162. customShader: any;
  11163. /**
  11164. * By default particle system starts as soon as they are created. This prevents the
  11165. * automatic start to happen and let you decide when to start emitting particles.
  11166. */
  11167. preventAutoStart: boolean;
  11168. private _noiseTexture;
  11169. /**
  11170. * Gets or sets a texture used to add random noise to particle positions
  11171. */
  11172. get noiseTexture(): Nullable<ProceduralTexture>;
  11173. set noiseTexture(value: Nullable<ProceduralTexture>);
  11174. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11175. noiseStrength: Vector3;
  11176. /**
  11177. * Callback triggered when the particle animation is ending.
  11178. */
  11179. onAnimationEnd: Nullable<() => void>;
  11180. /**
  11181. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11182. */
  11183. blendMode: number;
  11184. /**
  11185. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11186. * to override the particles.
  11187. */
  11188. forceDepthWrite: boolean;
  11189. /** 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 */
  11190. preWarmCycles: number;
  11191. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11192. preWarmStepOffset: number;
  11193. /**
  11194. * 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)
  11195. */
  11196. spriteCellChangeSpeed: number;
  11197. /**
  11198. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11199. */
  11200. startSpriteCellID: number;
  11201. /**
  11202. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11203. */
  11204. endSpriteCellID: number;
  11205. /**
  11206. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11207. */
  11208. spriteCellWidth: number;
  11209. /**
  11210. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11211. */
  11212. spriteCellHeight: number;
  11213. /**
  11214. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11215. */
  11216. spriteRandomStartCell: boolean;
  11217. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11218. translationPivot: Vector2;
  11219. /** @hidden */
  11220. protected _isAnimationSheetEnabled: boolean;
  11221. /**
  11222. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11223. */
  11224. beginAnimationOnStart: boolean;
  11225. /**
  11226. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11227. */
  11228. beginAnimationFrom: number;
  11229. /**
  11230. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11231. */
  11232. beginAnimationTo: number;
  11233. /**
  11234. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11235. */
  11236. beginAnimationLoop: boolean;
  11237. /**
  11238. * Gets or sets a world offset applied to all particles
  11239. */
  11240. worldOffset: Vector3;
  11241. /**
  11242. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11243. */
  11244. get isAnimationSheetEnabled(): boolean;
  11245. set isAnimationSheetEnabled(value: boolean);
  11246. /**
  11247. * Get hosting scene
  11248. * @returns the scene
  11249. */
  11250. getScene(): Scene;
  11251. /**
  11252. * You can use gravity if you want to give an orientation to your particles.
  11253. */
  11254. gravity: Vector3;
  11255. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11256. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11257. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11258. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11259. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11260. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11261. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11262. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11263. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11264. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11265. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11266. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11267. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11268. /**
  11269. * Defines the delay in milliseconds before starting the system (0 by default)
  11270. */
  11271. startDelay: number;
  11272. /**
  11273. * Gets the current list of drag gradients.
  11274. * You must use addDragGradient and removeDragGradient to udpate this list
  11275. * @returns the list of drag gradients
  11276. */
  11277. getDragGradients(): Nullable<Array<FactorGradient>>;
  11278. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11279. limitVelocityDamping: number;
  11280. /**
  11281. * Gets the current list of limit velocity gradients.
  11282. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11283. * @returns the list of limit velocity gradients
  11284. */
  11285. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11286. /**
  11287. * Gets the current list of color gradients.
  11288. * You must use addColorGradient and removeColorGradient to udpate this list
  11289. * @returns the list of color gradients
  11290. */
  11291. getColorGradients(): Nullable<Array<ColorGradient>>;
  11292. /**
  11293. * Gets the current list of size gradients.
  11294. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11295. * @returns the list of size gradients
  11296. */
  11297. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11298. /**
  11299. * Gets the current list of color remap gradients.
  11300. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11301. * @returns the list of color remap gradients
  11302. */
  11303. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11304. /**
  11305. * Gets the current list of alpha remap gradients.
  11306. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11307. * @returns the list of alpha remap gradients
  11308. */
  11309. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11310. /**
  11311. * Gets the current list of life time gradients.
  11312. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11313. * @returns the list of life time gradients
  11314. */
  11315. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11316. /**
  11317. * Gets the current list of angular speed gradients.
  11318. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11319. * @returns the list of angular speed gradients
  11320. */
  11321. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11322. /**
  11323. * Gets the current list of velocity gradients.
  11324. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11325. * @returns the list of velocity gradients
  11326. */
  11327. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11328. /**
  11329. * Gets the current list of start size gradients.
  11330. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11331. * @returns the list of start size gradients
  11332. */
  11333. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11334. /**
  11335. * Gets the current list of emit rate gradients.
  11336. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11337. * @returns the list of emit rate gradients
  11338. */
  11339. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11340. /**
  11341. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11342. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11343. */
  11344. get direction1(): Vector3;
  11345. set direction1(value: Vector3);
  11346. /**
  11347. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11348. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11349. */
  11350. get direction2(): Vector3;
  11351. set direction2(value: Vector3);
  11352. /**
  11353. * 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.
  11354. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11355. */
  11356. get minEmitBox(): Vector3;
  11357. set minEmitBox(value: Vector3);
  11358. /**
  11359. * 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.
  11360. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11361. */
  11362. get maxEmitBox(): Vector3;
  11363. set maxEmitBox(value: Vector3);
  11364. /**
  11365. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11366. */
  11367. color1: Color4;
  11368. /**
  11369. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11370. */
  11371. color2: Color4;
  11372. /**
  11373. * Color the particle will have at the end of its lifetime
  11374. */
  11375. colorDead: Color4;
  11376. /**
  11377. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11378. */
  11379. textureMask: Color4;
  11380. /**
  11381. * The particle emitter type defines the emitter used by the particle system.
  11382. * It can be for example box, sphere, or cone...
  11383. */
  11384. particleEmitterType: IParticleEmitterType;
  11385. /** @hidden */
  11386. _isSubEmitter: boolean;
  11387. /**
  11388. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11389. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11390. */
  11391. billboardMode: number;
  11392. protected _isBillboardBased: boolean;
  11393. /**
  11394. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11395. */
  11396. get isBillboardBased(): boolean;
  11397. set isBillboardBased(value: boolean);
  11398. /**
  11399. * The scene the particle system belongs to.
  11400. */
  11401. protected _scene: Scene;
  11402. /**
  11403. * Local cache of defines for image processing.
  11404. */
  11405. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11406. /**
  11407. * Default configuration related to image processing available in the standard Material.
  11408. */
  11409. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11410. /**
  11411. * Gets the image processing configuration used either in this material.
  11412. */
  11413. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11414. /**
  11415. * Sets the Default image processing configuration used either in the this material.
  11416. *
  11417. * If sets to null, the scene one is in use.
  11418. */
  11419. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11420. /**
  11421. * Attaches a new image processing configuration to the Standard Material.
  11422. * @param configuration
  11423. */
  11424. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11425. /** @hidden */
  11426. protected _reset(): void;
  11427. /** @hidden */
  11428. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11429. /**
  11430. * Instantiates a particle system.
  11431. * 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.
  11432. * @param name The name of the particle system
  11433. */
  11434. constructor(name: string);
  11435. /**
  11436. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11437. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11438. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11439. * @returns the emitter
  11440. */
  11441. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11442. /**
  11443. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11444. * @param radius The radius of the hemisphere to emit from
  11445. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11446. * @returns the emitter
  11447. */
  11448. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11449. /**
  11450. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11451. * @param radius The radius of the sphere to emit from
  11452. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11453. * @returns the emitter
  11454. */
  11455. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11456. /**
  11457. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11458. * @param radius The radius of the sphere to emit from
  11459. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11460. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11461. * @returns the emitter
  11462. */
  11463. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11464. /**
  11465. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11466. * @param radius The radius of the emission cylinder
  11467. * @param height The height of the emission cylinder
  11468. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11469. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11470. * @returns the emitter
  11471. */
  11472. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11473. /**
  11474. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11475. * @param radius The radius of the cylinder to emit from
  11476. * @param height The height of the emission cylinder
  11477. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11478. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11479. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11480. * @returns the emitter
  11481. */
  11482. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11483. /**
  11484. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11485. * @param radius The radius of the cone to emit from
  11486. * @param angle The base angle of the cone
  11487. * @returns the emitter
  11488. */
  11489. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11490. /**
  11491. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11492. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11493. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11494. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11495. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11496. * @returns the emitter
  11497. */
  11498. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11499. }
  11500. }
  11501. declare module BABYLON {
  11502. /**
  11503. * Type of sub emitter
  11504. */
  11505. export enum SubEmitterType {
  11506. /**
  11507. * Attached to the particle over it's lifetime
  11508. */
  11509. ATTACHED = 0,
  11510. /**
  11511. * Created when the particle dies
  11512. */
  11513. END = 1
  11514. }
  11515. /**
  11516. * Sub emitter class used to emit particles from an existing particle
  11517. */
  11518. export class SubEmitter {
  11519. /**
  11520. * the particle system to be used by the sub emitter
  11521. */
  11522. particleSystem: ParticleSystem;
  11523. /**
  11524. * Type of the submitter (Default: END)
  11525. */
  11526. type: SubEmitterType;
  11527. /**
  11528. * 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)
  11529. * Note: This only is supported when using an emitter of type Mesh
  11530. */
  11531. inheritDirection: boolean;
  11532. /**
  11533. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11534. */
  11535. inheritedVelocityAmount: number;
  11536. /**
  11537. * Creates a sub emitter
  11538. * @param particleSystem the particle system to be used by the sub emitter
  11539. */
  11540. constructor(
  11541. /**
  11542. * the particle system to be used by the sub emitter
  11543. */
  11544. particleSystem: ParticleSystem);
  11545. /**
  11546. * Clones the sub emitter
  11547. * @returns the cloned sub emitter
  11548. */
  11549. clone(): SubEmitter;
  11550. /**
  11551. * Serialize current object to a JSON object
  11552. * @returns the serialized object
  11553. */
  11554. serialize(): any;
  11555. /** @hidden */
  11556. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11557. /**
  11558. * Creates a new SubEmitter from a serialized JSON version
  11559. * @param serializationObject defines the JSON object to read from
  11560. * @param scene defines the hosting scene
  11561. * @param rootUrl defines the rootUrl for data loading
  11562. * @returns a new SubEmitter
  11563. */
  11564. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11565. /** Release associated resources */
  11566. dispose(): void;
  11567. }
  11568. }
  11569. declare module BABYLON {
  11570. /** @hidden */
  11571. export var imageProcessingDeclaration: {
  11572. name: string;
  11573. shader: string;
  11574. };
  11575. }
  11576. declare module BABYLON {
  11577. /** @hidden */
  11578. export var imageProcessingFunctions: {
  11579. name: string;
  11580. shader: string;
  11581. };
  11582. }
  11583. declare module BABYLON {
  11584. /** @hidden */
  11585. export var particlesPixelShader: {
  11586. name: string;
  11587. shader: string;
  11588. };
  11589. }
  11590. declare module BABYLON {
  11591. /** @hidden */
  11592. export var particlesVertexShader: {
  11593. name: string;
  11594. shader: string;
  11595. };
  11596. }
  11597. declare module BABYLON {
  11598. /**
  11599. * This represents a particle system in Babylon.
  11600. * 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.
  11601. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11602. * @example https://doc.babylonjs.com/babylon101/particles
  11603. */
  11604. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11605. /**
  11606. * Billboard mode will only apply to Y axis
  11607. */
  11608. static readonly BILLBOARDMODE_Y: number;
  11609. /**
  11610. * Billboard mode will apply to all axes
  11611. */
  11612. static readonly BILLBOARDMODE_ALL: number;
  11613. /**
  11614. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11615. */
  11616. static readonly BILLBOARDMODE_STRETCHED: number;
  11617. /**
  11618. * This function can be defined to provide custom update for active particles.
  11619. * This function will be called instead of regular update (age, position, color, etc.).
  11620. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11621. */
  11622. updateFunction: (particles: Particle[]) => void;
  11623. private _emitterWorldMatrix;
  11624. /**
  11625. * This function can be defined to specify initial direction for every new particle.
  11626. * It by default use the emitterType defined function
  11627. */
  11628. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11629. /**
  11630. * This function can be defined to specify initial position for every new particle.
  11631. * It by default use the emitterType defined function
  11632. */
  11633. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11634. /**
  11635. * @hidden
  11636. */
  11637. _inheritedVelocityOffset: Vector3;
  11638. /**
  11639. * An event triggered when the system is disposed
  11640. */
  11641. onDisposeObservable: Observable<ParticleSystem>;
  11642. private _onDisposeObserver;
  11643. /**
  11644. * Sets a callback that will be triggered when the system is disposed
  11645. */
  11646. set onDispose(callback: () => void);
  11647. private _particles;
  11648. private _epsilon;
  11649. private _capacity;
  11650. private _stockParticles;
  11651. private _newPartsExcess;
  11652. private _vertexData;
  11653. private _vertexBuffer;
  11654. private _vertexBuffers;
  11655. private _spriteBuffer;
  11656. private _indexBuffer;
  11657. private _effect;
  11658. private _customEffect;
  11659. private _cachedDefines;
  11660. private _scaledColorStep;
  11661. private _colorDiff;
  11662. private _scaledDirection;
  11663. private _scaledGravity;
  11664. private _currentRenderId;
  11665. private _alive;
  11666. private _useInstancing;
  11667. private _started;
  11668. private _stopped;
  11669. private _actualFrame;
  11670. private _scaledUpdateSpeed;
  11671. private _vertexBufferSize;
  11672. /** @hidden */
  11673. _currentEmitRateGradient: Nullable<FactorGradient>;
  11674. /** @hidden */
  11675. _currentEmitRate1: number;
  11676. /** @hidden */
  11677. _currentEmitRate2: number;
  11678. /** @hidden */
  11679. _currentStartSizeGradient: Nullable<FactorGradient>;
  11680. /** @hidden */
  11681. _currentStartSize1: number;
  11682. /** @hidden */
  11683. _currentStartSize2: number;
  11684. private readonly _rawTextureWidth;
  11685. private _rampGradientsTexture;
  11686. private _useRampGradients;
  11687. /** Gets or sets a boolean indicating that ramp gradients must be used
  11688. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11689. */
  11690. get useRampGradients(): boolean;
  11691. set useRampGradients(value: boolean);
  11692. /**
  11693. * 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.
  11694. * 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: [])
  11695. */
  11696. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11697. private _subEmitters;
  11698. /**
  11699. * @hidden
  11700. * If the particle systems emitter should be disposed when the particle system is disposed
  11701. */
  11702. _disposeEmitterOnDispose: boolean;
  11703. /**
  11704. * The current active Sub-systems, this property is used by the root particle system only.
  11705. */
  11706. activeSubSystems: Array<ParticleSystem>;
  11707. /**
  11708. * Specifies if the particles are updated in emitter local space or world space
  11709. */
  11710. isLocal: boolean;
  11711. private _rootParticleSystem;
  11712. /**
  11713. * Gets the current list of active particles
  11714. */
  11715. get particles(): Particle[];
  11716. /**
  11717. * Gets the number of particles active at the same time.
  11718. * @returns The number of active particles.
  11719. */
  11720. getActiveCount(): number;
  11721. /**
  11722. * Returns the string "ParticleSystem"
  11723. * @returns a string containing the class name
  11724. */
  11725. getClassName(): string;
  11726. /**
  11727. * Gets a boolean indicating that the system is stopping
  11728. * @returns true if the system is currently stopping
  11729. */
  11730. isStopping(): boolean;
  11731. /**
  11732. * Instantiates a particle system.
  11733. * 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.
  11734. * @param name The name of the particle system
  11735. * @param capacity The max number of particles alive at the same time
  11736. * @param scene The scene the particle system belongs to
  11737. * @param customEffect a custom effect used to change the way particles are rendered by default
  11738. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11739. * @param epsilon Offset used to render the particles
  11740. */
  11741. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11742. private _addFactorGradient;
  11743. private _removeFactorGradient;
  11744. /**
  11745. * Adds a new life time gradient
  11746. * @param gradient defines the gradient to use (between 0 and 1)
  11747. * @param factor defines the life time factor to affect to the specified gradient
  11748. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11749. * @returns the current particle system
  11750. */
  11751. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11752. /**
  11753. * Remove a specific life time gradient
  11754. * @param gradient defines the gradient to remove
  11755. * @returns the current particle system
  11756. */
  11757. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11758. /**
  11759. * Adds a new size gradient
  11760. * @param gradient defines the gradient to use (between 0 and 1)
  11761. * @param factor defines the size factor to affect to the specified gradient
  11762. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11763. * @returns the current particle system
  11764. */
  11765. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11766. /**
  11767. * Remove a specific size gradient
  11768. * @param gradient defines the gradient to remove
  11769. * @returns the current particle system
  11770. */
  11771. removeSizeGradient(gradient: number): IParticleSystem;
  11772. /**
  11773. * Adds a new color remap gradient
  11774. * @param gradient defines the gradient to use (between 0 and 1)
  11775. * @param min defines the color remap minimal range
  11776. * @param max defines the color remap maximal range
  11777. * @returns the current particle system
  11778. */
  11779. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11780. /**
  11781. * Remove a specific color remap gradient
  11782. * @param gradient defines the gradient to remove
  11783. * @returns the current particle system
  11784. */
  11785. removeColorRemapGradient(gradient: number): IParticleSystem;
  11786. /**
  11787. * Adds a new alpha remap gradient
  11788. * @param gradient defines the gradient to use (between 0 and 1)
  11789. * @param min defines the alpha remap minimal range
  11790. * @param max defines the alpha remap maximal range
  11791. * @returns the current particle system
  11792. */
  11793. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11794. /**
  11795. * Remove a specific alpha remap gradient
  11796. * @param gradient defines the gradient to remove
  11797. * @returns the current particle system
  11798. */
  11799. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11800. /**
  11801. * Adds a new angular speed gradient
  11802. * @param gradient defines the gradient to use (between 0 and 1)
  11803. * @param factor defines the angular speed to affect to the specified gradient
  11804. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11805. * @returns the current particle system
  11806. */
  11807. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11808. /**
  11809. * Remove a specific angular speed gradient
  11810. * @param gradient defines the gradient to remove
  11811. * @returns the current particle system
  11812. */
  11813. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11814. /**
  11815. * Adds a new velocity gradient
  11816. * @param gradient defines the gradient to use (between 0 and 1)
  11817. * @param factor defines the velocity to affect to the specified gradient
  11818. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11819. * @returns the current particle system
  11820. */
  11821. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11822. /**
  11823. * Remove a specific velocity gradient
  11824. * @param gradient defines the gradient to remove
  11825. * @returns the current particle system
  11826. */
  11827. removeVelocityGradient(gradient: number): IParticleSystem;
  11828. /**
  11829. * Adds a new limit velocity gradient
  11830. * @param gradient defines the gradient to use (between 0 and 1)
  11831. * @param factor defines the limit velocity value to affect to the specified gradient
  11832. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11833. * @returns the current particle system
  11834. */
  11835. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11836. /**
  11837. * Remove a specific limit velocity gradient
  11838. * @param gradient defines the gradient to remove
  11839. * @returns the current particle system
  11840. */
  11841. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11842. /**
  11843. * Adds a new drag gradient
  11844. * @param gradient defines the gradient to use (between 0 and 1)
  11845. * @param factor defines the drag value to affect to the specified gradient
  11846. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11847. * @returns the current particle system
  11848. */
  11849. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11850. /**
  11851. * Remove a specific drag gradient
  11852. * @param gradient defines the gradient to remove
  11853. * @returns the current particle system
  11854. */
  11855. removeDragGradient(gradient: number): IParticleSystem;
  11856. /**
  11857. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11858. * @param gradient defines the gradient to use (between 0 and 1)
  11859. * @param factor defines the emit rate value to affect to the specified gradient
  11860. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11861. * @returns the current particle system
  11862. */
  11863. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11864. /**
  11865. * Remove a specific emit rate gradient
  11866. * @param gradient defines the gradient to remove
  11867. * @returns the current particle system
  11868. */
  11869. removeEmitRateGradient(gradient: number): IParticleSystem;
  11870. /**
  11871. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11872. * @param gradient defines the gradient to use (between 0 and 1)
  11873. * @param factor defines the start size value to affect to the specified gradient
  11874. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11875. * @returns the current particle system
  11876. */
  11877. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11878. /**
  11879. * Remove a specific start size gradient
  11880. * @param gradient defines the gradient to remove
  11881. * @returns the current particle system
  11882. */
  11883. removeStartSizeGradient(gradient: number): IParticleSystem;
  11884. private _createRampGradientTexture;
  11885. /**
  11886. * Gets the current list of ramp gradients.
  11887. * You must use addRampGradient and removeRampGradient to udpate this list
  11888. * @returns the list of ramp gradients
  11889. */
  11890. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11891. /**
  11892. * Adds a new ramp gradient used to remap particle colors
  11893. * @param gradient defines the gradient to use (between 0 and 1)
  11894. * @param color defines the color to affect to the specified gradient
  11895. * @returns the current particle system
  11896. */
  11897. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11898. /**
  11899. * Remove a specific ramp gradient
  11900. * @param gradient defines the gradient to remove
  11901. * @returns the current particle system
  11902. */
  11903. removeRampGradient(gradient: number): ParticleSystem;
  11904. /**
  11905. * Adds a new color gradient
  11906. * @param gradient defines the gradient to use (between 0 and 1)
  11907. * @param color1 defines the color to affect to the specified gradient
  11908. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11909. * @returns this particle system
  11910. */
  11911. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11912. /**
  11913. * Remove a specific color gradient
  11914. * @param gradient defines the gradient to remove
  11915. * @returns this particle system
  11916. */
  11917. removeColorGradient(gradient: number): IParticleSystem;
  11918. private _fetchR;
  11919. protected _reset(): void;
  11920. private _resetEffect;
  11921. private _createVertexBuffers;
  11922. private _createIndexBuffer;
  11923. /**
  11924. * Gets the maximum number of particles active at the same time.
  11925. * @returns The max number of active particles.
  11926. */
  11927. getCapacity(): number;
  11928. /**
  11929. * Gets whether there are still active particles in the system.
  11930. * @returns True if it is alive, otherwise false.
  11931. */
  11932. isAlive(): boolean;
  11933. /**
  11934. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11935. * @returns True if it has been started, otherwise false.
  11936. */
  11937. isStarted(): boolean;
  11938. private _prepareSubEmitterInternalArray;
  11939. /**
  11940. * Starts the particle system and begins to emit
  11941. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11942. */
  11943. start(delay?: number): void;
  11944. /**
  11945. * Stops the particle system.
  11946. * @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.
  11947. */
  11948. stop(stopSubEmitters?: boolean): void;
  11949. /**
  11950. * Remove all active particles
  11951. */
  11952. reset(): void;
  11953. /**
  11954. * @hidden (for internal use only)
  11955. */
  11956. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  11957. /**
  11958. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  11959. * Its lifetime will start back at 0.
  11960. */
  11961. recycleParticle: (particle: Particle) => void;
  11962. private _stopSubEmitters;
  11963. private _createParticle;
  11964. private _removeFromRoot;
  11965. private _emitFromParticle;
  11966. private _update;
  11967. /** @hidden */
  11968. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  11969. /** @hidden */
  11970. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  11971. /** @hidden */
  11972. private _getEffect;
  11973. /**
  11974. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  11975. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  11976. */
  11977. animate(preWarmOnly?: boolean): void;
  11978. private _appendParticleVertices;
  11979. /**
  11980. * Rebuilds the particle system.
  11981. */
  11982. rebuild(): void;
  11983. /**
  11984. * Is this system ready to be used/rendered
  11985. * @return true if the system is ready
  11986. */
  11987. isReady(): boolean;
  11988. private _render;
  11989. /**
  11990. * Renders the particle system in its current state.
  11991. * @returns the current number of particles
  11992. */
  11993. render(): number;
  11994. /**
  11995. * Disposes the particle system and free the associated resources
  11996. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  11997. */
  11998. dispose(disposeTexture?: boolean): void;
  11999. /**
  12000. * Clones the particle system.
  12001. * @param name The name of the cloned object
  12002. * @param newEmitter The new emitter to use
  12003. * @returns the cloned particle system
  12004. */
  12005. clone(name: string, newEmitter: any): ParticleSystem;
  12006. /**
  12007. * Serializes the particle system to a JSON object
  12008. * @param serializeTexture defines if the texture must be serialized as well
  12009. * @returns the JSON object
  12010. */
  12011. serialize(serializeTexture?: boolean): any;
  12012. /** @hidden */
  12013. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12014. /** @hidden */
  12015. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12016. /**
  12017. * Parses a JSON object to create a particle system.
  12018. * @param parsedParticleSystem The JSON object to parse
  12019. * @param scene The scene to create the particle system in
  12020. * @param rootUrl The root url to use to load external dependencies like texture
  12021. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12022. * @returns the Parsed particle system
  12023. */
  12024. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12025. }
  12026. }
  12027. declare module BABYLON {
  12028. /**
  12029. * A particle represents one of the element emitted by a particle system.
  12030. * This is mainly define by its coordinates, direction, velocity and age.
  12031. */
  12032. export class Particle {
  12033. /**
  12034. * The particle system the particle belongs to.
  12035. */
  12036. particleSystem: ParticleSystem;
  12037. private static _Count;
  12038. /**
  12039. * Unique ID of the particle
  12040. */
  12041. id: number;
  12042. /**
  12043. * The world position of the particle in the scene.
  12044. */
  12045. position: Vector3;
  12046. /**
  12047. * The world direction of the particle in the scene.
  12048. */
  12049. direction: Vector3;
  12050. /**
  12051. * The color of the particle.
  12052. */
  12053. color: Color4;
  12054. /**
  12055. * The color change of the particle per step.
  12056. */
  12057. colorStep: Color4;
  12058. /**
  12059. * Defines how long will the life of the particle be.
  12060. */
  12061. lifeTime: number;
  12062. /**
  12063. * The current age of the particle.
  12064. */
  12065. age: number;
  12066. /**
  12067. * The current size of the particle.
  12068. */
  12069. size: number;
  12070. /**
  12071. * The current scale of the particle.
  12072. */
  12073. scale: Vector2;
  12074. /**
  12075. * The current angle of the particle.
  12076. */
  12077. angle: number;
  12078. /**
  12079. * Defines how fast is the angle changing.
  12080. */
  12081. angularSpeed: number;
  12082. /**
  12083. * Defines the cell index used by the particle to be rendered from a sprite.
  12084. */
  12085. cellIndex: number;
  12086. /**
  12087. * The information required to support color remapping
  12088. */
  12089. remapData: Vector4;
  12090. /** @hidden */
  12091. _randomCellOffset?: number;
  12092. /** @hidden */
  12093. _initialDirection: Nullable<Vector3>;
  12094. /** @hidden */
  12095. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12096. /** @hidden */
  12097. _initialStartSpriteCellID: number;
  12098. /** @hidden */
  12099. _initialEndSpriteCellID: number;
  12100. /** @hidden */
  12101. _currentColorGradient: Nullable<ColorGradient>;
  12102. /** @hidden */
  12103. _currentColor1: Color4;
  12104. /** @hidden */
  12105. _currentColor2: Color4;
  12106. /** @hidden */
  12107. _currentSizeGradient: Nullable<FactorGradient>;
  12108. /** @hidden */
  12109. _currentSize1: number;
  12110. /** @hidden */
  12111. _currentSize2: number;
  12112. /** @hidden */
  12113. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12114. /** @hidden */
  12115. _currentAngularSpeed1: number;
  12116. /** @hidden */
  12117. _currentAngularSpeed2: number;
  12118. /** @hidden */
  12119. _currentVelocityGradient: Nullable<FactorGradient>;
  12120. /** @hidden */
  12121. _currentVelocity1: number;
  12122. /** @hidden */
  12123. _currentVelocity2: number;
  12124. /** @hidden */
  12125. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12126. /** @hidden */
  12127. _currentLimitVelocity1: number;
  12128. /** @hidden */
  12129. _currentLimitVelocity2: number;
  12130. /** @hidden */
  12131. _currentDragGradient: Nullable<FactorGradient>;
  12132. /** @hidden */
  12133. _currentDrag1: number;
  12134. /** @hidden */
  12135. _currentDrag2: number;
  12136. /** @hidden */
  12137. _randomNoiseCoordinates1: Vector3;
  12138. /** @hidden */
  12139. _randomNoiseCoordinates2: Vector3;
  12140. /** @hidden */
  12141. _localPosition?: Vector3;
  12142. /**
  12143. * Creates a new instance Particle
  12144. * @param particleSystem the particle system the particle belongs to
  12145. */
  12146. constructor(
  12147. /**
  12148. * The particle system the particle belongs to.
  12149. */
  12150. particleSystem: ParticleSystem);
  12151. private updateCellInfoFromSystem;
  12152. /**
  12153. * Defines how the sprite cell index is updated for the particle
  12154. */
  12155. updateCellIndex(): void;
  12156. /** @hidden */
  12157. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12158. /** @hidden */
  12159. _inheritParticleInfoToSubEmitters(): void;
  12160. /** @hidden */
  12161. _reset(): void;
  12162. /**
  12163. * Copy the properties of particle to another one.
  12164. * @param other the particle to copy the information to.
  12165. */
  12166. copyTo(other: Particle): void;
  12167. }
  12168. }
  12169. declare module BABYLON {
  12170. /**
  12171. * Particle emitter represents a volume emitting particles.
  12172. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12173. */
  12174. export interface IParticleEmitterType {
  12175. /**
  12176. * Called by the particle System when the direction is computed for the created particle.
  12177. * @param worldMatrix is the world matrix of the particle system
  12178. * @param directionToUpdate is the direction vector to update with the result
  12179. * @param particle is the particle we are computed the direction for
  12180. * @param isLocal defines if the direction should be set in local space
  12181. */
  12182. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12183. /**
  12184. * Called by the particle System when the position is computed for the created particle.
  12185. * @param worldMatrix is the world matrix of the particle system
  12186. * @param positionToUpdate is the position vector to update with the result
  12187. * @param particle is the particle we are computed the position for
  12188. * @param isLocal defines if the position should be set in local space
  12189. */
  12190. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12191. /**
  12192. * Clones the current emitter and returns a copy of it
  12193. * @returns the new emitter
  12194. */
  12195. clone(): IParticleEmitterType;
  12196. /**
  12197. * Called by the GPUParticleSystem to setup the update shader
  12198. * @param effect defines the update shader
  12199. */
  12200. applyToShader(effect: Effect): void;
  12201. /**
  12202. * Returns a string to use to update the GPU particles update shader
  12203. * @returns the effect defines string
  12204. */
  12205. getEffectDefines(): string;
  12206. /**
  12207. * Returns a string representing the class name
  12208. * @returns a string containing the class name
  12209. */
  12210. getClassName(): string;
  12211. /**
  12212. * Serializes the particle system to a JSON object.
  12213. * @returns the JSON object
  12214. */
  12215. serialize(): any;
  12216. /**
  12217. * Parse properties from a JSON object
  12218. * @param serializationObject defines the JSON object
  12219. * @param scene defines the hosting scene
  12220. */
  12221. parse(serializationObject: any, scene: Scene): void;
  12222. }
  12223. }
  12224. declare module BABYLON {
  12225. /**
  12226. * Particle emitter emitting particles from the inside of a box.
  12227. * It emits the particles randomly between 2 given directions.
  12228. */
  12229. export class BoxParticleEmitter implements IParticleEmitterType {
  12230. /**
  12231. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12232. */
  12233. direction1: Vector3;
  12234. /**
  12235. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12236. */
  12237. direction2: Vector3;
  12238. /**
  12239. * 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.
  12240. */
  12241. minEmitBox: Vector3;
  12242. /**
  12243. * 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.
  12244. */
  12245. maxEmitBox: Vector3;
  12246. /**
  12247. * Creates a new instance BoxParticleEmitter
  12248. */
  12249. constructor();
  12250. /**
  12251. * Called by the particle System when the direction is computed for the created particle.
  12252. * @param worldMatrix is the world matrix of the particle system
  12253. * @param directionToUpdate is the direction vector to update with the result
  12254. * @param particle is the particle we are computed the direction for
  12255. * @param isLocal defines if the direction should be set in local space
  12256. */
  12257. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12258. /**
  12259. * Called by the particle System when the position is computed for the created particle.
  12260. * @param worldMatrix is the world matrix of the particle system
  12261. * @param positionToUpdate is the position vector to update with the result
  12262. * @param particle is the particle we are computed the position for
  12263. * @param isLocal defines if the position should be set in local space
  12264. */
  12265. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12266. /**
  12267. * Clones the current emitter and returns a copy of it
  12268. * @returns the new emitter
  12269. */
  12270. clone(): BoxParticleEmitter;
  12271. /**
  12272. * Called by the GPUParticleSystem to setup the update shader
  12273. * @param effect defines the update shader
  12274. */
  12275. applyToShader(effect: Effect): void;
  12276. /**
  12277. * Returns a string to use to update the GPU particles update shader
  12278. * @returns a string containng the defines string
  12279. */
  12280. getEffectDefines(): string;
  12281. /**
  12282. * Returns the string "BoxParticleEmitter"
  12283. * @returns a string containing the class name
  12284. */
  12285. getClassName(): string;
  12286. /**
  12287. * Serializes the particle system to a JSON object.
  12288. * @returns the JSON object
  12289. */
  12290. serialize(): any;
  12291. /**
  12292. * Parse properties from a JSON object
  12293. * @param serializationObject defines the JSON object
  12294. */
  12295. parse(serializationObject: any): void;
  12296. }
  12297. }
  12298. declare module BABYLON {
  12299. /**
  12300. * Particle emitter emitting particles from the inside of a cone.
  12301. * It emits the particles alongside the cone volume from the base to the particle.
  12302. * The emission direction might be randomized.
  12303. */
  12304. export class ConeParticleEmitter implements IParticleEmitterType {
  12305. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12306. directionRandomizer: number;
  12307. private _radius;
  12308. private _angle;
  12309. private _height;
  12310. /**
  12311. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12312. */
  12313. radiusRange: number;
  12314. /**
  12315. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12316. */
  12317. heightRange: number;
  12318. /**
  12319. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12320. */
  12321. emitFromSpawnPointOnly: boolean;
  12322. /**
  12323. * Gets or sets the radius of the emission cone
  12324. */
  12325. get radius(): number;
  12326. set radius(value: number);
  12327. /**
  12328. * Gets or sets the angle of the emission cone
  12329. */
  12330. get angle(): number;
  12331. set angle(value: number);
  12332. private _buildHeight;
  12333. /**
  12334. * Creates a new instance ConeParticleEmitter
  12335. * @param radius the radius of the emission cone (1 by default)
  12336. * @param angle the cone base angle (PI by default)
  12337. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12338. */
  12339. constructor(radius?: number, angle?: number,
  12340. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12341. directionRandomizer?: number);
  12342. /**
  12343. * Called by the particle System when the direction is computed for the created particle.
  12344. * @param worldMatrix is the world matrix of the particle system
  12345. * @param directionToUpdate is the direction vector to update with the result
  12346. * @param particle is the particle we are computed the direction for
  12347. * @param isLocal defines if the direction should be set in local space
  12348. */
  12349. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12350. /**
  12351. * Called by the particle System when the position is computed for the created particle.
  12352. * @param worldMatrix is the world matrix of the particle system
  12353. * @param positionToUpdate is the position vector to update with the result
  12354. * @param particle is the particle we are computed the position for
  12355. * @param isLocal defines if the position should be set in local space
  12356. */
  12357. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12358. /**
  12359. * Clones the current emitter and returns a copy of it
  12360. * @returns the new emitter
  12361. */
  12362. clone(): ConeParticleEmitter;
  12363. /**
  12364. * Called by the GPUParticleSystem to setup the update shader
  12365. * @param effect defines the update shader
  12366. */
  12367. applyToShader(effect: Effect): void;
  12368. /**
  12369. * Returns a string to use to update the GPU particles update shader
  12370. * @returns a string containng the defines string
  12371. */
  12372. getEffectDefines(): string;
  12373. /**
  12374. * Returns the string "ConeParticleEmitter"
  12375. * @returns a string containing the class name
  12376. */
  12377. getClassName(): string;
  12378. /**
  12379. * Serializes the particle system to a JSON object.
  12380. * @returns the JSON object
  12381. */
  12382. serialize(): any;
  12383. /**
  12384. * Parse properties from a JSON object
  12385. * @param serializationObject defines the JSON object
  12386. */
  12387. parse(serializationObject: any): void;
  12388. }
  12389. }
  12390. declare module BABYLON {
  12391. /**
  12392. * Particle emitter emitting particles from the inside of a cylinder.
  12393. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12394. */
  12395. export class CylinderParticleEmitter implements IParticleEmitterType {
  12396. /**
  12397. * The radius of the emission cylinder.
  12398. */
  12399. radius: number;
  12400. /**
  12401. * The height of the emission cylinder.
  12402. */
  12403. height: number;
  12404. /**
  12405. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12406. */
  12407. radiusRange: number;
  12408. /**
  12409. * How much to randomize the particle direction [0-1].
  12410. */
  12411. directionRandomizer: number;
  12412. /**
  12413. * Creates a new instance CylinderParticleEmitter
  12414. * @param radius the radius of the emission cylinder (1 by default)
  12415. * @param height the height of the emission cylinder (1 by default)
  12416. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12417. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12418. */
  12419. constructor(
  12420. /**
  12421. * The radius of the emission cylinder.
  12422. */
  12423. radius?: number,
  12424. /**
  12425. * The height of the emission cylinder.
  12426. */
  12427. height?: number,
  12428. /**
  12429. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12430. */
  12431. radiusRange?: number,
  12432. /**
  12433. * How much to randomize the particle direction [0-1].
  12434. */
  12435. directionRandomizer?: number);
  12436. /**
  12437. * Called by the particle System when the direction is computed for the created particle.
  12438. * @param worldMatrix is the world matrix of the particle system
  12439. * @param directionToUpdate is the direction vector to update with the result
  12440. * @param particle is the particle we are computed the direction for
  12441. * @param isLocal defines if the direction should be set in local space
  12442. */
  12443. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12444. /**
  12445. * Called by the particle System when the position is computed for the created particle.
  12446. * @param worldMatrix is the world matrix of the particle system
  12447. * @param positionToUpdate is the position vector to update with the result
  12448. * @param particle is the particle we are computed the position for
  12449. * @param isLocal defines if the position should be set in local space
  12450. */
  12451. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12452. /**
  12453. * Clones the current emitter and returns a copy of it
  12454. * @returns the new emitter
  12455. */
  12456. clone(): CylinderParticleEmitter;
  12457. /**
  12458. * Called by the GPUParticleSystem to setup the update shader
  12459. * @param effect defines the update shader
  12460. */
  12461. applyToShader(effect: Effect): void;
  12462. /**
  12463. * Returns a string to use to update the GPU particles update shader
  12464. * @returns a string containng the defines string
  12465. */
  12466. getEffectDefines(): string;
  12467. /**
  12468. * Returns the string "CylinderParticleEmitter"
  12469. * @returns a string containing the class name
  12470. */
  12471. getClassName(): string;
  12472. /**
  12473. * Serializes the particle system to a JSON object.
  12474. * @returns the JSON object
  12475. */
  12476. serialize(): any;
  12477. /**
  12478. * Parse properties from a JSON object
  12479. * @param serializationObject defines the JSON object
  12480. */
  12481. parse(serializationObject: any): void;
  12482. }
  12483. /**
  12484. * Particle emitter emitting particles from the inside of a cylinder.
  12485. * It emits the particles randomly between two vectors.
  12486. */
  12487. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12488. /**
  12489. * The min limit of the emission direction.
  12490. */
  12491. direction1: Vector3;
  12492. /**
  12493. * The max limit of the emission direction.
  12494. */
  12495. direction2: Vector3;
  12496. /**
  12497. * Creates a new instance CylinderDirectedParticleEmitter
  12498. * @param radius the radius of the emission cylinder (1 by default)
  12499. * @param height the height of the emission cylinder (1 by default)
  12500. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12501. * @param direction1 the min limit of the emission direction (up vector by default)
  12502. * @param direction2 the max limit of the emission direction (up vector by default)
  12503. */
  12504. constructor(radius?: number, height?: number, radiusRange?: number,
  12505. /**
  12506. * The min limit of the emission direction.
  12507. */
  12508. direction1?: Vector3,
  12509. /**
  12510. * The max limit of the emission direction.
  12511. */
  12512. direction2?: Vector3);
  12513. /**
  12514. * Called by the particle System when the direction is computed for the created particle.
  12515. * @param worldMatrix is the world matrix of the particle system
  12516. * @param directionToUpdate is the direction vector to update with the result
  12517. * @param particle is the particle we are computed the direction for
  12518. */
  12519. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12520. /**
  12521. * Clones the current emitter and returns a copy of it
  12522. * @returns the new emitter
  12523. */
  12524. clone(): CylinderDirectedParticleEmitter;
  12525. /**
  12526. * Called by the GPUParticleSystem to setup the update shader
  12527. * @param effect defines the update shader
  12528. */
  12529. applyToShader(effect: Effect): void;
  12530. /**
  12531. * Returns a string to use to update the GPU particles update shader
  12532. * @returns a string containng the defines string
  12533. */
  12534. getEffectDefines(): string;
  12535. /**
  12536. * Returns the string "CylinderDirectedParticleEmitter"
  12537. * @returns a string containing the class name
  12538. */
  12539. getClassName(): string;
  12540. /**
  12541. * Serializes the particle system to a JSON object.
  12542. * @returns the JSON object
  12543. */
  12544. serialize(): any;
  12545. /**
  12546. * Parse properties from a JSON object
  12547. * @param serializationObject defines the JSON object
  12548. */
  12549. parse(serializationObject: any): void;
  12550. }
  12551. }
  12552. declare module BABYLON {
  12553. /**
  12554. * Particle emitter emitting particles from the inside of a hemisphere.
  12555. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12556. */
  12557. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12558. /**
  12559. * The radius of the emission hemisphere.
  12560. */
  12561. radius: number;
  12562. /**
  12563. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12564. */
  12565. radiusRange: number;
  12566. /**
  12567. * How much to randomize the particle direction [0-1].
  12568. */
  12569. directionRandomizer: number;
  12570. /**
  12571. * Creates a new instance HemisphericParticleEmitter
  12572. * @param radius the radius of the emission hemisphere (1 by default)
  12573. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12574. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12575. */
  12576. constructor(
  12577. /**
  12578. * The radius of the emission hemisphere.
  12579. */
  12580. radius?: number,
  12581. /**
  12582. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12583. */
  12584. radiusRange?: number,
  12585. /**
  12586. * How much to randomize the particle direction [0-1].
  12587. */
  12588. directionRandomizer?: number);
  12589. /**
  12590. * Called by the particle System when the direction is computed for the created particle.
  12591. * @param worldMatrix is the world matrix of the particle system
  12592. * @param directionToUpdate is the direction vector to update with the result
  12593. * @param particle is the particle we are computed the direction for
  12594. * @param isLocal defines if the direction should be set in local space
  12595. */
  12596. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12597. /**
  12598. * Called by the particle System when the position is computed for the created particle.
  12599. * @param worldMatrix is the world matrix of the particle system
  12600. * @param positionToUpdate is the position vector to update with the result
  12601. * @param particle is the particle we are computed the position for
  12602. * @param isLocal defines if the position should be set in local space
  12603. */
  12604. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12605. /**
  12606. * Clones the current emitter and returns a copy of it
  12607. * @returns the new emitter
  12608. */
  12609. clone(): HemisphericParticleEmitter;
  12610. /**
  12611. * Called by the GPUParticleSystem to setup the update shader
  12612. * @param effect defines the update shader
  12613. */
  12614. applyToShader(effect: Effect): void;
  12615. /**
  12616. * Returns a string to use to update the GPU particles update shader
  12617. * @returns a string containng the defines string
  12618. */
  12619. getEffectDefines(): string;
  12620. /**
  12621. * Returns the string "HemisphericParticleEmitter"
  12622. * @returns a string containing the class name
  12623. */
  12624. getClassName(): string;
  12625. /**
  12626. * Serializes the particle system to a JSON object.
  12627. * @returns the JSON object
  12628. */
  12629. serialize(): any;
  12630. /**
  12631. * Parse properties from a JSON object
  12632. * @param serializationObject defines the JSON object
  12633. */
  12634. parse(serializationObject: any): void;
  12635. }
  12636. }
  12637. declare module BABYLON {
  12638. /**
  12639. * Particle emitter emitting particles from a point.
  12640. * It emits the particles randomly between 2 given directions.
  12641. */
  12642. export class PointParticleEmitter implements IParticleEmitterType {
  12643. /**
  12644. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12645. */
  12646. direction1: Vector3;
  12647. /**
  12648. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12649. */
  12650. direction2: Vector3;
  12651. /**
  12652. * Creates a new instance PointParticleEmitter
  12653. */
  12654. constructor();
  12655. /**
  12656. * Called by the particle System when the direction is computed for the created particle.
  12657. * @param worldMatrix is the world matrix of the particle system
  12658. * @param directionToUpdate is the direction vector to update with the result
  12659. * @param particle is the particle we are computed the direction for
  12660. * @param isLocal defines if the direction should be set in local space
  12661. */
  12662. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12663. /**
  12664. * Called by the particle System when the position is computed for the created particle.
  12665. * @param worldMatrix is the world matrix of the particle system
  12666. * @param positionToUpdate is the position vector to update with the result
  12667. * @param particle is the particle we are computed the position for
  12668. * @param isLocal defines if the position should be set in local space
  12669. */
  12670. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12671. /**
  12672. * Clones the current emitter and returns a copy of it
  12673. * @returns the new emitter
  12674. */
  12675. clone(): PointParticleEmitter;
  12676. /**
  12677. * Called by the GPUParticleSystem to setup the update shader
  12678. * @param effect defines the update shader
  12679. */
  12680. applyToShader(effect: Effect): void;
  12681. /**
  12682. * Returns a string to use to update the GPU particles update shader
  12683. * @returns a string containng the defines string
  12684. */
  12685. getEffectDefines(): string;
  12686. /**
  12687. * Returns the string "PointParticleEmitter"
  12688. * @returns a string containing the class name
  12689. */
  12690. getClassName(): string;
  12691. /**
  12692. * Serializes the particle system to a JSON object.
  12693. * @returns the JSON object
  12694. */
  12695. serialize(): any;
  12696. /**
  12697. * Parse properties from a JSON object
  12698. * @param serializationObject defines the JSON object
  12699. */
  12700. parse(serializationObject: any): void;
  12701. }
  12702. }
  12703. declare module BABYLON {
  12704. /**
  12705. * Particle emitter emitting particles from the inside of a sphere.
  12706. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12707. */
  12708. export class SphereParticleEmitter implements IParticleEmitterType {
  12709. /**
  12710. * The radius of the emission sphere.
  12711. */
  12712. radius: number;
  12713. /**
  12714. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12715. */
  12716. radiusRange: number;
  12717. /**
  12718. * How much to randomize the particle direction [0-1].
  12719. */
  12720. directionRandomizer: number;
  12721. /**
  12722. * Creates a new instance SphereParticleEmitter
  12723. * @param radius the radius of the emission sphere (1 by default)
  12724. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12725. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12726. */
  12727. constructor(
  12728. /**
  12729. * The radius of the emission sphere.
  12730. */
  12731. radius?: number,
  12732. /**
  12733. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12734. */
  12735. radiusRange?: number,
  12736. /**
  12737. * How much to randomize the particle direction [0-1].
  12738. */
  12739. directionRandomizer?: number);
  12740. /**
  12741. * Called by the particle System when the direction is computed for the created particle.
  12742. * @param worldMatrix is the world matrix of the particle system
  12743. * @param directionToUpdate is the direction vector to update with the result
  12744. * @param particle is the particle we are computed the direction for
  12745. * @param isLocal defines if the direction should be set in local space
  12746. */
  12747. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12748. /**
  12749. * Called by the particle System when the position is computed for the created particle.
  12750. * @param worldMatrix is the world matrix of the particle system
  12751. * @param positionToUpdate is the position vector to update with the result
  12752. * @param particle is the particle we are computed the position for
  12753. * @param isLocal defines if the position should be set in local space
  12754. */
  12755. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12756. /**
  12757. * Clones the current emitter and returns a copy of it
  12758. * @returns the new emitter
  12759. */
  12760. clone(): SphereParticleEmitter;
  12761. /**
  12762. * Called by the GPUParticleSystem to setup the update shader
  12763. * @param effect defines the update shader
  12764. */
  12765. applyToShader(effect: Effect): void;
  12766. /**
  12767. * Returns a string to use to update the GPU particles update shader
  12768. * @returns a string containng the defines string
  12769. */
  12770. getEffectDefines(): string;
  12771. /**
  12772. * Returns the string "SphereParticleEmitter"
  12773. * @returns a string containing the class name
  12774. */
  12775. getClassName(): string;
  12776. /**
  12777. * Serializes the particle system to a JSON object.
  12778. * @returns the JSON object
  12779. */
  12780. serialize(): any;
  12781. /**
  12782. * Parse properties from a JSON object
  12783. * @param serializationObject defines the JSON object
  12784. */
  12785. parse(serializationObject: any): void;
  12786. }
  12787. /**
  12788. * Particle emitter emitting particles from the inside of a sphere.
  12789. * It emits the particles randomly between two vectors.
  12790. */
  12791. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12792. /**
  12793. * The min limit of the emission direction.
  12794. */
  12795. direction1: Vector3;
  12796. /**
  12797. * The max limit of the emission direction.
  12798. */
  12799. direction2: Vector3;
  12800. /**
  12801. * Creates a new instance SphereDirectedParticleEmitter
  12802. * @param radius the radius of the emission sphere (1 by default)
  12803. * @param direction1 the min limit of the emission direction (up vector by default)
  12804. * @param direction2 the max limit of the emission direction (up vector by default)
  12805. */
  12806. constructor(radius?: number,
  12807. /**
  12808. * The min limit of the emission direction.
  12809. */
  12810. direction1?: Vector3,
  12811. /**
  12812. * The max limit of the emission direction.
  12813. */
  12814. direction2?: Vector3);
  12815. /**
  12816. * Called by the particle System when the direction is computed for the created particle.
  12817. * @param worldMatrix is the world matrix of the particle system
  12818. * @param directionToUpdate is the direction vector to update with the result
  12819. * @param particle is the particle we are computed the direction for
  12820. */
  12821. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12822. /**
  12823. * Clones the current emitter and returns a copy of it
  12824. * @returns the new emitter
  12825. */
  12826. clone(): SphereDirectedParticleEmitter;
  12827. /**
  12828. * Called by the GPUParticleSystem to setup the update shader
  12829. * @param effect defines the update shader
  12830. */
  12831. applyToShader(effect: Effect): void;
  12832. /**
  12833. * Returns a string to use to update the GPU particles update shader
  12834. * @returns a string containng the defines string
  12835. */
  12836. getEffectDefines(): string;
  12837. /**
  12838. * Returns the string "SphereDirectedParticleEmitter"
  12839. * @returns a string containing the class name
  12840. */
  12841. getClassName(): string;
  12842. /**
  12843. * Serializes the particle system to a JSON object.
  12844. * @returns the JSON object
  12845. */
  12846. serialize(): any;
  12847. /**
  12848. * Parse properties from a JSON object
  12849. * @param serializationObject defines the JSON object
  12850. */
  12851. parse(serializationObject: any): void;
  12852. }
  12853. }
  12854. declare module BABYLON {
  12855. /**
  12856. * Particle emitter emitting particles from a custom list of positions.
  12857. */
  12858. export class CustomParticleEmitter implements IParticleEmitterType {
  12859. /**
  12860. * Gets or sets the position generator that will create the inital position of each particle.
  12861. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12862. */
  12863. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12864. /**
  12865. * Gets or sets the destination generator that will create the final destination of each particle.
  12866. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12867. */
  12868. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12869. /**
  12870. * Creates a new instance CustomParticleEmitter
  12871. */
  12872. constructor();
  12873. /**
  12874. * Called by the particle System when the direction is computed for the created particle.
  12875. * @param worldMatrix is the world matrix of the particle system
  12876. * @param directionToUpdate is the direction vector to update with the result
  12877. * @param particle is the particle we are computed the direction for
  12878. * @param isLocal defines if the direction should be set in local space
  12879. */
  12880. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12881. /**
  12882. * Called by the particle System when the position is computed for the created particle.
  12883. * @param worldMatrix is the world matrix of the particle system
  12884. * @param positionToUpdate is the position vector to update with the result
  12885. * @param particle is the particle we are computed the position for
  12886. * @param isLocal defines if the position should be set in local space
  12887. */
  12888. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12889. /**
  12890. * Clones the current emitter and returns a copy of it
  12891. * @returns the new emitter
  12892. */
  12893. clone(): CustomParticleEmitter;
  12894. /**
  12895. * Called by the GPUParticleSystem to setup the update shader
  12896. * @param effect defines the update shader
  12897. */
  12898. applyToShader(effect: Effect): void;
  12899. /**
  12900. * Returns a string to use to update the GPU particles update shader
  12901. * @returns a string containng the defines string
  12902. */
  12903. getEffectDefines(): string;
  12904. /**
  12905. * Returns the string "PointParticleEmitter"
  12906. * @returns a string containing the class name
  12907. */
  12908. getClassName(): string;
  12909. /**
  12910. * Serializes the particle system to a JSON object.
  12911. * @returns the JSON object
  12912. */
  12913. serialize(): any;
  12914. /**
  12915. * Parse properties from a JSON object
  12916. * @param serializationObject defines the JSON object
  12917. */
  12918. parse(serializationObject: any): void;
  12919. }
  12920. }
  12921. declare module BABYLON {
  12922. /**
  12923. * Particle emitter emitting particles from the inside of a box.
  12924. * It emits the particles randomly between 2 given directions.
  12925. */
  12926. export class MeshParticleEmitter implements IParticleEmitterType {
  12927. private _indices;
  12928. private _positions;
  12929. private _normals;
  12930. private _storedNormal;
  12931. private _mesh;
  12932. /**
  12933. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12934. */
  12935. direction1: Vector3;
  12936. /**
  12937. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12938. */
  12939. direction2: Vector3;
  12940. /**
  12941. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12942. */
  12943. useMeshNormalsForDirection: boolean;
  12944. /** Defines the mesh to use as source */
  12945. get mesh(): Nullable<AbstractMesh>;
  12946. set mesh(value: Nullable<AbstractMesh>);
  12947. /**
  12948. * Creates a new instance MeshParticleEmitter
  12949. * @param mesh defines the mesh to use as source
  12950. */
  12951. constructor(mesh?: Nullable<AbstractMesh>);
  12952. /**
  12953. * Called by the particle System when the direction is computed for the created particle.
  12954. * @param worldMatrix is the world matrix of the particle system
  12955. * @param directionToUpdate is the direction vector to update with the result
  12956. * @param particle is the particle we are computed the direction for
  12957. * @param isLocal defines if the direction should be set in local space
  12958. */
  12959. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12960. /**
  12961. * Called by the particle System when the position is computed for the created particle.
  12962. * @param worldMatrix is the world matrix of the particle system
  12963. * @param positionToUpdate is the position vector to update with the result
  12964. * @param particle is the particle we are computed the position for
  12965. * @param isLocal defines if the position should be set in local space
  12966. */
  12967. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12968. /**
  12969. * Clones the current emitter and returns a copy of it
  12970. * @returns the new emitter
  12971. */
  12972. clone(): MeshParticleEmitter;
  12973. /**
  12974. * Called by the GPUParticleSystem to setup the update shader
  12975. * @param effect defines the update shader
  12976. */
  12977. applyToShader(effect: Effect): void;
  12978. /**
  12979. * Returns a string to use to update the GPU particles update shader
  12980. * @returns a string containng the defines string
  12981. */
  12982. getEffectDefines(): string;
  12983. /**
  12984. * Returns the string "BoxParticleEmitter"
  12985. * @returns a string containing the class name
  12986. */
  12987. getClassName(): string;
  12988. /**
  12989. * Serializes the particle system to a JSON object.
  12990. * @returns the JSON object
  12991. */
  12992. serialize(): any;
  12993. /**
  12994. * Parse properties from a JSON object
  12995. * @param serializationObject defines the JSON object
  12996. * @param scene defines the hosting scene
  12997. */
  12998. parse(serializationObject: any, scene: Scene): void;
  12999. }
  13000. }
  13001. declare module BABYLON {
  13002. /**
  13003. * Interface representing a particle system in Babylon.js.
  13004. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13005. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13006. */
  13007. export interface IParticleSystem {
  13008. /**
  13009. * List of animations used by the particle system.
  13010. */
  13011. animations: Animation[];
  13012. /**
  13013. * The id of the Particle system.
  13014. */
  13015. id: string;
  13016. /**
  13017. * The name of the Particle system.
  13018. */
  13019. name: string;
  13020. /**
  13021. * The emitter represents the Mesh or position we are attaching the particle system to.
  13022. */
  13023. emitter: Nullable<AbstractMesh | Vector3>;
  13024. /**
  13025. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13026. */
  13027. isBillboardBased: boolean;
  13028. /**
  13029. * The rendering group used by the Particle system to chose when to render.
  13030. */
  13031. renderingGroupId: number;
  13032. /**
  13033. * The layer mask we are rendering the particles through.
  13034. */
  13035. layerMask: number;
  13036. /**
  13037. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13038. */
  13039. updateSpeed: number;
  13040. /**
  13041. * The amount of time the particle system is running (depends of the overall update speed).
  13042. */
  13043. targetStopDuration: number;
  13044. /**
  13045. * The texture used to render each particle. (this can be a spritesheet)
  13046. */
  13047. particleTexture: Nullable<Texture>;
  13048. /**
  13049. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13050. */
  13051. blendMode: number;
  13052. /**
  13053. * Minimum life time of emitting particles.
  13054. */
  13055. minLifeTime: number;
  13056. /**
  13057. * Maximum life time of emitting particles.
  13058. */
  13059. maxLifeTime: number;
  13060. /**
  13061. * Minimum Size of emitting particles.
  13062. */
  13063. minSize: number;
  13064. /**
  13065. * Maximum Size of emitting particles.
  13066. */
  13067. maxSize: number;
  13068. /**
  13069. * Minimum scale of emitting particles on X axis.
  13070. */
  13071. minScaleX: number;
  13072. /**
  13073. * Maximum scale of emitting particles on X axis.
  13074. */
  13075. maxScaleX: number;
  13076. /**
  13077. * Minimum scale of emitting particles on Y axis.
  13078. */
  13079. minScaleY: number;
  13080. /**
  13081. * Maximum scale of emitting particles on Y axis.
  13082. */
  13083. maxScaleY: number;
  13084. /**
  13085. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13086. */
  13087. color1: Color4;
  13088. /**
  13089. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13090. */
  13091. color2: Color4;
  13092. /**
  13093. * Color the particle will have at the end of its lifetime.
  13094. */
  13095. colorDead: Color4;
  13096. /**
  13097. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13098. */
  13099. emitRate: number;
  13100. /**
  13101. * You can use gravity if you want to give an orientation to your particles.
  13102. */
  13103. gravity: Vector3;
  13104. /**
  13105. * Minimum power of emitting particles.
  13106. */
  13107. minEmitPower: number;
  13108. /**
  13109. * Maximum power of emitting particles.
  13110. */
  13111. maxEmitPower: number;
  13112. /**
  13113. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13114. */
  13115. minAngularSpeed: number;
  13116. /**
  13117. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13118. */
  13119. maxAngularSpeed: number;
  13120. /**
  13121. * Gets or sets the minimal initial rotation in radians.
  13122. */
  13123. minInitialRotation: number;
  13124. /**
  13125. * Gets or sets the maximal initial rotation in radians.
  13126. */
  13127. maxInitialRotation: number;
  13128. /**
  13129. * The particle emitter type defines the emitter used by the particle system.
  13130. * It can be for example box, sphere, or cone...
  13131. */
  13132. particleEmitterType: Nullable<IParticleEmitterType>;
  13133. /**
  13134. * Defines the delay in milliseconds before starting the system (0 by default)
  13135. */
  13136. startDelay: number;
  13137. /**
  13138. * 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
  13139. */
  13140. preWarmCycles: number;
  13141. /**
  13142. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13143. */
  13144. preWarmStepOffset: number;
  13145. /**
  13146. * 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)
  13147. */
  13148. spriteCellChangeSpeed: number;
  13149. /**
  13150. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13151. */
  13152. startSpriteCellID: number;
  13153. /**
  13154. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13155. */
  13156. endSpriteCellID: number;
  13157. /**
  13158. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13159. */
  13160. spriteCellWidth: number;
  13161. /**
  13162. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13163. */
  13164. spriteCellHeight: number;
  13165. /**
  13166. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13167. */
  13168. spriteRandomStartCell: boolean;
  13169. /**
  13170. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13171. */
  13172. isAnimationSheetEnabled: boolean;
  13173. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13174. translationPivot: Vector2;
  13175. /**
  13176. * Gets or sets a texture used to add random noise to particle positions
  13177. */
  13178. noiseTexture: Nullable<BaseTexture>;
  13179. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13180. noiseStrength: Vector3;
  13181. /**
  13182. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13183. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13184. */
  13185. billboardMode: number;
  13186. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13187. limitVelocityDamping: number;
  13188. /**
  13189. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13190. */
  13191. beginAnimationOnStart: boolean;
  13192. /**
  13193. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13194. */
  13195. beginAnimationFrom: number;
  13196. /**
  13197. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13198. */
  13199. beginAnimationTo: number;
  13200. /**
  13201. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13202. */
  13203. beginAnimationLoop: boolean;
  13204. /**
  13205. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13206. */
  13207. disposeOnStop: boolean;
  13208. /**
  13209. * Specifies if the particles are updated in emitter local space or world space
  13210. */
  13211. isLocal: boolean;
  13212. /** Snippet ID if the particle system was created from the snippet server */
  13213. snippetId: string;
  13214. /**
  13215. * Gets the maximum number of particles active at the same time.
  13216. * @returns The max number of active particles.
  13217. */
  13218. getCapacity(): number;
  13219. /**
  13220. * Gets the number of particles active at the same time.
  13221. * @returns The number of active particles.
  13222. */
  13223. getActiveCount(): number;
  13224. /**
  13225. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13226. * @returns True if it has been started, otherwise false.
  13227. */
  13228. isStarted(): boolean;
  13229. /**
  13230. * Animates the particle system for this frame.
  13231. */
  13232. animate(): void;
  13233. /**
  13234. * Renders the particle system in its current state.
  13235. * @returns the current number of particles
  13236. */
  13237. render(): number;
  13238. /**
  13239. * Dispose the particle system and frees its associated resources.
  13240. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13241. */
  13242. dispose(disposeTexture?: boolean): void;
  13243. /**
  13244. * Clones the particle system.
  13245. * @param name The name of the cloned object
  13246. * @param newEmitter The new emitter to use
  13247. * @returns the cloned particle system
  13248. */
  13249. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13250. /**
  13251. * Serializes the particle system to a JSON object
  13252. * @param serializeTexture defines if the texture must be serialized as well
  13253. * @returns the JSON object
  13254. */
  13255. serialize(serializeTexture: boolean): any;
  13256. /**
  13257. * Rebuild the particle system
  13258. */
  13259. rebuild(): void;
  13260. /**
  13261. * Starts the particle system and begins to emit
  13262. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13263. */
  13264. start(delay?: number): void;
  13265. /**
  13266. * Stops the particle system.
  13267. */
  13268. stop(): void;
  13269. /**
  13270. * Remove all active particles
  13271. */
  13272. reset(): void;
  13273. /**
  13274. * Gets a boolean indicating that the system is stopping
  13275. * @returns true if the system is currently stopping
  13276. */
  13277. isStopping(): boolean;
  13278. /**
  13279. * Is this system ready to be used/rendered
  13280. * @return true if the system is ready
  13281. */
  13282. isReady(): boolean;
  13283. /**
  13284. * Returns the string "ParticleSystem"
  13285. * @returns a string containing the class name
  13286. */
  13287. getClassName(): string;
  13288. /**
  13289. * Adds a new color gradient
  13290. * @param gradient defines the gradient to use (between 0 and 1)
  13291. * @param color1 defines the color to affect to the specified gradient
  13292. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13293. * @returns the current particle system
  13294. */
  13295. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13296. /**
  13297. * Remove a specific color gradient
  13298. * @param gradient defines the gradient to remove
  13299. * @returns the current particle system
  13300. */
  13301. removeColorGradient(gradient: number): IParticleSystem;
  13302. /**
  13303. * Adds a new size gradient
  13304. * @param gradient defines the gradient to use (between 0 and 1)
  13305. * @param factor defines the size factor to affect to the specified gradient
  13306. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13307. * @returns the current particle system
  13308. */
  13309. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13310. /**
  13311. * Remove a specific size gradient
  13312. * @param gradient defines the gradient to remove
  13313. * @returns the current particle system
  13314. */
  13315. removeSizeGradient(gradient: number): IParticleSystem;
  13316. /**
  13317. * Gets the current list of color gradients.
  13318. * You must use addColorGradient and removeColorGradient to udpate this list
  13319. * @returns the list of color gradients
  13320. */
  13321. getColorGradients(): Nullable<Array<ColorGradient>>;
  13322. /**
  13323. * Gets the current list of size gradients.
  13324. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13325. * @returns the list of size gradients
  13326. */
  13327. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13328. /**
  13329. * Gets the current list of angular speed gradients.
  13330. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13331. * @returns the list of angular speed gradients
  13332. */
  13333. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13334. /**
  13335. * Adds a new angular speed gradient
  13336. * @param gradient defines the gradient to use (between 0 and 1)
  13337. * @param factor defines the angular speed to affect to the specified gradient
  13338. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13339. * @returns the current particle system
  13340. */
  13341. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13342. /**
  13343. * Remove a specific angular speed gradient
  13344. * @param gradient defines the gradient to remove
  13345. * @returns the current particle system
  13346. */
  13347. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13348. /**
  13349. * Gets the current list of velocity gradients.
  13350. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13351. * @returns the list of velocity gradients
  13352. */
  13353. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13354. /**
  13355. * Adds a new velocity gradient
  13356. * @param gradient defines the gradient to use (between 0 and 1)
  13357. * @param factor defines the velocity to affect to the specified gradient
  13358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13359. * @returns the current particle system
  13360. */
  13361. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13362. /**
  13363. * Remove a specific velocity gradient
  13364. * @param gradient defines the gradient to remove
  13365. * @returns the current particle system
  13366. */
  13367. removeVelocityGradient(gradient: number): IParticleSystem;
  13368. /**
  13369. * Gets the current list of limit velocity gradients.
  13370. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13371. * @returns the list of limit velocity gradients
  13372. */
  13373. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13374. /**
  13375. * Adds a new limit velocity gradient
  13376. * @param gradient defines the gradient to use (between 0 and 1)
  13377. * @param factor defines the limit velocity to affect to the specified gradient
  13378. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13379. * @returns the current particle system
  13380. */
  13381. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13382. /**
  13383. * Remove a specific limit velocity gradient
  13384. * @param gradient defines the gradient to remove
  13385. * @returns the current particle system
  13386. */
  13387. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13388. /**
  13389. * Adds a new drag gradient
  13390. * @param gradient defines the gradient to use (between 0 and 1)
  13391. * @param factor defines the drag to affect to the specified gradient
  13392. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13393. * @returns the current particle system
  13394. */
  13395. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13396. /**
  13397. * Remove a specific drag gradient
  13398. * @param gradient defines the gradient to remove
  13399. * @returns the current particle system
  13400. */
  13401. removeDragGradient(gradient: number): IParticleSystem;
  13402. /**
  13403. * Gets the current list of drag gradients.
  13404. * You must use addDragGradient and removeDragGradient to udpate this list
  13405. * @returns the list of drag gradients
  13406. */
  13407. getDragGradients(): Nullable<Array<FactorGradient>>;
  13408. /**
  13409. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13410. * @param gradient defines the gradient to use (between 0 and 1)
  13411. * @param factor defines the emit rate to affect to the specified gradient
  13412. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13413. * @returns the current particle system
  13414. */
  13415. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13416. /**
  13417. * Remove a specific emit rate gradient
  13418. * @param gradient defines the gradient to remove
  13419. * @returns the current particle system
  13420. */
  13421. removeEmitRateGradient(gradient: number): IParticleSystem;
  13422. /**
  13423. * Gets the current list of emit rate gradients.
  13424. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13425. * @returns the list of emit rate gradients
  13426. */
  13427. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13428. /**
  13429. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13430. * @param gradient defines the gradient to use (between 0 and 1)
  13431. * @param factor defines the start size to affect to the specified gradient
  13432. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13433. * @returns the current particle system
  13434. */
  13435. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13436. /**
  13437. * Remove a specific start size gradient
  13438. * @param gradient defines the gradient to remove
  13439. * @returns the current particle system
  13440. */
  13441. removeStartSizeGradient(gradient: number): IParticleSystem;
  13442. /**
  13443. * Gets the current list of start size gradients.
  13444. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13445. * @returns the list of start size gradients
  13446. */
  13447. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13448. /**
  13449. * Adds a new life time gradient
  13450. * @param gradient defines the gradient to use (between 0 and 1)
  13451. * @param factor defines the life time factor to affect to the specified gradient
  13452. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13453. * @returns the current particle system
  13454. */
  13455. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13456. /**
  13457. * Remove a specific life time gradient
  13458. * @param gradient defines the gradient to remove
  13459. * @returns the current particle system
  13460. */
  13461. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13462. /**
  13463. * Gets the current list of life time gradients.
  13464. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13465. * @returns the list of life time gradients
  13466. */
  13467. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13468. /**
  13469. * Gets the current list of color gradients.
  13470. * You must use addColorGradient and removeColorGradient to udpate this list
  13471. * @returns the list of color gradients
  13472. */
  13473. getColorGradients(): Nullable<Array<ColorGradient>>;
  13474. /**
  13475. * Adds a new ramp gradient used to remap particle colors
  13476. * @param gradient defines the gradient to use (between 0 and 1)
  13477. * @param color defines the color to affect to the specified gradient
  13478. * @returns the current particle system
  13479. */
  13480. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13481. /**
  13482. * Gets the current list of ramp gradients.
  13483. * You must use addRampGradient and removeRampGradient to udpate this list
  13484. * @returns the list of ramp gradients
  13485. */
  13486. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13487. /** Gets or sets a boolean indicating that ramp gradients must be used
  13488. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13489. */
  13490. useRampGradients: boolean;
  13491. /**
  13492. * Adds a new color remap gradient
  13493. * @param gradient defines the gradient to use (between 0 and 1)
  13494. * @param min defines the color remap minimal range
  13495. * @param max defines the color remap maximal range
  13496. * @returns the current particle system
  13497. */
  13498. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13499. /**
  13500. * Gets the current list of color remap gradients.
  13501. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13502. * @returns the list of color remap gradients
  13503. */
  13504. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13505. /**
  13506. * Adds a new alpha remap gradient
  13507. * @param gradient defines the gradient to use (between 0 and 1)
  13508. * @param min defines the alpha remap minimal range
  13509. * @param max defines the alpha remap maximal range
  13510. * @returns the current particle system
  13511. */
  13512. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13513. /**
  13514. * Gets the current list of alpha remap gradients.
  13515. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13516. * @returns the list of alpha remap gradients
  13517. */
  13518. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13519. /**
  13520. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13521. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13522. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13523. * @returns the emitter
  13524. */
  13525. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13526. /**
  13527. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13528. * @param radius The radius of the hemisphere to emit from
  13529. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13530. * @returns the emitter
  13531. */
  13532. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13533. /**
  13534. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13535. * @param radius The radius of the sphere to emit from
  13536. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13537. * @returns the emitter
  13538. */
  13539. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13540. /**
  13541. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13542. * @param radius The radius of the sphere to emit from
  13543. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13544. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13545. * @returns the emitter
  13546. */
  13547. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13548. /**
  13549. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13550. * @param radius The radius of the emission cylinder
  13551. * @param height The height of the emission cylinder
  13552. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13553. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13554. * @returns the emitter
  13555. */
  13556. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13557. /**
  13558. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13559. * @param radius The radius of the cylinder to emit from
  13560. * @param height The height of the emission cylinder
  13561. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13562. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13563. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13564. * @returns the emitter
  13565. */
  13566. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13567. /**
  13568. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13569. * @param radius The radius of the cone to emit from
  13570. * @param angle The base angle of the cone
  13571. * @returns the emitter
  13572. */
  13573. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13574. /**
  13575. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13576. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13577. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13578. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13579. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13580. * @returns the emitter
  13581. */
  13582. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13583. /**
  13584. * Get hosting scene
  13585. * @returns the scene
  13586. */
  13587. getScene(): Scene;
  13588. }
  13589. }
  13590. declare module BABYLON {
  13591. /**
  13592. * 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.
  13593. * @see https://doc.babylonjs.com/how_to/transformnode
  13594. */
  13595. export class TransformNode extends Node {
  13596. /**
  13597. * Object will not rotate to face the camera
  13598. */
  13599. static BILLBOARDMODE_NONE: number;
  13600. /**
  13601. * Object will rotate to face the camera but only on the x axis
  13602. */
  13603. static BILLBOARDMODE_X: number;
  13604. /**
  13605. * Object will rotate to face the camera but only on the y axis
  13606. */
  13607. static BILLBOARDMODE_Y: number;
  13608. /**
  13609. * Object will rotate to face the camera but only on the z axis
  13610. */
  13611. static BILLBOARDMODE_Z: number;
  13612. /**
  13613. * Object will rotate to face the camera
  13614. */
  13615. static BILLBOARDMODE_ALL: number;
  13616. /**
  13617. * Object will rotate to face the camera's position instead of orientation
  13618. */
  13619. static BILLBOARDMODE_USE_POSITION: number;
  13620. private _forward;
  13621. private _forwardInverted;
  13622. private _up;
  13623. private _right;
  13624. private _rightInverted;
  13625. private _position;
  13626. private _rotation;
  13627. private _rotationQuaternion;
  13628. protected _scaling: Vector3;
  13629. protected _isDirty: boolean;
  13630. private _transformToBoneReferal;
  13631. private _isAbsoluteSynced;
  13632. private _billboardMode;
  13633. /**
  13634. * Gets or sets the billboard mode. Default is 0.
  13635. *
  13636. * | Value | Type | Description |
  13637. * | --- | --- | --- |
  13638. * | 0 | BILLBOARDMODE_NONE | |
  13639. * | 1 | BILLBOARDMODE_X | |
  13640. * | 2 | BILLBOARDMODE_Y | |
  13641. * | 4 | BILLBOARDMODE_Z | |
  13642. * | 7 | BILLBOARDMODE_ALL | |
  13643. *
  13644. */
  13645. get billboardMode(): number;
  13646. set billboardMode(value: number);
  13647. private _preserveParentRotationForBillboard;
  13648. /**
  13649. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13650. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13651. */
  13652. get preserveParentRotationForBillboard(): boolean;
  13653. set preserveParentRotationForBillboard(value: boolean);
  13654. /**
  13655. * 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
  13656. */
  13657. scalingDeterminant: number;
  13658. private _infiniteDistance;
  13659. /**
  13660. * Gets or sets the distance of the object to max, often used by skybox
  13661. */
  13662. get infiniteDistance(): boolean;
  13663. set infiniteDistance(value: boolean);
  13664. /**
  13665. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13666. * By default the system will update normals to compensate
  13667. */
  13668. ignoreNonUniformScaling: boolean;
  13669. /**
  13670. * 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
  13671. */
  13672. reIntegrateRotationIntoRotationQuaternion: boolean;
  13673. /** @hidden */
  13674. _poseMatrix: Nullable<Matrix>;
  13675. /** @hidden */
  13676. _localMatrix: Matrix;
  13677. private _usePivotMatrix;
  13678. private _absolutePosition;
  13679. private _absoluteScaling;
  13680. private _absoluteRotationQuaternion;
  13681. private _pivotMatrix;
  13682. private _pivotMatrixInverse;
  13683. protected _postMultiplyPivotMatrix: boolean;
  13684. protected _isWorldMatrixFrozen: boolean;
  13685. /** @hidden */
  13686. _indexInSceneTransformNodesArray: number;
  13687. /**
  13688. * An event triggered after the world matrix is updated
  13689. */
  13690. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13691. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13692. /**
  13693. * Gets a string identifying the name of the class
  13694. * @returns "TransformNode" string
  13695. */
  13696. getClassName(): string;
  13697. /**
  13698. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13699. */
  13700. get position(): Vector3;
  13701. set position(newPosition: Vector3);
  13702. /**
  13703. * 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)).
  13704. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13705. */
  13706. get rotation(): Vector3;
  13707. set rotation(newRotation: Vector3);
  13708. /**
  13709. * 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)).
  13710. */
  13711. get scaling(): Vector3;
  13712. set scaling(newScaling: Vector3);
  13713. /**
  13714. * 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).
  13715. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13716. */
  13717. get rotationQuaternion(): Nullable<Quaternion>;
  13718. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13719. /**
  13720. * The forward direction of that transform in world space.
  13721. */
  13722. get forward(): Vector3;
  13723. /**
  13724. * The up direction of that transform in world space.
  13725. */
  13726. get up(): Vector3;
  13727. /**
  13728. * The right direction of that transform in world space.
  13729. */
  13730. get right(): Vector3;
  13731. /**
  13732. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13733. * @param matrix the matrix to copy the pose from
  13734. * @returns this TransformNode.
  13735. */
  13736. updatePoseMatrix(matrix: Matrix): TransformNode;
  13737. /**
  13738. * Returns the mesh Pose matrix.
  13739. * @returns the pose matrix
  13740. */
  13741. getPoseMatrix(): Matrix;
  13742. /** @hidden */
  13743. _isSynchronized(): boolean;
  13744. /** @hidden */
  13745. _initCache(): void;
  13746. /**
  13747. * Flag the transform node as dirty (Forcing it to update everything)
  13748. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13749. * @returns this transform node
  13750. */
  13751. markAsDirty(property: string): TransformNode;
  13752. /**
  13753. * Returns the current mesh absolute position.
  13754. * Returns a Vector3.
  13755. */
  13756. get absolutePosition(): Vector3;
  13757. /**
  13758. * Returns the current mesh absolute scaling.
  13759. * Returns a Vector3.
  13760. */
  13761. get absoluteScaling(): Vector3;
  13762. /**
  13763. * Returns the current mesh absolute rotation.
  13764. * Returns a Quaternion.
  13765. */
  13766. get absoluteRotationQuaternion(): Quaternion;
  13767. /**
  13768. * Sets a new matrix to apply before all other transformation
  13769. * @param matrix defines the transform matrix
  13770. * @returns the current TransformNode
  13771. */
  13772. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13773. /**
  13774. * Sets a new pivot matrix to the current node
  13775. * @param matrix defines the new pivot matrix to use
  13776. * @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
  13777. * @returns the current TransformNode
  13778. */
  13779. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13780. /**
  13781. * Returns the mesh pivot matrix.
  13782. * Default : Identity.
  13783. * @returns the matrix
  13784. */
  13785. getPivotMatrix(): Matrix;
  13786. /**
  13787. * Instantiate (when possible) or clone that node with its hierarchy
  13788. * @param newParent defines the new parent to use for the instance (or clone)
  13789. * @param options defines options to configure how copy is done
  13790. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13791. * @returns an instance (or a clone) of the current node with its hiearchy
  13792. */
  13793. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13794. doNotInstantiate: boolean;
  13795. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13796. /**
  13797. * Prevents the World matrix to be computed any longer
  13798. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13799. * @returns the TransformNode.
  13800. */
  13801. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13802. /**
  13803. * Allows back the World matrix computation.
  13804. * @returns the TransformNode.
  13805. */
  13806. unfreezeWorldMatrix(): this;
  13807. /**
  13808. * True if the World matrix has been frozen.
  13809. */
  13810. get isWorldMatrixFrozen(): boolean;
  13811. /**
  13812. * Retuns the mesh absolute position in the World.
  13813. * @returns a Vector3.
  13814. */
  13815. getAbsolutePosition(): Vector3;
  13816. /**
  13817. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13818. * @param absolutePosition the absolute position to set
  13819. * @returns the TransformNode.
  13820. */
  13821. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13822. /**
  13823. * Sets the mesh position in its local space.
  13824. * @param vector3 the position to set in localspace
  13825. * @returns the TransformNode.
  13826. */
  13827. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13828. /**
  13829. * Returns the mesh position in the local space from the current World matrix values.
  13830. * @returns a new Vector3.
  13831. */
  13832. getPositionExpressedInLocalSpace(): Vector3;
  13833. /**
  13834. * Translates the mesh along the passed Vector3 in its local space.
  13835. * @param vector3 the distance to translate in localspace
  13836. * @returns the TransformNode.
  13837. */
  13838. locallyTranslate(vector3: Vector3): TransformNode;
  13839. private static _lookAtVectorCache;
  13840. /**
  13841. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13842. * @param targetPoint the position (must be in same space as current mesh) to look at
  13843. * @param yawCor optional yaw (y-axis) correction in radians
  13844. * @param pitchCor optional pitch (x-axis) correction in radians
  13845. * @param rollCor optional roll (z-axis) correction in radians
  13846. * @param space the choosen space of the target
  13847. * @returns the TransformNode.
  13848. */
  13849. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13850. /**
  13851. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13852. * This Vector3 is expressed in the World space.
  13853. * @param localAxis axis to rotate
  13854. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13855. */
  13856. getDirection(localAxis: Vector3): Vector3;
  13857. /**
  13858. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13859. * localAxis is expressed in the mesh local space.
  13860. * result is computed in the Wordl space from the mesh World matrix.
  13861. * @param localAxis axis to rotate
  13862. * @param result the resulting transformnode
  13863. * @returns this TransformNode.
  13864. */
  13865. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13866. /**
  13867. * Sets this transform node rotation to the given local axis.
  13868. * @param localAxis the axis in local space
  13869. * @param yawCor optional yaw (y-axis) correction in radians
  13870. * @param pitchCor optional pitch (x-axis) correction in radians
  13871. * @param rollCor optional roll (z-axis) correction in radians
  13872. * @returns this TransformNode
  13873. */
  13874. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13875. /**
  13876. * Sets a new pivot point to the current node
  13877. * @param point defines the new pivot point to use
  13878. * @param space defines if the point is in world or local space (local by default)
  13879. * @returns the current TransformNode
  13880. */
  13881. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13882. /**
  13883. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13884. * @returns the pivot point
  13885. */
  13886. getPivotPoint(): Vector3;
  13887. /**
  13888. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13889. * @param result the vector3 to store the result
  13890. * @returns this TransformNode.
  13891. */
  13892. getPivotPointToRef(result: Vector3): TransformNode;
  13893. /**
  13894. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13895. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13896. */
  13897. getAbsolutePivotPoint(): Vector3;
  13898. /**
  13899. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13900. * @param result vector3 to store the result
  13901. * @returns this TransformNode.
  13902. */
  13903. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13904. /**
  13905. * Defines the passed node as the parent of the current node.
  13906. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13907. * @see https://doc.babylonjs.com/how_to/parenting
  13908. * @param node the node ot set as the parent
  13909. * @returns this TransformNode.
  13910. */
  13911. setParent(node: Nullable<Node>): TransformNode;
  13912. private _nonUniformScaling;
  13913. /**
  13914. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13915. */
  13916. get nonUniformScaling(): boolean;
  13917. /** @hidden */
  13918. _updateNonUniformScalingState(value: boolean): boolean;
  13919. /**
  13920. * Attach the current TransformNode to another TransformNode associated with a bone
  13921. * @param bone Bone affecting the TransformNode
  13922. * @param affectedTransformNode TransformNode associated with the bone
  13923. * @returns this object
  13924. */
  13925. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13926. /**
  13927. * Detach the transform node if its associated with a bone
  13928. * @returns this object
  13929. */
  13930. detachFromBone(): TransformNode;
  13931. private static _rotationAxisCache;
  13932. /**
  13933. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13934. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13935. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13936. * The passed axis is also normalized.
  13937. * @param axis the axis to rotate around
  13938. * @param amount the amount to rotate in radians
  13939. * @param space Space to rotate in (Default: local)
  13940. * @returns the TransformNode.
  13941. */
  13942. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13943. /**
  13944. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13945. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13946. * The passed axis is also normalized. .
  13947. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13948. * @param point the point to rotate around
  13949. * @param axis the axis to rotate around
  13950. * @param amount the amount to rotate in radians
  13951. * @returns the TransformNode
  13952. */
  13953. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13954. /**
  13955. * Translates the mesh along the axis vector for the passed distance in the given space.
  13956. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13957. * @param axis the axis to translate in
  13958. * @param distance the distance to translate
  13959. * @param space Space to rotate in (Default: local)
  13960. * @returns the TransformNode.
  13961. */
  13962. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13963. /**
  13964. * Adds a rotation step to the mesh current rotation.
  13965. * x, y, z are Euler angles expressed in radians.
  13966. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13967. * This means this rotation is made in the mesh local space only.
  13968. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13969. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13970. * ```javascript
  13971. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13972. * ```
  13973. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13974. * 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.
  13975. * @param x Rotation to add
  13976. * @param y Rotation to add
  13977. * @param z Rotation to add
  13978. * @returns the TransformNode.
  13979. */
  13980. addRotation(x: number, y: number, z: number): TransformNode;
  13981. /**
  13982. * @hidden
  13983. */
  13984. protected _getEffectiveParent(): Nullable<Node>;
  13985. /**
  13986. * Computes the world matrix of the node
  13987. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13988. * @returns the world matrix
  13989. */
  13990. computeWorldMatrix(force?: boolean): Matrix;
  13991. /**
  13992. * Resets this nodeTransform's local matrix to Matrix.Identity().
  13993. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  13994. */
  13995. resetLocalMatrix(independentOfChildren?: boolean): void;
  13996. protected _afterComputeWorldMatrix(): void;
  13997. /**
  13998. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13999. * @param func callback function to add
  14000. *
  14001. * @returns the TransformNode.
  14002. */
  14003. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14004. /**
  14005. * Removes a registered callback function.
  14006. * @param func callback function to remove
  14007. * @returns the TransformNode.
  14008. */
  14009. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14010. /**
  14011. * Gets the position of the current mesh in camera space
  14012. * @param camera defines the camera to use
  14013. * @returns a position
  14014. */
  14015. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14016. /**
  14017. * Returns the distance from the mesh to the active camera
  14018. * @param camera defines the camera to use
  14019. * @returns the distance
  14020. */
  14021. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14022. /**
  14023. * Clone the current transform node
  14024. * @param name Name of the new clone
  14025. * @param newParent New parent for the clone
  14026. * @param doNotCloneChildren Do not clone children hierarchy
  14027. * @returns the new transform node
  14028. */
  14029. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14030. /**
  14031. * Serializes the objects information.
  14032. * @param currentSerializationObject defines the object to serialize in
  14033. * @returns the serialized object
  14034. */
  14035. serialize(currentSerializationObject?: any): any;
  14036. /**
  14037. * Returns a new TransformNode object parsed from the source provided.
  14038. * @param parsedTransformNode is the source.
  14039. * @param scene the scne the object belongs to
  14040. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14041. * @returns a new TransformNode object parsed from the source provided.
  14042. */
  14043. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14044. /**
  14045. * Get all child-transformNodes of this node
  14046. * @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
  14047. * @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
  14048. * @returns an array of TransformNode
  14049. */
  14050. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14051. /**
  14052. * Releases resources associated with this transform node.
  14053. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14054. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14055. */
  14056. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14057. /**
  14058. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14059. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14060. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14061. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14062. * @returns the current mesh
  14063. */
  14064. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14065. private _syncAbsoluteScalingAndRotation;
  14066. }
  14067. }
  14068. declare module BABYLON {
  14069. /**
  14070. * Class used to override all child animations of a given target
  14071. */
  14072. export class AnimationPropertiesOverride {
  14073. /**
  14074. * Gets or sets a value indicating if animation blending must be used
  14075. */
  14076. enableBlending: boolean;
  14077. /**
  14078. * Gets or sets the blending speed to use when enableBlending is true
  14079. */
  14080. blendingSpeed: number;
  14081. /**
  14082. * Gets or sets the default loop mode to use
  14083. */
  14084. loopMode: number;
  14085. }
  14086. }
  14087. declare module BABYLON {
  14088. /**
  14089. * Class used to store bone information
  14090. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14091. */
  14092. export class Bone extends Node {
  14093. /**
  14094. * defines the bone name
  14095. */
  14096. name: string;
  14097. private static _tmpVecs;
  14098. private static _tmpQuat;
  14099. private static _tmpMats;
  14100. /**
  14101. * Gets the list of child bones
  14102. */
  14103. children: Bone[];
  14104. /** Gets the animations associated with this bone */
  14105. animations: Animation[];
  14106. /**
  14107. * Gets or sets bone length
  14108. */
  14109. length: number;
  14110. /**
  14111. * @hidden Internal only
  14112. * Set this value to map this bone to a different index in the transform matrices
  14113. * Set this value to -1 to exclude the bone from the transform matrices
  14114. */
  14115. _index: Nullable<number>;
  14116. private _skeleton;
  14117. private _localMatrix;
  14118. private _restPose;
  14119. private _baseMatrix;
  14120. private _absoluteTransform;
  14121. private _invertedAbsoluteTransform;
  14122. private _parent;
  14123. private _scalingDeterminant;
  14124. private _worldTransform;
  14125. private _localScaling;
  14126. private _localRotation;
  14127. private _localPosition;
  14128. private _needToDecompose;
  14129. private _needToCompose;
  14130. /** @hidden */
  14131. _linkedTransformNode: Nullable<TransformNode>;
  14132. /** @hidden */
  14133. _waitingTransformNodeId: Nullable<string>;
  14134. /** @hidden */
  14135. get _matrix(): Matrix;
  14136. /** @hidden */
  14137. set _matrix(value: Matrix);
  14138. /**
  14139. * Create a new bone
  14140. * @param name defines the bone name
  14141. * @param skeleton defines the parent skeleton
  14142. * @param parentBone defines the parent (can be null if the bone is the root)
  14143. * @param localMatrix defines the local matrix
  14144. * @param restPose defines the rest pose matrix
  14145. * @param baseMatrix defines the base matrix
  14146. * @param index defines index of the bone in the hiearchy
  14147. */
  14148. constructor(
  14149. /**
  14150. * defines the bone name
  14151. */
  14152. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14153. /**
  14154. * Gets the current object class name.
  14155. * @return the class name
  14156. */
  14157. getClassName(): string;
  14158. /**
  14159. * Gets the parent skeleton
  14160. * @returns a skeleton
  14161. */
  14162. getSkeleton(): Skeleton;
  14163. /**
  14164. * Gets parent bone
  14165. * @returns a bone or null if the bone is the root of the bone hierarchy
  14166. */
  14167. getParent(): Nullable<Bone>;
  14168. /**
  14169. * Returns an array containing the root bones
  14170. * @returns an array containing the root bones
  14171. */
  14172. getChildren(): Array<Bone>;
  14173. /**
  14174. * Gets the node index in matrix array generated for rendering
  14175. * @returns the node index
  14176. */
  14177. getIndex(): number;
  14178. /**
  14179. * Sets the parent bone
  14180. * @param parent defines the parent (can be null if the bone is the root)
  14181. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14182. */
  14183. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14184. /**
  14185. * Gets the local matrix
  14186. * @returns a matrix
  14187. */
  14188. getLocalMatrix(): Matrix;
  14189. /**
  14190. * Gets the base matrix (initial matrix which remains unchanged)
  14191. * @returns a matrix
  14192. */
  14193. getBaseMatrix(): Matrix;
  14194. /**
  14195. * Gets the rest pose matrix
  14196. * @returns a matrix
  14197. */
  14198. getRestPose(): Matrix;
  14199. /**
  14200. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14201. */
  14202. getWorldMatrix(): Matrix;
  14203. /**
  14204. * Sets the local matrix to rest pose matrix
  14205. */
  14206. returnToRest(): void;
  14207. /**
  14208. * Gets the inverse of the absolute transform matrix.
  14209. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14210. * @returns a matrix
  14211. */
  14212. getInvertedAbsoluteTransform(): Matrix;
  14213. /**
  14214. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14215. * @returns a matrix
  14216. */
  14217. getAbsoluteTransform(): Matrix;
  14218. /**
  14219. * Links with the given transform node.
  14220. * The local matrix of this bone is copied from the transform node every frame.
  14221. * @param transformNode defines the transform node to link to
  14222. */
  14223. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14224. /**
  14225. * Gets the node used to drive the bone's transformation
  14226. * @returns a transform node or null
  14227. */
  14228. getTransformNode(): Nullable<TransformNode>;
  14229. /** Gets or sets current position (in local space) */
  14230. get position(): Vector3;
  14231. set position(newPosition: Vector3);
  14232. /** Gets or sets current rotation (in local space) */
  14233. get rotation(): Vector3;
  14234. set rotation(newRotation: Vector3);
  14235. /** Gets or sets current rotation quaternion (in local space) */
  14236. get rotationQuaternion(): Quaternion;
  14237. set rotationQuaternion(newRotation: Quaternion);
  14238. /** Gets or sets current scaling (in local space) */
  14239. get scaling(): Vector3;
  14240. set scaling(newScaling: Vector3);
  14241. /**
  14242. * Gets the animation properties override
  14243. */
  14244. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14245. private _decompose;
  14246. private _compose;
  14247. /**
  14248. * Update the base and local matrices
  14249. * @param matrix defines the new base or local matrix
  14250. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14251. * @param updateLocalMatrix defines if the local matrix should be updated
  14252. */
  14253. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14254. /** @hidden */
  14255. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14256. /**
  14257. * Flag the bone as dirty (Forcing it to update everything)
  14258. */
  14259. markAsDirty(): void;
  14260. /** @hidden */
  14261. _markAsDirtyAndCompose(): void;
  14262. private _markAsDirtyAndDecompose;
  14263. /**
  14264. * Translate the bone in local or world space
  14265. * @param vec The amount to translate the bone
  14266. * @param space The space that the translation is in
  14267. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14268. */
  14269. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14270. /**
  14271. * Set the postion of the bone in local or world space
  14272. * @param position The position to set the bone
  14273. * @param space The space that the position is in
  14274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14275. */
  14276. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14277. /**
  14278. * Set the absolute position of the bone (world space)
  14279. * @param position The position to set the bone
  14280. * @param mesh The mesh that this bone is attached to
  14281. */
  14282. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14283. /**
  14284. * Scale the bone on the x, y and z axes (in local space)
  14285. * @param x The amount to scale the bone on the x axis
  14286. * @param y The amount to scale the bone on the y axis
  14287. * @param z The amount to scale the bone on the z axis
  14288. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14289. */
  14290. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14291. /**
  14292. * Set the bone scaling in local space
  14293. * @param scale defines the scaling vector
  14294. */
  14295. setScale(scale: Vector3): void;
  14296. /**
  14297. * Gets the current scaling in local space
  14298. * @returns the current scaling vector
  14299. */
  14300. getScale(): Vector3;
  14301. /**
  14302. * Gets the current scaling in local space and stores it in a target vector
  14303. * @param result defines the target vector
  14304. */
  14305. getScaleToRef(result: Vector3): void;
  14306. /**
  14307. * Set the yaw, pitch, and roll of the bone in local or world space
  14308. * @param yaw The rotation of the bone on the y axis
  14309. * @param pitch The rotation of the bone on the x axis
  14310. * @param roll The rotation of the bone on the z axis
  14311. * @param space The space that the axes of rotation are in
  14312. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14313. */
  14314. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14315. /**
  14316. * Add a rotation to the bone on an axis in local or world space
  14317. * @param axis The axis to rotate the bone on
  14318. * @param amount The amount to rotate the bone
  14319. * @param space The space that the axis is in
  14320. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14321. */
  14322. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14323. /**
  14324. * Set the rotation of the bone to a particular axis angle in local or world space
  14325. * @param axis The axis to rotate the bone on
  14326. * @param angle The angle that the bone should be rotated to
  14327. * @param space The space that the axis is in
  14328. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14329. */
  14330. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14331. /**
  14332. * Set the euler rotation of the bone in local of world space
  14333. * @param rotation The euler rotation that the bone should be set to
  14334. * @param space The space that the rotation is in
  14335. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14336. */
  14337. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14338. /**
  14339. * Set the quaternion rotation of the bone in local of world space
  14340. * @param quat The quaternion rotation that the bone should be set to
  14341. * @param space The space that the rotation is in
  14342. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14343. */
  14344. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14345. /**
  14346. * Set the rotation matrix of the bone in local of world space
  14347. * @param rotMat The rotation matrix that the bone should be set to
  14348. * @param space The space that the rotation is in
  14349. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14350. */
  14351. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14352. private _rotateWithMatrix;
  14353. private _getNegativeRotationToRef;
  14354. /**
  14355. * Get the position of the bone in local or world space
  14356. * @param space The space that the returned position is in
  14357. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14358. * @returns The position of the bone
  14359. */
  14360. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14361. /**
  14362. * Copy the position of the bone to a vector3 in local or world space
  14363. * @param space The space that the returned position is in
  14364. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14365. * @param result The vector3 to copy the position to
  14366. */
  14367. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14368. /**
  14369. * Get the absolute position of the bone (world space)
  14370. * @param mesh The mesh that this bone is attached to
  14371. * @returns The absolute position of the bone
  14372. */
  14373. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14374. /**
  14375. * Copy the absolute position of the bone (world space) to the result param
  14376. * @param mesh The mesh that this bone is attached to
  14377. * @param result The vector3 to copy the absolute position to
  14378. */
  14379. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14380. /**
  14381. * Compute the absolute transforms of this bone and its children
  14382. */
  14383. computeAbsoluteTransforms(): void;
  14384. /**
  14385. * Get the world direction from an axis that is in the local space of the bone
  14386. * @param localAxis The local direction that is used to compute the world direction
  14387. * @param mesh The mesh that this bone is attached to
  14388. * @returns The world direction
  14389. */
  14390. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14391. /**
  14392. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14393. * @param localAxis The local direction that is used to compute the world direction
  14394. * @param mesh The mesh that this bone is attached to
  14395. * @param result The vector3 that the world direction will be copied to
  14396. */
  14397. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14398. /**
  14399. * Get the euler rotation of the bone in local or world space
  14400. * @param space The space that the rotation should be in
  14401. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14402. * @returns The euler rotation
  14403. */
  14404. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14405. /**
  14406. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14407. * @param space The space that the rotation should be in
  14408. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14409. * @param result The vector3 that the rotation should be copied to
  14410. */
  14411. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14412. /**
  14413. * Get the quaternion rotation of the bone in either local or world space
  14414. * @param space The space that the rotation should be in
  14415. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14416. * @returns The quaternion rotation
  14417. */
  14418. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14419. /**
  14420. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14421. * @param space The space that the rotation should be in
  14422. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14423. * @param result The quaternion that the rotation should be copied to
  14424. */
  14425. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14426. /**
  14427. * Get the rotation matrix of the bone in local or world space
  14428. * @param space The space that the rotation should be in
  14429. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14430. * @returns The rotation matrix
  14431. */
  14432. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14433. /**
  14434. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14435. * @param space The space that the rotation should be in
  14436. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14437. * @param result The quaternion that the rotation should be copied to
  14438. */
  14439. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14440. /**
  14441. * Get the world position of a point that is in the local space of the bone
  14442. * @param position The local position
  14443. * @param mesh The mesh that this bone is attached to
  14444. * @returns The world position
  14445. */
  14446. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14447. /**
  14448. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14449. * @param position The local position
  14450. * @param mesh The mesh that this bone is attached to
  14451. * @param result The vector3 that the world position should be copied to
  14452. */
  14453. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14454. /**
  14455. * Get the local position of a point that is in world space
  14456. * @param position The world position
  14457. * @param mesh The mesh that this bone is attached to
  14458. * @returns The local position
  14459. */
  14460. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14461. /**
  14462. * Get the local position of a point that is in world space and copy it to the result param
  14463. * @param position The world position
  14464. * @param mesh The mesh that this bone is attached to
  14465. * @param result The vector3 that the local position should be copied to
  14466. */
  14467. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14468. }
  14469. }
  14470. declare module BABYLON {
  14471. /**
  14472. * Defines a runtime animation
  14473. */
  14474. export class RuntimeAnimation {
  14475. private _events;
  14476. /**
  14477. * The current frame of the runtime animation
  14478. */
  14479. private _currentFrame;
  14480. /**
  14481. * The animation used by the runtime animation
  14482. */
  14483. private _animation;
  14484. /**
  14485. * The target of the runtime animation
  14486. */
  14487. private _target;
  14488. /**
  14489. * The initiating animatable
  14490. */
  14491. private _host;
  14492. /**
  14493. * The original value of the runtime animation
  14494. */
  14495. private _originalValue;
  14496. /**
  14497. * The original blend value of the runtime animation
  14498. */
  14499. private _originalBlendValue;
  14500. /**
  14501. * The offsets cache of the runtime animation
  14502. */
  14503. private _offsetsCache;
  14504. /**
  14505. * The high limits cache of the runtime animation
  14506. */
  14507. private _highLimitsCache;
  14508. /**
  14509. * Specifies if the runtime animation has been stopped
  14510. */
  14511. private _stopped;
  14512. /**
  14513. * The blending factor of the runtime animation
  14514. */
  14515. private _blendingFactor;
  14516. /**
  14517. * The BabylonJS scene
  14518. */
  14519. private _scene;
  14520. /**
  14521. * The current value of the runtime animation
  14522. */
  14523. private _currentValue;
  14524. /** @hidden */
  14525. _animationState: _IAnimationState;
  14526. /**
  14527. * The active target of the runtime animation
  14528. */
  14529. private _activeTargets;
  14530. private _currentActiveTarget;
  14531. private _directTarget;
  14532. /**
  14533. * The target path of the runtime animation
  14534. */
  14535. private _targetPath;
  14536. /**
  14537. * The weight of the runtime animation
  14538. */
  14539. private _weight;
  14540. /**
  14541. * The ratio offset of the runtime animation
  14542. */
  14543. private _ratioOffset;
  14544. /**
  14545. * The previous delay of the runtime animation
  14546. */
  14547. private _previousDelay;
  14548. /**
  14549. * The previous ratio of the runtime animation
  14550. */
  14551. private _previousRatio;
  14552. private _enableBlending;
  14553. private _keys;
  14554. private _minFrame;
  14555. private _maxFrame;
  14556. private _minValue;
  14557. private _maxValue;
  14558. private _targetIsArray;
  14559. /**
  14560. * Gets the current frame of the runtime animation
  14561. */
  14562. get currentFrame(): number;
  14563. /**
  14564. * Gets the weight of the runtime animation
  14565. */
  14566. get weight(): number;
  14567. /**
  14568. * Gets the current value of the runtime animation
  14569. */
  14570. get currentValue(): any;
  14571. /**
  14572. * Gets the target path of the runtime animation
  14573. */
  14574. get targetPath(): string;
  14575. /**
  14576. * Gets the actual target of the runtime animation
  14577. */
  14578. get target(): any;
  14579. /**
  14580. * Gets the additive state of the runtime animation
  14581. */
  14582. get isAdditive(): boolean;
  14583. /** @hidden */
  14584. _onLoop: () => void;
  14585. /**
  14586. * Create a new RuntimeAnimation object
  14587. * @param target defines the target of the animation
  14588. * @param animation defines the source animation object
  14589. * @param scene defines the hosting scene
  14590. * @param host defines the initiating Animatable
  14591. */
  14592. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14593. private _preparePath;
  14594. /**
  14595. * Gets the animation from the runtime animation
  14596. */
  14597. get animation(): Animation;
  14598. /**
  14599. * Resets the runtime animation to the beginning
  14600. * @param restoreOriginal defines whether to restore the target property to the original value
  14601. */
  14602. reset(restoreOriginal?: boolean): void;
  14603. /**
  14604. * Specifies if the runtime animation is stopped
  14605. * @returns Boolean specifying if the runtime animation is stopped
  14606. */
  14607. isStopped(): boolean;
  14608. /**
  14609. * Disposes of the runtime animation
  14610. */
  14611. dispose(): void;
  14612. /**
  14613. * Apply the interpolated value to the target
  14614. * @param currentValue defines the value computed by the animation
  14615. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14616. */
  14617. setValue(currentValue: any, weight: number): void;
  14618. private _getOriginalValues;
  14619. private _setValue;
  14620. /**
  14621. * Gets the loop pmode of the runtime animation
  14622. * @returns Loop Mode
  14623. */
  14624. private _getCorrectLoopMode;
  14625. /**
  14626. * Move the current animation to a given frame
  14627. * @param frame defines the frame to move to
  14628. */
  14629. goToFrame(frame: number): void;
  14630. /**
  14631. * @hidden Internal use only
  14632. */
  14633. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14634. /**
  14635. * Execute the current animation
  14636. * @param delay defines the delay to add to the current frame
  14637. * @param from defines the lower bound of the animation range
  14638. * @param to defines the upper bound of the animation range
  14639. * @param loop defines if the current animation must loop
  14640. * @param speedRatio defines the current speed ratio
  14641. * @param weight defines the weight of the animation (default is -1 so no weight)
  14642. * @param onLoop optional callback called when animation loops
  14643. * @returns a boolean indicating if the animation is running
  14644. */
  14645. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14646. }
  14647. }
  14648. declare module BABYLON {
  14649. /**
  14650. * Class used to store an actual running animation
  14651. */
  14652. export class Animatable {
  14653. /** defines the target object */
  14654. target: any;
  14655. /** defines the starting frame number (default is 0) */
  14656. fromFrame: number;
  14657. /** defines the ending frame number (default is 100) */
  14658. toFrame: number;
  14659. /** defines if the animation must loop (default is false) */
  14660. loopAnimation: boolean;
  14661. /** defines a callback to call when animation ends if it is not looping */
  14662. onAnimationEnd?: (() => void) | null | undefined;
  14663. /** defines a callback to call when animation loops */
  14664. onAnimationLoop?: (() => void) | null | undefined;
  14665. /** defines whether the animation should be evaluated additively */
  14666. isAdditive: boolean;
  14667. private _localDelayOffset;
  14668. private _pausedDelay;
  14669. private _runtimeAnimations;
  14670. private _paused;
  14671. private _scene;
  14672. private _speedRatio;
  14673. private _weight;
  14674. private _syncRoot;
  14675. /**
  14676. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14677. * This will only apply for non looping animation (default is true)
  14678. */
  14679. disposeOnEnd: boolean;
  14680. /**
  14681. * Gets a boolean indicating if the animation has started
  14682. */
  14683. animationStarted: boolean;
  14684. /**
  14685. * Observer raised when the animation ends
  14686. */
  14687. onAnimationEndObservable: Observable<Animatable>;
  14688. /**
  14689. * Observer raised when the animation loops
  14690. */
  14691. onAnimationLoopObservable: Observable<Animatable>;
  14692. /**
  14693. * Gets the root Animatable used to synchronize and normalize animations
  14694. */
  14695. get syncRoot(): Nullable<Animatable>;
  14696. /**
  14697. * Gets the current frame of the first RuntimeAnimation
  14698. * Used to synchronize Animatables
  14699. */
  14700. get masterFrame(): number;
  14701. /**
  14702. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14703. */
  14704. get weight(): number;
  14705. set weight(value: number);
  14706. /**
  14707. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14708. */
  14709. get speedRatio(): number;
  14710. set speedRatio(value: number);
  14711. /**
  14712. * Creates a new Animatable
  14713. * @param scene defines the hosting scene
  14714. * @param target defines the target object
  14715. * @param fromFrame defines the starting frame number (default is 0)
  14716. * @param toFrame defines the ending frame number (default is 100)
  14717. * @param loopAnimation defines if the animation must loop (default is false)
  14718. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14719. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14720. * @param animations defines a group of animation to add to the new Animatable
  14721. * @param onAnimationLoop defines a callback to call when animation loops
  14722. * @param isAdditive defines whether the animation should be evaluated additively
  14723. */
  14724. constructor(scene: Scene,
  14725. /** defines the target object */
  14726. target: any,
  14727. /** defines the starting frame number (default is 0) */
  14728. fromFrame?: number,
  14729. /** defines the ending frame number (default is 100) */
  14730. toFrame?: number,
  14731. /** defines if the animation must loop (default is false) */
  14732. loopAnimation?: boolean, speedRatio?: number,
  14733. /** defines a callback to call when animation ends if it is not looping */
  14734. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14735. /** defines a callback to call when animation loops */
  14736. onAnimationLoop?: (() => void) | null | undefined,
  14737. /** defines whether the animation should be evaluated additively */
  14738. isAdditive?: boolean);
  14739. /**
  14740. * Synchronize and normalize current Animatable with a source Animatable
  14741. * This is useful when using animation weights and when animations are not of the same length
  14742. * @param root defines the root Animatable to synchronize with
  14743. * @returns the current Animatable
  14744. */
  14745. syncWith(root: Animatable): Animatable;
  14746. /**
  14747. * Gets the list of runtime animations
  14748. * @returns an array of RuntimeAnimation
  14749. */
  14750. getAnimations(): RuntimeAnimation[];
  14751. /**
  14752. * Adds more animations to the current animatable
  14753. * @param target defines the target of the animations
  14754. * @param animations defines the new animations to add
  14755. */
  14756. appendAnimations(target: any, animations: Animation[]): void;
  14757. /**
  14758. * Gets the source animation for a specific property
  14759. * @param property defines the propertyu to look for
  14760. * @returns null or the source animation for the given property
  14761. */
  14762. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14763. /**
  14764. * Gets the runtime animation for a specific property
  14765. * @param property defines the propertyu to look for
  14766. * @returns null or the runtime animation for the given property
  14767. */
  14768. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14769. /**
  14770. * Resets the animatable to its original state
  14771. */
  14772. reset(): void;
  14773. /**
  14774. * Allows the animatable to blend with current running animations
  14775. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14776. * @param blendingSpeed defines the blending speed to use
  14777. */
  14778. enableBlending(blendingSpeed: number): void;
  14779. /**
  14780. * Disable animation blending
  14781. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14782. */
  14783. disableBlending(): void;
  14784. /**
  14785. * Jump directly to a given frame
  14786. * @param frame defines the frame to jump to
  14787. */
  14788. goToFrame(frame: number): void;
  14789. /**
  14790. * Pause the animation
  14791. */
  14792. pause(): void;
  14793. /**
  14794. * Restart the animation
  14795. */
  14796. restart(): void;
  14797. private _raiseOnAnimationEnd;
  14798. /**
  14799. * Stop and delete the current animation
  14800. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14801. * @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)
  14802. */
  14803. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14804. /**
  14805. * Wait asynchronously for the animation to end
  14806. * @returns a promise which will be fullfilled when the animation ends
  14807. */
  14808. waitAsync(): Promise<Animatable>;
  14809. /** @hidden */
  14810. _animate(delay: number): boolean;
  14811. }
  14812. interface Scene {
  14813. /** @hidden */
  14814. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14815. /** @hidden */
  14816. _processLateAnimationBindingsForMatrices(holder: {
  14817. totalWeight: number;
  14818. totalAdditiveWeight: number;
  14819. animations: RuntimeAnimation[];
  14820. additiveAnimations: RuntimeAnimation[];
  14821. originalValue: Matrix;
  14822. }): any;
  14823. /** @hidden */
  14824. _processLateAnimationBindingsForQuaternions(holder: {
  14825. totalWeight: number;
  14826. totalAdditiveWeight: number;
  14827. animations: RuntimeAnimation[];
  14828. additiveAnimations: RuntimeAnimation[];
  14829. originalValue: Quaternion;
  14830. }, refQuaternion: Quaternion): Quaternion;
  14831. /** @hidden */
  14832. _processLateAnimationBindings(): void;
  14833. /**
  14834. * Will start the animation sequence of a given target
  14835. * @param target defines the target
  14836. * @param from defines from which frame should animation start
  14837. * @param to defines until which frame should animation run.
  14838. * @param weight defines the weight to apply to the animation (1.0 by default)
  14839. * @param loop defines if the animation loops
  14840. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14841. * @param onAnimationEnd defines the function to be executed when the animation ends
  14842. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14843. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14844. * @param onAnimationLoop defines the callback to call when an animation loops
  14845. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14846. * @returns the animatable object created for this animation
  14847. */
  14848. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14849. /**
  14850. * Will start the animation sequence of a given target
  14851. * @param target defines the target
  14852. * @param from defines from which frame should animation start
  14853. * @param to defines until which frame should animation run.
  14854. * @param loop defines if the animation loops
  14855. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14856. * @param onAnimationEnd defines the function to be executed when the animation ends
  14857. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14858. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14859. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14860. * @param onAnimationLoop defines the callback to call when an animation loops
  14861. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14862. * @returns the animatable object created for this animation
  14863. */
  14864. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14865. /**
  14866. * Will start the animation sequence of a given target and its hierarchy
  14867. * @param target defines the target
  14868. * @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.
  14869. * @param from defines from which frame should animation start
  14870. * @param to defines until which frame should animation run.
  14871. * @param loop defines if the animation loops
  14872. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14873. * @param onAnimationEnd defines the function to be executed when the animation ends
  14874. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14875. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14876. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14877. * @param onAnimationLoop defines the callback to call when an animation loops
  14878. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14879. * @returns the list of created animatables
  14880. */
  14881. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  14882. /**
  14883. * Begin a new animation on a given node
  14884. * @param target defines the target where the animation will take place
  14885. * @param animations defines the list of animations to start
  14886. * @param from defines the initial value
  14887. * @param to defines the final value
  14888. * @param loop defines if you want animation to loop (off by default)
  14889. * @param speedRatio defines the speed ratio to apply to all animations
  14890. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14891. * @param onAnimationLoop defines the callback to call when an animation loops
  14892. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14893. * @returns the list of created animatables
  14894. */
  14895. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14896. /**
  14897. * Begin a new animation on a given node and its hierarchy
  14898. * @param target defines the root node where the animation will take place
  14899. * @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.
  14900. * @param animations defines the list of animations to start
  14901. * @param from defines the initial value
  14902. * @param to defines the final value
  14903. * @param loop defines if you want animation to loop (off by default)
  14904. * @param speedRatio defines the speed ratio to apply to all animations
  14905. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14906. * @param onAnimationLoop defines the callback to call when an animation loops
  14907. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14908. * @returns the list of animatables created for all nodes
  14909. */
  14910. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  14911. /**
  14912. * Gets the animatable associated with a specific target
  14913. * @param target defines the target of the animatable
  14914. * @returns the required animatable if found
  14915. */
  14916. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14917. /**
  14918. * Gets all animatables associated with a given target
  14919. * @param target defines the target to look animatables for
  14920. * @returns an array of Animatables
  14921. */
  14922. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14923. /**
  14924. * Stops and removes all animations that have been applied to the scene
  14925. */
  14926. stopAllAnimations(): void;
  14927. /**
  14928. * Gets the current delta time used by animation engine
  14929. */
  14930. deltaTime: number;
  14931. }
  14932. interface Bone {
  14933. /**
  14934. * Copy an animation range from another bone
  14935. * @param source defines the source bone
  14936. * @param rangeName defines the range name to copy
  14937. * @param frameOffset defines the frame offset
  14938. * @param rescaleAsRequired defines if rescaling must be applied if required
  14939. * @param skelDimensionsRatio defines the scaling ratio
  14940. * @returns true if operation was successful
  14941. */
  14942. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14943. }
  14944. }
  14945. declare module BABYLON {
  14946. /**
  14947. * Class used to handle skinning animations
  14948. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14949. */
  14950. export class Skeleton implements IAnimatable {
  14951. /** defines the skeleton name */
  14952. name: string;
  14953. /** defines the skeleton Id */
  14954. id: string;
  14955. /**
  14956. * Defines the list of child bones
  14957. */
  14958. bones: Bone[];
  14959. /**
  14960. * Defines an estimate of the dimension of the skeleton at rest
  14961. */
  14962. dimensionsAtRest: Vector3;
  14963. /**
  14964. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  14965. */
  14966. needInitialSkinMatrix: boolean;
  14967. /**
  14968. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  14969. */
  14970. overrideMesh: Nullable<AbstractMesh>;
  14971. /**
  14972. * Gets the list of animations attached to this skeleton
  14973. */
  14974. animations: Array<Animation>;
  14975. private _scene;
  14976. private _isDirty;
  14977. private _transformMatrices;
  14978. private _transformMatrixTexture;
  14979. private _meshesWithPoseMatrix;
  14980. private _animatables;
  14981. private _identity;
  14982. private _synchronizedWithMesh;
  14983. private _ranges;
  14984. private _lastAbsoluteTransformsUpdateId;
  14985. private _canUseTextureForBones;
  14986. private _uniqueId;
  14987. /** @hidden */
  14988. _numBonesWithLinkedTransformNode: number;
  14989. /** @hidden */
  14990. _hasWaitingData: Nullable<boolean>;
  14991. /**
  14992. * Specifies if the skeleton should be serialized
  14993. */
  14994. doNotSerialize: boolean;
  14995. private _useTextureToStoreBoneMatrices;
  14996. /**
  14997. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  14998. * Please note that this option is not available if the hardware does not support it
  14999. */
  15000. get useTextureToStoreBoneMatrices(): boolean;
  15001. set useTextureToStoreBoneMatrices(value: boolean);
  15002. private _animationPropertiesOverride;
  15003. /**
  15004. * Gets or sets the animation properties override
  15005. */
  15006. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15007. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15008. /**
  15009. * List of inspectable custom properties (used by the Inspector)
  15010. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15011. */
  15012. inspectableCustomProperties: IInspectable[];
  15013. /**
  15014. * An observable triggered before computing the skeleton's matrices
  15015. */
  15016. onBeforeComputeObservable: Observable<Skeleton>;
  15017. /**
  15018. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15019. */
  15020. get isUsingTextureForMatrices(): boolean;
  15021. /**
  15022. * Gets the unique ID of this skeleton
  15023. */
  15024. get uniqueId(): number;
  15025. /**
  15026. * Creates a new skeleton
  15027. * @param name defines the skeleton name
  15028. * @param id defines the skeleton Id
  15029. * @param scene defines the hosting scene
  15030. */
  15031. constructor(
  15032. /** defines the skeleton name */
  15033. name: string,
  15034. /** defines the skeleton Id */
  15035. id: string, scene: Scene);
  15036. /**
  15037. * Gets the current object class name.
  15038. * @return the class name
  15039. */
  15040. getClassName(): string;
  15041. /**
  15042. * Returns an array containing the root bones
  15043. * @returns an array containing the root bones
  15044. */
  15045. getChildren(): Array<Bone>;
  15046. /**
  15047. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15048. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15049. * @returns a Float32Array containing matrices data
  15050. */
  15051. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15052. /**
  15053. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15054. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15055. * @returns a raw texture containing the data
  15056. */
  15057. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15058. /**
  15059. * Gets the current hosting scene
  15060. * @returns a scene object
  15061. */
  15062. getScene(): Scene;
  15063. /**
  15064. * Gets a string representing the current skeleton data
  15065. * @param fullDetails defines a boolean indicating if we want a verbose version
  15066. * @returns a string representing the current skeleton data
  15067. */
  15068. toString(fullDetails?: boolean): string;
  15069. /**
  15070. * Get bone's index searching by name
  15071. * @param name defines bone's name to search for
  15072. * @return the indice of the bone. Returns -1 if not found
  15073. */
  15074. getBoneIndexByName(name: string): number;
  15075. /**
  15076. * Creater a new animation range
  15077. * @param name defines the name of the range
  15078. * @param from defines the start key
  15079. * @param to defines the end key
  15080. */
  15081. createAnimationRange(name: string, from: number, to: number): void;
  15082. /**
  15083. * Delete a specific animation range
  15084. * @param name defines the name of the range
  15085. * @param deleteFrames defines if frames must be removed as well
  15086. */
  15087. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15088. /**
  15089. * Gets a specific animation range
  15090. * @param name defines the name of the range to look for
  15091. * @returns the requested animation range or null if not found
  15092. */
  15093. getAnimationRange(name: string): Nullable<AnimationRange>;
  15094. /**
  15095. * Gets the list of all animation ranges defined on this skeleton
  15096. * @returns an array
  15097. */
  15098. getAnimationRanges(): Nullable<AnimationRange>[];
  15099. /**
  15100. * Copy animation range from a source skeleton.
  15101. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15102. * @param source defines the source skeleton
  15103. * @param name defines the name of the range to copy
  15104. * @param rescaleAsRequired defines if rescaling must be applied if required
  15105. * @returns true if operation was successful
  15106. */
  15107. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15108. /**
  15109. * Forces the skeleton to go to rest pose
  15110. */
  15111. returnToRest(): void;
  15112. private _getHighestAnimationFrame;
  15113. /**
  15114. * Begin a specific animation range
  15115. * @param name defines the name of the range to start
  15116. * @param loop defines if looping must be turned on (false by default)
  15117. * @param speedRatio defines the speed ratio to apply (1 by default)
  15118. * @param onAnimationEnd defines a callback which will be called when animation will end
  15119. * @returns a new animatable
  15120. */
  15121. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15122. /**
  15123. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15124. * @param skeleton defines the Skeleton containing the animation range to convert
  15125. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15126. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15127. * @returns the original skeleton
  15128. */
  15129. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15130. /** @hidden */
  15131. _markAsDirty(): void;
  15132. /** @hidden */
  15133. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15134. /** @hidden */
  15135. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15136. private _computeTransformMatrices;
  15137. /**
  15138. * Build all resources required to render a skeleton
  15139. */
  15140. prepare(): void;
  15141. /**
  15142. * Gets the list of animatables currently running for this skeleton
  15143. * @returns an array of animatables
  15144. */
  15145. getAnimatables(): IAnimatable[];
  15146. /**
  15147. * Clone the current skeleton
  15148. * @param name defines the name of the new skeleton
  15149. * @param id defines the id of the new skeleton
  15150. * @returns the new skeleton
  15151. */
  15152. clone(name: string, id?: string): Skeleton;
  15153. /**
  15154. * Enable animation blending for this skeleton
  15155. * @param blendingSpeed defines the blending speed to apply
  15156. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15157. */
  15158. enableBlending(blendingSpeed?: number): void;
  15159. /**
  15160. * Releases all resources associated with the current skeleton
  15161. */
  15162. dispose(): void;
  15163. /**
  15164. * Serialize the skeleton in a JSON object
  15165. * @returns a JSON object
  15166. */
  15167. serialize(): any;
  15168. /**
  15169. * Creates a new skeleton from serialized data
  15170. * @param parsedSkeleton defines the serialized data
  15171. * @param scene defines the hosting scene
  15172. * @returns a new skeleton
  15173. */
  15174. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15175. /**
  15176. * Compute all node absolute transforms
  15177. * @param forceUpdate defines if computation must be done even if cache is up to date
  15178. */
  15179. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15180. /**
  15181. * Gets the root pose matrix
  15182. * @returns a matrix
  15183. */
  15184. getPoseMatrix(): Nullable<Matrix>;
  15185. /**
  15186. * Sorts bones per internal index
  15187. */
  15188. sortBones(): void;
  15189. private _sortBones;
  15190. }
  15191. }
  15192. declare module BABYLON {
  15193. /**
  15194. * Creates an instance based on a source mesh.
  15195. */
  15196. export class InstancedMesh extends AbstractMesh {
  15197. private _sourceMesh;
  15198. private _currentLOD;
  15199. /** @hidden */
  15200. _indexInSourceMeshInstanceArray: number;
  15201. constructor(name: string, source: Mesh);
  15202. /**
  15203. * Returns the string "InstancedMesh".
  15204. */
  15205. getClassName(): string;
  15206. /** Gets the list of lights affecting that mesh */
  15207. get lightSources(): Light[];
  15208. _resyncLightSources(): void;
  15209. _resyncLightSource(light: Light): void;
  15210. _removeLightSource(light: Light, dispose: boolean): void;
  15211. /**
  15212. * If the source mesh receives shadows
  15213. */
  15214. get receiveShadows(): boolean;
  15215. /**
  15216. * The material of the source mesh
  15217. */
  15218. get material(): Nullable<Material>;
  15219. /**
  15220. * Visibility of the source mesh
  15221. */
  15222. get visibility(): number;
  15223. /**
  15224. * Skeleton of the source mesh
  15225. */
  15226. get skeleton(): Nullable<Skeleton>;
  15227. /**
  15228. * Rendering ground id of the source mesh
  15229. */
  15230. get renderingGroupId(): number;
  15231. set renderingGroupId(value: number);
  15232. /**
  15233. * Returns the total number of vertices (integer).
  15234. */
  15235. getTotalVertices(): number;
  15236. /**
  15237. * Returns a positive integer : the total number of indices in this mesh geometry.
  15238. * @returns the numner of indices or zero if the mesh has no geometry.
  15239. */
  15240. getTotalIndices(): number;
  15241. /**
  15242. * The source mesh of the instance
  15243. */
  15244. get sourceMesh(): Mesh;
  15245. /**
  15246. * Is this node ready to be used/rendered
  15247. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15248. * @return {boolean} is it ready
  15249. */
  15250. isReady(completeCheck?: boolean): boolean;
  15251. /**
  15252. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15253. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15254. * @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.
  15255. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15256. */
  15257. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15258. /**
  15259. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15260. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15261. * The `data` are either a numeric array either a Float32Array.
  15262. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15263. * 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).
  15264. * Note that a new underlying VertexBuffer object is created each call.
  15265. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15266. *
  15267. * Possible `kind` values :
  15268. * - VertexBuffer.PositionKind
  15269. * - VertexBuffer.UVKind
  15270. * - VertexBuffer.UV2Kind
  15271. * - VertexBuffer.UV3Kind
  15272. * - VertexBuffer.UV4Kind
  15273. * - VertexBuffer.UV5Kind
  15274. * - VertexBuffer.UV6Kind
  15275. * - VertexBuffer.ColorKind
  15276. * - VertexBuffer.MatricesIndicesKind
  15277. * - VertexBuffer.MatricesIndicesExtraKind
  15278. * - VertexBuffer.MatricesWeightsKind
  15279. * - VertexBuffer.MatricesWeightsExtraKind
  15280. *
  15281. * Returns the Mesh.
  15282. */
  15283. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15284. /**
  15285. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15286. * If the mesh has no geometry, it is simply returned as it is.
  15287. * The `data` are either a numeric array either a Float32Array.
  15288. * No new underlying VertexBuffer object is created.
  15289. * 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.
  15290. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15291. *
  15292. * Possible `kind` values :
  15293. * - VertexBuffer.PositionKind
  15294. * - VertexBuffer.UVKind
  15295. * - VertexBuffer.UV2Kind
  15296. * - VertexBuffer.UV3Kind
  15297. * - VertexBuffer.UV4Kind
  15298. * - VertexBuffer.UV5Kind
  15299. * - VertexBuffer.UV6Kind
  15300. * - VertexBuffer.ColorKind
  15301. * - VertexBuffer.MatricesIndicesKind
  15302. * - VertexBuffer.MatricesIndicesExtraKind
  15303. * - VertexBuffer.MatricesWeightsKind
  15304. * - VertexBuffer.MatricesWeightsExtraKind
  15305. *
  15306. * Returns the Mesh.
  15307. */
  15308. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15309. /**
  15310. * Sets the mesh indices.
  15311. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15312. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15313. * This method creates a new index buffer each call.
  15314. * Returns the Mesh.
  15315. */
  15316. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15317. /**
  15318. * Boolean : True if the mesh owns the requested kind of data.
  15319. */
  15320. isVerticesDataPresent(kind: string): boolean;
  15321. /**
  15322. * Returns an array of indices (IndicesArray).
  15323. */
  15324. getIndices(): Nullable<IndicesArray>;
  15325. get _positions(): Nullable<Vector3[]>;
  15326. /**
  15327. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15328. * This means the mesh underlying bounding box and sphere are recomputed.
  15329. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15330. * @returns the current mesh
  15331. */
  15332. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15333. /** @hidden */
  15334. _preActivate(): InstancedMesh;
  15335. /** @hidden */
  15336. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15337. /** @hidden */
  15338. _postActivate(): void;
  15339. getWorldMatrix(): Matrix;
  15340. get isAnInstance(): boolean;
  15341. /**
  15342. * Returns the current associated LOD AbstractMesh.
  15343. */
  15344. getLOD(camera: Camera): AbstractMesh;
  15345. /** @hidden */
  15346. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15347. /** @hidden */
  15348. _syncSubMeshes(): InstancedMesh;
  15349. /** @hidden */
  15350. _generatePointsArray(): boolean;
  15351. /**
  15352. * Creates a new InstancedMesh from the current mesh.
  15353. * - name (string) : the cloned mesh name
  15354. * - newParent (optional Node) : the optional Node to parent the clone to.
  15355. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15356. *
  15357. * Returns the clone.
  15358. */
  15359. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15360. /**
  15361. * Disposes the InstancedMesh.
  15362. * Returns nothing.
  15363. */
  15364. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15365. }
  15366. interface Mesh {
  15367. /**
  15368. * Register a custom buffer that will be instanced
  15369. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15370. * @param kind defines the buffer kind
  15371. * @param stride defines the stride in floats
  15372. */
  15373. registerInstancedBuffer(kind: string, stride: number): void;
  15374. /** @hidden */
  15375. _userInstancedBuffersStorage: {
  15376. data: {
  15377. [key: string]: Float32Array;
  15378. };
  15379. sizes: {
  15380. [key: string]: number;
  15381. };
  15382. vertexBuffers: {
  15383. [key: string]: Nullable<VertexBuffer>;
  15384. };
  15385. strides: {
  15386. [key: string]: number;
  15387. };
  15388. };
  15389. }
  15390. interface AbstractMesh {
  15391. /**
  15392. * Object used to store instanced buffers defined by user
  15393. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15394. */
  15395. instancedBuffers: {
  15396. [key: string]: any;
  15397. };
  15398. }
  15399. }
  15400. declare module BABYLON {
  15401. /**
  15402. * Defines the options associated with the creation of a shader material.
  15403. */
  15404. export interface IShaderMaterialOptions {
  15405. /**
  15406. * Does the material work in alpha blend mode
  15407. */
  15408. needAlphaBlending: boolean;
  15409. /**
  15410. * Does the material work in alpha test mode
  15411. */
  15412. needAlphaTesting: boolean;
  15413. /**
  15414. * The list of attribute names used in the shader
  15415. */
  15416. attributes: string[];
  15417. /**
  15418. * The list of unifrom names used in the shader
  15419. */
  15420. uniforms: string[];
  15421. /**
  15422. * The list of UBO names used in the shader
  15423. */
  15424. uniformBuffers: string[];
  15425. /**
  15426. * The list of sampler names used in the shader
  15427. */
  15428. samplers: string[];
  15429. /**
  15430. * The list of defines used in the shader
  15431. */
  15432. defines: string[];
  15433. }
  15434. /**
  15435. * 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.
  15436. *
  15437. * This returned material effects how the mesh will look based on the code in the shaders.
  15438. *
  15439. * @see http://doc.babylonjs.com/how_to/shader_material
  15440. */
  15441. export class ShaderMaterial extends Material {
  15442. private _shaderPath;
  15443. private _options;
  15444. private _textures;
  15445. private _textureArrays;
  15446. private _floats;
  15447. private _ints;
  15448. private _floatsArrays;
  15449. private _colors3;
  15450. private _colors3Arrays;
  15451. private _colors4;
  15452. private _colors4Arrays;
  15453. private _vectors2;
  15454. private _vectors3;
  15455. private _vectors4;
  15456. private _matrices;
  15457. private _matrixArrays;
  15458. private _matrices3x3;
  15459. private _matrices2x2;
  15460. private _vectors2Arrays;
  15461. private _vectors3Arrays;
  15462. private _vectors4Arrays;
  15463. private _cachedWorldViewMatrix;
  15464. private _cachedWorldViewProjectionMatrix;
  15465. private _renderId;
  15466. private _multiview;
  15467. /**
  15468. * Instantiate a new shader material.
  15469. * 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.
  15470. * This returned material effects how the mesh will look based on the code in the shaders.
  15471. * @see http://doc.babylonjs.com/how_to/shader_material
  15472. * @param name Define the name of the material in the scene
  15473. * @param scene Define the scene the material belongs to
  15474. * @param shaderPath Defines the route to the shader code in one of three ways:
  15475. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15476. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15477. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15478. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15479. * @param options Define the options used to create the shader
  15480. */
  15481. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15482. /**
  15483. * Gets the shader path used to define the shader code
  15484. * It can be modified to trigger a new compilation
  15485. */
  15486. get shaderPath(): any;
  15487. /**
  15488. * Sets the shader path used to define the shader code
  15489. * It can be modified to trigger a new compilation
  15490. */
  15491. set shaderPath(shaderPath: any);
  15492. /**
  15493. * Gets the options used to compile the shader.
  15494. * They can be modified to trigger a new compilation
  15495. */
  15496. get options(): IShaderMaterialOptions;
  15497. /**
  15498. * Gets the current class name of the material e.g. "ShaderMaterial"
  15499. * Mainly use in serialization.
  15500. * @returns the class name
  15501. */
  15502. getClassName(): string;
  15503. /**
  15504. * Specifies if the material will require alpha blending
  15505. * @returns a boolean specifying if alpha blending is needed
  15506. */
  15507. needAlphaBlending(): boolean;
  15508. /**
  15509. * Specifies if this material should be rendered in alpha test mode
  15510. * @returns a boolean specifying if an alpha test is needed.
  15511. */
  15512. needAlphaTesting(): boolean;
  15513. private _checkUniform;
  15514. /**
  15515. * Set a texture in the shader.
  15516. * @param name Define the name of the uniform samplers as defined in the shader
  15517. * @param texture Define the texture to bind to this sampler
  15518. * @return the material itself allowing "fluent" like uniform updates
  15519. */
  15520. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15521. /**
  15522. * Set a texture array in the shader.
  15523. * @param name Define the name of the uniform sampler array as defined in the shader
  15524. * @param textures Define the list of textures to bind to this sampler
  15525. * @return the material itself allowing "fluent" like uniform updates
  15526. */
  15527. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15528. /**
  15529. * Set a float in the shader.
  15530. * @param name Define the name of the uniform as defined in the shader
  15531. * @param value Define the value to give to the uniform
  15532. * @return the material itself allowing "fluent" like uniform updates
  15533. */
  15534. setFloat(name: string, value: number): ShaderMaterial;
  15535. /**
  15536. * Set a int in the shader.
  15537. * @param name Define the name of the uniform as defined in the shader
  15538. * @param value Define the value to give to the uniform
  15539. * @return the material itself allowing "fluent" like uniform updates
  15540. */
  15541. setInt(name: string, value: number): ShaderMaterial;
  15542. /**
  15543. * Set an array of floats in the shader.
  15544. * @param name Define the name of the uniform as defined in the shader
  15545. * @param value Define the value to give to the uniform
  15546. * @return the material itself allowing "fluent" like uniform updates
  15547. */
  15548. setFloats(name: string, value: number[]): ShaderMaterial;
  15549. /**
  15550. * Set a vec3 in the shader from a Color3.
  15551. * @param name Define the name of the uniform as defined in the shader
  15552. * @param value Define the value to give to the uniform
  15553. * @return the material itself allowing "fluent" like uniform updates
  15554. */
  15555. setColor3(name: string, value: Color3): ShaderMaterial;
  15556. /**
  15557. * Set a vec3 array in the shader from a Color3 array.
  15558. * @param name Define the name of the uniform as defined in the shader
  15559. * @param value Define the value to give to the uniform
  15560. * @return the material itself allowing "fluent" like uniform updates
  15561. */
  15562. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15563. /**
  15564. * Set a vec4 in the shader from a Color4.
  15565. * @param name Define the name of the uniform as defined in the shader
  15566. * @param value Define the value to give to the uniform
  15567. * @return the material itself allowing "fluent" like uniform updates
  15568. */
  15569. setColor4(name: string, value: Color4): ShaderMaterial;
  15570. /**
  15571. * Set a vec4 array in the shader from a Color4 array.
  15572. * @param name Define the name of the uniform as defined in the shader
  15573. * @param value Define the value to give to the uniform
  15574. * @return the material itself allowing "fluent" like uniform updates
  15575. */
  15576. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15577. /**
  15578. * Set a vec2 in the shader from a Vector2.
  15579. * @param name Define the name of the uniform as defined in the shader
  15580. * @param value Define the value to give to the uniform
  15581. * @return the material itself allowing "fluent" like uniform updates
  15582. */
  15583. setVector2(name: string, value: Vector2): ShaderMaterial;
  15584. /**
  15585. * Set a vec3 in the shader from a Vector3.
  15586. * @param name Define the name of the uniform as defined in the shader
  15587. * @param value Define the value to give to the uniform
  15588. * @return the material itself allowing "fluent" like uniform updates
  15589. */
  15590. setVector3(name: string, value: Vector3): ShaderMaterial;
  15591. /**
  15592. * Set a vec4 in the shader from a Vector4.
  15593. * @param name Define the name of the uniform as defined in the shader
  15594. * @param value Define the value to give to the uniform
  15595. * @return the material itself allowing "fluent" like uniform updates
  15596. */
  15597. setVector4(name: string, value: Vector4): ShaderMaterial;
  15598. /**
  15599. * Set a mat4 in the shader from a Matrix.
  15600. * @param name Define the name of the uniform as defined in the shader
  15601. * @param value Define the value to give to the uniform
  15602. * @return the material itself allowing "fluent" like uniform updates
  15603. */
  15604. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15605. /**
  15606. * Set a float32Array in the shader from a matrix array.
  15607. * @param name Define the name of the uniform as defined in the shader
  15608. * @param value Define the value to give to the uniform
  15609. * @return the material itself allowing "fluent" like uniform updates
  15610. */
  15611. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15612. /**
  15613. * Set a mat3 in the shader from a Float32Array.
  15614. * @param name Define the name of the uniform as defined in the shader
  15615. * @param value Define the value to give to the uniform
  15616. * @return the material itself allowing "fluent" like uniform updates
  15617. */
  15618. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15619. /**
  15620. * Set a mat2 in the shader from a Float32Array.
  15621. * @param name Define the name of the uniform as defined in the shader
  15622. * @param value Define the value to give to the uniform
  15623. * @return the material itself allowing "fluent" like uniform updates
  15624. */
  15625. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15626. /**
  15627. * Set a vec2 array in the shader from a number array.
  15628. * @param name Define the name of the uniform as defined in the shader
  15629. * @param value Define the value to give to the uniform
  15630. * @return the material itself allowing "fluent" like uniform updates
  15631. */
  15632. setArray2(name: string, value: number[]): ShaderMaterial;
  15633. /**
  15634. * Set a vec3 array in the shader from a number array.
  15635. * @param name Define the name of the uniform as defined in the shader
  15636. * @param value Define the value to give to the uniform
  15637. * @return the material itself allowing "fluent" like uniform updates
  15638. */
  15639. setArray3(name: string, value: number[]): ShaderMaterial;
  15640. /**
  15641. * Set a vec4 array in the shader from a number array.
  15642. * @param name Define the name of the uniform as defined in the shader
  15643. * @param value Define the value to give to the uniform
  15644. * @return the material itself allowing "fluent" like uniform updates
  15645. */
  15646. setArray4(name: string, value: number[]): ShaderMaterial;
  15647. private _checkCache;
  15648. /**
  15649. * Specifies that the submesh is ready to be used
  15650. * @param mesh defines the mesh to check
  15651. * @param subMesh defines which submesh to check
  15652. * @param useInstances specifies that instances should be used
  15653. * @returns a boolean indicating that the submesh is ready or not
  15654. */
  15655. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15656. /**
  15657. * Checks if the material is ready to render the requested mesh
  15658. * @param mesh Define the mesh to render
  15659. * @param useInstances Define whether or not the material is used with instances
  15660. * @returns true if ready, otherwise false
  15661. */
  15662. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15663. /**
  15664. * Binds the world matrix to the material
  15665. * @param world defines the world transformation matrix
  15666. */
  15667. bindOnlyWorldMatrix(world: Matrix): void;
  15668. /**
  15669. * Binds the material to the mesh
  15670. * @param world defines the world transformation matrix
  15671. * @param mesh defines the mesh to bind the material to
  15672. */
  15673. bind(world: Matrix, mesh?: Mesh): void;
  15674. /**
  15675. * Gets the active textures from the material
  15676. * @returns an array of textures
  15677. */
  15678. getActiveTextures(): BaseTexture[];
  15679. /**
  15680. * Specifies if the material uses a texture
  15681. * @param texture defines the texture to check against the material
  15682. * @returns a boolean specifying if the material uses the texture
  15683. */
  15684. hasTexture(texture: BaseTexture): boolean;
  15685. /**
  15686. * Makes a duplicate of the material, and gives it a new name
  15687. * @param name defines the new name for the duplicated material
  15688. * @returns the cloned material
  15689. */
  15690. clone(name: string): ShaderMaterial;
  15691. /**
  15692. * Disposes the material
  15693. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15694. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15695. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15696. */
  15697. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15698. /**
  15699. * Serializes this material in a JSON representation
  15700. * @returns the serialized material object
  15701. */
  15702. serialize(): any;
  15703. /**
  15704. * Creates a shader material from parsed shader material data
  15705. * @param source defines the JSON represnetation of the material
  15706. * @param scene defines the hosting scene
  15707. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15708. * @returns a new material
  15709. */
  15710. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15711. }
  15712. }
  15713. declare module BABYLON {
  15714. /** @hidden */
  15715. export var colorPixelShader: {
  15716. name: string;
  15717. shader: string;
  15718. };
  15719. }
  15720. declare module BABYLON {
  15721. /** @hidden */
  15722. export var colorVertexShader: {
  15723. name: string;
  15724. shader: string;
  15725. };
  15726. }
  15727. declare module BABYLON {
  15728. /**
  15729. * Line mesh
  15730. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15731. */
  15732. export class LinesMesh extends Mesh {
  15733. /**
  15734. * If vertex color should be applied to the mesh
  15735. */
  15736. readonly useVertexColor?: boolean | undefined;
  15737. /**
  15738. * If vertex alpha should be applied to the mesh
  15739. */
  15740. readonly useVertexAlpha?: boolean | undefined;
  15741. /**
  15742. * Color of the line (Default: White)
  15743. */
  15744. color: Color3;
  15745. /**
  15746. * Alpha of the line (Default: 1)
  15747. */
  15748. alpha: number;
  15749. /**
  15750. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15751. * This margin is expressed in world space coordinates, so its value may vary.
  15752. * Default value is 0.1
  15753. */
  15754. intersectionThreshold: number;
  15755. private _colorShader;
  15756. private color4;
  15757. /**
  15758. * Creates a new LinesMesh
  15759. * @param name defines the name
  15760. * @param scene defines the hosting scene
  15761. * @param parent defines the parent mesh if any
  15762. * @param source defines the optional source LinesMesh used to clone data from
  15763. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15764. * When false, achieved by calling a clone(), also passing False.
  15765. * This will make creation of children, recursive.
  15766. * @param useVertexColor defines if this LinesMesh supports vertex color
  15767. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15768. */
  15769. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15770. /**
  15771. * If vertex color should be applied to the mesh
  15772. */
  15773. useVertexColor?: boolean | undefined,
  15774. /**
  15775. * If vertex alpha should be applied to the mesh
  15776. */
  15777. useVertexAlpha?: boolean | undefined);
  15778. private _addClipPlaneDefine;
  15779. private _removeClipPlaneDefine;
  15780. isReady(): boolean;
  15781. /**
  15782. * Returns the string "LineMesh"
  15783. */
  15784. getClassName(): string;
  15785. /**
  15786. * @hidden
  15787. */
  15788. get material(): Material;
  15789. /**
  15790. * @hidden
  15791. */
  15792. set material(value: Material);
  15793. /**
  15794. * @hidden
  15795. */
  15796. get checkCollisions(): boolean;
  15797. /** @hidden */
  15798. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15799. /** @hidden */
  15800. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15801. /**
  15802. * Disposes of the line mesh
  15803. * @param doNotRecurse If children should be disposed
  15804. */
  15805. dispose(doNotRecurse?: boolean): void;
  15806. /**
  15807. * Returns a new LineMesh object cloned from the current one.
  15808. */
  15809. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15810. /**
  15811. * Creates a new InstancedLinesMesh object from the mesh model.
  15812. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15813. * @param name defines the name of the new instance
  15814. * @returns a new InstancedLinesMesh
  15815. */
  15816. createInstance(name: string): InstancedLinesMesh;
  15817. }
  15818. /**
  15819. * Creates an instance based on a source LinesMesh
  15820. */
  15821. export class InstancedLinesMesh extends InstancedMesh {
  15822. /**
  15823. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15824. * This margin is expressed in world space coordinates, so its value may vary.
  15825. * Initilized with the intersectionThreshold value of the source LinesMesh
  15826. */
  15827. intersectionThreshold: number;
  15828. constructor(name: string, source: LinesMesh);
  15829. /**
  15830. * Returns the string "InstancedLinesMesh".
  15831. */
  15832. getClassName(): string;
  15833. }
  15834. }
  15835. declare module BABYLON {
  15836. /** @hidden */
  15837. export var linePixelShader: {
  15838. name: string;
  15839. shader: string;
  15840. };
  15841. }
  15842. declare module BABYLON {
  15843. /** @hidden */
  15844. export var lineVertexShader: {
  15845. name: string;
  15846. shader: string;
  15847. };
  15848. }
  15849. declare module BABYLON {
  15850. interface AbstractMesh {
  15851. /**
  15852. * Gets the edgesRenderer associated with the mesh
  15853. */
  15854. edgesRenderer: Nullable<EdgesRenderer>;
  15855. }
  15856. interface LinesMesh {
  15857. /**
  15858. * Enables the edge rendering mode on the mesh.
  15859. * This mode makes the mesh edges visible
  15860. * @param epsilon defines the maximal distance between two angles to detect a face
  15861. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15862. * @returns the currentAbstractMesh
  15863. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15864. */
  15865. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15866. }
  15867. interface InstancedLinesMesh {
  15868. /**
  15869. * Enables the edge rendering mode on the mesh.
  15870. * This mode makes the mesh edges visible
  15871. * @param epsilon defines the maximal distance between two angles to detect a face
  15872. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15873. * @returns the current InstancedLinesMesh
  15874. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15875. */
  15876. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15877. }
  15878. /**
  15879. * Defines the minimum contract an Edges renderer should follow.
  15880. */
  15881. export interface IEdgesRenderer extends IDisposable {
  15882. /**
  15883. * Gets or sets a boolean indicating if the edgesRenderer is active
  15884. */
  15885. isEnabled: boolean;
  15886. /**
  15887. * Renders the edges of the attached mesh,
  15888. */
  15889. render(): void;
  15890. /**
  15891. * Checks wether or not the edges renderer is ready to render.
  15892. * @return true if ready, otherwise false.
  15893. */
  15894. isReady(): boolean;
  15895. }
  15896. /**
  15897. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15898. */
  15899. export class EdgesRenderer implements IEdgesRenderer {
  15900. /**
  15901. * Define the size of the edges with an orthographic camera
  15902. */
  15903. edgesWidthScalerForOrthographic: number;
  15904. /**
  15905. * Define the size of the edges with a perspective camera
  15906. */
  15907. edgesWidthScalerForPerspective: number;
  15908. protected _source: AbstractMesh;
  15909. protected _linesPositions: number[];
  15910. protected _linesNormals: number[];
  15911. protected _linesIndices: number[];
  15912. protected _epsilon: number;
  15913. protected _indicesCount: number;
  15914. protected _lineShader: ShaderMaterial;
  15915. protected _ib: DataBuffer;
  15916. protected _buffers: {
  15917. [key: string]: Nullable<VertexBuffer>;
  15918. };
  15919. protected _checkVerticesInsteadOfIndices: boolean;
  15920. private _meshRebuildObserver;
  15921. private _meshDisposeObserver;
  15922. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15923. isEnabled: boolean;
  15924. /**
  15925. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15926. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15927. * @param source Mesh used to create edges
  15928. * @param epsilon sum of angles in adjacency to check for edge
  15929. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15930. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15931. */
  15932. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15933. protected _prepareRessources(): void;
  15934. /** @hidden */
  15935. _rebuild(): void;
  15936. /**
  15937. * Releases the required resources for the edges renderer
  15938. */
  15939. dispose(): void;
  15940. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  15941. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  15942. /**
  15943. * Checks if the pair of p0 and p1 is en edge
  15944. * @param faceIndex
  15945. * @param edge
  15946. * @param faceNormals
  15947. * @param p0
  15948. * @param p1
  15949. * @private
  15950. */
  15951. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  15952. /**
  15953. * push line into the position, normal and index buffer
  15954. * @protected
  15955. */
  15956. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  15957. /**
  15958. * Generates lines edges from adjacencjes
  15959. * @private
  15960. */
  15961. _generateEdgesLines(): void;
  15962. /**
  15963. * Checks wether or not the edges renderer is ready to render.
  15964. * @return true if ready, otherwise false.
  15965. */
  15966. isReady(): boolean;
  15967. /**
  15968. * Renders the edges of the attached mesh,
  15969. */
  15970. render(): void;
  15971. }
  15972. /**
  15973. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  15974. */
  15975. export class LineEdgesRenderer extends EdgesRenderer {
  15976. /**
  15977. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  15978. * @param source LineMesh used to generate edges
  15979. * @param epsilon not important (specified angle for edge detection)
  15980. * @param checkVerticesInsteadOfIndices not important for LineMesh
  15981. */
  15982. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  15983. /**
  15984. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  15985. */
  15986. _generateEdgesLines(): void;
  15987. }
  15988. }
  15989. declare module BABYLON {
  15990. /**
  15991. * This represents the object necessary to create a rendering group.
  15992. * This is exclusively used and created by the rendering manager.
  15993. * To modify the behavior, you use the available helpers in your scene or meshes.
  15994. * @hidden
  15995. */
  15996. export class RenderingGroup {
  15997. index: number;
  15998. private static _zeroVector;
  15999. private _scene;
  16000. private _opaqueSubMeshes;
  16001. private _transparentSubMeshes;
  16002. private _alphaTestSubMeshes;
  16003. private _depthOnlySubMeshes;
  16004. private _particleSystems;
  16005. private _spriteManagers;
  16006. private _opaqueSortCompareFn;
  16007. private _alphaTestSortCompareFn;
  16008. private _transparentSortCompareFn;
  16009. private _renderOpaque;
  16010. private _renderAlphaTest;
  16011. private _renderTransparent;
  16012. /** @hidden */
  16013. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16014. onBeforeTransparentRendering: () => void;
  16015. /**
  16016. * Set the opaque sort comparison function.
  16017. * If null the sub meshes will be render in the order they were created
  16018. */
  16019. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16020. /**
  16021. * Set the alpha test sort comparison function.
  16022. * If null the sub meshes will be render in the order they were created
  16023. */
  16024. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16025. /**
  16026. * Set the transparent sort comparison function.
  16027. * If null the sub meshes will be render in the order they were created
  16028. */
  16029. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16030. /**
  16031. * Creates a new rendering group.
  16032. * @param index The rendering group index
  16033. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16034. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16035. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16036. */
  16037. 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>);
  16038. /**
  16039. * Render all the sub meshes contained in the group.
  16040. * @param customRenderFunction Used to override the default render behaviour of the group.
  16041. * @returns true if rendered some submeshes.
  16042. */
  16043. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16044. /**
  16045. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16046. * @param subMeshes The submeshes to render
  16047. */
  16048. private renderOpaqueSorted;
  16049. /**
  16050. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16051. * @param subMeshes The submeshes to render
  16052. */
  16053. private renderAlphaTestSorted;
  16054. /**
  16055. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16056. * @param subMeshes The submeshes to render
  16057. */
  16058. private renderTransparentSorted;
  16059. /**
  16060. * Renders the submeshes in a specified order.
  16061. * @param subMeshes The submeshes to sort before render
  16062. * @param sortCompareFn The comparison function use to sort
  16063. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16064. * @param transparent Specifies to activate blending if true
  16065. */
  16066. private static renderSorted;
  16067. /**
  16068. * Renders the submeshes in the order they were dispatched (no sort applied).
  16069. * @param subMeshes The submeshes to render
  16070. */
  16071. private static renderUnsorted;
  16072. /**
  16073. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16074. * are rendered back to front if in the same alpha index.
  16075. *
  16076. * @param a The first submesh
  16077. * @param b The second submesh
  16078. * @returns The result of the comparison
  16079. */
  16080. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16081. /**
  16082. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16083. * are rendered back to front.
  16084. *
  16085. * @param a The first submesh
  16086. * @param b The second submesh
  16087. * @returns The result of the comparison
  16088. */
  16089. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16090. /**
  16091. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16092. * are rendered front to back (prevent overdraw).
  16093. *
  16094. * @param a The first submesh
  16095. * @param b The second submesh
  16096. * @returns The result of the comparison
  16097. */
  16098. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16099. /**
  16100. * Resets the different lists of submeshes to prepare a new frame.
  16101. */
  16102. prepare(): void;
  16103. dispose(): void;
  16104. /**
  16105. * Inserts the submesh in its correct queue depending on its material.
  16106. * @param subMesh The submesh to dispatch
  16107. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16108. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16109. */
  16110. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16111. dispatchSprites(spriteManager: ISpriteManager): void;
  16112. dispatchParticles(particleSystem: IParticleSystem): void;
  16113. private _renderParticles;
  16114. private _renderSprites;
  16115. }
  16116. }
  16117. declare module BABYLON {
  16118. /**
  16119. * Interface describing the different options available in the rendering manager
  16120. * regarding Auto Clear between groups.
  16121. */
  16122. export interface IRenderingManagerAutoClearSetup {
  16123. /**
  16124. * Defines whether or not autoclear is enable.
  16125. */
  16126. autoClear: boolean;
  16127. /**
  16128. * Defines whether or not to autoclear the depth buffer.
  16129. */
  16130. depth: boolean;
  16131. /**
  16132. * Defines whether or not to autoclear the stencil buffer.
  16133. */
  16134. stencil: boolean;
  16135. }
  16136. /**
  16137. * This class is used by the onRenderingGroupObservable
  16138. */
  16139. export class RenderingGroupInfo {
  16140. /**
  16141. * The Scene that being rendered
  16142. */
  16143. scene: Scene;
  16144. /**
  16145. * The camera currently used for the rendering pass
  16146. */
  16147. camera: Nullable<Camera>;
  16148. /**
  16149. * The ID of the renderingGroup being processed
  16150. */
  16151. renderingGroupId: number;
  16152. }
  16153. /**
  16154. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16155. * It is enable to manage the different groups as well as the different necessary sort functions.
  16156. * This should not be used directly aside of the few static configurations
  16157. */
  16158. export class RenderingManager {
  16159. /**
  16160. * The max id used for rendering groups (not included)
  16161. */
  16162. static MAX_RENDERINGGROUPS: number;
  16163. /**
  16164. * The min id used for rendering groups (included)
  16165. */
  16166. static MIN_RENDERINGGROUPS: number;
  16167. /**
  16168. * Used to globally prevent autoclearing scenes.
  16169. */
  16170. static AUTOCLEAR: boolean;
  16171. /**
  16172. * @hidden
  16173. */
  16174. _useSceneAutoClearSetup: boolean;
  16175. private _scene;
  16176. private _renderingGroups;
  16177. private _depthStencilBufferAlreadyCleaned;
  16178. private _autoClearDepthStencil;
  16179. private _customOpaqueSortCompareFn;
  16180. private _customAlphaTestSortCompareFn;
  16181. private _customTransparentSortCompareFn;
  16182. private _renderingGroupInfo;
  16183. /**
  16184. * Instantiates a new rendering group for a particular scene
  16185. * @param scene Defines the scene the groups belongs to
  16186. */
  16187. constructor(scene: Scene);
  16188. private _clearDepthStencilBuffer;
  16189. /**
  16190. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16191. * @hidden
  16192. */
  16193. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16194. /**
  16195. * Resets the different information of the group to prepare a new frame
  16196. * @hidden
  16197. */
  16198. reset(): void;
  16199. /**
  16200. * Dispose and release the group and its associated resources.
  16201. * @hidden
  16202. */
  16203. dispose(): void;
  16204. /**
  16205. * Clear the info related to rendering groups preventing retention points during dispose.
  16206. */
  16207. freeRenderingGroups(): void;
  16208. private _prepareRenderingGroup;
  16209. /**
  16210. * Add a sprite manager to the rendering manager in order to render it this frame.
  16211. * @param spriteManager Define the sprite manager to render
  16212. */
  16213. dispatchSprites(spriteManager: ISpriteManager): void;
  16214. /**
  16215. * Add a particle system to the rendering manager in order to render it this frame.
  16216. * @param particleSystem Define the particle system to render
  16217. */
  16218. dispatchParticles(particleSystem: IParticleSystem): void;
  16219. /**
  16220. * Add a submesh to the manager in order to render it this frame
  16221. * @param subMesh The submesh to dispatch
  16222. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16223. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16224. */
  16225. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16226. /**
  16227. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16228. * This allowed control for front to back rendering or reversly depending of the special needs.
  16229. *
  16230. * @param renderingGroupId The rendering group id corresponding to its index
  16231. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16232. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16233. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16234. */
  16235. 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;
  16236. /**
  16237. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16238. *
  16239. * @param renderingGroupId The rendering group id corresponding to its index
  16240. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16241. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16242. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16243. */
  16244. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16245. /**
  16246. * Gets the current auto clear configuration for one rendering group of the rendering
  16247. * manager.
  16248. * @param index the rendering group index to get the information for
  16249. * @returns The auto clear setup for the requested rendering group
  16250. */
  16251. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16252. }
  16253. }
  16254. declare module BABYLON {
  16255. /**
  16256. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16257. */
  16258. export interface ICustomShaderOptions {
  16259. /**
  16260. * Gets or sets the custom shader name to use
  16261. */
  16262. shaderName: string;
  16263. /**
  16264. * The list of attribute names used in the shader
  16265. */
  16266. attributes?: string[];
  16267. /**
  16268. * The list of unifrom names used in the shader
  16269. */
  16270. uniforms?: string[];
  16271. /**
  16272. * The list of sampler names used in the shader
  16273. */
  16274. samplers?: string[];
  16275. /**
  16276. * The list of defines used in the shader
  16277. */
  16278. defines?: string[];
  16279. }
  16280. /**
  16281. * Interface to implement to create a shadow generator compatible with BJS.
  16282. */
  16283. export interface IShadowGenerator {
  16284. /**
  16285. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16286. * @returns The render target texture if present otherwise, null
  16287. */
  16288. getShadowMap(): Nullable<RenderTargetTexture>;
  16289. /**
  16290. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16291. * @param subMesh The submesh we want to render in the shadow map
  16292. * @param useInstances Defines wether will draw in the map using instances
  16293. * @returns true if ready otherwise, false
  16294. */
  16295. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16296. /**
  16297. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16298. * @param defines Defines of the material we want to update
  16299. * @param lightIndex Index of the light in the enabled light list of the material
  16300. */
  16301. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16302. /**
  16303. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16304. * defined in the generator but impacting the effect).
  16305. * It implies the unifroms available on the materials are the standard BJS ones.
  16306. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16307. * @param effect The effect we are binfing the information for
  16308. */
  16309. bindShadowLight(lightIndex: string, effect: Effect): void;
  16310. /**
  16311. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16312. * (eq to shadow prjection matrix * light transform matrix)
  16313. * @returns The transform matrix used to create the shadow map
  16314. */
  16315. getTransformMatrix(): Matrix;
  16316. /**
  16317. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16318. * Cube and 2D textures for instance.
  16319. */
  16320. recreateShadowMap(): void;
  16321. /**
  16322. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16323. * @param onCompiled Callback triggered at the and of the effects compilation
  16324. * @param options Sets of optional options forcing the compilation with different modes
  16325. */
  16326. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16327. useInstances: boolean;
  16328. }>): void;
  16329. /**
  16330. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16331. * @param options Sets of optional options forcing the compilation with different modes
  16332. * @returns A promise that resolves when the compilation completes
  16333. */
  16334. forceCompilationAsync(options?: Partial<{
  16335. useInstances: boolean;
  16336. }>): Promise<void>;
  16337. /**
  16338. * Serializes the shadow generator setup to a json object.
  16339. * @returns The serialized JSON object
  16340. */
  16341. serialize(): any;
  16342. /**
  16343. * Disposes the Shadow map and related Textures and effects.
  16344. */
  16345. dispose(): void;
  16346. }
  16347. /**
  16348. * Default implementation IShadowGenerator.
  16349. * This is the main object responsible of generating shadows in the framework.
  16350. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16351. */
  16352. export class ShadowGenerator implements IShadowGenerator {
  16353. /**
  16354. * Name of the shadow generator class
  16355. */
  16356. static CLASSNAME: string;
  16357. /**
  16358. * Shadow generator mode None: no filtering applied.
  16359. */
  16360. static readonly FILTER_NONE: number;
  16361. /**
  16362. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16363. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16364. */
  16365. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16366. /**
  16367. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16368. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16369. */
  16370. static readonly FILTER_POISSONSAMPLING: number;
  16371. /**
  16372. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16373. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16374. */
  16375. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16376. /**
  16377. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16378. * edge artifacts on steep falloff.
  16379. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16380. */
  16381. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16382. /**
  16383. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16384. * edge artifacts on steep falloff.
  16385. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16386. */
  16387. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16388. /**
  16389. * Shadow generator mode PCF: Percentage Closer Filtering
  16390. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16391. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16392. */
  16393. static readonly FILTER_PCF: number;
  16394. /**
  16395. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16396. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16397. * Contact Hardening
  16398. */
  16399. static readonly FILTER_PCSS: number;
  16400. /**
  16401. * Reserved for PCF and PCSS
  16402. * Highest Quality.
  16403. *
  16404. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16405. *
  16406. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16407. */
  16408. static readonly QUALITY_HIGH: number;
  16409. /**
  16410. * Reserved for PCF and PCSS
  16411. * Good tradeoff for quality/perf cross devices
  16412. *
  16413. * Execute PCF on a 3*3 kernel.
  16414. *
  16415. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16416. */
  16417. static readonly QUALITY_MEDIUM: number;
  16418. /**
  16419. * Reserved for PCF and PCSS
  16420. * The lowest quality but the fastest.
  16421. *
  16422. * Execute PCF on a 1*1 kernel.
  16423. *
  16424. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16425. */
  16426. static readonly QUALITY_LOW: number;
  16427. /** Gets or sets the custom shader name to use */
  16428. customShaderOptions: ICustomShaderOptions;
  16429. /**
  16430. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16431. */
  16432. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16433. /**
  16434. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16435. */
  16436. onAfterShadowMapRenderObservable: Observable<Effect>;
  16437. /**
  16438. * Observable triggered before a mesh is rendered in the shadow map.
  16439. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16440. */
  16441. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16442. /**
  16443. * Observable triggered after a mesh is rendered in the shadow map.
  16444. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16445. */
  16446. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16447. protected _bias: number;
  16448. /**
  16449. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16450. */
  16451. get bias(): number;
  16452. /**
  16453. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16454. */
  16455. set bias(bias: number);
  16456. protected _normalBias: number;
  16457. /**
  16458. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16459. */
  16460. get normalBias(): number;
  16461. /**
  16462. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16463. */
  16464. set normalBias(normalBias: number);
  16465. protected _blurBoxOffset: number;
  16466. /**
  16467. * Gets the blur box offset: offset applied during the blur pass.
  16468. * Only useful if useKernelBlur = false
  16469. */
  16470. get blurBoxOffset(): number;
  16471. /**
  16472. * Sets the blur box offset: offset applied during the blur pass.
  16473. * Only useful if useKernelBlur = false
  16474. */
  16475. set blurBoxOffset(value: number);
  16476. protected _blurScale: number;
  16477. /**
  16478. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16479. * 2 means half of the size.
  16480. */
  16481. get blurScale(): number;
  16482. /**
  16483. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16484. * 2 means half of the size.
  16485. */
  16486. set blurScale(value: number);
  16487. protected _blurKernel: number;
  16488. /**
  16489. * Gets the blur kernel: kernel size of the blur pass.
  16490. * Only useful if useKernelBlur = true
  16491. */
  16492. get blurKernel(): number;
  16493. /**
  16494. * Sets the blur kernel: kernel size of the blur pass.
  16495. * Only useful if useKernelBlur = true
  16496. */
  16497. set blurKernel(value: number);
  16498. protected _useKernelBlur: boolean;
  16499. /**
  16500. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16501. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16502. */
  16503. get useKernelBlur(): boolean;
  16504. /**
  16505. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16506. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16507. */
  16508. set useKernelBlur(value: boolean);
  16509. protected _depthScale: number;
  16510. /**
  16511. * Gets the depth scale used in ESM mode.
  16512. */
  16513. get depthScale(): number;
  16514. /**
  16515. * Sets the depth scale used in ESM mode.
  16516. * This can override the scale stored on the light.
  16517. */
  16518. set depthScale(value: number);
  16519. protected _validateFilter(filter: number): number;
  16520. protected _filter: number;
  16521. /**
  16522. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16523. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16524. */
  16525. get filter(): number;
  16526. /**
  16527. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16528. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16529. */
  16530. set filter(value: number);
  16531. /**
  16532. * Gets if the current filter is set to Poisson Sampling.
  16533. */
  16534. get usePoissonSampling(): boolean;
  16535. /**
  16536. * Sets the current filter to Poisson Sampling.
  16537. */
  16538. set usePoissonSampling(value: boolean);
  16539. /**
  16540. * Gets if the current filter is set to ESM.
  16541. */
  16542. get useExponentialShadowMap(): boolean;
  16543. /**
  16544. * Sets the current filter is to ESM.
  16545. */
  16546. set useExponentialShadowMap(value: boolean);
  16547. /**
  16548. * Gets if the current filter is set to filtered ESM.
  16549. */
  16550. get useBlurExponentialShadowMap(): boolean;
  16551. /**
  16552. * Gets if the current filter is set to filtered ESM.
  16553. */
  16554. set useBlurExponentialShadowMap(value: boolean);
  16555. /**
  16556. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16557. * exponential to prevent steep falloff artifacts).
  16558. */
  16559. get useCloseExponentialShadowMap(): boolean;
  16560. /**
  16561. * Sets the current filter to "close ESM" (using the inverse of the
  16562. * exponential to prevent steep falloff artifacts).
  16563. */
  16564. set useCloseExponentialShadowMap(value: boolean);
  16565. /**
  16566. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16567. * exponential to prevent steep falloff artifacts).
  16568. */
  16569. get useBlurCloseExponentialShadowMap(): boolean;
  16570. /**
  16571. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16572. * exponential to prevent steep falloff artifacts).
  16573. */
  16574. set useBlurCloseExponentialShadowMap(value: boolean);
  16575. /**
  16576. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16577. */
  16578. get usePercentageCloserFiltering(): boolean;
  16579. /**
  16580. * Sets the current filter to "PCF" (percentage closer filtering).
  16581. */
  16582. set usePercentageCloserFiltering(value: boolean);
  16583. protected _filteringQuality: number;
  16584. /**
  16585. * Gets the PCF or PCSS Quality.
  16586. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16587. */
  16588. get filteringQuality(): number;
  16589. /**
  16590. * Sets the PCF or PCSS Quality.
  16591. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16592. */
  16593. set filteringQuality(filteringQuality: number);
  16594. /**
  16595. * Gets if the current filter is set to "PCSS" (contact hardening).
  16596. */
  16597. get useContactHardeningShadow(): boolean;
  16598. /**
  16599. * Sets the current filter to "PCSS" (contact hardening).
  16600. */
  16601. set useContactHardeningShadow(value: boolean);
  16602. protected _contactHardeningLightSizeUVRatio: number;
  16603. /**
  16604. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16605. * Using a ratio helps keeping shape stability independently of the map size.
  16606. *
  16607. * It does not account for the light projection as it was having too much
  16608. * instability during the light setup or during light position changes.
  16609. *
  16610. * Only valid if useContactHardeningShadow is true.
  16611. */
  16612. get contactHardeningLightSizeUVRatio(): number;
  16613. /**
  16614. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16615. * Using a ratio helps keeping shape stability independently of the map size.
  16616. *
  16617. * It does not account for the light projection as it was having too much
  16618. * instability during the light setup or during light position changes.
  16619. *
  16620. * Only valid if useContactHardeningShadow is true.
  16621. */
  16622. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16623. protected _darkness: number;
  16624. /** Gets or sets the actual darkness of a shadow */
  16625. get darkness(): number;
  16626. set darkness(value: number);
  16627. /**
  16628. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16629. * 0 means strongest and 1 would means no shadow.
  16630. * @returns the darkness.
  16631. */
  16632. getDarkness(): number;
  16633. /**
  16634. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16635. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16636. * @returns the shadow generator allowing fluent coding.
  16637. */
  16638. setDarkness(darkness: number): ShadowGenerator;
  16639. protected _transparencyShadow: boolean;
  16640. /** Gets or sets the ability to have transparent shadow */
  16641. get transparencyShadow(): boolean;
  16642. set transparencyShadow(value: boolean);
  16643. /**
  16644. * Sets the ability to have transparent shadow (boolean).
  16645. * @param transparent True if transparent else False
  16646. * @returns the shadow generator allowing fluent coding
  16647. */
  16648. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16649. protected _shadowMap: Nullable<RenderTargetTexture>;
  16650. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16651. /**
  16652. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16653. * @returns The render target texture if present otherwise, null
  16654. */
  16655. getShadowMap(): Nullable<RenderTargetTexture>;
  16656. /**
  16657. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16658. * @returns The render target texture if the shadow map is present otherwise, null
  16659. */
  16660. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16661. /**
  16662. * Gets the class name of that object
  16663. * @returns "ShadowGenerator"
  16664. */
  16665. getClassName(): string;
  16666. /**
  16667. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16668. * @param mesh Mesh to add
  16669. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16670. * @returns the Shadow Generator itself
  16671. */
  16672. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16673. /**
  16674. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16675. * @param mesh Mesh to remove
  16676. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16677. * @returns the Shadow Generator itself
  16678. */
  16679. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16680. /**
  16681. * Controls the extent to which the shadows fade out at the edge of the frustum
  16682. */
  16683. frustumEdgeFalloff: number;
  16684. protected _light: IShadowLight;
  16685. /**
  16686. * Returns the associated light object.
  16687. * @returns the light generating the shadow
  16688. */
  16689. getLight(): IShadowLight;
  16690. /**
  16691. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16692. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16693. * It might on the other hand introduce peter panning.
  16694. */
  16695. forceBackFacesOnly: boolean;
  16696. protected _scene: Scene;
  16697. protected _lightDirection: Vector3;
  16698. protected _effect: Effect;
  16699. protected _viewMatrix: Matrix;
  16700. protected _projectionMatrix: Matrix;
  16701. protected _transformMatrix: Matrix;
  16702. protected _cachedPosition: Vector3;
  16703. protected _cachedDirection: Vector3;
  16704. protected _cachedDefines: string;
  16705. protected _currentRenderID: number;
  16706. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16707. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16708. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16709. protected _blurPostProcesses: PostProcess[];
  16710. protected _mapSize: number;
  16711. protected _currentFaceIndex: number;
  16712. protected _currentFaceIndexCache: number;
  16713. protected _textureType: number;
  16714. protected _defaultTextureMatrix: Matrix;
  16715. protected _storedUniqueId: Nullable<number>;
  16716. /** @hidden */
  16717. static _SceneComponentInitialization: (scene: Scene) => void;
  16718. /**
  16719. * Creates a ShadowGenerator object.
  16720. * A ShadowGenerator is the required tool to use the shadows.
  16721. * Each light casting shadows needs to use its own ShadowGenerator.
  16722. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16723. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16724. * @param light The light object generating the shadows.
  16725. * @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.
  16726. */
  16727. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16728. protected _initializeGenerator(): void;
  16729. protected _createTargetRenderTexture(): void;
  16730. protected _initializeShadowMap(): void;
  16731. protected _initializeBlurRTTAndPostProcesses(): void;
  16732. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16733. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  16734. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16735. protected _applyFilterValues(): void;
  16736. /**
  16737. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16738. * @param onCompiled Callback triggered at the and of the effects compilation
  16739. * @param options Sets of optional options forcing the compilation with different modes
  16740. */
  16741. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16742. useInstances: boolean;
  16743. }>): void;
  16744. /**
  16745. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16746. * @param options Sets of optional options forcing the compilation with different modes
  16747. * @returns A promise that resolves when the compilation completes
  16748. */
  16749. forceCompilationAsync(options?: Partial<{
  16750. useInstances: boolean;
  16751. }>): Promise<void>;
  16752. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16753. /**
  16754. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16755. * @param subMesh The submesh we want to render in the shadow map
  16756. * @param useInstances Defines wether will draw in the map using instances
  16757. * @returns true if ready otherwise, false
  16758. */
  16759. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16760. /**
  16761. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16762. * @param defines Defines of the material we want to update
  16763. * @param lightIndex Index of the light in the enabled light list of the material
  16764. */
  16765. prepareDefines(defines: any, lightIndex: number): void;
  16766. /**
  16767. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16768. * defined in the generator but impacting the effect).
  16769. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16770. * @param effect The effect we are binfing the information for
  16771. */
  16772. bindShadowLight(lightIndex: string, effect: Effect): void;
  16773. /**
  16774. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16775. * (eq to shadow prjection matrix * light transform matrix)
  16776. * @returns The transform matrix used to create the shadow map
  16777. */
  16778. getTransformMatrix(): Matrix;
  16779. /**
  16780. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16781. * Cube and 2D textures for instance.
  16782. */
  16783. recreateShadowMap(): void;
  16784. protected _disposeBlurPostProcesses(): void;
  16785. protected _disposeRTTandPostProcesses(): void;
  16786. /**
  16787. * Disposes the ShadowGenerator.
  16788. * Returns nothing.
  16789. */
  16790. dispose(): void;
  16791. /**
  16792. * Serializes the shadow generator setup to a json object.
  16793. * @returns The serialized JSON object
  16794. */
  16795. serialize(): any;
  16796. /**
  16797. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16798. * @param parsedShadowGenerator The JSON object to parse
  16799. * @param scene The scene to create the shadow map for
  16800. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16801. * @returns The parsed shadow generator
  16802. */
  16803. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16804. }
  16805. }
  16806. declare module BABYLON {
  16807. /**
  16808. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16809. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16810. * 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.
  16811. */
  16812. export abstract class Light extends Node {
  16813. /**
  16814. * Falloff Default: light is falling off following the material specification:
  16815. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16816. */
  16817. static readonly FALLOFF_DEFAULT: number;
  16818. /**
  16819. * Falloff Physical: light is falling off following the inverse squared distance law.
  16820. */
  16821. static readonly FALLOFF_PHYSICAL: number;
  16822. /**
  16823. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16824. * to enhance interoperability with other engines.
  16825. */
  16826. static readonly FALLOFF_GLTF: number;
  16827. /**
  16828. * Falloff Standard: light is falling off like in the standard material
  16829. * to enhance interoperability with other materials.
  16830. */
  16831. static readonly FALLOFF_STANDARD: number;
  16832. /**
  16833. * If every light affecting the material is in this lightmapMode,
  16834. * material.lightmapTexture adds or multiplies
  16835. * (depends on material.useLightmapAsShadowmap)
  16836. * after every other light calculations.
  16837. */
  16838. static readonly LIGHTMAP_DEFAULT: number;
  16839. /**
  16840. * material.lightmapTexture as only diffuse lighting from this light
  16841. * adds only specular lighting from this light
  16842. * adds dynamic shadows
  16843. */
  16844. static readonly LIGHTMAP_SPECULAR: number;
  16845. /**
  16846. * material.lightmapTexture as only lighting
  16847. * no light calculation from this light
  16848. * only adds dynamic shadows from this light
  16849. */
  16850. static readonly LIGHTMAP_SHADOWSONLY: number;
  16851. /**
  16852. * Each light type uses the default quantity according to its type:
  16853. * point/spot lights use luminous intensity
  16854. * directional lights use illuminance
  16855. */
  16856. static readonly INTENSITYMODE_AUTOMATIC: number;
  16857. /**
  16858. * lumen (lm)
  16859. */
  16860. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16861. /**
  16862. * candela (lm/sr)
  16863. */
  16864. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16865. /**
  16866. * lux (lm/m^2)
  16867. */
  16868. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16869. /**
  16870. * nit (cd/m^2)
  16871. */
  16872. static readonly INTENSITYMODE_LUMINANCE: number;
  16873. /**
  16874. * Light type const id of the point light.
  16875. */
  16876. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16877. /**
  16878. * Light type const id of the directional light.
  16879. */
  16880. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16881. /**
  16882. * Light type const id of the spot light.
  16883. */
  16884. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16885. /**
  16886. * Light type const id of the hemispheric light.
  16887. */
  16888. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16889. /**
  16890. * Diffuse gives the basic color to an object.
  16891. */
  16892. diffuse: Color3;
  16893. /**
  16894. * Specular produces a highlight color on an object.
  16895. * Note: This is note affecting PBR materials.
  16896. */
  16897. specular: Color3;
  16898. /**
  16899. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16900. * falling off base on range or angle.
  16901. * This can be set to any values in Light.FALLOFF_x.
  16902. *
  16903. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16904. * other types of materials.
  16905. */
  16906. falloffType: number;
  16907. /**
  16908. * Strength of the light.
  16909. * Note: By default it is define in the framework own unit.
  16910. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16911. */
  16912. intensity: number;
  16913. private _range;
  16914. protected _inverseSquaredRange: number;
  16915. /**
  16916. * Defines how far from the source the light is impacting in scene units.
  16917. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16918. */
  16919. get range(): number;
  16920. /**
  16921. * Defines how far from the source the light is impacting in scene units.
  16922. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16923. */
  16924. set range(value: number);
  16925. /**
  16926. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16927. * of light.
  16928. */
  16929. private _photometricScale;
  16930. private _intensityMode;
  16931. /**
  16932. * Gets the photometric scale used to interpret the intensity.
  16933. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16934. */
  16935. get intensityMode(): number;
  16936. /**
  16937. * Sets the photometric scale used to interpret the intensity.
  16938. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16939. */
  16940. set intensityMode(value: number);
  16941. private _radius;
  16942. /**
  16943. * Gets the light radius used by PBR Materials to simulate soft area lights.
  16944. */
  16945. get radius(): number;
  16946. /**
  16947. * sets the light radius used by PBR Materials to simulate soft area lights.
  16948. */
  16949. set radius(value: number);
  16950. private _renderPriority;
  16951. /**
  16952. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  16953. * exceeding the number allowed of the materials.
  16954. */
  16955. renderPriority: number;
  16956. private _shadowEnabled;
  16957. /**
  16958. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16959. * the current shadow generator.
  16960. */
  16961. get shadowEnabled(): boolean;
  16962. /**
  16963. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16964. * the current shadow generator.
  16965. */
  16966. set shadowEnabled(value: boolean);
  16967. private _includedOnlyMeshes;
  16968. /**
  16969. * Gets the only meshes impacted by this light.
  16970. */
  16971. get includedOnlyMeshes(): AbstractMesh[];
  16972. /**
  16973. * Sets the only meshes impacted by this light.
  16974. */
  16975. set includedOnlyMeshes(value: AbstractMesh[]);
  16976. private _excludedMeshes;
  16977. /**
  16978. * Gets the meshes not impacted by this light.
  16979. */
  16980. get excludedMeshes(): AbstractMesh[];
  16981. /**
  16982. * Sets the meshes not impacted by this light.
  16983. */
  16984. set excludedMeshes(value: AbstractMesh[]);
  16985. private _excludeWithLayerMask;
  16986. /**
  16987. * Gets the layer id use to find what meshes are not impacted by the light.
  16988. * Inactive if 0
  16989. */
  16990. get excludeWithLayerMask(): number;
  16991. /**
  16992. * Sets the layer id use to find what meshes are not impacted by the light.
  16993. * Inactive if 0
  16994. */
  16995. set excludeWithLayerMask(value: number);
  16996. private _includeOnlyWithLayerMask;
  16997. /**
  16998. * Gets the layer id use to find what meshes are impacted by the light.
  16999. * Inactive if 0
  17000. */
  17001. get includeOnlyWithLayerMask(): number;
  17002. /**
  17003. * Sets the layer id use to find what meshes are impacted by the light.
  17004. * Inactive if 0
  17005. */
  17006. set includeOnlyWithLayerMask(value: number);
  17007. private _lightmapMode;
  17008. /**
  17009. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17010. */
  17011. get lightmapMode(): number;
  17012. /**
  17013. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17014. */
  17015. set lightmapMode(value: number);
  17016. /**
  17017. * Shadow generator associted to the light.
  17018. * @hidden Internal use only.
  17019. */
  17020. _shadowGenerator: Nullable<IShadowGenerator>;
  17021. /**
  17022. * @hidden Internal use only.
  17023. */
  17024. _excludedMeshesIds: string[];
  17025. /**
  17026. * @hidden Internal use only.
  17027. */
  17028. _includedOnlyMeshesIds: string[];
  17029. /**
  17030. * The current light unifom buffer.
  17031. * @hidden Internal use only.
  17032. */
  17033. _uniformBuffer: UniformBuffer;
  17034. /** @hidden */
  17035. _renderId: number;
  17036. /**
  17037. * Creates a Light object in the scene.
  17038. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17039. * @param name The firendly name of the light
  17040. * @param scene The scene the light belongs too
  17041. */
  17042. constructor(name: string, scene: Scene);
  17043. protected abstract _buildUniformLayout(): void;
  17044. /**
  17045. * Sets the passed Effect "effect" with the Light information.
  17046. * @param effect The effect to update
  17047. * @param lightIndex The index of the light in the effect to update
  17048. * @returns The light
  17049. */
  17050. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17051. /**
  17052. * Sets the passed Effect "effect" with the Light textures.
  17053. * @param effect The effect to update
  17054. * @param lightIndex The index of the light in the effect to update
  17055. * @returns The light
  17056. */
  17057. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17058. /**
  17059. * Binds the lights information from the scene to the effect for the given mesh.
  17060. * @param lightIndex Light index
  17061. * @param scene The scene where the light belongs to
  17062. * @param effect The effect we are binding the data to
  17063. * @param useSpecular Defines if specular is supported
  17064. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17065. */
  17066. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17067. /**
  17068. * Sets the passed Effect "effect" with the Light information.
  17069. * @param effect The effect to update
  17070. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17071. * @returns The light
  17072. */
  17073. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17074. /**
  17075. * Returns the string "Light".
  17076. * @returns the class name
  17077. */
  17078. getClassName(): string;
  17079. /** @hidden */
  17080. readonly _isLight: boolean;
  17081. /**
  17082. * Converts the light information to a readable string for debug purpose.
  17083. * @param fullDetails Supports for multiple levels of logging within scene loading
  17084. * @returns the human readable light info
  17085. */
  17086. toString(fullDetails?: boolean): string;
  17087. /** @hidden */
  17088. protected _syncParentEnabledState(): void;
  17089. /**
  17090. * Set the enabled state of this node.
  17091. * @param value - the new enabled state
  17092. */
  17093. setEnabled(value: boolean): void;
  17094. /**
  17095. * Returns the Light associated shadow generator if any.
  17096. * @return the associated shadow generator.
  17097. */
  17098. getShadowGenerator(): Nullable<IShadowGenerator>;
  17099. /**
  17100. * Returns a Vector3, the absolute light position in the World.
  17101. * @returns the world space position of the light
  17102. */
  17103. getAbsolutePosition(): Vector3;
  17104. /**
  17105. * Specifies if the light will affect the passed mesh.
  17106. * @param mesh The mesh to test against the light
  17107. * @return true the mesh is affected otherwise, false.
  17108. */
  17109. canAffectMesh(mesh: AbstractMesh): boolean;
  17110. /**
  17111. * Sort function to order lights for rendering.
  17112. * @param a First Light object to compare to second.
  17113. * @param b Second Light object to compare first.
  17114. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17115. */
  17116. static CompareLightsPriority(a: Light, b: Light): number;
  17117. /**
  17118. * Releases resources associated with this node.
  17119. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17120. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17121. */
  17122. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17123. /**
  17124. * Returns the light type ID (integer).
  17125. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17126. */
  17127. getTypeID(): number;
  17128. /**
  17129. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17130. * @returns the scaled intensity in intensity mode unit
  17131. */
  17132. getScaledIntensity(): number;
  17133. /**
  17134. * Returns a new Light object, named "name", from the current one.
  17135. * @param name The name of the cloned light
  17136. * @returns the new created light
  17137. */
  17138. clone(name: string): Nullable<Light>;
  17139. /**
  17140. * Serializes the current light into a Serialization object.
  17141. * @returns the serialized object.
  17142. */
  17143. serialize(): any;
  17144. /**
  17145. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17146. * This new light is named "name" and added to the passed scene.
  17147. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17148. * @param name The friendly name of the light
  17149. * @param scene The scene the new light will belong to
  17150. * @returns the constructor function
  17151. */
  17152. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17153. /**
  17154. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17155. * @param parsedLight The JSON representation of the light
  17156. * @param scene The scene to create the parsed light in
  17157. * @returns the created light after parsing
  17158. */
  17159. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17160. private _hookArrayForExcluded;
  17161. private _hookArrayForIncludedOnly;
  17162. private _resyncMeshes;
  17163. /**
  17164. * Forces the meshes to update their light related information in their rendering used effects
  17165. * @hidden Internal Use Only
  17166. */
  17167. _markMeshesAsLightDirty(): void;
  17168. /**
  17169. * Recomputes the cached photometric scale if needed.
  17170. */
  17171. private _computePhotometricScale;
  17172. /**
  17173. * Returns the Photometric Scale according to the light type and intensity mode.
  17174. */
  17175. private _getPhotometricScale;
  17176. /**
  17177. * Reorder the light in the scene according to their defined priority.
  17178. * @hidden Internal Use Only
  17179. */
  17180. _reorderLightsInScene(): void;
  17181. /**
  17182. * Prepares the list of defines specific to the light type.
  17183. * @param defines the list of defines
  17184. * @param lightIndex defines the index of the light for the effect
  17185. */
  17186. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17187. }
  17188. }
  17189. declare module BABYLON {
  17190. /**
  17191. * Interface used to define Action
  17192. */
  17193. export interface IAction {
  17194. /**
  17195. * Trigger for the action
  17196. */
  17197. trigger: number;
  17198. /** Options of the trigger */
  17199. triggerOptions: any;
  17200. /**
  17201. * Gets the trigger parameters
  17202. * @returns the trigger parameters
  17203. */
  17204. getTriggerParameter(): any;
  17205. /**
  17206. * Internal only - executes current action event
  17207. * @hidden
  17208. */
  17209. _executeCurrent(evt?: ActionEvent): void;
  17210. /**
  17211. * Serialize placeholder for child classes
  17212. * @param parent of child
  17213. * @returns the serialized object
  17214. */
  17215. serialize(parent: any): any;
  17216. /**
  17217. * Internal only
  17218. * @hidden
  17219. */
  17220. _prepare(): void;
  17221. /**
  17222. * Internal only - manager for action
  17223. * @hidden
  17224. */
  17225. _actionManager: AbstractActionManager;
  17226. /**
  17227. * Adds action to chain of actions, may be a DoNothingAction
  17228. * @param action defines the next action to execute
  17229. * @returns The action passed in
  17230. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17231. */
  17232. then(action: IAction): IAction;
  17233. }
  17234. /**
  17235. * The action to be carried out following a trigger
  17236. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17237. */
  17238. export class Action implements IAction {
  17239. /** the trigger, with or without parameters, for the action */
  17240. triggerOptions: any;
  17241. /**
  17242. * Trigger for the action
  17243. */
  17244. trigger: number;
  17245. /**
  17246. * Internal only - manager for action
  17247. * @hidden
  17248. */
  17249. _actionManager: ActionManager;
  17250. private _nextActiveAction;
  17251. private _child;
  17252. private _condition?;
  17253. private _triggerParameter;
  17254. /**
  17255. * An event triggered prior to action being executed.
  17256. */
  17257. onBeforeExecuteObservable: Observable<Action>;
  17258. /**
  17259. * Creates a new Action
  17260. * @param triggerOptions the trigger, with or without parameters, for the action
  17261. * @param condition an optional determinant of action
  17262. */
  17263. constructor(
  17264. /** the trigger, with or without parameters, for the action */
  17265. triggerOptions: any, condition?: Condition);
  17266. /**
  17267. * Internal only
  17268. * @hidden
  17269. */
  17270. _prepare(): void;
  17271. /**
  17272. * Gets the trigger parameters
  17273. * @returns the trigger parameters
  17274. */
  17275. getTriggerParameter(): any;
  17276. /**
  17277. * Internal only - executes current action event
  17278. * @hidden
  17279. */
  17280. _executeCurrent(evt?: ActionEvent): void;
  17281. /**
  17282. * Execute placeholder for child classes
  17283. * @param evt optional action event
  17284. */
  17285. execute(evt?: ActionEvent): void;
  17286. /**
  17287. * Skips to next active action
  17288. */
  17289. skipToNextActiveAction(): void;
  17290. /**
  17291. * Adds action to chain of actions, may be a DoNothingAction
  17292. * @param action defines the next action to execute
  17293. * @returns The action passed in
  17294. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17295. */
  17296. then(action: Action): Action;
  17297. /**
  17298. * Internal only
  17299. * @hidden
  17300. */
  17301. _getProperty(propertyPath: string): string;
  17302. /**
  17303. * Internal only
  17304. * @hidden
  17305. */
  17306. _getEffectiveTarget(target: any, propertyPath: string): any;
  17307. /**
  17308. * Serialize placeholder for child classes
  17309. * @param parent of child
  17310. * @returns the serialized object
  17311. */
  17312. serialize(parent: any): any;
  17313. /**
  17314. * Internal only called by serialize
  17315. * @hidden
  17316. */
  17317. protected _serialize(serializedAction: any, parent?: any): any;
  17318. /**
  17319. * Internal only
  17320. * @hidden
  17321. */
  17322. static _SerializeValueAsString: (value: any) => string;
  17323. /**
  17324. * Internal only
  17325. * @hidden
  17326. */
  17327. static _GetTargetProperty: (target: Node | Scene) => {
  17328. name: string;
  17329. targetType: string;
  17330. value: string;
  17331. };
  17332. }
  17333. }
  17334. declare module BABYLON {
  17335. /**
  17336. * A Condition applied to an Action
  17337. */
  17338. export class Condition {
  17339. /**
  17340. * Internal only - manager for action
  17341. * @hidden
  17342. */
  17343. _actionManager: ActionManager;
  17344. /**
  17345. * Internal only
  17346. * @hidden
  17347. */
  17348. _evaluationId: number;
  17349. /**
  17350. * Internal only
  17351. * @hidden
  17352. */
  17353. _currentResult: boolean;
  17354. /**
  17355. * Creates a new Condition
  17356. * @param actionManager the manager of the action the condition is applied to
  17357. */
  17358. constructor(actionManager: ActionManager);
  17359. /**
  17360. * Check if the current condition is valid
  17361. * @returns a boolean
  17362. */
  17363. isValid(): boolean;
  17364. /**
  17365. * Internal only
  17366. * @hidden
  17367. */
  17368. _getProperty(propertyPath: string): string;
  17369. /**
  17370. * Internal only
  17371. * @hidden
  17372. */
  17373. _getEffectiveTarget(target: any, propertyPath: string): any;
  17374. /**
  17375. * Serialize placeholder for child classes
  17376. * @returns the serialized object
  17377. */
  17378. serialize(): any;
  17379. /**
  17380. * Internal only
  17381. * @hidden
  17382. */
  17383. protected _serialize(serializedCondition: any): any;
  17384. }
  17385. /**
  17386. * Defines specific conditional operators as extensions of Condition
  17387. */
  17388. export class ValueCondition extends Condition {
  17389. /** path to specify the property of the target the conditional operator uses */
  17390. propertyPath: string;
  17391. /** the value compared by the conditional operator against the current value of the property */
  17392. value: any;
  17393. /** the conditional operator, default ValueCondition.IsEqual */
  17394. operator: number;
  17395. /**
  17396. * Internal only
  17397. * @hidden
  17398. */
  17399. private static _IsEqual;
  17400. /**
  17401. * Internal only
  17402. * @hidden
  17403. */
  17404. private static _IsDifferent;
  17405. /**
  17406. * Internal only
  17407. * @hidden
  17408. */
  17409. private static _IsGreater;
  17410. /**
  17411. * Internal only
  17412. * @hidden
  17413. */
  17414. private static _IsLesser;
  17415. /**
  17416. * returns the number for IsEqual
  17417. */
  17418. static get IsEqual(): number;
  17419. /**
  17420. * Returns the number for IsDifferent
  17421. */
  17422. static get IsDifferent(): number;
  17423. /**
  17424. * Returns the number for IsGreater
  17425. */
  17426. static get IsGreater(): number;
  17427. /**
  17428. * Returns the number for IsLesser
  17429. */
  17430. static get IsLesser(): number;
  17431. /**
  17432. * Internal only The action manager for the condition
  17433. * @hidden
  17434. */
  17435. _actionManager: ActionManager;
  17436. /**
  17437. * Internal only
  17438. * @hidden
  17439. */
  17440. private _target;
  17441. /**
  17442. * Internal only
  17443. * @hidden
  17444. */
  17445. private _effectiveTarget;
  17446. /**
  17447. * Internal only
  17448. * @hidden
  17449. */
  17450. private _property;
  17451. /**
  17452. * Creates a new ValueCondition
  17453. * @param actionManager manager for the action the condition applies to
  17454. * @param target for the action
  17455. * @param propertyPath path to specify the property of the target the conditional operator uses
  17456. * @param value the value compared by the conditional operator against the current value of the property
  17457. * @param operator the conditional operator, default ValueCondition.IsEqual
  17458. */
  17459. constructor(actionManager: ActionManager, target: any,
  17460. /** path to specify the property of the target the conditional operator uses */
  17461. propertyPath: string,
  17462. /** the value compared by the conditional operator against the current value of the property */
  17463. value: any,
  17464. /** the conditional operator, default ValueCondition.IsEqual */
  17465. operator?: number);
  17466. /**
  17467. * Compares the given value with the property value for the specified conditional operator
  17468. * @returns the result of the comparison
  17469. */
  17470. isValid(): boolean;
  17471. /**
  17472. * Serialize the ValueCondition into a JSON compatible object
  17473. * @returns serialization object
  17474. */
  17475. serialize(): any;
  17476. /**
  17477. * Gets the name of the conditional operator for the ValueCondition
  17478. * @param operator the conditional operator
  17479. * @returns the name
  17480. */
  17481. static GetOperatorName(operator: number): string;
  17482. }
  17483. /**
  17484. * Defines a predicate condition as an extension of Condition
  17485. */
  17486. export class PredicateCondition extends Condition {
  17487. /** defines the predicate function used to validate the condition */
  17488. predicate: () => boolean;
  17489. /**
  17490. * Internal only - manager for action
  17491. * @hidden
  17492. */
  17493. _actionManager: ActionManager;
  17494. /**
  17495. * Creates a new PredicateCondition
  17496. * @param actionManager manager for the action the condition applies to
  17497. * @param predicate defines the predicate function used to validate the condition
  17498. */
  17499. constructor(actionManager: ActionManager,
  17500. /** defines the predicate function used to validate the condition */
  17501. predicate: () => boolean);
  17502. /**
  17503. * @returns the validity of the predicate condition
  17504. */
  17505. isValid(): boolean;
  17506. }
  17507. /**
  17508. * Defines a state condition as an extension of Condition
  17509. */
  17510. export class StateCondition extends Condition {
  17511. /** Value to compare with target state */
  17512. value: string;
  17513. /**
  17514. * Internal only - manager for action
  17515. * @hidden
  17516. */
  17517. _actionManager: ActionManager;
  17518. /**
  17519. * Internal only
  17520. * @hidden
  17521. */
  17522. private _target;
  17523. /**
  17524. * Creates a new StateCondition
  17525. * @param actionManager manager for the action the condition applies to
  17526. * @param target of the condition
  17527. * @param value to compare with target state
  17528. */
  17529. constructor(actionManager: ActionManager, target: any,
  17530. /** Value to compare with target state */
  17531. value: string);
  17532. /**
  17533. * Gets a boolean indicating if the current condition is met
  17534. * @returns the validity of the state
  17535. */
  17536. isValid(): boolean;
  17537. /**
  17538. * Serialize the StateCondition into a JSON compatible object
  17539. * @returns serialization object
  17540. */
  17541. serialize(): any;
  17542. }
  17543. }
  17544. declare module BABYLON {
  17545. /**
  17546. * This defines an action responsible to toggle a boolean once triggered.
  17547. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17548. */
  17549. export class SwitchBooleanAction extends Action {
  17550. /**
  17551. * The path to the boolean property in the target object
  17552. */
  17553. propertyPath: string;
  17554. private _target;
  17555. private _effectiveTarget;
  17556. private _property;
  17557. /**
  17558. * Instantiate the action
  17559. * @param triggerOptions defines the trigger options
  17560. * @param target defines the object containing the boolean
  17561. * @param propertyPath defines the path to the boolean property in the target object
  17562. * @param condition defines the trigger related conditions
  17563. */
  17564. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17565. /** @hidden */
  17566. _prepare(): void;
  17567. /**
  17568. * Execute the action toggle the boolean value.
  17569. */
  17570. execute(): void;
  17571. /**
  17572. * Serializes the actions and its related information.
  17573. * @param parent defines the object to serialize in
  17574. * @returns the serialized object
  17575. */
  17576. serialize(parent: any): any;
  17577. }
  17578. /**
  17579. * This defines an action responsible to set a the state field of the target
  17580. * to a desired value once triggered.
  17581. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17582. */
  17583. export class SetStateAction extends Action {
  17584. /**
  17585. * The value to store in the state field.
  17586. */
  17587. value: string;
  17588. private _target;
  17589. /**
  17590. * Instantiate the action
  17591. * @param triggerOptions defines the trigger options
  17592. * @param target defines the object containing the state property
  17593. * @param value defines the value to store in the state field
  17594. * @param condition defines the trigger related conditions
  17595. */
  17596. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17597. /**
  17598. * Execute the action and store the value on the target state property.
  17599. */
  17600. execute(): void;
  17601. /**
  17602. * Serializes the actions and its related information.
  17603. * @param parent defines the object to serialize in
  17604. * @returns the serialized object
  17605. */
  17606. serialize(parent: any): any;
  17607. }
  17608. /**
  17609. * This defines an action responsible to set a property of the target
  17610. * to a desired value once triggered.
  17611. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17612. */
  17613. export class SetValueAction extends Action {
  17614. /**
  17615. * The path of the property to set in the target.
  17616. */
  17617. propertyPath: string;
  17618. /**
  17619. * The value to set in the property
  17620. */
  17621. value: any;
  17622. private _target;
  17623. private _effectiveTarget;
  17624. private _property;
  17625. /**
  17626. * Instantiate the action
  17627. * @param triggerOptions defines the trigger options
  17628. * @param target defines the object containing the property
  17629. * @param propertyPath defines the path of the property to set in the target
  17630. * @param value defines the value to set in the property
  17631. * @param condition defines the trigger related conditions
  17632. */
  17633. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17634. /** @hidden */
  17635. _prepare(): void;
  17636. /**
  17637. * Execute the action and set the targetted property to the desired value.
  17638. */
  17639. execute(): void;
  17640. /**
  17641. * Serializes the actions and its related information.
  17642. * @param parent defines the object to serialize in
  17643. * @returns the serialized object
  17644. */
  17645. serialize(parent: any): any;
  17646. }
  17647. /**
  17648. * This defines an action responsible to increment the target value
  17649. * to a desired value once triggered.
  17650. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17651. */
  17652. export class IncrementValueAction extends Action {
  17653. /**
  17654. * The path of the property to increment in the target.
  17655. */
  17656. propertyPath: string;
  17657. /**
  17658. * The value we should increment the property by.
  17659. */
  17660. value: any;
  17661. private _target;
  17662. private _effectiveTarget;
  17663. private _property;
  17664. /**
  17665. * Instantiate the action
  17666. * @param triggerOptions defines the trigger options
  17667. * @param target defines the object containing the property
  17668. * @param propertyPath defines the path of the property to increment in the target
  17669. * @param value defines the value value we should increment the property by
  17670. * @param condition defines the trigger related conditions
  17671. */
  17672. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17673. /** @hidden */
  17674. _prepare(): void;
  17675. /**
  17676. * Execute the action and increment the target of the value amount.
  17677. */
  17678. execute(): void;
  17679. /**
  17680. * Serializes the actions and its related information.
  17681. * @param parent defines the object to serialize in
  17682. * @returns the serialized object
  17683. */
  17684. serialize(parent: any): any;
  17685. }
  17686. /**
  17687. * This defines an action responsible to start an animation once triggered.
  17688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17689. */
  17690. export class PlayAnimationAction extends Action {
  17691. /**
  17692. * Where the animation should start (animation frame)
  17693. */
  17694. from: number;
  17695. /**
  17696. * Where the animation should stop (animation frame)
  17697. */
  17698. to: number;
  17699. /**
  17700. * Define if the animation should loop or stop after the first play.
  17701. */
  17702. loop?: boolean;
  17703. private _target;
  17704. /**
  17705. * Instantiate the action
  17706. * @param triggerOptions defines the trigger options
  17707. * @param target defines the target animation or animation name
  17708. * @param from defines from where the animation should start (animation frame)
  17709. * @param end defines where the animation should stop (animation frame)
  17710. * @param loop defines if the animation should loop or stop after the first play
  17711. * @param condition defines the trigger related conditions
  17712. */
  17713. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17714. /** @hidden */
  17715. _prepare(): void;
  17716. /**
  17717. * Execute the action and play the animation.
  17718. */
  17719. execute(): void;
  17720. /**
  17721. * Serializes the actions and its related information.
  17722. * @param parent defines the object to serialize in
  17723. * @returns the serialized object
  17724. */
  17725. serialize(parent: any): any;
  17726. }
  17727. /**
  17728. * This defines an action responsible to stop an animation once triggered.
  17729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17730. */
  17731. export class StopAnimationAction extends Action {
  17732. private _target;
  17733. /**
  17734. * Instantiate the action
  17735. * @param triggerOptions defines the trigger options
  17736. * @param target defines the target animation or animation name
  17737. * @param condition defines the trigger related conditions
  17738. */
  17739. constructor(triggerOptions: any, target: any, condition?: Condition);
  17740. /** @hidden */
  17741. _prepare(): void;
  17742. /**
  17743. * Execute the action and stop the animation.
  17744. */
  17745. execute(): void;
  17746. /**
  17747. * Serializes the actions and its related information.
  17748. * @param parent defines the object to serialize in
  17749. * @returns the serialized object
  17750. */
  17751. serialize(parent: any): any;
  17752. }
  17753. /**
  17754. * This defines an action responsible that does nothing once triggered.
  17755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17756. */
  17757. export class DoNothingAction extends Action {
  17758. /**
  17759. * Instantiate the action
  17760. * @param triggerOptions defines the trigger options
  17761. * @param condition defines the trigger related conditions
  17762. */
  17763. constructor(triggerOptions?: any, condition?: Condition);
  17764. /**
  17765. * Execute the action and do nothing.
  17766. */
  17767. execute(): void;
  17768. /**
  17769. * Serializes the actions and its related information.
  17770. * @param parent defines the object to serialize in
  17771. * @returns the serialized object
  17772. */
  17773. serialize(parent: any): any;
  17774. }
  17775. /**
  17776. * This defines an action responsible to trigger several actions once triggered.
  17777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17778. */
  17779. export class CombineAction extends Action {
  17780. /**
  17781. * The list of aggregated animations to run.
  17782. */
  17783. children: Action[];
  17784. /**
  17785. * Instantiate the action
  17786. * @param triggerOptions defines the trigger options
  17787. * @param children defines the list of aggregated animations to run
  17788. * @param condition defines the trigger related conditions
  17789. */
  17790. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17791. /** @hidden */
  17792. _prepare(): void;
  17793. /**
  17794. * Execute the action and executes all the aggregated actions.
  17795. */
  17796. execute(evt: ActionEvent): void;
  17797. /**
  17798. * Serializes the actions and its related information.
  17799. * @param parent defines the object to serialize in
  17800. * @returns the serialized object
  17801. */
  17802. serialize(parent: any): any;
  17803. }
  17804. /**
  17805. * This defines an action responsible to run code (external event) once triggered.
  17806. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17807. */
  17808. export class ExecuteCodeAction extends Action {
  17809. /**
  17810. * The callback function to run.
  17811. */
  17812. func: (evt: ActionEvent) => void;
  17813. /**
  17814. * Instantiate the action
  17815. * @param triggerOptions defines the trigger options
  17816. * @param func defines the callback function to run
  17817. * @param condition defines the trigger related conditions
  17818. */
  17819. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17820. /**
  17821. * Execute the action and run the attached code.
  17822. */
  17823. execute(evt: ActionEvent): void;
  17824. }
  17825. /**
  17826. * This defines an action responsible to set the parent property of the target once triggered.
  17827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17828. */
  17829. export class SetParentAction extends Action {
  17830. private _parent;
  17831. private _target;
  17832. /**
  17833. * Instantiate the action
  17834. * @param triggerOptions defines the trigger options
  17835. * @param target defines the target containing the parent property
  17836. * @param parent defines from where the animation should start (animation frame)
  17837. * @param condition defines the trigger related conditions
  17838. */
  17839. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17840. /** @hidden */
  17841. _prepare(): void;
  17842. /**
  17843. * Execute the action and set the parent property.
  17844. */
  17845. execute(): void;
  17846. /**
  17847. * Serializes the actions and its related information.
  17848. * @param parent defines the object to serialize in
  17849. * @returns the serialized object
  17850. */
  17851. serialize(parent: any): any;
  17852. }
  17853. }
  17854. declare module BABYLON {
  17855. /**
  17856. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17857. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17859. */
  17860. export class ActionManager extends AbstractActionManager {
  17861. /**
  17862. * Nothing
  17863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17864. */
  17865. static readonly NothingTrigger: number;
  17866. /**
  17867. * On pick
  17868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17869. */
  17870. static readonly OnPickTrigger: number;
  17871. /**
  17872. * On left pick
  17873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17874. */
  17875. static readonly OnLeftPickTrigger: number;
  17876. /**
  17877. * On right pick
  17878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17879. */
  17880. static readonly OnRightPickTrigger: number;
  17881. /**
  17882. * On center pick
  17883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17884. */
  17885. static readonly OnCenterPickTrigger: number;
  17886. /**
  17887. * On pick down
  17888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17889. */
  17890. static readonly OnPickDownTrigger: number;
  17891. /**
  17892. * On double pick
  17893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17894. */
  17895. static readonly OnDoublePickTrigger: number;
  17896. /**
  17897. * On pick up
  17898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17899. */
  17900. static readonly OnPickUpTrigger: number;
  17901. /**
  17902. * On pick out.
  17903. * This trigger will only be raised if you also declared a OnPickDown
  17904. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17905. */
  17906. static readonly OnPickOutTrigger: number;
  17907. /**
  17908. * On long press
  17909. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17910. */
  17911. static readonly OnLongPressTrigger: number;
  17912. /**
  17913. * On pointer over
  17914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17915. */
  17916. static readonly OnPointerOverTrigger: number;
  17917. /**
  17918. * On pointer out
  17919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17920. */
  17921. static readonly OnPointerOutTrigger: number;
  17922. /**
  17923. * On every frame
  17924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17925. */
  17926. static readonly OnEveryFrameTrigger: number;
  17927. /**
  17928. * On intersection enter
  17929. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17930. */
  17931. static readonly OnIntersectionEnterTrigger: number;
  17932. /**
  17933. * On intersection exit
  17934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17935. */
  17936. static readonly OnIntersectionExitTrigger: number;
  17937. /**
  17938. * On key down
  17939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17940. */
  17941. static readonly OnKeyDownTrigger: number;
  17942. /**
  17943. * On key up
  17944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17945. */
  17946. static readonly OnKeyUpTrigger: number;
  17947. private _scene;
  17948. /**
  17949. * Creates a new action manager
  17950. * @param scene defines the hosting scene
  17951. */
  17952. constructor(scene: Scene);
  17953. /**
  17954. * Releases all associated resources
  17955. */
  17956. dispose(): void;
  17957. /**
  17958. * Gets hosting scene
  17959. * @returns the hosting scene
  17960. */
  17961. getScene(): Scene;
  17962. /**
  17963. * Does this action manager handles actions of any of the given triggers
  17964. * @param triggers defines the triggers to be tested
  17965. * @return a boolean indicating whether one (or more) of the triggers is handled
  17966. */
  17967. hasSpecificTriggers(triggers: number[]): boolean;
  17968. /**
  17969. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  17970. * speed.
  17971. * @param triggerA defines the trigger to be tested
  17972. * @param triggerB defines the trigger to be tested
  17973. * @return a boolean indicating whether one (or more) of the triggers is handled
  17974. */
  17975. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  17976. /**
  17977. * Does this action manager handles actions of a given trigger
  17978. * @param trigger defines the trigger to be tested
  17979. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  17980. * @return whether the trigger is handled
  17981. */
  17982. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  17983. /**
  17984. * Does this action manager has pointer triggers
  17985. */
  17986. get hasPointerTriggers(): boolean;
  17987. /**
  17988. * Does this action manager has pick triggers
  17989. */
  17990. get hasPickTriggers(): boolean;
  17991. /**
  17992. * Registers an action to this action manager
  17993. * @param action defines the action to be registered
  17994. * @return the action amended (prepared) after registration
  17995. */
  17996. registerAction(action: IAction): Nullable<IAction>;
  17997. /**
  17998. * Unregisters an action to this action manager
  17999. * @param action defines the action to be unregistered
  18000. * @return a boolean indicating whether the action has been unregistered
  18001. */
  18002. unregisterAction(action: IAction): Boolean;
  18003. /**
  18004. * Process a specific trigger
  18005. * @param trigger defines the trigger to process
  18006. * @param evt defines the event details to be processed
  18007. */
  18008. processTrigger(trigger: number, evt?: IActionEvent): void;
  18009. /** @hidden */
  18010. _getEffectiveTarget(target: any, propertyPath: string): any;
  18011. /** @hidden */
  18012. _getProperty(propertyPath: string): string;
  18013. /**
  18014. * Serialize this manager to a JSON object
  18015. * @param name defines the property name to store this manager
  18016. * @returns a JSON representation of this manager
  18017. */
  18018. serialize(name: string): any;
  18019. /**
  18020. * Creates a new ActionManager from a JSON data
  18021. * @param parsedActions defines the JSON data to read from
  18022. * @param object defines the hosting mesh
  18023. * @param scene defines the hosting scene
  18024. */
  18025. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18026. /**
  18027. * Get a trigger name by index
  18028. * @param trigger defines the trigger index
  18029. * @returns a trigger name
  18030. */
  18031. static GetTriggerName(trigger: number): string;
  18032. }
  18033. }
  18034. declare module BABYLON {
  18035. /**
  18036. * Class used to represent a sprite
  18037. * @see http://doc.babylonjs.com/babylon101/sprites
  18038. */
  18039. export class Sprite {
  18040. /** defines the name */
  18041. name: string;
  18042. /** Gets or sets the current world position */
  18043. position: Vector3;
  18044. /** Gets or sets the main color */
  18045. color: Color4;
  18046. /** Gets or sets the width */
  18047. width: number;
  18048. /** Gets or sets the height */
  18049. height: number;
  18050. /** Gets or sets rotation angle */
  18051. angle: number;
  18052. /** Gets or sets the cell index in the sprite sheet */
  18053. cellIndex: number;
  18054. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18055. cellRef: string;
  18056. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18057. invertU: number;
  18058. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18059. invertV: number;
  18060. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18061. disposeWhenFinishedAnimating: boolean;
  18062. /** Gets the list of attached animations */
  18063. animations: Animation[];
  18064. /** Gets or sets a boolean indicating if the sprite can be picked */
  18065. isPickable: boolean;
  18066. /**
  18067. * Gets or sets the associated action manager
  18068. */
  18069. actionManager: Nullable<ActionManager>;
  18070. private _animationStarted;
  18071. private _loopAnimation;
  18072. private _fromIndex;
  18073. private _toIndex;
  18074. private _delay;
  18075. private _direction;
  18076. private _manager;
  18077. private _time;
  18078. private _onAnimationEnd;
  18079. /**
  18080. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18081. */
  18082. isVisible: boolean;
  18083. /**
  18084. * Gets or sets the sprite size
  18085. */
  18086. get size(): number;
  18087. set size(value: number);
  18088. /**
  18089. * Creates a new Sprite
  18090. * @param name defines the name
  18091. * @param manager defines the manager
  18092. */
  18093. constructor(
  18094. /** defines the name */
  18095. name: string, manager: ISpriteManager);
  18096. /**
  18097. * Starts an animation
  18098. * @param from defines the initial key
  18099. * @param to defines the end key
  18100. * @param loop defines if the animation must loop
  18101. * @param delay defines the start delay (in ms)
  18102. * @param onAnimationEnd defines a callback to call when animation ends
  18103. */
  18104. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18105. /** Stops current animation (if any) */
  18106. stopAnimation(): void;
  18107. /** @hidden */
  18108. _animate(deltaTime: number): void;
  18109. /** Release associated resources */
  18110. dispose(): void;
  18111. }
  18112. }
  18113. declare module BABYLON {
  18114. /**
  18115. * Information about the result of picking within a scene
  18116. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18117. */
  18118. export class PickingInfo {
  18119. /** @hidden */
  18120. _pickingUnavailable: boolean;
  18121. /**
  18122. * If the pick collided with an object
  18123. */
  18124. hit: boolean;
  18125. /**
  18126. * Distance away where the pick collided
  18127. */
  18128. distance: number;
  18129. /**
  18130. * The location of pick collision
  18131. */
  18132. pickedPoint: Nullable<Vector3>;
  18133. /**
  18134. * The mesh corresponding the the pick collision
  18135. */
  18136. pickedMesh: Nullable<AbstractMesh>;
  18137. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18138. bu: number;
  18139. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18140. bv: number;
  18141. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18142. faceId: number;
  18143. /** Id of the the submesh that was picked */
  18144. subMeshId: number;
  18145. /** If a sprite was picked, this will be the sprite the pick collided with */
  18146. pickedSprite: Nullable<Sprite>;
  18147. /**
  18148. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18149. */
  18150. originMesh: Nullable<AbstractMesh>;
  18151. /**
  18152. * The ray that was used to perform the picking.
  18153. */
  18154. ray: Nullable<Ray>;
  18155. /**
  18156. * Gets the normal correspodning to the face the pick collided with
  18157. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18158. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18159. * @returns The normal correspodning to the face the pick collided with
  18160. */
  18161. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18162. /**
  18163. * Gets the texture coordinates of where the pick occured
  18164. * @returns the vector containing the coordnates of the texture
  18165. */
  18166. getTextureCoordinates(): Nullable<Vector2>;
  18167. }
  18168. }
  18169. declare module BABYLON {
  18170. /**
  18171. * Gather the list of pointer event types as constants.
  18172. */
  18173. export class PointerEventTypes {
  18174. /**
  18175. * 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.
  18176. */
  18177. static readonly POINTERDOWN: number;
  18178. /**
  18179. * The pointerup event is fired when a pointer is no longer active.
  18180. */
  18181. static readonly POINTERUP: number;
  18182. /**
  18183. * The pointermove event is fired when a pointer changes coordinates.
  18184. */
  18185. static readonly POINTERMOVE: number;
  18186. /**
  18187. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18188. */
  18189. static readonly POINTERWHEEL: number;
  18190. /**
  18191. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18192. */
  18193. static readonly POINTERPICK: number;
  18194. /**
  18195. * The pointertap event is fired when a the object has been touched and released without drag.
  18196. */
  18197. static readonly POINTERTAP: number;
  18198. /**
  18199. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18200. */
  18201. static readonly POINTERDOUBLETAP: number;
  18202. }
  18203. /**
  18204. * Base class of pointer info types.
  18205. */
  18206. export class PointerInfoBase {
  18207. /**
  18208. * Defines the type of event (PointerEventTypes)
  18209. */
  18210. type: number;
  18211. /**
  18212. * Defines the related dom event
  18213. */
  18214. event: PointerEvent | MouseWheelEvent;
  18215. /**
  18216. * Instantiates the base class of pointers info.
  18217. * @param type Defines the type of event (PointerEventTypes)
  18218. * @param event Defines the related dom event
  18219. */
  18220. constructor(
  18221. /**
  18222. * Defines the type of event (PointerEventTypes)
  18223. */
  18224. type: number,
  18225. /**
  18226. * Defines the related dom event
  18227. */
  18228. event: PointerEvent | MouseWheelEvent);
  18229. }
  18230. /**
  18231. * This class is used to store pointer related info for the onPrePointerObservable event.
  18232. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18233. */
  18234. export class PointerInfoPre extends PointerInfoBase {
  18235. /**
  18236. * Ray from a pointer if availible (eg. 6dof controller)
  18237. */
  18238. ray: Nullable<Ray>;
  18239. /**
  18240. * Defines the local position of the pointer on the canvas.
  18241. */
  18242. localPosition: Vector2;
  18243. /**
  18244. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18245. */
  18246. skipOnPointerObservable: boolean;
  18247. /**
  18248. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18249. * @param type Defines the type of event (PointerEventTypes)
  18250. * @param event Defines the related dom event
  18251. * @param localX Defines the local x coordinates of the pointer when the event occured
  18252. * @param localY Defines the local y coordinates of the pointer when the event occured
  18253. */
  18254. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18255. }
  18256. /**
  18257. * This type contains all the data related to a pointer event in Babylon.js.
  18258. * 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.
  18259. */
  18260. export class PointerInfo extends PointerInfoBase {
  18261. /**
  18262. * Defines the picking info associated to the info (if any)\
  18263. */
  18264. pickInfo: Nullable<PickingInfo>;
  18265. /**
  18266. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18267. * @param type Defines the type of event (PointerEventTypes)
  18268. * @param event Defines the related dom event
  18269. * @param pickInfo Defines the picking info associated to the info (if any)\
  18270. */
  18271. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18272. /**
  18273. * Defines the picking info associated to the info (if any)\
  18274. */
  18275. pickInfo: Nullable<PickingInfo>);
  18276. }
  18277. /**
  18278. * Data relating to a touch event on the screen.
  18279. */
  18280. export interface PointerTouch {
  18281. /**
  18282. * X coordinate of touch.
  18283. */
  18284. x: number;
  18285. /**
  18286. * Y coordinate of touch.
  18287. */
  18288. y: number;
  18289. /**
  18290. * Id of touch. Unique for each finger.
  18291. */
  18292. pointerId: number;
  18293. /**
  18294. * Event type passed from DOM.
  18295. */
  18296. type: any;
  18297. }
  18298. }
  18299. declare module BABYLON {
  18300. /**
  18301. * Manage the mouse inputs to control the movement of a free camera.
  18302. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18303. */
  18304. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18305. /**
  18306. * Define if touch is enabled in the mouse input
  18307. */
  18308. touchEnabled: boolean;
  18309. /**
  18310. * Defines the camera the input is attached to.
  18311. */
  18312. camera: FreeCamera;
  18313. /**
  18314. * Defines the buttons associated with the input to handle camera move.
  18315. */
  18316. buttons: number[];
  18317. /**
  18318. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18319. */
  18320. angularSensibility: number;
  18321. private _pointerInput;
  18322. private _onMouseMove;
  18323. private _observer;
  18324. private previousPosition;
  18325. /**
  18326. * Observable for when a pointer move event occurs containing the move offset
  18327. */
  18328. onPointerMovedObservable: Observable<{
  18329. offsetX: number;
  18330. offsetY: number;
  18331. }>;
  18332. /**
  18333. * @hidden
  18334. * If the camera should be rotated automatically based on pointer movement
  18335. */
  18336. _allowCameraRotation: boolean;
  18337. /**
  18338. * Manage the mouse inputs to control the movement of a free camera.
  18339. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18340. * @param touchEnabled Defines if touch is enabled or not
  18341. */
  18342. constructor(
  18343. /**
  18344. * Define if touch is enabled in the mouse input
  18345. */
  18346. touchEnabled?: boolean);
  18347. /**
  18348. * Attach the input controls to a specific dom element to get the input from.
  18349. * @param element Defines the element the controls should be listened from
  18350. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18351. */
  18352. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18353. /**
  18354. * Called on JS contextmenu event.
  18355. * Override this method to provide functionality.
  18356. */
  18357. protected onContextMenu(evt: PointerEvent): void;
  18358. /**
  18359. * Detach the current controls from the specified dom element.
  18360. * @param element Defines the element to stop listening the inputs from
  18361. */
  18362. detachControl(element: Nullable<HTMLElement>): void;
  18363. /**
  18364. * Gets the class name of the current intput.
  18365. * @returns the class name
  18366. */
  18367. getClassName(): string;
  18368. /**
  18369. * Get the friendly name associated with the input class.
  18370. * @returns the input friendly name
  18371. */
  18372. getSimpleName(): string;
  18373. }
  18374. }
  18375. declare module BABYLON {
  18376. /**
  18377. * Manage the touch inputs to control the movement of a free camera.
  18378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18379. */
  18380. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18381. /**
  18382. * Defines the camera the input is attached to.
  18383. */
  18384. camera: FreeCamera;
  18385. /**
  18386. * Defines the touch sensibility for rotation.
  18387. * The higher the faster.
  18388. */
  18389. touchAngularSensibility: number;
  18390. /**
  18391. * Defines the touch sensibility for move.
  18392. * The higher the faster.
  18393. */
  18394. touchMoveSensibility: number;
  18395. private _offsetX;
  18396. private _offsetY;
  18397. private _pointerPressed;
  18398. private _pointerInput;
  18399. private _observer;
  18400. private _onLostFocus;
  18401. /**
  18402. * Attach the input controls to a specific dom element to get the input from.
  18403. * @param element Defines the element the controls should be listened from
  18404. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18405. */
  18406. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18407. /**
  18408. * Detach the current controls from the specified dom element.
  18409. * @param element Defines the element to stop listening the inputs from
  18410. */
  18411. detachControl(element: Nullable<HTMLElement>): void;
  18412. /**
  18413. * Update the current camera state depending on the inputs that have been used this frame.
  18414. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18415. */
  18416. checkInputs(): void;
  18417. /**
  18418. * Gets the class name of the current intput.
  18419. * @returns the class name
  18420. */
  18421. getClassName(): string;
  18422. /**
  18423. * Get the friendly name associated with the input class.
  18424. * @returns the input friendly name
  18425. */
  18426. getSimpleName(): string;
  18427. }
  18428. }
  18429. declare module BABYLON {
  18430. /**
  18431. * Default Inputs manager for the FreeCamera.
  18432. * It groups all the default supported inputs for ease of use.
  18433. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18434. */
  18435. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18436. /**
  18437. * @hidden
  18438. */
  18439. _mouseInput: Nullable<FreeCameraMouseInput>;
  18440. /**
  18441. * Instantiates a new FreeCameraInputsManager.
  18442. * @param camera Defines the camera the inputs belong to
  18443. */
  18444. constructor(camera: FreeCamera);
  18445. /**
  18446. * Add keyboard input support to the input manager.
  18447. * @returns the current input manager
  18448. */
  18449. addKeyboard(): FreeCameraInputsManager;
  18450. /**
  18451. * Add mouse input support to the input manager.
  18452. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18453. * @returns the current input manager
  18454. */
  18455. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18456. /**
  18457. * Removes the mouse input support from the manager
  18458. * @returns the current input manager
  18459. */
  18460. removeMouse(): FreeCameraInputsManager;
  18461. /**
  18462. * Add touch input support to the input manager.
  18463. * @returns the current input manager
  18464. */
  18465. addTouch(): FreeCameraInputsManager;
  18466. /**
  18467. * Remove all attached input methods from a camera
  18468. */
  18469. clear(): void;
  18470. }
  18471. }
  18472. declare module BABYLON {
  18473. /**
  18474. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18475. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18476. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18477. */
  18478. export class FreeCamera extends TargetCamera {
  18479. /**
  18480. * Define the collision ellipsoid of the camera.
  18481. * This is helpful to simulate a camera body like the player body around the camera
  18482. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18483. */
  18484. ellipsoid: Vector3;
  18485. /**
  18486. * Define an offset for the position of the ellipsoid around the camera.
  18487. * This can be helpful to determine the center of the body near the gravity center of the body
  18488. * instead of its head.
  18489. */
  18490. ellipsoidOffset: Vector3;
  18491. /**
  18492. * Enable or disable collisions of the camera with the rest of the scene objects.
  18493. */
  18494. checkCollisions: boolean;
  18495. /**
  18496. * Enable or disable gravity on the camera.
  18497. */
  18498. applyGravity: boolean;
  18499. /**
  18500. * Define the input manager associated to the camera.
  18501. */
  18502. inputs: FreeCameraInputsManager;
  18503. /**
  18504. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18505. * Higher values reduce sensitivity.
  18506. */
  18507. get angularSensibility(): number;
  18508. /**
  18509. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18510. * Higher values reduce sensitivity.
  18511. */
  18512. set angularSensibility(value: number);
  18513. /**
  18514. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18515. */
  18516. get keysUp(): number[];
  18517. set keysUp(value: number[]);
  18518. /**
  18519. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18520. */
  18521. get keysUpward(): number[];
  18522. set keysUpward(value: number[]);
  18523. /**
  18524. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18525. */
  18526. get keysDown(): number[];
  18527. set keysDown(value: number[]);
  18528. /**
  18529. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18530. */
  18531. get keysDownward(): number[];
  18532. set keysDownward(value: number[]);
  18533. /**
  18534. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18535. */
  18536. get keysLeft(): number[];
  18537. set keysLeft(value: number[]);
  18538. /**
  18539. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18540. */
  18541. get keysRight(): number[];
  18542. set keysRight(value: number[]);
  18543. /**
  18544. * Event raised when the camera collide with a mesh in the scene.
  18545. */
  18546. onCollide: (collidedMesh: AbstractMesh) => void;
  18547. private _collider;
  18548. private _needMoveForGravity;
  18549. private _oldPosition;
  18550. private _diffPosition;
  18551. private _newPosition;
  18552. /** @hidden */
  18553. _localDirection: Vector3;
  18554. /** @hidden */
  18555. _transformedDirection: Vector3;
  18556. /**
  18557. * Instantiates a Free Camera.
  18558. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18559. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18560. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18561. * @param name Define the name of the camera in the scene
  18562. * @param position Define the start position of the camera in the scene
  18563. * @param scene Define the scene the camera belongs to
  18564. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18565. */
  18566. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18567. /**
  18568. * Attached controls to the current camera.
  18569. * @param element Defines the element the controls should be listened from
  18570. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18571. */
  18572. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18573. /**
  18574. * Detach the current controls from the camera.
  18575. * The camera will stop reacting to inputs.
  18576. * @param element Defines the element to stop listening the inputs from
  18577. */
  18578. detachControl(element: HTMLElement): void;
  18579. private _collisionMask;
  18580. /**
  18581. * Define a collision mask to limit the list of object the camera can collide with
  18582. */
  18583. get collisionMask(): number;
  18584. set collisionMask(mask: number);
  18585. /** @hidden */
  18586. _collideWithWorld(displacement: Vector3): void;
  18587. private _onCollisionPositionChange;
  18588. /** @hidden */
  18589. _checkInputs(): void;
  18590. /** @hidden */
  18591. _decideIfNeedsToMove(): boolean;
  18592. /** @hidden */
  18593. _updatePosition(): void;
  18594. /**
  18595. * Destroy the camera and release the current resources hold by it.
  18596. */
  18597. dispose(): void;
  18598. /**
  18599. * Gets the current object class name.
  18600. * @return the class name
  18601. */
  18602. getClassName(): string;
  18603. }
  18604. }
  18605. declare module BABYLON {
  18606. /**
  18607. * Represents a gamepad control stick position
  18608. */
  18609. export class StickValues {
  18610. /**
  18611. * The x component of the control stick
  18612. */
  18613. x: number;
  18614. /**
  18615. * The y component of the control stick
  18616. */
  18617. y: number;
  18618. /**
  18619. * Initializes the gamepad x and y control stick values
  18620. * @param x The x component of the gamepad control stick value
  18621. * @param y The y component of the gamepad control stick value
  18622. */
  18623. constructor(
  18624. /**
  18625. * The x component of the control stick
  18626. */
  18627. x: number,
  18628. /**
  18629. * The y component of the control stick
  18630. */
  18631. y: number);
  18632. }
  18633. /**
  18634. * An interface which manages callbacks for gamepad button changes
  18635. */
  18636. export interface GamepadButtonChanges {
  18637. /**
  18638. * Called when a gamepad has been changed
  18639. */
  18640. changed: boolean;
  18641. /**
  18642. * Called when a gamepad press event has been triggered
  18643. */
  18644. pressChanged: boolean;
  18645. /**
  18646. * Called when a touch event has been triggered
  18647. */
  18648. touchChanged: boolean;
  18649. /**
  18650. * Called when a value has changed
  18651. */
  18652. valueChanged: boolean;
  18653. }
  18654. /**
  18655. * Represents a gamepad
  18656. */
  18657. export class Gamepad {
  18658. /**
  18659. * The id of the gamepad
  18660. */
  18661. id: string;
  18662. /**
  18663. * The index of the gamepad
  18664. */
  18665. index: number;
  18666. /**
  18667. * The browser gamepad
  18668. */
  18669. browserGamepad: any;
  18670. /**
  18671. * Specifies what type of gamepad this represents
  18672. */
  18673. type: number;
  18674. private _leftStick;
  18675. private _rightStick;
  18676. /** @hidden */
  18677. _isConnected: boolean;
  18678. private _leftStickAxisX;
  18679. private _leftStickAxisY;
  18680. private _rightStickAxisX;
  18681. private _rightStickAxisY;
  18682. /**
  18683. * Triggered when the left control stick has been changed
  18684. */
  18685. private _onleftstickchanged;
  18686. /**
  18687. * Triggered when the right control stick has been changed
  18688. */
  18689. private _onrightstickchanged;
  18690. /**
  18691. * Represents a gamepad controller
  18692. */
  18693. static GAMEPAD: number;
  18694. /**
  18695. * Represents a generic controller
  18696. */
  18697. static GENERIC: number;
  18698. /**
  18699. * Represents an XBox controller
  18700. */
  18701. static XBOX: number;
  18702. /**
  18703. * Represents a pose-enabled controller
  18704. */
  18705. static POSE_ENABLED: number;
  18706. /**
  18707. * Represents an Dual Shock controller
  18708. */
  18709. static DUALSHOCK: number;
  18710. /**
  18711. * Specifies whether the left control stick should be Y-inverted
  18712. */
  18713. protected _invertLeftStickY: boolean;
  18714. /**
  18715. * Specifies if the gamepad has been connected
  18716. */
  18717. get isConnected(): boolean;
  18718. /**
  18719. * Initializes the gamepad
  18720. * @param id The id of the gamepad
  18721. * @param index The index of the gamepad
  18722. * @param browserGamepad The browser gamepad
  18723. * @param leftStickX The x component of the left joystick
  18724. * @param leftStickY The y component of the left joystick
  18725. * @param rightStickX The x component of the right joystick
  18726. * @param rightStickY The y component of the right joystick
  18727. */
  18728. constructor(
  18729. /**
  18730. * The id of the gamepad
  18731. */
  18732. id: string,
  18733. /**
  18734. * The index of the gamepad
  18735. */
  18736. index: number,
  18737. /**
  18738. * The browser gamepad
  18739. */
  18740. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18741. /**
  18742. * Callback triggered when the left joystick has changed
  18743. * @param callback
  18744. */
  18745. onleftstickchanged(callback: (values: StickValues) => void): void;
  18746. /**
  18747. * Callback triggered when the right joystick has changed
  18748. * @param callback
  18749. */
  18750. onrightstickchanged(callback: (values: StickValues) => void): void;
  18751. /**
  18752. * Gets the left joystick
  18753. */
  18754. get leftStick(): StickValues;
  18755. /**
  18756. * Sets the left joystick values
  18757. */
  18758. set leftStick(newValues: StickValues);
  18759. /**
  18760. * Gets the right joystick
  18761. */
  18762. get rightStick(): StickValues;
  18763. /**
  18764. * Sets the right joystick value
  18765. */
  18766. set rightStick(newValues: StickValues);
  18767. /**
  18768. * Updates the gamepad joystick positions
  18769. */
  18770. update(): void;
  18771. /**
  18772. * Disposes the gamepad
  18773. */
  18774. dispose(): void;
  18775. }
  18776. /**
  18777. * Represents a generic gamepad
  18778. */
  18779. export class GenericPad extends Gamepad {
  18780. private _buttons;
  18781. private _onbuttondown;
  18782. private _onbuttonup;
  18783. /**
  18784. * Observable triggered when a button has been pressed
  18785. */
  18786. onButtonDownObservable: Observable<number>;
  18787. /**
  18788. * Observable triggered when a button has been released
  18789. */
  18790. onButtonUpObservable: Observable<number>;
  18791. /**
  18792. * Callback triggered when a button has been pressed
  18793. * @param callback Called when a button has been pressed
  18794. */
  18795. onbuttondown(callback: (buttonPressed: number) => void): void;
  18796. /**
  18797. * Callback triggered when a button has been released
  18798. * @param callback Called when a button has been released
  18799. */
  18800. onbuttonup(callback: (buttonReleased: number) => void): void;
  18801. /**
  18802. * Initializes the generic gamepad
  18803. * @param id The id of the generic gamepad
  18804. * @param index The index of the generic gamepad
  18805. * @param browserGamepad The browser gamepad
  18806. */
  18807. constructor(id: string, index: number, browserGamepad: any);
  18808. private _setButtonValue;
  18809. /**
  18810. * Updates the generic gamepad
  18811. */
  18812. update(): void;
  18813. /**
  18814. * Disposes the generic gamepad
  18815. */
  18816. dispose(): void;
  18817. }
  18818. }
  18819. declare module BABYLON {
  18820. /**
  18821. * Defines the types of pose enabled controllers that are supported
  18822. */
  18823. export enum PoseEnabledControllerType {
  18824. /**
  18825. * HTC Vive
  18826. */
  18827. VIVE = 0,
  18828. /**
  18829. * Oculus Rift
  18830. */
  18831. OCULUS = 1,
  18832. /**
  18833. * Windows mixed reality
  18834. */
  18835. WINDOWS = 2,
  18836. /**
  18837. * Samsung gear VR
  18838. */
  18839. GEAR_VR = 3,
  18840. /**
  18841. * Google Daydream
  18842. */
  18843. DAYDREAM = 4,
  18844. /**
  18845. * Generic
  18846. */
  18847. GENERIC = 5
  18848. }
  18849. /**
  18850. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18851. */
  18852. export interface MutableGamepadButton {
  18853. /**
  18854. * Value of the button/trigger
  18855. */
  18856. value: number;
  18857. /**
  18858. * If the button/trigger is currently touched
  18859. */
  18860. touched: boolean;
  18861. /**
  18862. * If the button/trigger is currently pressed
  18863. */
  18864. pressed: boolean;
  18865. }
  18866. /**
  18867. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18868. * @hidden
  18869. */
  18870. export interface ExtendedGamepadButton extends GamepadButton {
  18871. /**
  18872. * If the button/trigger is currently pressed
  18873. */
  18874. readonly pressed: boolean;
  18875. /**
  18876. * If the button/trigger is currently touched
  18877. */
  18878. readonly touched: boolean;
  18879. /**
  18880. * Value of the button/trigger
  18881. */
  18882. readonly value: number;
  18883. }
  18884. /** @hidden */
  18885. export interface _GamePadFactory {
  18886. /**
  18887. * Returns whether or not the current gamepad can be created for this type of controller.
  18888. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18889. * @returns true if it can be created, otherwise false
  18890. */
  18891. canCreate(gamepadInfo: any): boolean;
  18892. /**
  18893. * Creates a new instance of the Gamepad.
  18894. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18895. * @returns the new gamepad instance
  18896. */
  18897. create(gamepadInfo: any): Gamepad;
  18898. }
  18899. /**
  18900. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18901. */
  18902. export class PoseEnabledControllerHelper {
  18903. /** @hidden */
  18904. static _ControllerFactories: _GamePadFactory[];
  18905. /** @hidden */
  18906. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18907. /**
  18908. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18909. * @param vrGamepad the gamepad to initialized
  18910. * @returns a vr controller of the type the gamepad identified as
  18911. */
  18912. static InitiateController(vrGamepad: any): Gamepad;
  18913. }
  18914. /**
  18915. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18916. */
  18917. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18918. /**
  18919. * If the controller is used in a webXR session
  18920. */
  18921. isXR: boolean;
  18922. private _deviceRoomPosition;
  18923. private _deviceRoomRotationQuaternion;
  18924. /**
  18925. * The device position in babylon space
  18926. */
  18927. devicePosition: Vector3;
  18928. /**
  18929. * The device rotation in babylon space
  18930. */
  18931. deviceRotationQuaternion: Quaternion;
  18932. /**
  18933. * The scale factor of the device in babylon space
  18934. */
  18935. deviceScaleFactor: number;
  18936. /**
  18937. * (Likely devicePosition should be used instead) The device position in its room space
  18938. */
  18939. position: Vector3;
  18940. /**
  18941. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  18942. */
  18943. rotationQuaternion: Quaternion;
  18944. /**
  18945. * The type of controller (Eg. Windows mixed reality)
  18946. */
  18947. controllerType: PoseEnabledControllerType;
  18948. protected _calculatedPosition: Vector3;
  18949. private _calculatedRotation;
  18950. /**
  18951. * The raw pose from the device
  18952. */
  18953. rawPose: DevicePose;
  18954. private _trackPosition;
  18955. private _maxRotationDistFromHeadset;
  18956. private _draggedRoomRotation;
  18957. /**
  18958. * @hidden
  18959. */
  18960. _disableTrackPosition(fixedPosition: Vector3): void;
  18961. /**
  18962. * Internal, the mesh attached to the controller
  18963. * @hidden
  18964. */
  18965. _mesh: Nullable<AbstractMesh>;
  18966. private _poseControlledCamera;
  18967. private _leftHandSystemQuaternion;
  18968. /**
  18969. * Internal, matrix used to convert room space to babylon space
  18970. * @hidden
  18971. */
  18972. _deviceToWorld: Matrix;
  18973. /**
  18974. * Node to be used when casting a ray from the controller
  18975. * @hidden
  18976. */
  18977. _pointingPoseNode: Nullable<TransformNode>;
  18978. /**
  18979. * Name of the child mesh that can be used to cast a ray from the controller
  18980. */
  18981. static readonly POINTING_POSE: string;
  18982. /**
  18983. * Creates a new PoseEnabledController from a gamepad
  18984. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  18985. */
  18986. constructor(browserGamepad: any);
  18987. private _workingMatrix;
  18988. /**
  18989. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  18990. */
  18991. update(): void;
  18992. /**
  18993. * Updates only the pose device and mesh without doing any button event checking
  18994. */
  18995. protected _updatePoseAndMesh(): void;
  18996. /**
  18997. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  18998. * @param poseData raw pose fromthe device
  18999. */
  19000. updateFromDevice(poseData: DevicePose): void;
  19001. /**
  19002. * @hidden
  19003. */
  19004. _meshAttachedObservable: Observable<AbstractMesh>;
  19005. /**
  19006. * Attaches a mesh to the controller
  19007. * @param mesh the mesh to be attached
  19008. */
  19009. attachToMesh(mesh: AbstractMesh): void;
  19010. /**
  19011. * Attaches the controllers mesh to a camera
  19012. * @param camera the camera the mesh should be attached to
  19013. */
  19014. attachToPoseControlledCamera(camera: TargetCamera): void;
  19015. /**
  19016. * Disposes of the controller
  19017. */
  19018. dispose(): void;
  19019. /**
  19020. * The mesh that is attached to the controller
  19021. */
  19022. get mesh(): Nullable<AbstractMesh>;
  19023. /**
  19024. * Gets the ray of the controller in the direction the controller is pointing
  19025. * @param length the length the resulting ray should be
  19026. * @returns a ray in the direction the controller is pointing
  19027. */
  19028. getForwardRay(length?: number): Ray;
  19029. }
  19030. }
  19031. declare module BABYLON {
  19032. /**
  19033. * Defines the WebVRController object that represents controllers tracked in 3D space
  19034. */
  19035. export abstract class WebVRController extends PoseEnabledController {
  19036. /**
  19037. * Internal, the default controller model for the controller
  19038. */
  19039. protected _defaultModel: Nullable<AbstractMesh>;
  19040. /**
  19041. * Fired when the trigger state has changed
  19042. */
  19043. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19044. /**
  19045. * Fired when the main button state has changed
  19046. */
  19047. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19048. /**
  19049. * Fired when the secondary button state has changed
  19050. */
  19051. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19052. /**
  19053. * Fired when the pad state has changed
  19054. */
  19055. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19056. /**
  19057. * Fired when controllers stick values have changed
  19058. */
  19059. onPadValuesChangedObservable: Observable<StickValues>;
  19060. /**
  19061. * Array of button availible on the controller
  19062. */
  19063. protected _buttons: Array<MutableGamepadButton>;
  19064. private _onButtonStateChange;
  19065. /**
  19066. * Fired when a controller button's state has changed
  19067. * @param callback the callback containing the button that was modified
  19068. */
  19069. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19070. /**
  19071. * X and Y axis corresponding to the controllers joystick
  19072. */
  19073. pad: StickValues;
  19074. /**
  19075. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19076. */
  19077. hand: string;
  19078. /**
  19079. * The default controller model for the controller
  19080. */
  19081. get defaultModel(): Nullable<AbstractMesh>;
  19082. /**
  19083. * Creates a new WebVRController from a gamepad
  19084. * @param vrGamepad the gamepad that the WebVRController should be created from
  19085. */
  19086. constructor(vrGamepad: any);
  19087. /**
  19088. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19089. */
  19090. update(): void;
  19091. /**
  19092. * Function to be called when a button is modified
  19093. */
  19094. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19095. /**
  19096. * Loads a mesh and attaches it to the controller
  19097. * @param scene the scene the mesh should be added to
  19098. * @param meshLoaded callback for when the mesh has been loaded
  19099. */
  19100. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19101. private _setButtonValue;
  19102. private _changes;
  19103. private _checkChanges;
  19104. /**
  19105. * Disposes of th webVRCOntroller
  19106. */
  19107. dispose(): void;
  19108. }
  19109. }
  19110. declare module BABYLON {
  19111. /**
  19112. * The HemisphericLight simulates the ambient environment light,
  19113. * so the passed direction is the light reflection direction, not the incoming direction.
  19114. */
  19115. export class HemisphericLight extends Light {
  19116. /**
  19117. * The groundColor is the light in the opposite direction to the one specified during creation.
  19118. * 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.
  19119. */
  19120. groundColor: Color3;
  19121. /**
  19122. * The light reflection direction, not the incoming direction.
  19123. */
  19124. direction: Vector3;
  19125. /**
  19126. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19127. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19128. * The HemisphericLight can't cast shadows.
  19129. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19130. * @param name The friendly name of the light
  19131. * @param direction The direction of the light reflection
  19132. * @param scene The scene the light belongs to
  19133. */
  19134. constructor(name: string, direction: Vector3, scene: Scene);
  19135. protected _buildUniformLayout(): void;
  19136. /**
  19137. * Returns the string "HemisphericLight".
  19138. * @return The class name
  19139. */
  19140. getClassName(): string;
  19141. /**
  19142. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19143. * Returns the updated direction.
  19144. * @param target The target the direction should point to
  19145. * @return The computed direction
  19146. */
  19147. setDirectionToTarget(target: Vector3): Vector3;
  19148. /**
  19149. * Returns the shadow generator associated to the light.
  19150. * @returns Always null for hemispheric lights because it does not support shadows.
  19151. */
  19152. getShadowGenerator(): Nullable<IShadowGenerator>;
  19153. /**
  19154. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19155. * @param effect The effect to update
  19156. * @param lightIndex The index of the light in the effect to update
  19157. * @returns The hemispheric light
  19158. */
  19159. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19160. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19161. /**
  19162. * Computes the world matrix of the node
  19163. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19164. * @param useWasUpdatedFlag defines a reserved property
  19165. * @returns the world matrix
  19166. */
  19167. computeWorldMatrix(): Matrix;
  19168. /**
  19169. * Returns the integer 3.
  19170. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19171. */
  19172. getTypeID(): number;
  19173. /**
  19174. * Prepares the list of defines specific to the light type.
  19175. * @param defines the list of defines
  19176. * @param lightIndex defines the index of the light for the effect
  19177. */
  19178. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19179. }
  19180. }
  19181. declare module BABYLON {
  19182. /** @hidden */
  19183. export var vrMultiviewToSingleviewPixelShader: {
  19184. name: string;
  19185. shader: string;
  19186. };
  19187. }
  19188. declare module BABYLON {
  19189. /**
  19190. * Renders to multiple views with a single draw call
  19191. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19192. */
  19193. export class MultiviewRenderTarget extends RenderTargetTexture {
  19194. /**
  19195. * Creates a multiview render target
  19196. * @param scene scene used with the render target
  19197. * @param size the size of the render target (used for each view)
  19198. */
  19199. constructor(scene: Scene, size?: number | {
  19200. width: number;
  19201. height: number;
  19202. } | {
  19203. ratio: number;
  19204. });
  19205. /**
  19206. * @hidden
  19207. * @param faceIndex the face index, if its a cube texture
  19208. */
  19209. _bindFrameBuffer(faceIndex?: number): void;
  19210. /**
  19211. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19212. * @returns the view count
  19213. */
  19214. getViewCount(): number;
  19215. }
  19216. }
  19217. declare module BABYLON {
  19218. /**
  19219. * Represents a camera frustum
  19220. */
  19221. export class Frustum {
  19222. /**
  19223. * Gets the planes representing the frustum
  19224. * @param transform matrix to be applied to the returned planes
  19225. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19226. */
  19227. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19228. /**
  19229. * Gets the near frustum plane transformed by the transform matrix
  19230. * @param transform transformation matrix to be applied to the resulting frustum plane
  19231. * @param frustumPlane the resuling frustum plane
  19232. */
  19233. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19234. /**
  19235. * Gets the far frustum plane transformed by the transform matrix
  19236. * @param transform transformation matrix to be applied to the resulting frustum plane
  19237. * @param frustumPlane the resuling frustum plane
  19238. */
  19239. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19240. /**
  19241. * Gets the left frustum plane transformed by the transform matrix
  19242. * @param transform transformation matrix to be applied to the resulting frustum plane
  19243. * @param frustumPlane the resuling frustum plane
  19244. */
  19245. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19246. /**
  19247. * Gets the right frustum plane transformed by the transform matrix
  19248. * @param transform transformation matrix to be applied to the resulting frustum plane
  19249. * @param frustumPlane the resuling frustum plane
  19250. */
  19251. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19252. /**
  19253. * Gets the top frustum plane transformed by the transform matrix
  19254. * @param transform transformation matrix to be applied to the resulting frustum plane
  19255. * @param frustumPlane the resuling frustum plane
  19256. */
  19257. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19258. /**
  19259. * Gets the bottom frustum plane transformed by the transform matrix
  19260. * @param transform transformation matrix to be applied to the resulting frustum plane
  19261. * @param frustumPlane the resuling frustum plane
  19262. */
  19263. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19264. /**
  19265. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19266. * @param transform transformation matrix to be applied to the resulting frustum planes
  19267. * @param frustumPlanes the resuling frustum planes
  19268. */
  19269. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19270. }
  19271. }
  19272. declare module BABYLON {
  19273. interface Engine {
  19274. /**
  19275. * Creates a new multiview render target
  19276. * @param width defines the width of the texture
  19277. * @param height defines the height of the texture
  19278. * @returns the created multiview texture
  19279. */
  19280. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19281. /**
  19282. * Binds a multiview framebuffer to be drawn to
  19283. * @param multiviewTexture texture to bind
  19284. */
  19285. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19286. }
  19287. interface Camera {
  19288. /**
  19289. * @hidden
  19290. * 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)
  19291. */
  19292. _useMultiviewToSingleView: boolean;
  19293. /**
  19294. * @hidden
  19295. * 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)
  19296. */
  19297. _multiviewTexture: Nullable<RenderTargetTexture>;
  19298. /**
  19299. * @hidden
  19300. * ensures the multiview texture of the camera exists and has the specified width/height
  19301. * @param width height to set on the multiview texture
  19302. * @param height width to set on the multiview texture
  19303. */
  19304. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19305. }
  19306. interface Scene {
  19307. /** @hidden */
  19308. _transformMatrixR: Matrix;
  19309. /** @hidden */
  19310. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19311. /** @hidden */
  19312. _createMultiviewUbo(): void;
  19313. /** @hidden */
  19314. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19315. /** @hidden */
  19316. _renderMultiviewToSingleView(camera: Camera): void;
  19317. }
  19318. }
  19319. declare module BABYLON {
  19320. /**
  19321. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19322. * This will not be used for webXR as it supports displaying texture arrays directly
  19323. */
  19324. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19325. /**
  19326. * Initializes a VRMultiviewToSingleview
  19327. * @param name name of the post process
  19328. * @param camera camera to be applied to
  19329. * @param scaleFactor scaling factor to the size of the output texture
  19330. */
  19331. constructor(name: string, camera: Camera, scaleFactor: number);
  19332. }
  19333. }
  19334. declare module BABYLON {
  19335. /**
  19336. * Interface used to define additional presentation attributes
  19337. */
  19338. export interface IVRPresentationAttributes {
  19339. /**
  19340. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19341. */
  19342. highRefreshRate: boolean;
  19343. /**
  19344. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19345. */
  19346. foveationLevel: number;
  19347. }
  19348. interface Engine {
  19349. /** @hidden */
  19350. _vrDisplay: any;
  19351. /** @hidden */
  19352. _vrSupported: boolean;
  19353. /** @hidden */
  19354. _oldSize: Size;
  19355. /** @hidden */
  19356. _oldHardwareScaleFactor: number;
  19357. /** @hidden */
  19358. _vrExclusivePointerMode: boolean;
  19359. /** @hidden */
  19360. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19361. /** @hidden */
  19362. _onVRDisplayPointerRestricted: () => void;
  19363. /** @hidden */
  19364. _onVRDisplayPointerUnrestricted: () => void;
  19365. /** @hidden */
  19366. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19367. /** @hidden */
  19368. _onVrDisplayDisconnect: Nullable<() => void>;
  19369. /** @hidden */
  19370. _onVrDisplayPresentChange: Nullable<() => void>;
  19371. /**
  19372. * Observable signaled when VR display mode changes
  19373. */
  19374. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19375. /**
  19376. * Observable signaled when VR request present is complete
  19377. */
  19378. onVRRequestPresentComplete: Observable<boolean>;
  19379. /**
  19380. * Observable signaled when VR request present starts
  19381. */
  19382. onVRRequestPresentStart: Observable<Engine>;
  19383. /**
  19384. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19385. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19386. */
  19387. isInVRExclusivePointerMode: boolean;
  19388. /**
  19389. * Gets a boolean indicating if a webVR device was detected
  19390. * @returns true if a webVR device was detected
  19391. */
  19392. isVRDevicePresent(): boolean;
  19393. /**
  19394. * Gets the current webVR device
  19395. * @returns the current webVR device (or null)
  19396. */
  19397. getVRDevice(): any;
  19398. /**
  19399. * Initializes a webVR display and starts listening to display change events
  19400. * The onVRDisplayChangedObservable will be notified upon these changes
  19401. * @returns A promise containing a VRDisplay and if vr is supported
  19402. */
  19403. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19404. /** @hidden */
  19405. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19406. /**
  19407. * Gets or sets the presentation attributes used to configure VR rendering
  19408. */
  19409. vrPresentationAttributes?: IVRPresentationAttributes;
  19410. /**
  19411. * Call this function to switch to webVR mode
  19412. * Will do nothing if webVR is not supported or if there is no webVR device
  19413. * @param options the webvr options provided to the camera. mainly used for multiview
  19414. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19415. */
  19416. enableVR(options: WebVROptions): void;
  19417. /** @hidden */
  19418. _onVRFullScreenTriggered(): void;
  19419. }
  19420. }
  19421. declare module BABYLON {
  19422. /**
  19423. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19424. * IMPORTANT!! The data is right-hand data.
  19425. * @export
  19426. * @interface DevicePose
  19427. */
  19428. export interface DevicePose {
  19429. /**
  19430. * The position of the device, values in array are [x,y,z].
  19431. */
  19432. readonly position: Nullable<Float32Array>;
  19433. /**
  19434. * The linearVelocity of the device, values in array are [x,y,z].
  19435. */
  19436. readonly linearVelocity: Nullable<Float32Array>;
  19437. /**
  19438. * The linearAcceleration of the device, values in array are [x,y,z].
  19439. */
  19440. readonly linearAcceleration: Nullable<Float32Array>;
  19441. /**
  19442. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19443. */
  19444. readonly orientation: Nullable<Float32Array>;
  19445. /**
  19446. * The angularVelocity of the device, values in array are [x,y,z].
  19447. */
  19448. readonly angularVelocity: Nullable<Float32Array>;
  19449. /**
  19450. * The angularAcceleration of the device, values in array are [x,y,z].
  19451. */
  19452. readonly angularAcceleration: Nullable<Float32Array>;
  19453. }
  19454. /**
  19455. * Interface representing a pose controlled object in Babylon.
  19456. * A pose controlled object has both regular pose values as well as pose values
  19457. * from an external device such as a VR head mounted display
  19458. */
  19459. export interface PoseControlled {
  19460. /**
  19461. * The position of the object in babylon space.
  19462. */
  19463. position: Vector3;
  19464. /**
  19465. * The rotation quaternion of the object in babylon space.
  19466. */
  19467. rotationQuaternion: Quaternion;
  19468. /**
  19469. * The position of the device in babylon space.
  19470. */
  19471. devicePosition?: Vector3;
  19472. /**
  19473. * The rotation quaternion of the device in babylon space.
  19474. */
  19475. deviceRotationQuaternion: Quaternion;
  19476. /**
  19477. * The raw pose coming from the device.
  19478. */
  19479. rawPose: Nullable<DevicePose>;
  19480. /**
  19481. * The scale of the device to be used when translating from device space to babylon space.
  19482. */
  19483. deviceScaleFactor: number;
  19484. /**
  19485. * Updates the poseControlled values based on the input device pose.
  19486. * @param poseData the pose data to update the object with
  19487. */
  19488. updateFromDevice(poseData: DevicePose): void;
  19489. }
  19490. /**
  19491. * Set of options to customize the webVRCamera
  19492. */
  19493. export interface WebVROptions {
  19494. /**
  19495. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19496. */
  19497. trackPosition?: boolean;
  19498. /**
  19499. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19500. */
  19501. positionScale?: number;
  19502. /**
  19503. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19504. */
  19505. displayName?: string;
  19506. /**
  19507. * Should the native controller meshes be initialized. (default: true)
  19508. */
  19509. controllerMeshes?: boolean;
  19510. /**
  19511. * Creating a default HemiLight only on controllers. (default: true)
  19512. */
  19513. defaultLightingOnControllers?: boolean;
  19514. /**
  19515. * If you don't want to use the default VR button of the helper. (default: false)
  19516. */
  19517. useCustomVRButton?: boolean;
  19518. /**
  19519. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19520. */
  19521. customVRButton?: HTMLButtonElement;
  19522. /**
  19523. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19524. */
  19525. rayLength?: number;
  19526. /**
  19527. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19528. */
  19529. defaultHeight?: number;
  19530. /**
  19531. * If multiview should be used if availible (default: false)
  19532. */
  19533. useMultiview?: boolean;
  19534. }
  19535. /**
  19536. * This represents a WebVR camera.
  19537. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19538. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19539. */
  19540. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19541. private webVROptions;
  19542. /**
  19543. * @hidden
  19544. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19545. */
  19546. _vrDevice: any;
  19547. /**
  19548. * The rawPose of the vrDevice.
  19549. */
  19550. rawPose: Nullable<DevicePose>;
  19551. private _onVREnabled;
  19552. private _specsVersion;
  19553. private _attached;
  19554. private _frameData;
  19555. protected _descendants: Array<Node>;
  19556. private _deviceRoomPosition;
  19557. /** @hidden */
  19558. _deviceRoomRotationQuaternion: Quaternion;
  19559. private _standingMatrix;
  19560. /**
  19561. * Represents device position in babylon space.
  19562. */
  19563. devicePosition: Vector3;
  19564. /**
  19565. * Represents device rotation in babylon space.
  19566. */
  19567. deviceRotationQuaternion: Quaternion;
  19568. /**
  19569. * The scale of the device to be used when translating from device space to babylon space.
  19570. */
  19571. deviceScaleFactor: number;
  19572. private _deviceToWorld;
  19573. private _worldToDevice;
  19574. /**
  19575. * References to the webVR controllers for the vrDevice.
  19576. */
  19577. controllers: Array<WebVRController>;
  19578. /**
  19579. * Emits an event when a controller is attached.
  19580. */
  19581. onControllersAttachedObservable: Observable<WebVRController[]>;
  19582. /**
  19583. * Emits an event when a controller's mesh has been loaded;
  19584. */
  19585. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19586. /**
  19587. * Emits an event when the HMD's pose has been updated.
  19588. */
  19589. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19590. private _poseSet;
  19591. /**
  19592. * If the rig cameras be used as parent instead of this camera.
  19593. */
  19594. rigParenting: boolean;
  19595. private _lightOnControllers;
  19596. private _defaultHeight?;
  19597. /**
  19598. * Instantiates a WebVRFreeCamera.
  19599. * @param name The name of the WebVRFreeCamera
  19600. * @param position The starting anchor position for the camera
  19601. * @param scene The scene the camera belongs to
  19602. * @param webVROptions a set of customizable options for the webVRCamera
  19603. */
  19604. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19605. /**
  19606. * Gets the device distance from the ground in meters.
  19607. * @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.
  19608. */
  19609. deviceDistanceToRoomGround(): number;
  19610. /**
  19611. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19612. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19613. */
  19614. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19615. /**
  19616. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19617. * @returns A promise with a boolean set to if the standing matrix is supported.
  19618. */
  19619. useStandingMatrixAsync(): Promise<boolean>;
  19620. /**
  19621. * Disposes the camera
  19622. */
  19623. dispose(): void;
  19624. /**
  19625. * Gets a vrController by name.
  19626. * @param name The name of the controller to retreive
  19627. * @returns the controller matching the name specified or null if not found
  19628. */
  19629. getControllerByName(name: string): Nullable<WebVRController>;
  19630. private _leftController;
  19631. /**
  19632. * The controller corresponding to the users left hand.
  19633. */
  19634. get leftController(): Nullable<WebVRController>;
  19635. private _rightController;
  19636. /**
  19637. * The controller corresponding to the users right hand.
  19638. */
  19639. get rightController(): Nullable<WebVRController>;
  19640. /**
  19641. * Casts a ray forward from the vrCamera's gaze.
  19642. * @param length Length of the ray (default: 100)
  19643. * @returns the ray corresponding to the gaze
  19644. */
  19645. getForwardRay(length?: number): Ray;
  19646. /**
  19647. * @hidden
  19648. * Updates the camera based on device's frame data
  19649. */
  19650. _checkInputs(): void;
  19651. /**
  19652. * Updates the poseControlled values based on the input device pose.
  19653. * @param poseData Pose coming from the device
  19654. */
  19655. updateFromDevice(poseData: DevicePose): void;
  19656. private _htmlElementAttached;
  19657. private _detachIfAttached;
  19658. /**
  19659. * WebVR's attach control will start broadcasting frames to the device.
  19660. * Note that in certain browsers (chrome for example) this function must be called
  19661. * within a user-interaction callback. Example:
  19662. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19663. *
  19664. * @param element html element to attach the vrDevice to
  19665. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19666. */
  19667. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19668. /**
  19669. * Detaches the camera from the html element and disables VR
  19670. *
  19671. * @param element html element to detach from
  19672. */
  19673. detachControl(element: HTMLElement): void;
  19674. /**
  19675. * @returns the name of this class
  19676. */
  19677. getClassName(): string;
  19678. /**
  19679. * Calls resetPose on the vrDisplay
  19680. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19681. */
  19682. resetToCurrentRotation(): void;
  19683. /**
  19684. * @hidden
  19685. * Updates the rig cameras (left and right eye)
  19686. */
  19687. _updateRigCameras(): void;
  19688. private _workingVector;
  19689. private _oneVector;
  19690. private _workingMatrix;
  19691. private updateCacheCalled;
  19692. private _correctPositionIfNotTrackPosition;
  19693. /**
  19694. * @hidden
  19695. * Updates the cached values of the camera
  19696. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19697. */
  19698. _updateCache(ignoreParentClass?: boolean): void;
  19699. /**
  19700. * @hidden
  19701. * Get current device position in babylon world
  19702. */
  19703. _computeDevicePosition(): void;
  19704. /**
  19705. * Updates the current device position and rotation in the babylon world
  19706. */
  19707. update(): void;
  19708. /**
  19709. * @hidden
  19710. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19711. * @returns an identity matrix
  19712. */
  19713. _getViewMatrix(): Matrix;
  19714. private _tmpMatrix;
  19715. /**
  19716. * This function is called by the two RIG cameras.
  19717. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19718. * @hidden
  19719. */
  19720. _getWebVRViewMatrix(): Matrix;
  19721. /** @hidden */
  19722. _getWebVRProjectionMatrix(): Matrix;
  19723. private _onGamepadConnectedObserver;
  19724. private _onGamepadDisconnectedObserver;
  19725. private _updateCacheWhenTrackingDisabledObserver;
  19726. /**
  19727. * Initializes the controllers and their meshes
  19728. */
  19729. initControllers(): void;
  19730. }
  19731. }
  19732. declare module BABYLON {
  19733. /**
  19734. * Size options for a post process
  19735. */
  19736. export type PostProcessOptions = {
  19737. width: number;
  19738. height: number;
  19739. };
  19740. /**
  19741. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19742. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19743. */
  19744. export class PostProcess {
  19745. /** Name of the PostProcess. */
  19746. name: string;
  19747. /**
  19748. * Gets or sets the unique id of the post process
  19749. */
  19750. uniqueId: number;
  19751. /**
  19752. * Width of the texture to apply the post process on
  19753. */
  19754. width: number;
  19755. /**
  19756. * Height of the texture to apply the post process on
  19757. */
  19758. height: number;
  19759. /**
  19760. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19761. * @hidden
  19762. */
  19763. _outputTexture: Nullable<InternalTexture>;
  19764. /**
  19765. * Sampling mode used by the shader
  19766. * See https://doc.babylonjs.com/classes/3.1/texture
  19767. */
  19768. renderTargetSamplingMode: number;
  19769. /**
  19770. * Clear color to use when screen clearing
  19771. */
  19772. clearColor: Color4;
  19773. /**
  19774. * If the buffer needs to be cleared before applying the post process. (default: true)
  19775. * Should be set to false if shader will overwrite all previous pixels.
  19776. */
  19777. autoClear: boolean;
  19778. /**
  19779. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19780. */
  19781. alphaMode: number;
  19782. /**
  19783. * Sets the setAlphaBlendConstants of the babylon engine
  19784. */
  19785. alphaConstants: Color4;
  19786. /**
  19787. * Animations to be used for the post processing
  19788. */
  19789. animations: Animation[];
  19790. /**
  19791. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19792. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19793. */
  19794. enablePixelPerfectMode: boolean;
  19795. /**
  19796. * Force the postprocess to be applied without taking in account viewport
  19797. */
  19798. forceFullscreenViewport: boolean;
  19799. /**
  19800. * List of inspectable custom properties (used by the Inspector)
  19801. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19802. */
  19803. inspectableCustomProperties: IInspectable[];
  19804. /**
  19805. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19806. *
  19807. * | Value | Type | Description |
  19808. * | ----- | ----------------------------------- | ----------- |
  19809. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19810. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19811. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19812. *
  19813. */
  19814. scaleMode: number;
  19815. /**
  19816. * Force textures to be a power of two (default: false)
  19817. */
  19818. alwaysForcePOT: boolean;
  19819. private _samples;
  19820. /**
  19821. * Number of sample textures (default: 1)
  19822. */
  19823. get samples(): number;
  19824. set samples(n: number);
  19825. /**
  19826. * Modify the scale of the post process to be the same as the viewport (default: false)
  19827. */
  19828. adaptScaleToCurrentViewport: boolean;
  19829. private _camera;
  19830. private _scene;
  19831. private _engine;
  19832. private _options;
  19833. private _reusable;
  19834. private _textureType;
  19835. private _textureFormat;
  19836. /**
  19837. * Smart array of input and output textures for the post process.
  19838. * @hidden
  19839. */
  19840. _textures: SmartArray<InternalTexture>;
  19841. /**
  19842. * The index in _textures that corresponds to the output texture.
  19843. * @hidden
  19844. */
  19845. _currentRenderTextureInd: number;
  19846. private _effect;
  19847. private _samplers;
  19848. private _fragmentUrl;
  19849. private _vertexUrl;
  19850. private _parameters;
  19851. private _scaleRatio;
  19852. protected _indexParameters: any;
  19853. private _shareOutputWithPostProcess;
  19854. private _texelSize;
  19855. private _forcedOutputTexture;
  19856. /**
  19857. * Returns the fragment url or shader name used in the post process.
  19858. * @returns the fragment url or name in the shader store.
  19859. */
  19860. getEffectName(): string;
  19861. /**
  19862. * An event triggered when the postprocess is activated.
  19863. */
  19864. onActivateObservable: Observable<Camera>;
  19865. private _onActivateObserver;
  19866. /**
  19867. * A function that is added to the onActivateObservable
  19868. */
  19869. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19870. /**
  19871. * An event triggered when the postprocess changes its size.
  19872. */
  19873. onSizeChangedObservable: Observable<PostProcess>;
  19874. private _onSizeChangedObserver;
  19875. /**
  19876. * A function that is added to the onSizeChangedObservable
  19877. */
  19878. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19879. /**
  19880. * An event triggered when the postprocess applies its effect.
  19881. */
  19882. onApplyObservable: Observable<Effect>;
  19883. private _onApplyObserver;
  19884. /**
  19885. * A function that is added to the onApplyObservable
  19886. */
  19887. set onApply(callback: (effect: Effect) => void);
  19888. /**
  19889. * An event triggered before rendering the postprocess
  19890. */
  19891. onBeforeRenderObservable: Observable<Effect>;
  19892. private _onBeforeRenderObserver;
  19893. /**
  19894. * A function that is added to the onBeforeRenderObservable
  19895. */
  19896. set onBeforeRender(callback: (effect: Effect) => void);
  19897. /**
  19898. * An event triggered after rendering the postprocess
  19899. */
  19900. onAfterRenderObservable: Observable<Effect>;
  19901. private _onAfterRenderObserver;
  19902. /**
  19903. * A function that is added to the onAfterRenderObservable
  19904. */
  19905. set onAfterRender(callback: (efect: Effect) => void);
  19906. /**
  19907. * 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
  19908. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19909. */
  19910. get inputTexture(): InternalTexture;
  19911. set inputTexture(value: InternalTexture);
  19912. /**
  19913. * Gets the camera which post process is applied to.
  19914. * @returns The camera the post process is applied to.
  19915. */
  19916. getCamera(): Camera;
  19917. /**
  19918. * Gets the texel size of the postprocess.
  19919. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19920. */
  19921. get texelSize(): Vector2;
  19922. /**
  19923. * Creates a new instance PostProcess
  19924. * @param name The name of the PostProcess.
  19925. * @param fragmentUrl The url of the fragment shader to be used.
  19926. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  19927. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  19928. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19929. * @param camera The camera to apply the render pass to.
  19930. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19931. * @param engine The engine which the post process will be applied. (default: current engine)
  19932. * @param reusable If the post process can be reused on the same frame. (default: false)
  19933. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  19934. * @param textureType Type of textures used when performing the post process. (default: 0)
  19935. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  19936. * @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
  19937. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  19938. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  19939. */
  19940. constructor(
  19941. /** Name of the PostProcess. */
  19942. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  19943. /**
  19944. * Gets a string idenfifying the name of the class
  19945. * @returns "PostProcess" string
  19946. */
  19947. getClassName(): string;
  19948. /**
  19949. * Gets the engine which this post process belongs to.
  19950. * @returns The engine the post process was enabled with.
  19951. */
  19952. getEngine(): Engine;
  19953. /**
  19954. * The effect that is created when initializing the post process.
  19955. * @returns The created effect corresponding the the postprocess.
  19956. */
  19957. getEffect(): Effect;
  19958. /**
  19959. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  19960. * @param postProcess The post process to share the output with.
  19961. * @returns This post process.
  19962. */
  19963. shareOutputWith(postProcess: PostProcess): PostProcess;
  19964. /**
  19965. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  19966. * This should be called if the post process that shares output with this post process is disabled/disposed.
  19967. */
  19968. useOwnOutput(): void;
  19969. /**
  19970. * Updates the effect with the current post process compile time values and recompiles the shader.
  19971. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19972. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19973. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19974. * @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
  19975. * @param onCompiled Called when the shader has been compiled.
  19976. * @param onError Called if there is an error when compiling a shader.
  19977. */
  19978. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19979. /**
  19980. * The post process is reusable if it can be used multiple times within one frame.
  19981. * @returns If the post process is reusable
  19982. */
  19983. isReusable(): boolean;
  19984. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  19985. markTextureDirty(): void;
  19986. /**
  19987. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  19988. * 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.
  19989. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  19990. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  19991. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  19992. * @returns The target texture that was bound to be written to.
  19993. */
  19994. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  19995. /**
  19996. * If the post process is supported.
  19997. */
  19998. get isSupported(): boolean;
  19999. /**
  20000. * The aspect ratio of the output texture.
  20001. */
  20002. get aspectRatio(): number;
  20003. /**
  20004. * Get a value indicating if the post-process is ready to be used
  20005. * @returns true if the post-process is ready (shader is compiled)
  20006. */
  20007. isReady(): boolean;
  20008. /**
  20009. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20010. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20011. */
  20012. apply(): Nullable<Effect>;
  20013. private _disposeTextures;
  20014. /**
  20015. * Disposes the post process.
  20016. * @param camera The camera to dispose the post process on.
  20017. */
  20018. dispose(camera?: Camera): void;
  20019. }
  20020. }
  20021. declare module BABYLON {
  20022. /** @hidden */
  20023. export var kernelBlurVaryingDeclaration: {
  20024. name: string;
  20025. shader: string;
  20026. };
  20027. }
  20028. declare module BABYLON {
  20029. /** @hidden */
  20030. export var kernelBlurFragment: {
  20031. name: string;
  20032. shader: string;
  20033. };
  20034. }
  20035. declare module BABYLON {
  20036. /** @hidden */
  20037. export var kernelBlurFragment2: {
  20038. name: string;
  20039. shader: string;
  20040. };
  20041. }
  20042. declare module BABYLON {
  20043. /** @hidden */
  20044. export var kernelBlurPixelShader: {
  20045. name: string;
  20046. shader: string;
  20047. };
  20048. }
  20049. declare module BABYLON {
  20050. /** @hidden */
  20051. export var kernelBlurVertex: {
  20052. name: string;
  20053. shader: string;
  20054. };
  20055. }
  20056. declare module BABYLON {
  20057. /** @hidden */
  20058. export var kernelBlurVertexShader: {
  20059. name: string;
  20060. shader: string;
  20061. };
  20062. }
  20063. declare module BABYLON {
  20064. /**
  20065. * The Blur Post Process which blurs an image based on a kernel and direction.
  20066. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20067. */
  20068. export class BlurPostProcess extends PostProcess {
  20069. /** The direction in which to blur the image. */
  20070. direction: Vector2;
  20071. private blockCompilation;
  20072. protected _kernel: number;
  20073. protected _idealKernel: number;
  20074. protected _packedFloat: boolean;
  20075. private _staticDefines;
  20076. /**
  20077. * Sets the length in pixels of the blur sample region
  20078. */
  20079. set kernel(v: number);
  20080. /**
  20081. * Gets the length in pixels of the blur sample region
  20082. */
  20083. get kernel(): number;
  20084. /**
  20085. * Sets wether or not the blur needs to unpack/repack floats
  20086. */
  20087. set packedFloat(v: boolean);
  20088. /**
  20089. * Gets wether or not the blur is unpacking/repacking floats
  20090. */
  20091. get packedFloat(): boolean;
  20092. /**
  20093. * Creates a new instance BlurPostProcess
  20094. * @param name The name of the effect.
  20095. * @param direction The direction in which to blur the image.
  20096. * @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.
  20097. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20098. * @param camera The camera to apply the render pass to.
  20099. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20100. * @param engine The engine which the post process will be applied. (default: current engine)
  20101. * @param reusable If the post process can be reused on the same frame. (default: false)
  20102. * @param textureType Type of textures used when performing the post process. (default: 0)
  20103. * @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)
  20104. */
  20105. constructor(name: string,
  20106. /** The direction in which to blur the image. */
  20107. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20108. /**
  20109. * Updates the effect with the current post process compile time values and recompiles the shader.
  20110. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20111. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20112. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20113. * @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
  20114. * @param onCompiled Called when the shader has been compiled.
  20115. * @param onError Called if there is an error when compiling a shader.
  20116. */
  20117. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20118. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20119. /**
  20120. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20121. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20122. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20123. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20124. * The gaps between physical kernels are compensated for in the weighting of the samples
  20125. * @param idealKernel Ideal blur kernel.
  20126. * @return Nearest best kernel.
  20127. */
  20128. protected _nearestBestKernel(idealKernel: number): number;
  20129. /**
  20130. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20131. * @param x The point on the Gaussian distribution to sample.
  20132. * @return the value of the Gaussian function at x.
  20133. */
  20134. protected _gaussianWeight(x: number): number;
  20135. /**
  20136. * Generates a string that can be used as a floating point number in GLSL.
  20137. * @param x Value to print.
  20138. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20139. * @return GLSL float string.
  20140. */
  20141. protected _glslFloat(x: number, decimalFigures?: number): string;
  20142. }
  20143. }
  20144. declare module BABYLON {
  20145. /**
  20146. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20147. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20148. * You can then easily use it as a reflectionTexture on a flat surface.
  20149. * In case the surface is not a plane, please consider relying on reflection probes.
  20150. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20151. */
  20152. export class MirrorTexture extends RenderTargetTexture {
  20153. private scene;
  20154. /**
  20155. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20156. * 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.
  20157. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20158. */
  20159. mirrorPlane: Plane;
  20160. /**
  20161. * Define the blur ratio used to blur the reflection if needed.
  20162. */
  20163. set blurRatio(value: number);
  20164. get blurRatio(): number;
  20165. /**
  20166. * Define the adaptive blur kernel used to blur the reflection if needed.
  20167. * This will autocompute the closest best match for the `blurKernel`
  20168. */
  20169. set adaptiveBlurKernel(value: number);
  20170. /**
  20171. * Define the blur kernel used to blur the reflection if needed.
  20172. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20173. */
  20174. set blurKernel(value: number);
  20175. /**
  20176. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20177. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20178. */
  20179. set blurKernelX(value: number);
  20180. get blurKernelX(): number;
  20181. /**
  20182. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20183. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20184. */
  20185. set blurKernelY(value: number);
  20186. get blurKernelY(): number;
  20187. private _autoComputeBlurKernel;
  20188. protected _onRatioRescale(): void;
  20189. private _updateGammaSpace;
  20190. private _imageProcessingConfigChangeObserver;
  20191. private _transformMatrix;
  20192. private _mirrorMatrix;
  20193. private _savedViewMatrix;
  20194. private _blurX;
  20195. private _blurY;
  20196. private _adaptiveBlurKernel;
  20197. private _blurKernelX;
  20198. private _blurKernelY;
  20199. private _blurRatio;
  20200. /**
  20201. * Instantiates a Mirror Texture.
  20202. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20203. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20204. * You can then easily use it as a reflectionTexture on a flat surface.
  20205. * In case the surface is not a plane, please consider relying on reflection probes.
  20206. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20207. * @param name
  20208. * @param size
  20209. * @param scene
  20210. * @param generateMipMaps
  20211. * @param type
  20212. * @param samplingMode
  20213. * @param generateDepthBuffer
  20214. */
  20215. constructor(name: string, size: number | {
  20216. width: number;
  20217. height: number;
  20218. } | {
  20219. ratio: number;
  20220. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20221. private _preparePostProcesses;
  20222. /**
  20223. * Clone the mirror texture.
  20224. * @returns the cloned texture
  20225. */
  20226. clone(): MirrorTexture;
  20227. /**
  20228. * Serialize the texture to a JSON representation you could use in Parse later on
  20229. * @returns the serialized JSON representation
  20230. */
  20231. serialize(): any;
  20232. /**
  20233. * Dispose the texture and release its associated resources.
  20234. */
  20235. dispose(): void;
  20236. }
  20237. }
  20238. declare module BABYLON {
  20239. /**
  20240. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20241. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20242. */
  20243. export class Texture extends BaseTexture {
  20244. /**
  20245. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20246. */
  20247. static SerializeBuffers: boolean;
  20248. /** @hidden */
  20249. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20250. /** @hidden */
  20251. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20252. /** @hidden */
  20253. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20254. /** nearest is mag = nearest and min = nearest and mip = linear */
  20255. static readonly NEAREST_SAMPLINGMODE: number;
  20256. /** nearest is mag = nearest and min = nearest and mip = linear */
  20257. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20258. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20259. static readonly BILINEAR_SAMPLINGMODE: number;
  20260. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20261. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20262. /** Trilinear is mag = linear and min = linear and mip = linear */
  20263. static readonly TRILINEAR_SAMPLINGMODE: number;
  20264. /** Trilinear is mag = linear and min = linear and mip = linear */
  20265. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20266. /** mag = nearest and min = nearest and mip = nearest */
  20267. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20268. /** mag = nearest and min = linear and mip = nearest */
  20269. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20270. /** mag = nearest and min = linear and mip = linear */
  20271. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20272. /** mag = nearest and min = linear and mip = none */
  20273. static readonly NEAREST_LINEAR: number;
  20274. /** mag = nearest and min = nearest and mip = none */
  20275. static readonly NEAREST_NEAREST: number;
  20276. /** mag = linear and min = nearest and mip = nearest */
  20277. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20278. /** mag = linear and min = nearest and mip = linear */
  20279. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20280. /** mag = linear and min = linear and mip = none */
  20281. static readonly LINEAR_LINEAR: number;
  20282. /** mag = linear and min = nearest and mip = none */
  20283. static readonly LINEAR_NEAREST: number;
  20284. /** Explicit coordinates mode */
  20285. static readonly EXPLICIT_MODE: number;
  20286. /** Spherical coordinates mode */
  20287. static readonly SPHERICAL_MODE: number;
  20288. /** Planar coordinates mode */
  20289. static readonly PLANAR_MODE: number;
  20290. /** Cubic coordinates mode */
  20291. static readonly CUBIC_MODE: number;
  20292. /** Projection coordinates mode */
  20293. static readonly PROJECTION_MODE: number;
  20294. /** Inverse Cubic coordinates mode */
  20295. static readonly SKYBOX_MODE: number;
  20296. /** Inverse Cubic coordinates mode */
  20297. static readonly INVCUBIC_MODE: number;
  20298. /** Equirectangular coordinates mode */
  20299. static readonly EQUIRECTANGULAR_MODE: number;
  20300. /** Equirectangular Fixed coordinates mode */
  20301. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20302. /** Equirectangular Fixed Mirrored coordinates mode */
  20303. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20304. /** Texture is not repeating outside of 0..1 UVs */
  20305. static readonly CLAMP_ADDRESSMODE: number;
  20306. /** Texture is repeating outside of 0..1 UVs */
  20307. static readonly WRAP_ADDRESSMODE: number;
  20308. /** Texture is repeating and mirrored */
  20309. static readonly MIRROR_ADDRESSMODE: number;
  20310. /**
  20311. * 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
  20312. */
  20313. static UseSerializedUrlIfAny: boolean;
  20314. /**
  20315. * Define the url of the texture.
  20316. */
  20317. url: Nullable<string>;
  20318. /**
  20319. * Define an offset on the texture to offset the u coordinates of the UVs
  20320. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20321. */
  20322. uOffset: number;
  20323. /**
  20324. * Define an offset on the texture to offset the v coordinates of the UVs
  20325. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20326. */
  20327. vOffset: number;
  20328. /**
  20329. * Define an offset on the texture to scale the u coordinates of the UVs
  20330. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20331. */
  20332. uScale: number;
  20333. /**
  20334. * Define an offset on the texture to scale the v coordinates of the UVs
  20335. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20336. */
  20337. vScale: number;
  20338. /**
  20339. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20340. * @see http://doc.babylonjs.com/how_to/more_materials
  20341. */
  20342. uAng: number;
  20343. /**
  20344. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20345. * @see http://doc.babylonjs.com/how_to/more_materials
  20346. */
  20347. vAng: number;
  20348. /**
  20349. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20350. * @see http://doc.babylonjs.com/how_to/more_materials
  20351. */
  20352. wAng: number;
  20353. /**
  20354. * Defines the center of rotation (U)
  20355. */
  20356. uRotationCenter: number;
  20357. /**
  20358. * Defines the center of rotation (V)
  20359. */
  20360. vRotationCenter: number;
  20361. /**
  20362. * Defines the center of rotation (W)
  20363. */
  20364. wRotationCenter: number;
  20365. /**
  20366. * Are mip maps generated for this texture or not.
  20367. */
  20368. get noMipmap(): boolean;
  20369. /**
  20370. * List of inspectable custom properties (used by the Inspector)
  20371. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20372. */
  20373. inspectableCustomProperties: Nullable<IInspectable[]>;
  20374. private _noMipmap;
  20375. /** @hidden */
  20376. _invertY: boolean;
  20377. private _rowGenerationMatrix;
  20378. private _cachedTextureMatrix;
  20379. private _projectionModeMatrix;
  20380. private _t0;
  20381. private _t1;
  20382. private _t2;
  20383. private _cachedUOffset;
  20384. private _cachedVOffset;
  20385. private _cachedUScale;
  20386. private _cachedVScale;
  20387. private _cachedUAng;
  20388. private _cachedVAng;
  20389. private _cachedWAng;
  20390. private _cachedProjectionMatrixId;
  20391. private _cachedCoordinatesMode;
  20392. /** @hidden */
  20393. protected _initialSamplingMode: number;
  20394. /** @hidden */
  20395. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20396. private _deleteBuffer;
  20397. protected _format: Nullable<number>;
  20398. private _delayedOnLoad;
  20399. private _delayedOnError;
  20400. private _mimeType?;
  20401. /**
  20402. * Observable triggered once the texture has been loaded.
  20403. */
  20404. onLoadObservable: Observable<Texture>;
  20405. protected _isBlocking: boolean;
  20406. /**
  20407. * Is the texture preventing material to render while loading.
  20408. * If false, a default texture will be used instead of the loading one during the preparation step.
  20409. */
  20410. set isBlocking(value: boolean);
  20411. get isBlocking(): boolean;
  20412. /**
  20413. * Get the current sampling mode associated with the texture.
  20414. */
  20415. get samplingMode(): number;
  20416. /**
  20417. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20418. */
  20419. get invertY(): boolean;
  20420. /**
  20421. * Instantiates a new texture.
  20422. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20423. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20424. * @param url defines the url of the picture to load as a texture
  20425. * @param scene defines the scene or engine the texture will belong to
  20426. * @param noMipmap defines if the texture will require mip maps or not
  20427. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20428. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20429. * @param onLoad defines a callback triggered when the texture has been loaded
  20430. * @param onError defines a callback triggered when an error occurred during the loading session
  20431. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20432. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20433. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20434. * @param mimeType defines an optional mime type information
  20435. */
  20436. 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);
  20437. /**
  20438. * Update the url (and optional buffer) of this texture if url was null during construction.
  20439. * @param url the url of the texture
  20440. * @param buffer the buffer of the texture (defaults to null)
  20441. * @param onLoad callback called when the texture is loaded (defaults to null)
  20442. */
  20443. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20444. /**
  20445. * Finish the loading sequence of a texture flagged as delayed load.
  20446. * @hidden
  20447. */
  20448. delayLoad(): void;
  20449. private _prepareRowForTextureGeneration;
  20450. /**
  20451. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20452. * @returns the transform matrix of the texture.
  20453. */
  20454. getTextureMatrix(uBase?: number): Matrix;
  20455. /**
  20456. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20457. * @returns The reflection texture transform
  20458. */
  20459. getReflectionTextureMatrix(): Matrix;
  20460. /**
  20461. * Clones the texture.
  20462. * @returns the cloned texture
  20463. */
  20464. clone(): Texture;
  20465. /**
  20466. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20467. * @returns The JSON representation of the texture
  20468. */
  20469. serialize(): any;
  20470. /**
  20471. * Get the current class name of the texture useful for serialization or dynamic coding.
  20472. * @returns "Texture"
  20473. */
  20474. getClassName(): string;
  20475. /**
  20476. * Dispose the texture and release its associated resources.
  20477. */
  20478. dispose(): void;
  20479. /**
  20480. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20481. * @param parsedTexture Define the JSON representation of the texture
  20482. * @param scene Define the scene the parsed texture should be instantiated in
  20483. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20484. * @returns The parsed texture if successful
  20485. */
  20486. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20487. /**
  20488. * Creates a texture from its base 64 representation.
  20489. * @param data Define the base64 payload without the data: prefix
  20490. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20491. * @param scene Define the scene the texture should belong to
  20492. * @param noMipmap Forces the texture to not create mip map information if true
  20493. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20494. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20495. * @param onLoad define a callback triggered when the texture has been loaded
  20496. * @param onError define a callback triggered when an error occurred during the loading session
  20497. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20498. * @returns the created texture
  20499. */
  20500. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20501. /**
  20502. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20503. * @param data Define the base64 payload without the data: prefix
  20504. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20505. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20506. * @param scene Define the scene the texture should belong to
  20507. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20508. * @param noMipmap Forces the texture to not create mip map information if true
  20509. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20510. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20511. * @param onLoad define a callback triggered when the texture has been loaded
  20512. * @param onError define a callback triggered when an error occurred during the loading session
  20513. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20514. * @returns the created texture
  20515. */
  20516. 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;
  20517. }
  20518. }
  20519. declare module BABYLON {
  20520. /**
  20521. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20522. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20523. */
  20524. export class PostProcessManager {
  20525. private _scene;
  20526. private _indexBuffer;
  20527. private _vertexBuffers;
  20528. /**
  20529. * Creates a new instance PostProcess
  20530. * @param scene The scene that the post process is associated with.
  20531. */
  20532. constructor(scene: Scene);
  20533. private _prepareBuffers;
  20534. private _buildIndexBuffer;
  20535. /**
  20536. * Rebuilds the vertex buffers of the manager.
  20537. * @hidden
  20538. */
  20539. _rebuild(): void;
  20540. /**
  20541. * Prepares a frame to be run through a post process.
  20542. * @param sourceTexture The input texture to the post procesess. (default: null)
  20543. * @param postProcesses An array of post processes to be run. (default: null)
  20544. * @returns True if the post processes were able to be run.
  20545. * @hidden
  20546. */
  20547. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20548. /**
  20549. * Manually render a set of post processes to a texture.
  20550. * @param postProcesses An array of post processes to be run.
  20551. * @param targetTexture The target texture to render to.
  20552. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20553. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20554. * @param lodLevel defines which lod of the texture to render to
  20555. */
  20556. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20557. /**
  20558. * Finalize the result of the output of the postprocesses.
  20559. * @param doNotPresent If true the result will not be displayed to the screen.
  20560. * @param targetTexture The target texture to render to.
  20561. * @param faceIndex The index of the face to bind the target texture to.
  20562. * @param postProcesses The array of post processes to render.
  20563. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20564. * @hidden
  20565. */
  20566. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20567. /**
  20568. * Disposes of the post process manager.
  20569. */
  20570. dispose(): void;
  20571. }
  20572. }
  20573. declare module BABYLON {
  20574. /**
  20575. * This Helps creating a texture that will be created from a camera in your scene.
  20576. * It is basically a dynamic texture that could be used to create special effects for instance.
  20577. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20578. */
  20579. export class RenderTargetTexture extends Texture {
  20580. isCube: boolean;
  20581. /**
  20582. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20583. */
  20584. static readonly REFRESHRATE_RENDER_ONCE: number;
  20585. /**
  20586. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20587. */
  20588. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20589. /**
  20590. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20591. * the central point of your effect and can save a lot of performances.
  20592. */
  20593. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20594. /**
  20595. * Use this predicate to dynamically define the list of mesh you want to render.
  20596. * If set, the renderList property will be overwritten.
  20597. */
  20598. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20599. private _renderList;
  20600. /**
  20601. * Use this list to define the list of mesh you want to render.
  20602. */
  20603. get renderList(): Nullable<Array<AbstractMesh>>;
  20604. set renderList(value: Nullable<Array<AbstractMesh>>);
  20605. /**
  20606. * Use this function to overload the renderList array at rendering time.
  20607. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20608. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20609. * the cube (if the RTT is a cube, else layerOrFace=0).
  20610. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20611. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20612. * hold dummy elements!
  20613. */
  20614. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20615. private _hookArray;
  20616. /**
  20617. * Define if particles should be rendered in your texture.
  20618. */
  20619. renderParticles: boolean;
  20620. /**
  20621. * Define if sprites should be rendered in your texture.
  20622. */
  20623. renderSprites: boolean;
  20624. /**
  20625. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20626. */
  20627. coordinatesMode: number;
  20628. /**
  20629. * Define the camera used to render the texture.
  20630. */
  20631. activeCamera: Nullable<Camera>;
  20632. /**
  20633. * Override the mesh isReady function with your own one.
  20634. */
  20635. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  20636. /**
  20637. * Override the render function of the texture with your own one.
  20638. */
  20639. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20640. /**
  20641. * Define if camera post processes should be use while rendering the texture.
  20642. */
  20643. useCameraPostProcesses: boolean;
  20644. /**
  20645. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20646. */
  20647. ignoreCameraViewport: boolean;
  20648. private _postProcessManager;
  20649. private _postProcesses;
  20650. private _resizeObserver;
  20651. /**
  20652. * An event triggered when the texture is unbind.
  20653. */
  20654. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20655. /**
  20656. * An event triggered when the texture is unbind.
  20657. */
  20658. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20659. private _onAfterUnbindObserver;
  20660. /**
  20661. * Set a after unbind callback in the texture.
  20662. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20663. */
  20664. set onAfterUnbind(callback: () => void);
  20665. /**
  20666. * An event triggered before rendering the texture
  20667. */
  20668. onBeforeRenderObservable: Observable<number>;
  20669. private _onBeforeRenderObserver;
  20670. /**
  20671. * Set a before render callback in the texture.
  20672. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20673. */
  20674. set onBeforeRender(callback: (faceIndex: number) => void);
  20675. /**
  20676. * An event triggered after rendering the texture
  20677. */
  20678. onAfterRenderObservable: Observable<number>;
  20679. private _onAfterRenderObserver;
  20680. /**
  20681. * Set a after render callback in the texture.
  20682. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20683. */
  20684. set onAfterRender(callback: (faceIndex: number) => void);
  20685. /**
  20686. * An event triggered after the texture clear
  20687. */
  20688. onClearObservable: Observable<Engine>;
  20689. private _onClearObserver;
  20690. /**
  20691. * Set a clear callback in the texture.
  20692. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20693. */
  20694. set onClear(callback: (Engine: Engine) => void);
  20695. /**
  20696. * An event triggered when the texture is resized.
  20697. */
  20698. onResizeObservable: Observable<RenderTargetTexture>;
  20699. /**
  20700. * Define the clear color of the Render Target if it should be different from the scene.
  20701. */
  20702. clearColor: Color4;
  20703. protected _size: number | {
  20704. width: number;
  20705. height: number;
  20706. layers?: number;
  20707. };
  20708. protected _initialSizeParameter: number | {
  20709. width: number;
  20710. height: number;
  20711. } | {
  20712. ratio: number;
  20713. };
  20714. protected _sizeRatio: Nullable<number>;
  20715. /** @hidden */
  20716. _generateMipMaps: boolean;
  20717. protected _renderingManager: RenderingManager;
  20718. /** @hidden */
  20719. _waitingRenderList: string[];
  20720. protected _doNotChangeAspectRatio: boolean;
  20721. protected _currentRefreshId: number;
  20722. protected _refreshRate: number;
  20723. protected _textureMatrix: Matrix;
  20724. protected _samples: number;
  20725. protected _renderTargetOptions: RenderTargetCreationOptions;
  20726. /**
  20727. * Gets render target creation options that were used.
  20728. */
  20729. get renderTargetOptions(): RenderTargetCreationOptions;
  20730. protected _engine: Engine;
  20731. protected _onRatioRescale(): void;
  20732. /**
  20733. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20734. * It must define where the camera used to render the texture is set
  20735. */
  20736. boundingBoxPosition: Vector3;
  20737. private _boundingBoxSize;
  20738. /**
  20739. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20740. * When defined, the cubemap will switch to local mode
  20741. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20742. * @example https://www.babylonjs-playground.com/#RNASML
  20743. */
  20744. set boundingBoxSize(value: Vector3);
  20745. get boundingBoxSize(): Vector3;
  20746. /**
  20747. * In case the RTT has been created with a depth texture, get the associated
  20748. * depth texture.
  20749. * Otherwise, return null.
  20750. */
  20751. get depthStencilTexture(): Nullable<InternalTexture>;
  20752. /**
  20753. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20754. * or used a shadow, depth texture...
  20755. * @param name The friendly name of the texture
  20756. * @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)
  20757. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20758. * @param generateMipMaps True if mip maps need to be generated after render.
  20759. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20760. * @param type The type of the buffer in the RTT (int, half float, float...)
  20761. * @param isCube True if a cube texture needs to be created
  20762. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20763. * @param generateDepthBuffer True to generate a depth buffer
  20764. * @param generateStencilBuffer True to generate a stencil buffer
  20765. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20766. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20767. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20768. */
  20769. constructor(name: string, size: number | {
  20770. width: number;
  20771. height: number;
  20772. layers?: number;
  20773. } | {
  20774. ratio: number;
  20775. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20776. /**
  20777. * Creates a depth stencil texture.
  20778. * This is only available in WebGL 2 or with the depth texture extension available.
  20779. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20780. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20781. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20782. */
  20783. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20784. private _processSizeParameter;
  20785. /**
  20786. * Define the number of samples to use in case of MSAA.
  20787. * It defaults to one meaning no MSAA has been enabled.
  20788. */
  20789. get samples(): number;
  20790. set samples(value: number);
  20791. /**
  20792. * Resets the refresh counter of the texture and start bak from scratch.
  20793. * Could be useful to regenerate the texture if it is setup to render only once.
  20794. */
  20795. resetRefreshCounter(): void;
  20796. /**
  20797. * Define the refresh rate of the texture or the rendering frequency.
  20798. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20799. */
  20800. get refreshRate(): number;
  20801. set refreshRate(value: number);
  20802. /**
  20803. * Adds a post process to the render target rendering passes.
  20804. * @param postProcess define the post process to add
  20805. */
  20806. addPostProcess(postProcess: PostProcess): void;
  20807. /**
  20808. * Clear all the post processes attached to the render target
  20809. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20810. */
  20811. clearPostProcesses(dispose?: boolean): void;
  20812. /**
  20813. * Remove one of the post process from the list of attached post processes to the texture
  20814. * @param postProcess define the post process to remove from the list
  20815. */
  20816. removePostProcess(postProcess: PostProcess): void;
  20817. /** @hidden */
  20818. _shouldRender(): boolean;
  20819. /**
  20820. * Gets the actual render size of the texture.
  20821. * @returns the width of the render size
  20822. */
  20823. getRenderSize(): number;
  20824. /**
  20825. * Gets the actual render width of the texture.
  20826. * @returns the width of the render size
  20827. */
  20828. getRenderWidth(): number;
  20829. /**
  20830. * Gets the actual render height of the texture.
  20831. * @returns the height of the render size
  20832. */
  20833. getRenderHeight(): number;
  20834. /**
  20835. * Gets the actual number of layers of the texture.
  20836. * @returns the number of layers
  20837. */
  20838. getRenderLayers(): number;
  20839. /**
  20840. * Get if the texture can be rescaled or not.
  20841. */
  20842. get canRescale(): boolean;
  20843. /**
  20844. * Resize the texture using a ratio.
  20845. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20846. */
  20847. scale(ratio: number): void;
  20848. /**
  20849. * Get the texture reflection matrix used to rotate/transform the reflection.
  20850. * @returns the reflection matrix
  20851. */
  20852. getReflectionTextureMatrix(): Matrix;
  20853. /**
  20854. * Resize the texture to a new desired size.
  20855. * Be carrefull as it will recreate all the data in the new texture.
  20856. * @param size Define the new size. It can be:
  20857. * - a number for squared texture,
  20858. * - an object containing { width: number, height: number }
  20859. * - or an object containing a ratio { ratio: number }
  20860. */
  20861. resize(size: number | {
  20862. width: number;
  20863. height: number;
  20864. } | {
  20865. ratio: number;
  20866. }): void;
  20867. private _defaultRenderListPrepared;
  20868. /**
  20869. * Renders all the objects from the render list into the texture.
  20870. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20871. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20872. */
  20873. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20874. private _bestReflectionRenderTargetDimension;
  20875. private _prepareRenderingManager;
  20876. /**
  20877. * @hidden
  20878. * @param faceIndex face index to bind to if this is a cubetexture
  20879. * @param layer defines the index of the texture to bind in the array
  20880. */
  20881. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20882. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20883. private renderToTarget;
  20884. /**
  20885. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20886. * This allowed control for front to back rendering or reversly depending of the special needs.
  20887. *
  20888. * @param renderingGroupId The rendering group id corresponding to its index
  20889. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20890. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20891. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20892. */
  20893. 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;
  20894. /**
  20895. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20896. *
  20897. * @param renderingGroupId The rendering group id corresponding to its index
  20898. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20899. */
  20900. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20901. /**
  20902. * Clones the texture.
  20903. * @returns the cloned texture
  20904. */
  20905. clone(): RenderTargetTexture;
  20906. /**
  20907. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20908. * @returns The JSON representation of the texture
  20909. */
  20910. serialize(): any;
  20911. /**
  20912. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20913. */
  20914. disposeFramebufferObjects(): void;
  20915. /**
  20916. * Dispose the texture and release its associated resources.
  20917. */
  20918. dispose(): void;
  20919. /** @hidden */
  20920. _rebuild(): void;
  20921. /**
  20922. * Clear the info related to rendering groups preventing retention point in material dispose.
  20923. */
  20924. freeRenderingGroups(): void;
  20925. /**
  20926. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20927. * @returns the view count
  20928. */
  20929. getViewCount(): number;
  20930. }
  20931. }
  20932. declare module BABYLON {
  20933. /**
  20934. * Options for compiling materials.
  20935. */
  20936. export interface IMaterialCompilationOptions {
  20937. /**
  20938. * Defines whether clip planes are enabled.
  20939. */
  20940. clipPlane: boolean;
  20941. /**
  20942. * Defines whether instances are enabled.
  20943. */
  20944. useInstances: boolean;
  20945. }
  20946. /**
  20947. * Base class for the main features of a material in Babylon.js
  20948. */
  20949. export class Material implements IAnimatable {
  20950. /**
  20951. * Returns the triangle fill mode
  20952. */
  20953. static readonly TriangleFillMode: number;
  20954. /**
  20955. * Returns the wireframe mode
  20956. */
  20957. static readonly WireFrameFillMode: number;
  20958. /**
  20959. * Returns the point fill mode
  20960. */
  20961. static readonly PointFillMode: number;
  20962. /**
  20963. * Returns the point list draw mode
  20964. */
  20965. static readonly PointListDrawMode: number;
  20966. /**
  20967. * Returns the line list draw mode
  20968. */
  20969. static readonly LineListDrawMode: number;
  20970. /**
  20971. * Returns the line loop draw mode
  20972. */
  20973. static readonly LineLoopDrawMode: number;
  20974. /**
  20975. * Returns the line strip draw mode
  20976. */
  20977. static readonly LineStripDrawMode: number;
  20978. /**
  20979. * Returns the triangle strip draw mode
  20980. */
  20981. static readonly TriangleStripDrawMode: number;
  20982. /**
  20983. * Returns the triangle fan draw mode
  20984. */
  20985. static readonly TriangleFanDrawMode: number;
  20986. /**
  20987. * Stores the clock-wise side orientation
  20988. */
  20989. static readonly ClockWiseSideOrientation: number;
  20990. /**
  20991. * Stores the counter clock-wise side orientation
  20992. */
  20993. static readonly CounterClockWiseSideOrientation: number;
  20994. /**
  20995. * The dirty texture flag value
  20996. */
  20997. static readonly TextureDirtyFlag: number;
  20998. /**
  20999. * The dirty light flag value
  21000. */
  21001. static readonly LightDirtyFlag: number;
  21002. /**
  21003. * The dirty fresnel flag value
  21004. */
  21005. static readonly FresnelDirtyFlag: number;
  21006. /**
  21007. * The dirty attribute flag value
  21008. */
  21009. static readonly AttributesDirtyFlag: number;
  21010. /**
  21011. * The dirty misc flag value
  21012. */
  21013. static readonly MiscDirtyFlag: number;
  21014. /**
  21015. * The all dirty flag value
  21016. */
  21017. static readonly AllDirtyFlag: number;
  21018. /**
  21019. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21020. */
  21021. static readonly MATERIAL_OPAQUE: number;
  21022. /**
  21023. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21024. */
  21025. static readonly MATERIAL_ALPHATEST: number;
  21026. /**
  21027. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21028. */
  21029. static readonly MATERIAL_ALPHABLEND: number;
  21030. /**
  21031. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21032. * They are also discarded below the alpha cutoff threshold to improve performances.
  21033. */
  21034. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21035. /**
  21036. * The ID of the material
  21037. */
  21038. id: string;
  21039. /**
  21040. * Gets or sets the unique id of the material
  21041. */
  21042. uniqueId: number;
  21043. /**
  21044. * The name of the material
  21045. */
  21046. name: string;
  21047. /**
  21048. * Gets or sets user defined metadata
  21049. */
  21050. metadata: any;
  21051. /**
  21052. * For internal use only. Please do not use.
  21053. */
  21054. reservedDataStore: any;
  21055. /**
  21056. * Specifies if the ready state should be checked on each call
  21057. */
  21058. checkReadyOnEveryCall: boolean;
  21059. /**
  21060. * Specifies if the ready state should be checked once
  21061. */
  21062. checkReadyOnlyOnce: boolean;
  21063. /**
  21064. * The state of the material
  21065. */
  21066. state: string;
  21067. /**
  21068. * The alpha value of the material
  21069. */
  21070. protected _alpha: number;
  21071. /**
  21072. * List of inspectable custom properties (used by the Inspector)
  21073. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21074. */
  21075. inspectableCustomProperties: IInspectable[];
  21076. /**
  21077. * Sets the alpha value of the material
  21078. */
  21079. set alpha(value: number);
  21080. /**
  21081. * Gets the alpha value of the material
  21082. */
  21083. get alpha(): number;
  21084. /**
  21085. * Specifies if back face culling is enabled
  21086. */
  21087. protected _backFaceCulling: boolean;
  21088. /**
  21089. * Sets the back-face culling state
  21090. */
  21091. set backFaceCulling(value: boolean);
  21092. /**
  21093. * Gets the back-face culling state
  21094. */
  21095. get backFaceCulling(): boolean;
  21096. /**
  21097. * Stores the value for side orientation
  21098. */
  21099. sideOrientation: number;
  21100. /**
  21101. * Callback triggered when the material is compiled
  21102. */
  21103. onCompiled: Nullable<(effect: Effect) => void>;
  21104. /**
  21105. * Callback triggered when an error occurs
  21106. */
  21107. onError: Nullable<(effect: Effect, errors: string) => void>;
  21108. /**
  21109. * Callback triggered to get the render target textures
  21110. */
  21111. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21112. /**
  21113. * Gets a boolean indicating that current material needs to register RTT
  21114. */
  21115. get hasRenderTargetTextures(): boolean;
  21116. /**
  21117. * Specifies if the material should be serialized
  21118. */
  21119. doNotSerialize: boolean;
  21120. /**
  21121. * @hidden
  21122. */
  21123. _storeEffectOnSubMeshes: boolean;
  21124. /**
  21125. * Stores the animations for the material
  21126. */
  21127. animations: Nullable<Array<Animation>>;
  21128. /**
  21129. * An event triggered when the material is disposed
  21130. */
  21131. onDisposeObservable: Observable<Material>;
  21132. /**
  21133. * An observer which watches for dispose events
  21134. */
  21135. private _onDisposeObserver;
  21136. private _onUnBindObservable;
  21137. /**
  21138. * Called during a dispose event
  21139. */
  21140. set onDispose(callback: () => void);
  21141. private _onBindObservable;
  21142. /**
  21143. * An event triggered when the material is bound
  21144. */
  21145. get onBindObservable(): Observable<AbstractMesh>;
  21146. /**
  21147. * An observer which watches for bind events
  21148. */
  21149. private _onBindObserver;
  21150. /**
  21151. * Called during a bind event
  21152. */
  21153. set onBind(callback: (Mesh: AbstractMesh) => void);
  21154. /**
  21155. * An event triggered when the material is unbound
  21156. */
  21157. get onUnBindObservable(): Observable<Material>;
  21158. /**
  21159. * Stores the value of the alpha mode
  21160. */
  21161. private _alphaMode;
  21162. /**
  21163. * Sets the value of the alpha mode.
  21164. *
  21165. * | Value | Type | Description |
  21166. * | --- | --- | --- |
  21167. * | 0 | ALPHA_DISABLE | |
  21168. * | 1 | ALPHA_ADD | |
  21169. * | 2 | ALPHA_COMBINE | |
  21170. * | 3 | ALPHA_SUBTRACT | |
  21171. * | 4 | ALPHA_MULTIPLY | |
  21172. * | 5 | ALPHA_MAXIMIZED | |
  21173. * | 6 | ALPHA_ONEONE | |
  21174. * | 7 | ALPHA_PREMULTIPLIED | |
  21175. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21176. * | 9 | ALPHA_INTERPOLATE | |
  21177. * | 10 | ALPHA_SCREENMODE | |
  21178. *
  21179. */
  21180. set alphaMode(value: number);
  21181. /**
  21182. * Gets the value of the alpha mode
  21183. */
  21184. get alphaMode(): number;
  21185. /**
  21186. * Stores the state of the need depth pre-pass value
  21187. */
  21188. private _needDepthPrePass;
  21189. /**
  21190. * Sets the need depth pre-pass value
  21191. */
  21192. set needDepthPrePass(value: boolean);
  21193. /**
  21194. * Gets the depth pre-pass value
  21195. */
  21196. get needDepthPrePass(): boolean;
  21197. /**
  21198. * Specifies if depth writing should be disabled
  21199. */
  21200. disableDepthWrite: boolean;
  21201. /**
  21202. * Specifies if depth writing should be forced
  21203. */
  21204. forceDepthWrite: boolean;
  21205. /**
  21206. * Specifies the depth function that should be used. 0 means the default engine function
  21207. */
  21208. depthFunction: number;
  21209. /**
  21210. * Specifies if there should be a separate pass for culling
  21211. */
  21212. separateCullingPass: boolean;
  21213. /**
  21214. * Stores the state specifing if fog should be enabled
  21215. */
  21216. private _fogEnabled;
  21217. /**
  21218. * Sets the state for enabling fog
  21219. */
  21220. set fogEnabled(value: boolean);
  21221. /**
  21222. * Gets the value of the fog enabled state
  21223. */
  21224. get fogEnabled(): boolean;
  21225. /**
  21226. * Stores the size of points
  21227. */
  21228. pointSize: number;
  21229. /**
  21230. * Stores the z offset value
  21231. */
  21232. zOffset: number;
  21233. /**
  21234. * Gets a value specifying if wireframe mode is enabled
  21235. */
  21236. get wireframe(): boolean;
  21237. /**
  21238. * Sets the state of wireframe mode
  21239. */
  21240. set wireframe(value: boolean);
  21241. /**
  21242. * Gets the value specifying if point clouds are enabled
  21243. */
  21244. get pointsCloud(): boolean;
  21245. /**
  21246. * Sets the state of point cloud mode
  21247. */
  21248. set pointsCloud(value: boolean);
  21249. /**
  21250. * Gets the material fill mode
  21251. */
  21252. get fillMode(): number;
  21253. /**
  21254. * Sets the material fill mode
  21255. */
  21256. set fillMode(value: number);
  21257. /**
  21258. * @hidden
  21259. * Stores the effects for the material
  21260. */
  21261. _effect: Nullable<Effect>;
  21262. /**
  21263. * Specifies if uniform buffers should be used
  21264. */
  21265. private _useUBO;
  21266. /**
  21267. * Stores a reference to the scene
  21268. */
  21269. private _scene;
  21270. /**
  21271. * Stores the fill mode state
  21272. */
  21273. private _fillMode;
  21274. /**
  21275. * Specifies if the depth write state should be cached
  21276. */
  21277. private _cachedDepthWriteState;
  21278. /**
  21279. * Specifies if the depth function state should be cached
  21280. */
  21281. private _cachedDepthFunctionState;
  21282. /**
  21283. * Stores the uniform buffer
  21284. */
  21285. protected _uniformBuffer: UniformBuffer;
  21286. /** @hidden */
  21287. _indexInSceneMaterialArray: number;
  21288. /** @hidden */
  21289. meshMap: Nullable<{
  21290. [id: string]: AbstractMesh | undefined;
  21291. }>;
  21292. /**
  21293. * Creates a material instance
  21294. * @param name defines the name of the material
  21295. * @param scene defines the scene to reference
  21296. * @param doNotAdd specifies if the material should be added to the scene
  21297. */
  21298. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21299. /**
  21300. * Returns a string representation of the current material
  21301. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21302. * @returns a string with material information
  21303. */
  21304. toString(fullDetails?: boolean): string;
  21305. /**
  21306. * Gets the class name of the material
  21307. * @returns a string with the class name of the material
  21308. */
  21309. getClassName(): string;
  21310. /**
  21311. * Specifies if updates for the material been locked
  21312. */
  21313. get isFrozen(): boolean;
  21314. /**
  21315. * Locks updates for the material
  21316. */
  21317. freeze(): void;
  21318. /**
  21319. * Unlocks updates for the material
  21320. */
  21321. unfreeze(): void;
  21322. /**
  21323. * Specifies if the material is ready to be used
  21324. * @param mesh defines the mesh to check
  21325. * @param useInstances specifies if instances should be used
  21326. * @returns a boolean indicating if the material is ready to be used
  21327. */
  21328. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21329. /**
  21330. * Specifies that the submesh is ready to be used
  21331. * @param mesh defines the mesh to check
  21332. * @param subMesh defines which submesh to check
  21333. * @param useInstances specifies that instances should be used
  21334. * @returns a boolean indicating that the submesh is ready or not
  21335. */
  21336. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21337. /**
  21338. * Returns the material effect
  21339. * @returns the effect associated with the material
  21340. */
  21341. getEffect(): Nullable<Effect>;
  21342. /**
  21343. * Returns the current scene
  21344. * @returns a Scene
  21345. */
  21346. getScene(): Scene;
  21347. /**
  21348. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21349. */
  21350. protected _forceAlphaTest: boolean;
  21351. /**
  21352. * The transparency mode of the material.
  21353. */
  21354. protected _transparencyMode: Nullable<number>;
  21355. /**
  21356. * Gets the current transparency mode.
  21357. */
  21358. get transparencyMode(): Nullable<number>;
  21359. /**
  21360. * Sets the transparency mode of the material.
  21361. *
  21362. * | Value | Type | Description |
  21363. * | ----- | ----------------------------------- | ----------- |
  21364. * | 0 | OPAQUE | |
  21365. * | 1 | ALPHATEST | |
  21366. * | 2 | ALPHABLEND | |
  21367. * | 3 | ALPHATESTANDBLEND | |
  21368. *
  21369. */
  21370. set transparencyMode(value: Nullable<number>);
  21371. /**
  21372. * Returns true if alpha blending should be disabled.
  21373. */
  21374. protected get _disableAlphaBlending(): boolean;
  21375. /**
  21376. * Specifies whether or not this material should be rendered in alpha blend mode.
  21377. * @returns a boolean specifying if alpha blending is needed
  21378. */
  21379. needAlphaBlending(): boolean;
  21380. /**
  21381. * Specifies if the mesh will require alpha blending
  21382. * @param mesh defines the mesh to check
  21383. * @returns a boolean specifying if alpha blending is needed for the mesh
  21384. */
  21385. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21386. /**
  21387. * Specifies whether or not this material should be rendered in alpha test mode.
  21388. * @returns a boolean specifying if an alpha test is needed.
  21389. */
  21390. needAlphaTesting(): boolean;
  21391. /**
  21392. * Specifies if material alpha testing should be turned on for the mesh
  21393. * @param mesh defines the mesh to check
  21394. */
  21395. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21396. /**
  21397. * Gets the texture used for the alpha test
  21398. * @returns the texture to use for alpha testing
  21399. */
  21400. getAlphaTestTexture(): Nullable<BaseTexture>;
  21401. /**
  21402. * Marks the material to indicate that it needs to be re-calculated
  21403. */
  21404. markDirty(): void;
  21405. /** @hidden */
  21406. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21407. /**
  21408. * Binds the material to the mesh
  21409. * @param world defines the world transformation matrix
  21410. * @param mesh defines the mesh to bind the material to
  21411. */
  21412. bind(world: Matrix, mesh?: Mesh): void;
  21413. /**
  21414. * Binds the submesh to the material
  21415. * @param world defines the world transformation matrix
  21416. * @param mesh defines the mesh containing the submesh
  21417. * @param subMesh defines the submesh to bind the material to
  21418. */
  21419. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21420. /**
  21421. * Binds the world matrix to the material
  21422. * @param world defines the world transformation matrix
  21423. */
  21424. bindOnlyWorldMatrix(world: Matrix): void;
  21425. /**
  21426. * Binds the scene's uniform buffer to the effect.
  21427. * @param effect defines the effect to bind to the scene uniform buffer
  21428. * @param sceneUbo defines the uniform buffer storing scene data
  21429. */
  21430. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21431. /**
  21432. * Binds the view matrix to the effect
  21433. * @param effect defines the effect to bind the view matrix to
  21434. */
  21435. bindView(effect: Effect): void;
  21436. /**
  21437. * Binds the view projection matrix to the effect
  21438. * @param effect defines the effect to bind the view projection matrix to
  21439. */
  21440. bindViewProjection(effect: Effect): void;
  21441. /**
  21442. * Processes to execute after binding the material to a mesh
  21443. * @param mesh defines the rendered mesh
  21444. */
  21445. protected _afterBind(mesh?: Mesh): void;
  21446. /**
  21447. * Unbinds the material from the mesh
  21448. */
  21449. unbind(): void;
  21450. /**
  21451. * Gets the active textures from the material
  21452. * @returns an array of textures
  21453. */
  21454. getActiveTextures(): BaseTexture[];
  21455. /**
  21456. * Specifies if the material uses a texture
  21457. * @param texture defines the texture to check against the material
  21458. * @returns a boolean specifying if the material uses the texture
  21459. */
  21460. hasTexture(texture: BaseTexture): boolean;
  21461. /**
  21462. * Makes a duplicate of the material, and gives it a new name
  21463. * @param name defines the new name for the duplicated material
  21464. * @returns the cloned material
  21465. */
  21466. clone(name: string): Nullable<Material>;
  21467. /**
  21468. * Gets the meshes bound to the material
  21469. * @returns an array of meshes bound to the material
  21470. */
  21471. getBindedMeshes(): AbstractMesh[];
  21472. /**
  21473. * Force shader compilation
  21474. * @param mesh defines the mesh associated with this material
  21475. * @param onCompiled defines a function to execute once the material is compiled
  21476. * @param options defines the options to configure the compilation
  21477. * @param onError defines a function to execute if the material fails compiling
  21478. */
  21479. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21480. /**
  21481. * Force shader compilation
  21482. * @param mesh defines the mesh that will use this material
  21483. * @param options defines additional options for compiling the shaders
  21484. * @returns a promise that resolves when the compilation completes
  21485. */
  21486. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21487. private static readonly _AllDirtyCallBack;
  21488. private static readonly _ImageProcessingDirtyCallBack;
  21489. private static readonly _TextureDirtyCallBack;
  21490. private static readonly _FresnelDirtyCallBack;
  21491. private static readonly _MiscDirtyCallBack;
  21492. private static readonly _LightsDirtyCallBack;
  21493. private static readonly _AttributeDirtyCallBack;
  21494. private static _FresnelAndMiscDirtyCallBack;
  21495. private static _TextureAndMiscDirtyCallBack;
  21496. private static readonly _DirtyCallbackArray;
  21497. private static readonly _RunDirtyCallBacks;
  21498. /**
  21499. * Marks a define in the material to indicate that it needs to be re-computed
  21500. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21501. */
  21502. markAsDirty(flag: number): void;
  21503. /**
  21504. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21505. * @param func defines a function which checks material defines against the submeshes
  21506. */
  21507. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21508. /**
  21509. * Indicates that we need to re-calculated for all submeshes
  21510. */
  21511. protected _markAllSubMeshesAsAllDirty(): void;
  21512. /**
  21513. * Indicates that image processing needs to be re-calculated for all submeshes
  21514. */
  21515. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21516. /**
  21517. * Indicates that textures need to be re-calculated for all submeshes
  21518. */
  21519. protected _markAllSubMeshesAsTexturesDirty(): void;
  21520. /**
  21521. * Indicates that fresnel needs to be re-calculated for all submeshes
  21522. */
  21523. protected _markAllSubMeshesAsFresnelDirty(): void;
  21524. /**
  21525. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21526. */
  21527. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21528. /**
  21529. * Indicates that lights need to be re-calculated for all submeshes
  21530. */
  21531. protected _markAllSubMeshesAsLightsDirty(): void;
  21532. /**
  21533. * Indicates that attributes need to be re-calculated for all submeshes
  21534. */
  21535. protected _markAllSubMeshesAsAttributesDirty(): void;
  21536. /**
  21537. * Indicates that misc needs to be re-calculated for all submeshes
  21538. */
  21539. protected _markAllSubMeshesAsMiscDirty(): void;
  21540. /**
  21541. * Indicates that textures and misc need to be re-calculated for all submeshes
  21542. */
  21543. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21544. /**
  21545. * Disposes the material
  21546. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21547. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21548. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21549. */
  21550. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21551. /** @hidden */
  21552. private releaseVertexArrayObject;
  21553. /**
  21554. * Serializes this material
  21555. * @returns the serialized material object
  21556. */
  21557. serialize(): any;
  21558. /**
  21559. * Creates a material from parsed material data
  21560. * @param parsedMaterial defines parsed material data
  21561. * @param scene defines the hosting scene
  21562. * @param rootUrl defines the root URL to use to load textures
  21563. * @returns a new material
  21564. */
  21565. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21566. }
  21567. }
  21568. declare module BABYLON {
  21569. /**
  21570. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21571. * separate meshes. This can be use to improve performances.
  21572. * @see http://doc.babylonjs.com/how_to/multi_materials
  21573. */
  21574. export class MultiMaterial extends Material {
  21575. private _subMaterials;
  21576. /**
  21577. * Gets or Sets the list of Materials used within the multi material.
  21578. * They need to be ordered according to the submeshes order in the associated mesh
  21579. */
  21580. get subMaterials(): Nullable<Material>[];
  21581. set subMaterials(value: Nullable<Material>[]);
  21582. /**
  21583. * Function used to align with Node.getChildren()
  21584. * @returns the list of Materials used within the multi material
  21585. */
  21586. getChildren(): Nullable<Material>[];
  21587. /**
  21588. * Instantiates a new Multi Material
  21589. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21590. * separate meshes. This can be use to improve performances.
  21591. * @see http://doc.babylonjs.com/how_to/multi_materials
  21592. * @param name Define the name in the scene
  21593. * @param scene Define the scene the material belongs to
  21594. */
  21595. constructor(name: string, scene: Scene);
  21596. private _hookArray;
  21597. /**
  21598. * Get one of the submaterial by its index in the submaterials array
  21599. * @param index The index to look the sub material at
  21600. * @returns The Material if the index has been defined
  21601. */
  21602. getSubMaterial(index: number): Nullable<Material>;
  21603. /**
  21604. * Get the list of active textures for the whole sub materials list.
  21605. * @returns All the textures that will be used during the rendering
  21606. */
  21607. getActiveTextures(): BaseTexture[];
  21608. /**
  21609. * Gets the current class name of the material e.g. "MultiMaterial"
  21610. * Mainly use in serialization.
  21611. * @returns the class name
  21612. */
  21613. getClassName(): string;
  21614. /**
  21615. * Checks if the material is ready to render the requested sub mesh
  21616. * @param mesh Define the mesh the submesh belongs to
  21617. * @param subMesh Define the sub mesh to look readyness for
  21618. * @param useInstances Define whether or not the material is used with instances
  21619. * @returns true if ready, otherwise false
  21620. */
  21621. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21622. /**
  21623. * Clones the current material and its related sub materials
  21624. * @param name Define the name of the newly cloned material
  21625. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21626. * @returns the cloned material
  21627. */
  21628. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21629. /**
  21630. * Serializes the materials into a JSON representation.
  21631. * @returns the JSON representation
  21632. */
  21633. serialize(): any;
  21634. /**
  21635. * Dispose the material and release its associated resources
  21636. * @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)
  21637. * @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)
  21638. * @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)
  21639. */
  21640. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21641. /**
  21642. * Creates a MultiMaterial from parsed MultiMaterial data.
  21643. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21644. * @param scene defines the hosting scene
  21645. * @returns a new MultiMaterial
  21646. */
  21647. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21648. }
  21649. }
  21650. declare module BABYLON {
  21651. /**
  21652. * Base class for submeshes
  21653. */
  21654. export class BaseSubMesh {
  21655. /** @hidden */
  21656. _materialDefines: Nullable<MaterialDefines>;
  21657. /** @hidden */
  21658. _materialEffect: Nullable<Effect>;
  21659. /**
  21660. * Gets material defines used by the effect associated to the sub mesh
  21661. */
  21662. get materialDefines(): Nullable<MaterialDefines>;
  21663. /**
  21664. * Sets material defines used by the effect associated to the sub mesh
  21665. */
  21666. set materialDefines(defines: Nullable<MaterialDefines>);
  21667. /**
  21668. * Gets associated effect
  21669. */
  21670. get effect(): Nullable<Effect>;
  21671. /**
  21672. * Sets associated effect (effect used to render this submesh)
  21673. * @param effect defines the effect to associate with
  21674. * @param defines defines the set of defines used to compile this effect
  21675. */
  21676. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21677. }
  21678. /**
  21679. * Defines a subdivision inside a mesh
  21680. */
  21681. export class SubMesh extends BaseSubMesh implements ICullable {
  21682. /** the material index to use */
  21683. materialIndex: number;
  21684. /** vertex index start */
  21685. verticesStart: number;
  21686. /** vertices count */
  21687. verticesCount: number;
  21688. /** index start */
  21689. indexStart: number;
  21690. /** indices count */
  21691. indexCount: number;
  21692. /** @hidden */
  21693. _linesIndexCount: number;
  21694. private _mesh;
  21695. private _renderingMesh;
  21696. private _boundingInfo;
  21697. private _linesIndexBuffer;
  21698. /** @hidden */
  21699. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21700. /** @hidden */
  21701. _trianglePlanes: Plane[];
  21702. /** @hidden */
  21703. _lastColliderTransformMatrix: Nullable<Matrix>;
  21704. /** @hidden */
  21705. _renderId: number;
  21706. /** @hidden */
  21707. _alphaIndex: number;
  21708. /** @hidden */
  21709. _distanceToCamera: number;
  21710. /** @hidden */
  21711. _id: number;
  21712. private _currentMaterial;
  21713. /**
  21714. * Add a new submesh to a mesh
  21715. * @param materialIndex defines the material index to use
  21716. * @param verticesStart defines vertex index start
  21717. * @param verticesCount defines vertices count
  21718. * @param indexStart defines index start
  21719. * @param indexCount defines indices count
  21720. * @param mesh defines the parent mesh
  21721. * @param renderingMesh defines an optional rendering mesh
  21722. * @param createBoundingBox defines if bounding box should be created for this submesh
  21723. * @returns the new submesh
  21724. */
  21725. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21726. /**
  21727. * Creates a new submesh
  21728. * @param materialIndex defines the material index to use
  21729. * @param verticesStart defines vertex index start
  21730. * @param verticesCount defines vertices count
  21731. * @param indexStart defines index start
  21732. * @param indexCount defines indices count
  21733. * @param mesh defines the parent mesh
  21734. * @param renderingMesh defines an optional rendering mesh
  21735. * @param createBoundingBox defines if bounding box should be created for this submesh
  21736. */
  21737. constructor(
  21738. /** the material index to use */
  21739. materialIndex: number,
  21740. /** vertex index start */
  21741. verticesStart: number,
  21742. /** vertices count */
  21743. verticesCount: number,
  21744. /** index start */
  21745. indexStart: number,
  21746. /** indices count */
  21747. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21748. /**
  21749. * Returns true if this submesh covers the entire parent mesh
  21750. * @ignorenaming
  21751. */
  21752. get IsGlobal(): boolean;
  21753. /**
  21754. * Returns the submesh BoudingInfo object
  21755. * @returns current bounding info (or mesh's one if the submesh is global)
  21756. */
  21757. getBoundingInfo(): BoundingInfo;
  21758. /**
  21759. * Sets the submesh BoundingInfo
  21760. * @param boundingInfo defines the new bounding info to use
  21761. * @returns the SubMesh
  21762. */
  21763. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21764. /**
  21765. * Returns the mesh of the current submesh
  21766. * @return the parent mesh
  21767. */
  21768. getMesh(): AbstractMesh;
  21769. /**
  21770. * Returns the rendering mesh of the submesh
  21771. * @returns the rendering mesh (could be different from parent mesh)
  21772. */
  21773. getRenderingMesh(): Mesh;
  21774. /**
  21775. * Returns the submesh material
  21776. * @returns null or the current material
  21777. */
  21778. getMaterial(): Nullable<Material>;
  21779. /**
  21780. * Sets a new updated BoundingInfo object to the submesh
  21781. * @param data defines an optional position array to use to determine the bounding info
  21782. * @returns the SubMesh
  21783. */
  21784. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21785. /** @hidden */
  21786. _checkCollision(collider: Collider): boolean;
  21787. /**
  21788. * Updates the submesh BoundingInfo
  21789. * @param world defines the world matrix to use to update the bounding info
  21790. * @returns the submesh
  21791. */
  21792. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21793. /**
  21794. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21795. * @param frustumPlanes defines the frustum planes
  21796. * @returns true if the submesh is intersecting with the frustum
  21797. */
  21798. isInFrustum(frustumPlanes: Plane[]): boolean;
  21799. /**
  21800. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21801. * @param frustumPlanes defines the frustum planes
  21802. * @returns true if the submesh is inside the frustum
  21803. */
  21804. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21805. /**
  21806. * Renders the submesh
  21807. * @param enableAlphaMode defines if alpha needs to be used
  21808. * @returns the submesh
  21809. */
  21810. render(enableAlphaMode: boolean): SubMesh;
  21811. /**
  21812. * @hidden
  21813. */
  21814. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21815. /**
  21816. * Checks if the submesh intersects with a ray
  21817. * @param ray defines the ray to test
  21818. * @returns true is the passed ray intersects the submesh bounding box
  21819. */
  21820. canIntersects(ray: Ray): boolean;
  21821. /**
  21822. * Intersects current submesh with a ray
  21823. * @param ray defines the ray to test
  21824. * @param positions defines mesh's positions array
  21825. * @param indices defines mesh's indices array
  21826. * @param fastCheck defines if only bounding info should be used
  21827. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21828. * @returns intersection info or null if no intersection
  21829. */
  21830. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21831. /** @hidden */
  21832. private _intersectLines;
  21833. /** @hidden */
  21834. private _intersectUnIndexedLines;
  21835. /** @hidden */
  21836. private _intersectTriangles;
  21837. /** @hidden */
  21838. private _intersectUnIndexedTriangles;
  21839. /** @hidden */
  21840. _rebuild(): void;
  21841. /**
  21842. * Creates a new submesh from the passed mesh
  21843. * @param newMesh defines the new hosting mesh
  21844. * @param newRenderingMesh defines an optional rendering mesh
  21845. * @returns the new submesh
  21846. */
  21847. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21848. /**
  21849. * Release associated resources
  21850. */
  21851. dispose(): void;
  21852. /**
  21853. * Gets the class name
  21854. * @returns the string "SubMesh".
  21855. */
  21856. getClassName(): string;
  21857. /**
  21858. * Creates a new submesh from indices data
  21859. * @param materialIndex the index of the main mesh material
  21860. * @param startIndex the index where to start the copy in the mesh indices array
  21861. * @param indexCount the number of indices to copy then from the startIndex
  21862. * @param mesh the main mesh to create the submesh from
  21863. * @param renderingMesh the optional rendering mesh
  21864. * @returns a new submesh
  21865. */
  21866. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21867. }
  21868. }
  21869. declare module BABYLON {
  21870. /**
  21871. * Class used to represent data loading progression
  21872. */
  21873. export class SceneLoaderFlags {
  21874. private static _ForceFullSceneLoadingForIncremental;
  21875. private static _ShowLoadingScreen;
  21876. private static _CleanBoneMatrixWeights;
  21877. private static _loggingLevel;
  21878. /**
  21879. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21880. */
  21881. static get ForceFullSceneLoadingForIncremental(): boolean;
  21882. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21883. /**
  21884. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21885. */
  21886. static get ShowLoadingScreen(): boolean;
  21887. static set ShowLoadingScreen(value: boolean);
  21888. /**
  21889. * Defines the current logging level (while loading the scene)
  21890. * @ignorenaming
  21891. */
  21892. static get loggingLevel(): number;
  21893. static set loggingLevel(value: number);
  21894. /**
  21895. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21896. */
  21897. static get CleanBoneMatrixWeights(): boolean;
  21898. static set CleanBoneMatrixWeights(value: boolean);
  21899. }
  21900. }
  21901. declare module BABYLON {
  21902. /**
  21903. * Class used to store geometry data (vertex buffers + index buffer)
  21904. */
  21905. export class Geometry implements IGetSetVerticesData {
  21906. /**
  21907. * Gets or sets the ID of the geometry
  21908. */
  21909. id: string;
  21910. /**
  21911. * Gets or sets the unique ID of the geometry
  21912. */
  21913. uniqueId: number;
  21914. /**
  21915. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21916. */
  21917. delayLoadState: number;
  21918. /**
  21919. * Gets the file containing the data to load when running in delay load state
  21920. */
  21921. delayLoadingFile: Nullable<string>;
  21922. /**
  21923. * Callback called when the geometry is updated
  21924. */
  21925. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21926. private _scene;
  21927. private _engine;
  21928. private _meshes;
  21929. private _totalVertices;
  21930. /** @hidden */
  21931. _indices: IndicesArray;
  21932. /** @hidden */
  21933. _vertexBuffers: {
  21934. [key: string]: VertexBuffer;
  21935. };
  21936. private _isDisposed;
  21937. private _extend;
  21938. private _boundingBias;
  21939. /** @hidden */
  21940. _delayInfo: Array<string>;
  21941. private _indexBuffer;
  21942. private _indexBufferIsUpdatable;
  21943. /** @hidden */
  21944. _boundingInfo: Nullable<BoundingInfo>;
  21945. /** @hidden */
  21946. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21947. /** @hidden */
  21948. _softwareSkinningFrameId: number;
  21949. private _vertexArrayObjects;
  21950. private _updatable;
  21951. /** @hidden */
  21952. _positions: Nullable<Vector3[]>;
  21953. /**
  21954. * 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
  21955. */
  21956. get boundingBias(): Vector2;
  21957. /**
  21958. * 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
  21959. */
  21960. set boundingBias(value: Vector2);
  21961. /**
  21962. * Static function used to attach a new empty geometry to a mesh
  21963. * @param mesh defines the mesh to attach the geometry to
  21964. * @returns the new Geometry
  21965. */
  21966. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21967. /**
  21968. * Creates a new geometry
  21969. * @param id defines the unique ID
  21970. * @param scene defines the hosting scene
  21971. * @param vertexData defines the VertexData used to get geometry data
  21972. * @param updatable defines if geometry must be updatable (false by default)
  21973. * @param mesh defines the mesh that will be associated with the geometry
  21974. */
  21975. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21976. /**
  21977. * Gets the current extend of the geometry
  21978. */
  21979. get extend(): {
  21980. minimum: Vector3;
  21981. maximum: Vector3;
  21982. };
  21983. /**
  21984. * Gets the hosting scene
  21985. * @returns the hosting Scene
  21986. */
  21987. getScene(): Scene;
  21988. /**
  21989. * Gets the hosting engine
  21990. * @returns the hosting Engine
  21991. */
  21992. getEngine(): Engine;
  21993. /**
  21994. * Defines if the geometry is ready to use
  21995. * @returns true if the geometry is ready to be used
  21996. */
  21997. isReady(): boolean;
  21998. /**
  21999. * Gets a value indicating that the geometry should not be serialized
  22000. */
  22001. get doNotSerialize(): boolean;
  22002. /** @hidden */
  22003. _rebuild(): void;
  22004. /**
  22005. * Affects all geometry data in one call
  22006. * @param vertexData defines the geometry data
  22007. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22008. */
  22009. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22010. /**
  22011. * Set specific vertex data
  22012. * @param kind defines the data kind (Position, normal, etc...)
  22013. * @param data defines the vertex data to use
  22014. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22015. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22016. */
  22017. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22018. /**
  22019. * Removes a specific vertex data
  22020. * @param kind defines the data kind (Position, normal, etc...)
  22021. */
  22022. removeVerticesData(kind: string): void;
  22023. /**
  22024. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22025. * @param buffer defines the vertex buffer to use
  22026. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22027. */
  22028. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22029. /**
  22030. * Update a specific vertex buffer
  22031. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22032. * It will do nothing if the buffer is not updatable
  22033. * @param kind defines the data kind (Position, normal, etc...)
  22034. * @param data defines the data to use
  22035. * @param offset defines the offset in the target buffer where to store the data
  22036. * @param useBytes set to true if the offset is in bytes
  22037. */
  22038. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22039. /**
  22040. * Update a specific vertex buffer
  22041. * This function will create a new buffer if the current one is not updatable
  22042. * @param kind defines the data kind (Position, normal, etc...)
  22043. * @param data defines the data to use
  22044. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22045. */
  22046. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22047. private _updateBoundingInfo;
  22048. /** @hidden */
  22049. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22050. /**
  22051. * Gets total number of vertices
  22052. * @returns the total number of vertices
  22053. */
  22054. getTotalVertices(): number;
  22055. /**
  22056. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22057. * @param kind defines the data kind (Position, normal, etc...)
  22058. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22059. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22060. * @returns a float array containing vertex data
  22061. */
  22062. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22063. /**
  22064. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22065. * @param kind defines the data kind (Position, normal, etc...)
  22066. * @returns true if the vertex buffer with the specified kind is updatable
  22067. */
  22068. isVertexBufferUpdatable(kind: string): boolean;
  22069. /**
  22070. * Gets a specific vertex buffer
  22071. * @param kind defines the data kind (Position, normal, etc...)
  22072. * @returns a VertexBuffer
  22073. */
  22074. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22075. /**
  22076. * Returns all vertex buffers
  22077. * @return an object holding all vertex buffers indexed by kind
  22078. */
  22079. getVertexBuffers(): Nullable<{
  22080. [key: string]: VertexBuffer;
  22081. }>;
  22082. /**
  22083. * Gets a boolean indicating if specific vertex buffer is present
  22084. * @param kind defines the data kind (Position, normal, etc...)
  22085. * @returns true if data is present
  22086. */
  22087. isVerticesDataPresent(kind: string): boolean;
  22088. /**
  22089. * Gets a list of all attached data kinds (Position, normal, etc...)
  22090. * @returns a list of string containing all kinds
  22091. */
  22092. getVerticesDataKinds(): string[];
  22093. /**
  22094. * Update index buffer
  22095. * @param indices defines the indices to store in the index buffer
  22096. * @param offset defines the offset in the target buffer where to store the data
  22097. * @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)
  22098. */
  22099. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22100. /**
  22101. * Creates a new index buffer
  22102. * @param indices defines the indices to store in the index buffer
  22103. * @param totalVertices defines the total number of vertices (could be null)
  22104. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22105. */
  22106. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22107. /**
  22108. * Return the total number of indices
  22109. * @returns the total number of indices
  22110. */
  22111. getTotalIndices(): number;
  22112. /**
  22113. * Gets the index buffer array
  22114. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22115. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22116. * @returns the index buffer array
  22117. */
  22118. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22119. /**
  22120. * Gets the index buffer
  22121. * @return the index buffer
  22122. */
  22123. getIndexBuffer(): Nullable<DataBuffer>;
  22124. /** @hidden */
  22125. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22126. /**
  22127. * Release the associated resources for a specific mesh
  22128. * @param mesh defines the source mesh
  22129. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22130. */
  22131. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22132. /**
  22133. * Apply current geometry to a given mesh
  22134. * @param mesh defines the mesh to apply geometry to
  22135. */
  22136. applyToMesh(mesh: Mesh): void;
  22137. private _updateExtend;
  22138. private _applyToMesh;
  22139. private notifyUpdate;
  22140. /**
  22141. * Load the geometry if it was flagged as delay loaded
  22142. * @param scene defines the hosting scene
  22143. * @param onLoaded defines a callback called when the geometry is loaded
  22144. */
  22145. load(scene: Scene, onLoaded?: () => void): void;
  22146. private _queueLoad;
  22147. /**
  22148. * Invert the geometry to move from a right handed system to a left handed one.
  22149. */
  22150. toLeftHanded(): void;
  22151. /** @hidden */
  22152. _resetPointsArrayCache(): void;
  22153. /** @hidden */
  22154. _generatePointsArray(): boolean;
  22155. /**
  22156. * Gets a value indicating if the geometry is disposed
  22157. * @returns true if the geometry was disposed
  22158. */
  22159. isDisposed(): boolean;
  22160. private _disposeVertexArrayObjects;
  22161. /**
  22162. * Free all associated resources
  22163. */
  22164. dispose(): void;
  22165. /**
  22166. * Clone the current geometry into a new geometry
  22167. * @param id defines the unique ID of the new geometry
  22168. * @returns a new geometry object
  22169. */
  22170. copy(id: string): Geometry;
  22171. /**
  22172. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22173. * @return a JSON representation of the current geometry data (without the vertices data)
  22174. */
  22175. serialize(): any;
  22176. private toNumberArray;
  22177. /**
  22178. * Serialize all vertices data into a JSON oject
  22179. * @returns a JSON representation of the current geometry data
  22180. */
  22181. serializeVerticeData(): any;
  22182. /**
  22183. * Extracts a clone of a mesh geometry
  22184. * @param mesh defines the source mesh
  22185. * @param id defines the unique ID of the new geometry object
  22186. * @returns the new geometry object
  22187. */
  22188. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22189. /**
  22190. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22191. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22192. * Be aware Math.random() could cause collisions, but:
  22193. * "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"
  22194. * @returns a string containing a new GUID
  22195. */
  22196. static RandomId(): string;
  22197. /** @hidden */
  22198. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22199. private static _CleanMatricesWeights;
  22200. /**
  22201. * Create a new geometry from persisted data (Using .babylon file format)
  22202. * @param parsedVertexData defines the persisted data
  22203. * @param scene defines the hosting scene
  22204. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22205. * @returns the new geometry object
  22206. */
  22207. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22208. }
  22209. }
  22210. declare module BABYLON {
  22211. /**
  22212. * Define an interface for all classes that will get and set the data on vertices
  22213. */
  22214. export interface IGetSetVerticesData {
  22215. /**
  22216. * Gets a boolean indicating if specific vertex data is present
  22217. * @param kind defines the vertex data kind to use
  22218. * @returns true is data kind is present
  22219. */
  22220. isVerticesDataPresent(kind: string): boolean;
  22221. /**
  22222. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22223. * @param kind defines the data kind (Position, normal, etc...)
  22224. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22225. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22226. * @returns a float array containing vertex data
  22227. */
  22228. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22229. /**
  22230. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22231. * @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.
  22232. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22233. * @returns the indices array or an empty array if the mesh has no geometry
  22234. */
  22235. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22236. /**
  22237. * Set specific vertex data
  22238. * @param kind defines the data kind (Position, normal, etc...)
  22239. * @param data defines the vertex data to use
  22240. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22241. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22242. */
  22243. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22244. /**
  22245. * Update a specific associated vertex buffer
  22246. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22247. * - VertexBuffer.PositionKind
  22248. * - VertexBuffer.UVKind
  22249. * - VertexBuffer.UV2Kind
  22250. * - VertexBuffer.UV3Kind
  22251. * - VertexBuffer.UV4Kind
  22252. * - VertexBuffer.UV5Kind
  22253. * - VertexBuffer.UV6Kind
  22254. * - VertexBuffer.ColorKind
  22255. * - VertexBuffer.MatricesIndicesKind
  22256. * - VertexBuffer.MatricesIndicesExtraKind
  22257. * - VertexBuffer.MatricesWeightsKind
  22258. * - VertexBuffer.MatricesWeightsExtraKind
  22259. * @param data defines the data source
  22260. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22261. * @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)
  22262. */
  22263. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22264. /**
  22265. * Creates a new index buffer
  22266. * @param indices defines the indices to store in the index buffer
  22267. * @param totalVertices defines the total number of vertices (could be null)
  22268. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22269. */
  22270. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22271. }
  22272. /**
  22273. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22274. */
  22275. export class VertexData {
  22276. /**
  22277. * Mesh side orientation : usually the external or front surface
  22278. */
  22279. static readonly FRONTSIDE: number;
  22280. /**
  22281. * Mesh side orientation : usually the internal or back surface
  22282. */
  22283. static readonly BACKSIDE: number;
  22284. /**
  22285. * Mesh side orientation : both internal and external or front and back surfaces
  22286. */
  22287. static readonly DOUBLESIDE: number;
  22288. /**
  22289. * Mesh side orientation : by default, `FRONTSIDE`
  22290. */
  22291. static readonly DEFAULTSIDE: number;
  22292. /**
  22293. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22294. */
  22295. positions: Nullable<FloatArray>;
  22296. /**
  22297. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22298. */
  22299. normals: Nullable<FloatArray>;
  22300. /**
  22301. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22302. */
  22303. tangents: Nullable<FloatArray>;
  22304. /**
  22305. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22306. */
  22307. uvs: Nullable<FloatArray>;
  22308. /**
  22309. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22310. */
  22311. uvs2: Nullable<FloatArray>;
  22312. /**
  22313. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22314. */
  22315. uvs3: Nullable<FloatArray>;
  22316. /**
  22317. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22318. */
  22319. uvs4: Nullable<FloatArray>;
  22320. /**
  22321. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22322. */
  22323. uvs5: Nullable<FloatArray>;
  22324. /**
  22325. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22326. */
  22327. uvs6: Nullable<FloatArray>;
  22328. /**
  22329. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22330. */
  22331. colors: Nullable<FloatArray>;
  22332. /**
  22333. * 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).
  22334. */
  22335. matricesIndices: Nullable<FloatArray>;
  22336. /**
  22337. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22338. */
  22339. matricesWeights: Nullable<FloatArray>;
  22340. /**
  22341. * An array extending the number of possible indices
  22342. */
  22343. matricesIndicesExtra: Nullable<FloatArray>;
  22344. /**
  22345. * An array extending the number of possible weights when the number of indices is extended
  22346. */
  22347. matricesWeightsExtra: Nullable<FloatArray>;
  22348. /**
  22349. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22350. */
  22351. indices: Nullable<IndicesArray>;
  22352. /**
  22353. * Uses the passed data array to set the set the values for the specified kind of data
  22354. * @param data a linear array of floating numbers
  22355. * @param kind the type of data that is being set, eg positions, colors etc
  22356. */
  22357. set(data: FloatArray, kind: string): void;
  22358. /**
  22359. * Associates the vertexData to the passed Mesh.
  22360. * Sets it as updatable or not (default `false`)
  22361. * @param mesh the mesh the vertexData is applied to
  22362. * @param updatable when used and having the value true allows new data to update the vertexData
  22363. * @returns the VertexData
  22364. */
  22365. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22366. /**
  22367. * Associates the vertexData to the passed Geometry.
  22368. * Sets it as updatable or not (default `false`)
  22369. * @param geometry the geometry the vertexData is applied to
  22370. * @param updatable when used and having the value true allows new data to update the vertexData
  22371. * @returns VertexData
  22372. */
  22373. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22374. /**
  22375. * Updates the associated mesh
  22376. * @param mesh the mesh to be updated
  22377. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22378. * @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
  22379. * @returns VertexData
  22380. */
  22381. updateMesh(mesh: Mesh): VertexData;
  22382. /**
  22383. * Updates the associated geometry
  22384. * @param geometry the geometry to be updated
  22385. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22386. * @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
  22387. * @returns VertexData.
  22388. */
  22389. updateGeometry(geometry: Geometry): VertexData;
  22390. private _applyTo;
  22391. private _update;
  22392. /**
  22393. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22394. * @param matrix the transforming matrix
  22395. * @returns the VertexData
  22396. */
  22397. transform(matrix: Matrix): VertexData;
  22398. /**
  22399. * Merges the passed VertexData into the current one
  22400. * @param other the VertexData to be merged into the current one
  22401. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22402. * @returns the modified VertexData
  22403. */
  22404. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22405. private _mergeElement;
  22406. private _validate;
  22407. /**
  22408. * Serializes the VertexData
  22409. * @returns a serialized object
  22410. */
  22411. serialize(): any;
  22412. /**
  22413. * Extracts the vertexData from a mesh
  22414. * @param mesh the mesh from which to extract the VertexData
  22415. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22416. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22417. * @returns the object VertexData associated to the passed mesh
  22418. */
  22419. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22420. /**
  22421. * Extracts the vertexData from the geometry
  22422. * @param geometry the geometry from which to extract the VertexData
  22423. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22424. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22425. * @returns the object VertexData associated to the passed mesh
  22426. */
  22427. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22428. private static _ExtractFrom;
  22429. /**
  22430. * Creates the VertexData for a Ribbon
  22431. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22432. * * pathArray array of paths, each of which an array of successive Vector3
  22433. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22434. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22435. * * 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
  22436. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22437. * * 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)
  22438. * * 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)
  22439. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22440. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22441. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22442. * @returns the VertexData of the ribbon
  22443. */
  22444. static CreateRibbon(options: {
  22445. pathArray: Vector3[][];
  22446. closeArray?: boolean;
  22447. closePath?: boolean;
  22448. offset?: number;
  22449. sideOrientation?: number;
  22450. frontUVs?: Vector4;
  22451. backUVs?: Vector4;
  22452. invertUV?: boolean;
  22453. uvs?: Vector2[];
  22454. colors?: Color4[];
  22455. }): VertexData;
  22456. /**
  22457. * Creates the VertexData for a box
  22458. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22459. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22460. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22461. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22462. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22463. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22464. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22465. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22466. * * 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)
  22467. * * 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)
  22468. * @returns the VertexData of the box
  22469. */
  22470. static CreateBox(options: {
  22471. size?: number;
  22472. width?: number;
  22473. height?: number;
  22474. depth?: number;
  22475. faceUV?: Vector4[];
  22476. faceColors?: Color4[];
  22477. sideOrientation?: number;
  22478. frontUVs?: Vector4;
  22479. backUVs?: Vector4;
  22480. }): VertexData;
  22481. /**
  22482. * Creates the VertexData for a tiled box
  22483. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22484. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22485. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22486. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22487. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22488. * @returns the VertexData of the box
  22489. */
  22490. static CreateTiledBox(options: {
  22491. pattern?: number;
  22492. width?: number;
  22493. height?: number;
  22494. depth?: number;
  22495. tileSize?: number;
  22496. tileWidth?: number;
  22497. tileHeight?: number;
  22498. alignHorizontal?: number;
  22499. alignVertical?: number;
  22500. faceUV?: Vector4[];
  22501. faceColors?: Color4[];
  22502. sideOrientation?: number;
  22503. }): VertexData;
  22504. /**
  22505. * Creates the VertexData for a tiled plane
  22506. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22507. * * pattern a limited pattern arrangement depending on the number
  22508. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22509. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22510. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22511. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22512. * * 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)
  22513. * * 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)
  22514. * @returns the VertexData of the tiled plane
  22515. */
  22516. static CreateTiledPlane(options: {
  22517. pattern?: number;
  22518. tileSize?: number;
  22519. tileWidth?: number;
  22520. tileHeight?: number;
  22521. size?: number;
  22522. width?: number;
  22523. height?: number;
  22524. alignHorizontal?: number;
  22525. alignVertical?: number;
  22526. sideOrientation?: number;
  22527. frontUVs?: Vector4;
  22528. backUVs?: Vector4;
  22529. }): VertexData;
  22530. /**
  22531. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22532. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22533. * * segments sets the number of horizontal strips optional, default 32
  22534. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22535. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22536. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22537. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22538. * * 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
  22539. * * 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
  22540. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22541. * * 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)
  22542. * * 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)
  22543. * @returns the VertexData of the ellipsoid
  22544. */
  22545. static CreateSphere(options: {
  22546. segments?: number;
  22547. diameter?: number;
  22548. diameterX?: number;
  22549. diameterY?: number;
  22550. diameterZ?: number;
  22551. arc?: number;
  22552. slice?: number;
  22553. sideOrientation?: number;
  22554. frontUVs?: Vector4;
  22555. backUVs?: Vector4;
  22556. }): VertexData;
  22557. /**
  22558. * Creates the VertexData for a cylinder, cone or prism
  22559. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22560. * * height sets the height (y direction) of the cylinder, optional, default 2
  22561. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22562. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22563. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22564. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22565. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22566. * * 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
  22567. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22568. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22569. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22570. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22571. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22572. * * 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)
  22573. * * 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)
  22574. * @returns the VertexData of the cylinder, cone or prism
  22575. */
  22576. static CreateCylinder(options: {
  22577. height?: number;
  22578. diameterTop?: number;
  22579. diameterBottom?: number;
  22580. diameter?: number;
  22581. tessellation?: number;
  22582. subdivisions?: number;
  22583. arc?: number;
  22584. faceColors?: Color4[];
  22585. faceUV?: Vector4[];
  22586. hasRings?: boolean;
  22587. enclose?: boolean;
  22588. sideOrientation?: number;
  22589. frontUVs?: Vector4;
  22590. backUVs?: Vector4;
  22591. }): VertexData;
  22592. /**
  22593. * Creates the VertexData for a torus
  22594. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22595. * * diameter the diameter of the torus, optional default 1
  22596. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22597. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22598. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22599. * * 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)
  22600. * * 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)
  22601. * @returns the VertexData of the torus
  22602. */
  22603. static CreateTorus(options: {
  22604. diameter?: number;
  22605. thickness?: number;
  22606. tessellation?: number;
  22607. sideOrientation?: number;
  22608. frontUVs?: Vector4;
  22609. backUVs?: Vector4;
  22610. }): VertexData;
  22611. /**
  22612. * Creates the VertexData of the LineSystem
  22613. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22614. * - lines an array of lines, each line being an array of successive Vector3
  22615. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22616. * @returns the VertexData of the LineSystem
  22617. */
  22618. static CreateLineSystem(options: {
  22619. lines: Vector3[][];
  22620. colors?: Nullable<Color4[][]>;
  22621. }): VertexData;
  22622. /**
  22623. * Create the VertexData for a DashedLines
  22624. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22625. * - points an array successive Vector3
  22626. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22627. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22628. * - dashNb the intended total number of dashes, optional, default 200
  22629. * @returns the VertexData for the DashedLines
  22630. */
  22631. static CreateDashedLines(options: {
  22632. points: Vector3[];
  22633. dashSize?: number;
  22634. gapSize?: number;
  22635. dashNb?: number;
  22636. }): VertexData;
  22637. /**
  22638. * Creates the VertexData for a Ground
  22639. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22640. * - width the width (x direction) of the ground, optional, default 1
  22641. * - height the height (z direction) of the ground, optional, default 1
  22642. * - subdivisions the number of subdivisions per side, optional, default 1
  22643. * @returns the VertexData of the Ground
  22644. */
  22645. static CreateGround(options: {
  22646. width?: number;
  22647. height?: number;
  22648. subdivisions?: number;
  22649. subdivisionsX?: number;
  22650. subdivisionsY?: number;
  22651. }): VertexData;
  22652. /**
  22653. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22654. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22655. * * xmin the ground minimum X coordinate, optional, default -1
  22656. * * zmin the ground minimum Z coordinate, optional, default -1
  22657. * * xmax the ground maximum X coordinate, optional, default 1
  22658. * * zmax the ground maximum Z coordinate, optional, default 1
  22659. * * 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}
  22660. * * 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}
  22661. * @returns the VertexData of the TiledGround
  22662. */
  22663. static CreateTiledGround(options: {
  22664. xmin: number;
  22665. zmin: number;
  22666. xmax: number;
  22667. zmax: number;
  22668. subdivisions?: {
  22669. w: number;
  22670. h: number;
  22671. };
  22672. precision?: {
  22673. w: number;
  22674. h: number;
  22675. };
  22676. }): VertexData;
  22677. /**
  22678. * Creates the VertexData of the Ground designed from a heightmap
  22679. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22680. * * width the width (x direction) of the ground
  22681. * * height the height (z direction) of the ground
  22682. * * subdivisions the number of subdivisions per side
  22683. * * minHeight the minimum altitude on the ground, optional, default 0
  22684. * * maxHeight the maximum altitude on the ground, optional default 1
  22685. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22686. * * buffer the array holding the image color data
  22687. * * bufferWidth the width of image
  22688. * * bufferHeight the height of image
  22689. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22690. * @returns the VertexData of the Ground designed from a heightmap
  22691. */
  22692. static CreateGroundFromHeightMap(options: {
  22693. width: number;
  22694. height: number;
  22695. subdivisions: number;
  22696. minHeight: number;
  22697. maxHeight: number;
  22698. colorFilter: Color3;
  22699. buffer: Uint8Array;
  22700. bufferWidth: number;
  22701. bufferHeight: number;
  22702. alphaFilter: number;
  22703. }): VertexData;
  22704. /**
  22705. * Creates the VertexData for a Plane
  22706. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22707. * * size sets the width and height of the plane to the value of size, optional default 1
  22708. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22709. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22710. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22711. * * 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)
  22712. * * 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)
  22713. * @returns the VertexData of the box
  22714. */
  22715. static CreatePlane(options: {
  22716. size?: number;
  22717. width?: number;
  22718. height?: number;
  22719. sideOrientation?: number;
  22720. frontUVs?: Vector4;
  22721. backUVs?: Vector4;
  22722. }): VertexData;
  22723. /**
  22724. * Creates the VertexData of the Disc or regular Polygon
  22725. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22726. * * radius the radius of the disc, optional default 0.5
  22727. * * tessellation the number of polygon sides, optional, default 64
  22728. * * 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
  22729. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22730. * * 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)
  22731. * * 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)
  22732. * @returns the VertexData of the box
  22733. */
  22734. static CreateDisc(options: {
  22735. radius?: number;
  22736. tessellation?: number;
  22737. arc?: number;
  22738. sideOrientation?: number;
  22739. frontUVs?: Vector4;
  22740. backUVs?: Vector4;
  22741. }): VertexData;
  22742. /**
  22743. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22744. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22745. * @param polygon a mesh built from polygonTriangulation.build()
  22746. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22747. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22748. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22749. * @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)
  22750. * @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)
  22751. * @returns the VertexData of the Polygon
  22752. */
  22753. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22754. /**
  22755. * Creates the VertexData of the IcoSphere
  22756. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22757. * * radius the radius of the IcoSphere, optional default 1
  22758. * * radiusX allows stretching in the x direction, optional, default radius
  22759. * * radiusY allows stretching in the y direction, optional, default radius
  22760. * * radiusZ allows stretching in the z direction, optional, default radius
  22761. * * flat when true creates a flat shaded mesh, optional, default true
  22762. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22763. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22764. * * 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)
  22765. * * 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)
  22766. * @returns the VertexData of the IcoSphere
  22767. */
  22768. static CreateIcoSphere(options: {
  22769. radius?: number;
  22770. radiusX?: number;
  22771. radiusY?: number;
  22772. radiusZ?: number;
  22773. flat?: boolean;
  22774. subdivisions?: number;
  22775. sideOrientation?: number;
  22776. frontUVs?: Vector4;
  22777. backUVs?: Vector4;
  22778. }): VertexData;
  22779. /**
  22780. * Creates the VertexData for a Polyhedron
  22781. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22782. * * type provided types are:
  22783. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22784. * * 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)
  22785. * * size the size of the IcoSphere, optional default 1
  22786. * * sizeX allows stretching in the x direction, optional, default size
  22787. * * sizeY allows stretching in the y direction, optional, default size
  22788. * * sizeZ allows stretching in the z direction, optional, default size
  22789. * * 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
  22790. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22791. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22792. * * flat when true creates a flat shaded mesh, optional, default true
  22793. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22794. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22795. * * 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)
  22796. * * 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)
  22797. * @returns the VertexData of the Polyhedron
  22798. */
  22799. static CreatePolyhedron(options: {
  22800. type?: number;
  22801. size?: number;
  22802. sizeX?: number;
  22803. sizeY?: number;
  22804. sizeZ?: number;
  22805. custom?: any;
  22806. faceUV?: Vector4[];
  22807. faceColors?: Color4[];
  22808. flat?: boolean;
  22809. sideOrientation?: number;
  22810. frontUVs?: Vector4;
  22811. backUVs?: Vector4;
  22812. }): VertexData;
  22813. /**
  22814. * Creates the VertexData for a TorusKnot
  22815. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22816. * * radius the radius of the torus knot, optional, default 2
  22817. * * tube the thickness of the tube, optional, default 0.5
  22818. * * radialSegments the number of sides on each tube segments, optional, default 32
  22819. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22820. * * p the number of windings around the z axis, optional, default 2
  22821. * * q the number of windings around the x axis, optional, default 3
  22822. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22823. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22824. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22825. * @returns the VertexData of the Torus Knot
  22826. */
  22827. static CreateTorusKnot(options: {
  22828. radius?: number;
  22829. tube?: number;
  22830. radialSegments?: number;
  22831. tubularSegments?: number;
  22832. p?: number;
  22833. q?: number;
  22834. sideOrientation?: number;
  22835. frontUVs?: Vector4;
  22836. backUVs?: Vector4;
  22837. }): VertexData;
  22838. /**
  22839. * Compute normals for given positions and indices
  22840. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22841. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22842. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22843. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22844. * * facetNormals : optional array of facet normals (vector3)
  22845. * * facetPositions : optional array of facet positions (vector3)
  22846. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22847. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22848. * * bInfo : optional bounding info, required for facetPartitioning computation
  22849. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22850. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22851. * * useRightHandedSystem: optional boolean to for right handed system computation
  22852. * * depthSort : optional boolean to enable the facet depth sort computation
  22853. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22854. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22855. */
  22856. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22857. facetNormals?: any;
  22858. facetPositions?: any;
  22859. facetPartitioning?: any;
  22860. ratio?: number;
  22861. bInfo?: any;
  22862. bbSize?: Vector3;
  22863. subDiv?: any;
  22864. useRightHandedSystem?: boolean;
  22865. depthSort?: boolean;
  22866. distanceTo?: Vector3;
  22867. depthSortedFacets?: any;
  22868. }): void;
  22869. /** @hidden */
  22870. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22871. /**
  22872. * Applies VertexData created from the imported parameters to the geometry
  22873. * @param parsedVertexData the parsed data from an imported file
  22874. * @param geometry the geometry to apply the VertexData to
  22875. */
  22876. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22877. }
  22878. }
  22879. declare module BABYLON {
  22880. /**
  22881. * Defines a target to use with MorphTargetManager
  22882. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22883. */
  22884. export class MorphTarget implements IAnimatable {
  22885. /** defines the name of the target */
  22886. name: string;
  22887. /**
  22888. * Gets or sets the list of animations
  22889. */
  22890. animations: Animation[];
  22891. private _scene;
  22892. private _positions;
  22893. private _normals;
  22894. private _tangents;
  22895. private _uvs;
  22896. private _influence;
  22897. private _uniqueId;
  22898. /**
  22899. * Observable raised when the influence changes
  22900. */
  22901. onInfluenceChanged: Observable<boolean>;
  22902. /** @hidden */
  22903. _onDataLayoutChanged: Observable<void>;
  22904. /**
  22905. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22906. */
  22907. get influence(): number;
  22908. set influence(influence: number);
  22909. /**
  22910. * Gets or sets the id of the morph Target
  22911. */
  22912. id: string;
  22913. private _animationPropertiesOverride;
  22914. /**
  22915. * Gets or sets the animation properties override
  22916. */
  22917. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22918. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22919. /**
  22920. * Creates a new MorphTarget
  22921. * @param name defines the name of the target
  22922. * @param influence defines the influence to use
  22923. * @param scene defines the scene the morphtarget belongs to
  22924. */
  22925. constructor(
  22926. /** defines the name of the target */
  22927. name: string, influence?: number, scene?: Nullable<Scene>);
  22928. /**
  22929. * Gets the unique ID of this manager
  22930. */
  22931. get uniqueId(): number;
  22932. /**
  22933. * Gets a boolean defining if the target contains position data
  22934. */
  22935. get hasPositions(): boolean;
  22936. /**
  22937. * Gets a boolean defining if the target contains normal data
  22938. */
  22939. get hasNormals(): boolean;
  22940. /**
  22941. * Gets a boolean defining if the target contains tangent data
  22942. */
  22943. get hasTangents(): boolean;
  22944. /**
  22945. * Gets a boolean defining if the target contains texture coordinates data
  22946. */
  22947. get hasUVs(): boolean;
  22948. /**
  22949. * Affects position data to this target
  22950. * @param data defines the position data to use
  22951. */
  22952. setPositions(data: Nullable<FloatArray>): void;
  22953. /**
  22954. * Gets the position data stored in this target
  22955. * @returns a FloatArray containing the position data (or null if not present)
  22956. */
  22957. getPositions(): Nullable<FloatArray>;
  22958. /**
  22959. * Affects normal data to this target
  22960. * @param data defines the normal data to use
  22961. */
  22962. setNormals(data: Nullable<FloatArray>): void;
  22963. /**
  22964. * Gets the normal data stored in this target
  22965. * @returns a FloatArray containing the normal data (or null if not present)
  22966. */
  22967. getNormals(): Nullable<FloatArray>;
  22968. /**
  22969. * Affects tangent data to this target
  22970. * @param data defines the tangent data to use
  22971. */
  22972. setTangents(data: Nullable<FloatArray>): void;
  22973. /**
  22974. * Gets the tangent data stored in this target
  22975. * @returns a FloatArray containing the tangent data (or null if not present)
  22976. */
  22977. getTangents(): Nullable<FloatArray>;
  22978. /**
  22979. * Affects texture coordinates data to this target
  22980. * @param data defines the texture coordinates data to use
  22981. */
  22982. setUVs(data: Nullable<FloatArray>): void;
  22983. /**
  22984. * Gets the texture coordinates data stored in this target
  22985. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22986. */
  22987. getUVs(): Nullable<FloatArray>;
  22988. /**
  22989. * Clone the current target
  22990. * @returns a new MorphTarget
  22991. */
  22992. clone(): MorphTarget;
  22993. /**
  22994. * Serializes the current target into a Serialization object
  22995. * @returns the serialized object
  22996. */
  22997. serialize(): any;
  22998. /**
  22999. * Returns the string "MorphTarget"
  23000. * @returns "MorphTarget"
  23001. */
  23002. getClassName(): string;
  23003. /**
  23004. * Creates a new target from serialized data
  23005. * @param serializationObject defines the serialized data to use
  23006. * @returns a new MorphTarget
  23007. */
  23008. static Parse(serializationObject: any): MorphTarget;
  23009. /**
  23010. * Creates a MorphTarget from mesh data
  23011. * @param mesh defines the source mesh
  23012. * @param name defines the name to use for the new target
  23013. * @param influence defines the influence to attach to the target
  23014. * @returns a new MorphTarget
  23015. */
  23016. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23017. }
  23018. }
  23019. declare module BABYLON {
  23020. /**
  23021. * This class is used to deform meshes using morphing between different targets
  23022. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23023. */
  23024. export class MorphTargetManager {
  23025. private _targets;
  23026. private _targetInfluenceChangedObservers;
  23027. private _targetDataLayoutChangedObservers;
  23028. private _activeTargets;
  23029. private _scene;
  23030. private _influences;
  23031. private _supportsNormals;
  23032. private _supportsTangents;
  23033. private _supportsUVs;
  23034. private _vertexCount;
  23035. private _uniqueId;
  23036. private _tempInfluences;
  23037. /**
  23038. * Gets or sets a boolean indicating if normals must be morphed
  23039. */
  23040. enableNormalMorphing: boolean;
  23041. /**
  23042. * Gets or sets a boolean indicating if tangents must be morphed
  23043. */
  23044. enableTangentMorphing: boolean;
  23045. /**
  23046. * Gets or sets a boolean indicating if UV must be morphed
  23047. */
  23048. enableUVMorphing: boolean;
  23049. /**
  23050. * Creates a new MorphTargetManager
  23051. * @param scene defines the current scene
  23052. */
  23053. constructor(scene?: Nullable<Scene>);
  23054. /**
  23055. * Gets the unique ID of this manager
  23056. */
  23057. get uniqueId(): number;
  23058. /**
  23059. * Gets the number of vertices handled by this manager
  23060. */
  23061. get vertexCount(): number;
  23062. /**
  23063. * Gets a boolean indicating if this manager supports morphing of normals
  23064. */
  23065. get supportsNormals(): boolean;
  23066. /**
  23067. * Gets a boolean indicating if this manager supports morphing of tangents
  23068. */
  23069. get supportsTangents(): boolean;
  23070. /**
  23071. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23072. */
  23073. get supportsUVs(): boolean;
  23074. /**
  23075. * Gets the number of targets stored in this manager
  23076. */
  23077. get numTargets(): number;
  23078. /**
  23079. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23080. */
  23081. get numInfluencers(): number;
  23082. /**
  23083. * Gets the list of influences (one per target)
  23084. */
  23085. get influences(): Float32Array;
  23086. /**
  23087. * Gets the active target at specified index. An active target is a target with an influence > 0
  23088. * @param index defines the index to check
  23089. * @returns the requested target
  23090. */
  23091. getActiveTarget(index: number): MorphTarget;
  23092. /**
  23093. * Gets the target at specified index
  23094. * @param index defines the index to check
  23095. * @returns the requested target
  23096. */
  23097. getTarget(index: number): MorphTarget;
  23098. /**
  23099. * Add a new target to this manager
  23100. * @param target defines the target to add
  23101. */
  23102. addTarget(target: MorphTarget): void;
  23103. /**
  23104. * Removes a target from the manager
  23105. * @param target defines the target to remove
  23106. */
  23107. removeTarget(target: MorphTarget): void;
  23108. /**
  23109. * Clone the current manager
  23110. * @returns a new MorphTargetManager
  23111. */
  23112. clone(): MorphTargetManager;
  23113. /**
  23114. * Serializes the current manager into a Serialization object
  23115. * @returns the serialized object
  23116. */
  23117. serialize(): any;
  23118. private _syncActiveTargets;
  23119. /**
  23120. * Syncrhonize the targets with all the meshes using this morph target manager
  23121. */
  23122. synchronize(): void;
  23123. /**
  23124. * Creates a new MorphTargetManager from serialized data
  23125. * @param serializationObject defines the serialized data
  23126. * @param scene defines the hosting scene
  23127. * @returns the new MorphTargetManager
  23128. */
  23129. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23130. }
  23131. }
  23132. declare module BABYLON {
  23133. /**
  23134. * Class used to represent a specific level of detail of a mesh
  23135. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23136. */
  23137. export class MeshLODLevel {
  23138. /** Defines the distance where this level should start being displayed */
  23139. distance: number;
  23140. /** Defines the mesh to use to render this level */
  23141. mesh: Nullable<Mesh>;
  23142. /**
  23143. * Creates a new LOD level
  23144. * @param distance defines the distance where this level should star being displayed
  23145. * @param mesh defines the mesh to use to render this level
  23146. */
  23147. constructor(
  23148. /** Defines the distance where this level should start being displayed */
  23149. distance: number,
  23150. /** Defines the mesh to use to render this level */
  23151. mesh: Nullable<Mesh>);
  23152. }
  23153. }
  23154. declare module BABYLON {
  23155. /**
  23156. * Mesh representing the gorund
  23157. */
  23158. export class GroundMesh extends Mesh {
  23159. /** If octree should be generated */
  23160. generateOctree: boolean;
  23161. private _heightQuads;
  23162. /** @hidden */
  23163. _subdivisionsX: number;
  23164. /** @hidden */
  23165. _subdivisionsY: number;
  23166. /** @hidden */
  23167. _width: number;
  23168. /** @hidden */
  23169. _height: number;
  23170. /** @hidden */
  23171. _minX: number;
  23172. /** @hidden */
  23173. _maxX: number;
  23174. /** @hidden */
  23175. _minZ: number;
  23176. /** @hidden */
  23177. _maxZ: number;
  23178. constructor(name: string, scene: Scene);
  23179. /**
  23180. * "GroundMesh"
  23181. * @returns "GroundMesh"
  23182. */
  23183. getClassName(): string;
  23184. /**
  23185. * The minimum of x and y subdivisions
  23186. */
  23187. get subdivisions(): number;
  23188. /**
  23189. * X subdivisions
  23190. */
  23191. get subdivisionsX(): number;
  23192. /**
  23193. * Y subdivisions
  23194. */
  23195. get subdivisionsY(): number;
  23196. /**
  23197. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23198. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23199. * @param chunksCount the number of subdivisions for x and y
  23200. * @param octreeBlocksSize (Default: 32)
  23201. */
  23202. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23203. /**
  23204. * Returns a height (y) value in the Worl system :
  23205. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23206. * @param x x coordinate
  23207. * @param z z coordinate
  23208. * @returns the ground y position if (x, z) are outside the ground surface.
  23209. */
  23210. getHeightAtCoordinates(x: number, z: number): number;
  23211. /**
  23212. * Returns a normalized vector (Vector3) orthogonal to the ground
  23213. * at the ground coordinates (x, z) expressed in the World system.
  23214. * @param x x coordinate
  23215. * @param z z coordinate
  23216. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23217. */
  23218. getNormalAtCoordinates(x: number, z: number): Vector3;
  23219. /**
  23220. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23221. * at the ground coordinates (x, z) expressed in the World system.
  23222. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23223. * @param x x coordinate
  23224. * @param z z coordinate
  23225. * @param ref vector to store the result
  23226. * @returns the GroundMesh.
  23227. */
  23228. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23229. /**
  23230. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23231. * if the ground has been updated.
  23232. * This can be used in the render loop.
  23233. * @returns the GroundMesh.
  23234. */
  23235. updateCoordinateHeights(): GroundMesh;
  23236. private _getFacetAt;
  23237. private _initHeightQuads;
  23238. private _computeHeightQuads;
  23239. /**
  23240. * Serializes this ground mesh
  23241. * @param serializationObject object to write serialization to
  23242. */
  23243. serialize(serializationObject: any): void;
  23244. /**
  23245. * Parses a serialized ground mesh
  23246. * @param parsedMesh the serialized mesh
  23247. * @param scene the scene to create the ground mesh in
  23248. * @returns the created ground mesh
  23249. */
  23250. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23251. }
  23252. }
  23253. declare module BABYLON {
  23254. /**
  23255. * Interface for Physics-Joint data
  23256. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23257. */
  23258. export interface PhysicsJointData {
  23259. /**
  23260. * The main pivot of the joint
  23261. */
  23262. mainPivot?: Vector3;
  23263. /**
  23264. * The connected pivot of the joint
  23265. */
  23266. connectedPivot?: Vector3;
  23267. /**
  23268. * The main axis of the joint
  23269. */
  23270. mainAxis?: Vector3;
  23271. /**
  23272. * The connected axis of the joint
  23273. */
  23274. connectedAxis?: Vector3;
  23275. /**
  23276. * The collision of the joint
  23277. */
  23278. collision?: boolean;
  23279. /**
  23280. * Native Oimo/Cannon/Energy data
  23281. */
  23282. nativeParams?: any;
  23283. }
  23284. /**
  23285. * This is a holder class for the physics joint created by the physics plugin
  23286. * It holds a set of functions to control the underlying joint
  23287. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23288. */
  23289. export class PhysicsJoint {
  23290. /**
  23291. * The type of the physics joint
  23292. */
  23293. type: number;
  23294. /**
  23295. * The data for the physics joint
  23296. */
  23297. jointData: PhysicsJointData;
  23298. private _physicsJoint;
  23299. protected _physicsPlugin: IPhysicsEnginePlugin;
  23300. /**
  23301. * Initializes the physics joint
  23302. * @param type The type of the physics joint
  23303. * @param jointData The data for the physics joint
  23304. */
  23305. constructor(
  23306. /**
  23307. * The type of the physics joint
  23308. */
  23309. type: number,
  23310. /**
  23311. * The data for the physics joint
  23312. */
  23313. jointData: PhysicsJointData);
  23314. /**
  23315. * Gets the physics joint
  23316. */
  23317. get physicsJoint(): any;
  23318. /**
  23319. * Sets the physics joint
  23320. */
  23321. set physicsJoint(newJoint: any);
  23322. /**
  23323. * Sets the physics plugin
  23324. */
  23325. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23326. /**
  23327. * Execute a function that is physics-plugin specific.
  23328. * @param {Function} func the function that will be executed.
  23329. * It accepts two parameters: the physics world and the physics joint
  23330. */
  23331. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23332. /**
  23333. * Distance-Joint type
  23334. */
  23335. static DistanceJoint: number;
  23336. /**
  23337. * Hinge-Joint type
  23338. */
  23339. static HingeJoint: number;
  23340. /**
  23341. * Ball-and-Socket joint type
  23342. */
  23343. static BallAndSocketJoint: number;
  23344. /**
  23345. * Wheel-Joint type
  23346. */
  23347. static WheelJoint: number;
  23348. /**
  23349. * Slider-Joint type
  23350. */
  23351. static SliderJoint: number;
  23352. /**
  23353. * Prismatic-Joint type
  23354. */
  23355. static PrismaticJoint: number;
  23356. /**
  23357. * Universal-Joint type
  23358. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23359. */
  23360. static UniversalJoint: number;
  23361. /**
  23362. * Hinge-Joint 2 type
  23363. */
  23364. static Hinge2Joint: number;
  23365. /**
  23366. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23367. */
  23368. static PointToPointJoint: number;
  23369. /**
  23370. * Spring-Joint type
  23371. */
  23372. static SpringJoint: number;
  23373. /**
  23374. * Lock-Joint type
  23375. */
  23376. static LockJoint: number;
  23377. }
  23378. /**
  23379. * A class representing a physics distance joint
  23380. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23381. */
  23382. export class DistanceJoint extends PhysicsJoint {
  23383. /**
  23384. *
  23385. * @param jointData The data for the Distance-Joint
  23386. */
  23387. constructor(jointData: DistanceJointData);
  23388. /**
  23389. * Update the predefined distance.
  23390. * @param maxDistance The maximum preferred distance
  23391. * @param minDistance The minimum preferred distance
  23392. */
  23393. updateDistance(maxDistance: number, minDistance?: number): void;
  23394. }
  23395. /**
  23396. * Represents a Motor-Enabled Joint
  23397. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23398. */
  23399. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23400. /**
  23401. * Initializes the Motor-Enabled Joint
  23402. * @param type The type of the joint
  23403. * @param jointData The physica joint data for the joint
  23404. */
  23405. constructor(type: number, jointData: PhysicsJointData);
  23406. /**
  23407. * Set the motor values.
  23408. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23409. * @param force the force to apply
  23410. * @param maxForce max force for this motor.
  23411. */
  23412. setMotor(force?: number, maxForce?: number): void;
  23413. /**
  23414. * Set the motor's limits.
  23415. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23416. * @param upperLimit The upper limit of the motor
  23417. * @param lowerLimit The lower limit of the motor
  23418. */
  23419. setLimit(upperLimit: number, lowerLimit?: number): void;
  23420. }
  23421. /**
  23422. * This class represents a single physics Hinge-Joint
  23423. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23424. */
  23425. export class HingeJoint extends MotorEnabledJoint {
  23426. /**
  23427. * Initializes the Hinge-Joint
  23428. * @param jointData The joint data for the Hinge-Joint
  23429. */
  23430. constructor(jointData: PhysicsJointData);
  23431. /**
  23432. * Set the motor values.
  23433. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23434. * @param {number} force the force to apply
  23435. * @param {number} maxForce max force for this motor.
  23436. */
  23437. setMotor(force?: number, maxForce?: number): void;
  23438. /**
  23439. * Set the motor's limits.
  23440. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23441. * @param upperLimit The upper limit of the motor
  23442. * @param lowerLimit The lower limit of the motor
  23443. */
  23444. setLimit(upperLimit: number, lowerLimit?: number): void;
  23445. }
  23446. /**
  23447. * This class represents a dual hinge physics joint (same as wheel joint)
  23448. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23449. */
  23450. export class Hinge2Joint extends MotorEnabledJoint {
  23451. /**
  23452. * Initializes the Hinge2-Joint
  23453. * @param jointData The joint data for the Hinge2-Joint
  23454. */
  23455. constructor(jointData: PhysicsJointData);
  23456. /**
  23457. * Set the motor values.
  23458. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23459. * @param {number} targetSpeed the speed the motor is to reach
  23460. * @param {number} maxForce max force for this motor.
  23461. * @param {motorIndex} the motor's index, 0 or 1.
  23462. */
  23463. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23464. /**
  23465. * Set the motor limits.
  23466. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23467. * @param {number} upperLimit the upper limit
  23468. * @param {number} lowerLimit lower limit
  23469. * @param {motorIndex} the motor's index, 0 or 1.
  23470. */
  23471. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23472. }
  23473. /**
  23474. * Interface for a motor enabled joint
  23475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23476. */
  23477. export interface IMotorEnabledJoint {
  23478. /**
  23479. * Physics joint
  23480. */
  23481. physicsJoint: any;
  23482. /**
  23483. * Sets the motor of the motor-enabled joint
  23484. * @param force The force of the motor
  23485. * @param maxForce The maximum force of the motor
  23486. * @param motorIndex The index of the motor
  23487. */
  23488. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23489. /**
  23490. * Sets the limit of the motor
  23491. * @param upperLimit The upper limit of the motor
  23492. * @param lowerLimit The lower limit of the motor
  23493. * @param motorIndex The index of the motor
  23494. */
  23495. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23496. }
  23497. /**
  23498. * Joint data for a Distance-Joint
  23499. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23500. */
  23501. export interface DistanceJointData extends PhysicsJointData {
  23502. /**
  23503. * Max distance the 2 joint objects can be apart
  23504. */
  23505. maxDistance: number;
  23506. }
  23507. /**
  23508. * Joint data from a spring joint
  23509. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23510. */
  23511. export interface SpringJointData extends PhysicsJointData {
  23512. /**
  23513. * Length of the spring
  23514. */
  23515. length: number;
  23516. /**
  23517. * Stiffness of the spring
  23518. */
  23519. stiffness: number;
  23520. /**
  23521. * Damping of the spring
  23522. */
  23523. damping: number;
  23524. /** this callback will be called when applying the force to the impostors. */
  23525. forceApplicationCallback: () => void;
  23526. }
  23527. }
  23528. declare module BABYLON {
  23529. /**
  23530. * Holds the data for the raycast result
  23531. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23532. */
  23533. export class PhysicsRaycastResult {
  23534. private _hasHit;
  23535. private _hitDistance;
  23536. private _hitNormalWorld;
  23537. private _hitPointWorld;
  23538. private _rayFromWorld;
  23539. private _rayToWorld;
  23540. /**
  23541. * Gets if there was a hit
  23542. */
  23543. get hasHit(): boolean;
  23544. /**
  23545. * Gets the distance from the hit
  23546. */
  23547. get hitDistance(): number;
  23548. /**
  23549. * Gets the hit normal/direction in the world
  23550. */
  23551. get hitNormalWorld(): Vector3;
  23552. /**
  23553. * Gets the hit point in the world
  23554. */
  23555. get hitPointWorld(): Vector3;
  23556. /**
  23557. * Gets the ray "start point" of the ray in the world
  23558. */
  23559. get rayFromWorld(): Vector3;
  23560. /**
  23561. * Gets the ray "end point" of the ray in the world
  23562. */
  23563. get rayToWorld(): Vector3;
  23564. /**
  23565. * Sets the hit data (normal & point in world space)
  23566. * @param hitNormalWorld defines the normal in world space
  23567. * @param hitPointWorld defines the point in world space
  23568. */
  23569. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23570. /**
  23571. * Sets the distance from the start point to the hit point
  23572. * @param distance
  23573. */
  23574. setHitDistance(distance: number): void;
  23575. /**
  23576. * Calculates the distance manually
  23577. */
  23578. calculateHitDistance(): void;
  23579. /**
  23580. * Resets all the values to default
  23581. * @param from The from point on world space
  23582. * @param to The to point on world space
  23583. */
  23584. reset(from?: Vector3, to?: Vector3): void;
  23585. }
  23586. /**
  23587. * Interface for the size containing width and height
  23588. */
  23589. interface IXYZ {
  23590. /**
  23591. * X
  23592. */
  23593. x: number;
  23594. /**
  23595. * Y
  23596. */
  23597. y: number;
  23598. /**
  23599. * Z
  23600. */
  23601. z: number;
  23602. }
  23603. }
  23604. declare module BABYLON {
  23605. /**
  23606. * Interface used to describe a physics joint
  23607. */
  23608. export interface PhysicsImpostorJoint {
  23609. /** Defines the main impostor to which the joint is linked */
  23610. mainImpostor: PhysicsImpostor;
  23611. /** Defines the impostor that is connected to the main impostor using this joint */
  23612. connectedImpostor: PhysicsImpostor;
  23613. /** Defines the joint itself */
  23614. joint: PhysicsJoint;
  23615. }
  23616. /** @hidden */
  23617. export interface IPhysicsEnginePlugin {
  23618. world: any;
  23619. name: string;
  23620. setGravity(gravity: Vector3): void;
  23621. setTimeStep(timeStep: number): void;
  23622. getTimeStep(): number;
  23623. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23624. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23625. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23626. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23627. removePhysicsBody(impostor: PhysicsImpostor): void;
  23628. generateJoint(joint: PhysicsImpostorJoint): void;
  23629. removeJoint(joint: PhysicsImpostorJoint): void;
  23630. isSupported(): boolean;
  23631. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23632. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23633. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23634. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23635. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23636. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23637. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23638. getBodyMass(impostor: PhysicsImpostor): number;
  23639. getBodyFriction(impostor: PhysicsImpostor): number;
  23640. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23641. getBodyRestitution(impostor: PhysicsImpostor): number;
  23642. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23643. getBodyPressure?(impostor: PhysicsImpostor): number;
  23644. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23645. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23646. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23647. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23648. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23649. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23650. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23651. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23652. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23653. sleepBody(impostor: PhysicsImpostor): void;
  23654. wakeUpBody(impostor: PhysicsImpostor): void;
  23655. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23656. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23657. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23658. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23659. getRadius(impostor: PhysicsImpostor): number;
  23660. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23661. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23662. dispose(): void;
  23663. }
  23664. /**
  23665. * Interface used to define a physics engine
  23666. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23667. */
  23668. export interface IPhysicsEngine {
  23669. /**
  23670. * Gets the gravity vector used by the simulation
  23671. */
  23672. gravity: Vector3;
  23673. /**
  23674. * Sets the gravity vector used by the simulation
  23675. * @param gravity defines the gravity vector to use
  23676. */
  23677. setGravity(gravity: Vector3): void;
  23678. /**
  23679. * Set the time step of the physics engine.
  23680. * Default is 1/60.
  23681. * To slow it down, enter 1/600 for example.
  23682. * To speed it up, 1/30
  23683. * @param newTimeStep the new timestep to apply to this world.
  23684. */
  23685. setTimeStep(newTimeStep: number): void;
  23686. /**
  23687. * Get the time step of the physics engine.
  23688. * @returns the current time step
  23689. */
  23690. getTimeStep(): number;
  23691. /**
  23692. * Set the sub time step of the physics engine.
  23693. * Default is 0 meaning there is no sub steps
  23694. * To increase physics resolution precision, set a small value (like 1 ms)
  23695. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23696. */
  23697. setSubTimeStep(subTimeStep: number): void;
  23698. /**
  23699. * Get the sub time step of the physics engine.
  23700. * @returns the current sub time step
  23701. */
  23702. getSubTimeStep(): number;
  23703. /**
  23704. * Release all resources
  23705. */
  23706. dispose(): void;
  23707. /**
  23708. * Gets the name of the current physics plugin
  23709. * @returns the name of the plugin
  23710. */
  23711. getPhysicsPluginName(): string;
  23712. /**
  23713. * Adding a new impostor for the impostor tracking.
  23714. * This will be done by the impostor itself.
  23715. * @param impostor the impostor to add
  23716. */
  23717. addImpostor(impostor: PhysicsImpostor): void;
  23718. /**
  23719. * Remove an impostor from the engine.
  23720. * This impostor and its mesh will not longer be updated by the physics engine.
  23721. * @param impostor the impostor to remove
  23722. */
  23723. removeImpostor(impostor: PhysicsImpostor): void;
  23724. /**
  23725. * Add a joint to the physics engine
  23726. * @param mainImpostor defines the main impostor to which the joint is added.
  23727. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23728. * @param joint defines the joint that will connect both impostors.
  23729. */
  23730. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23731. /**
  23732. * Removes a joint from the simulation
  23733. * @param mainImpostor defines the impostor used with the joint
  23734. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23735. * @param joint defines the joint to remove
  23736. */
  23737. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23738. /**
  23739. * Gets the current plugin used to run the simulation
  23740. * @returns current plugin
  23741. */
  23742. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23743. /**
  23744. * Gets the list of physic impostors
  23745. * @returns an array of PhysicsImpostor
  23746. */
  23747. getImpostors(): Array<PhysicsImpostor>;
  23748. /**
  23749. * Gets the impostor for a physics enabled object
  23750. * @param object defines the object impersonated by the impostor
  23751. * @returns the PhysicsImpostor or null if not found
  23752. */
  23753. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23754. /**
  23755. * Gets the impostor for a physics body object
  23756. * @param body defines physics body used by the impostor
  23757. * @returns the PhysicsImpostor or null if not found
  23758. */
  23759. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23760. /**
  23761. * Does a raycast in the physics world
  23762. * @param from when should the ray start?
  23763. * @param to when should the ray end?
  23764. * @returns PhysicsRaycastResult
  23765. */
  23766. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23767. /**
  23768. * Called by the scene. No need to call it.
  23769. * @param delta defines the timespam between frames
  23770. */
  23771. _step(delta: number): void;
  23772. }
  23773. }
  23774. declare module BABYLON {
  23775. /**
  23776. * The interface for the physics imposter parameters
  23777. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23778. */
  23779. export interface PhysicsImpostorParameters {
  23780. /**
  23781. * The mass of the physics imposter
  23782. */
  23783. mass: number;
  23784. /**
  23785. * The friction of the physics imposter
  23786. */
  23787. friction?: number;
  23788. /**
  23789. * The coefficient of restitution of the physics imposter
  23790. */
  23791. restitution?: number;
  23792. /**
  23793. * The native options of the physics imposter
  23794. */
  23795. nativeOptions?: any;
  23796. /**
  23797. * Specifies if the parent should be ignored
  23798. */
  23799. ignoreParent?: boolean;
  23800. /**
  23801. * Specifies if bi-directional transformations should be disabled
  23802. */
  23803. disableBidirectionalTransformation?: boolean;
  23804. /**
  23805. * The pressure inside the physics imposter, soft object only
  23806. */
  23807. pressure?: number;
  23808. /**
  23809. * The stiffness the physics imposter, soft object only
  23810. */
  23811. stiffness?: number;
  23812. /**
  23813. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23814. */
  23815. velocityIterations?: number;
  23816. /**
  23817. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23818. */
  23819. positionIterations?: number;
  23820. /**
  23821. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23822. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23823. * Add to fix multiple points
  23824. */
  23825. fixedPoints?: number;
  23826. /**
  23827. * The collision margin around a soft object
  23828. */
  23829. margin?: number;
  23830. /**
  23831. * The collision margin around a soft object
  23832. */
  23833. damping?: number;
  23834. /**
  23835. * The path for a rope based on an extrusion
  23836. */
  23837. path?: any;
  23838. /**
  23839. * The shape of an extrusion used for a rope based on an extrusion
  23840. */
  23841. shape?: any;
  23842. }
  23843. /**
  23844. * Interface for a physics-enabled object
  23845. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23846. */
  23847. export interface IPhysicsEnabledObject {
  23848. /**
  23849. * The position of the physics-enabled object
  23850. */
  23851. position: Vector3;
  23852. /**
  23853. * The rotation of the physics-enabled object
  23854. */
  23855. rotationQuaternion: Nullable<Quaternion>;
  23856. /**
  23857. * The scale of the physics-enabled object
  23858. */
  23859. scaling: Vector3;
  23860. /**
  23861. * The rotation of the physics-enabled object
  23862. */
  23863. rotation?: Vector3;
  23864. /**
  23865. * The parent of the physics-enabled object
  23866. */
  23867. parent?: any;
  23868. /**
  23869. * The bounding info of the physics-enabled object
  23870. * @returns The bounding info of the physics-enabled object
  23871. */
  23872. getBoundingInfo(): BoundingInfo;
  23873. /**
  23874. * Computes the world matrix
  23875. * @param force Specifies if the world matrix should be computed by force
  23876. * @returns A world matrix
  23877. */
  23878. computeWorldMatrix(force: boolean): Matrix;
  23879. /**
  23880. * Gets the world matrix
  23881. * @returns A world matrix
  23882. */
  23883. getWorldMatrix?(): Matrix;
  23884. /**
  23885. * Gets the child meshes
  23886. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23887. * @returns An array of abstract meshes
  23888. */
  23889. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23890. /**
  23891. * Gets the vertex data
  23892. * @param kind The type of vertex data
  23893. * @returns A nullable array of numbers, or a float32 array
  23894. */
  23895. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23896. /**
  23897. * Gets the indices from the mesh
  23898. * @returns A nullable array of index arrays
  23899. */
  23900. getIndices?(): Nullable<IndicesArray>;
  23901. /**
  23902. * Gets the scene from the mesh
  23903. * @returns the indices array or null
  23904. */
  23905. getScene?(): Scene;
  23906. /**
  23907. * Gets the absolute position from the mesh
  23908. * @returns the absolute position
  23909. */
  23910. getAbsolutePosition(): Vector3;
  23911. /**
  23912. * Gets the absolute pivot point from the mesh
  23913. * @returns the absolute pivot point
  23914. */
  23915. getAbsolutePivotPoint(): Vector3;
  23916. /**
  23917. * Rotates the mesh
  23918. * @param axis The axis of rotation
  23919. * @param amount The amount of rotation
  23920. * @param space The space of the rotation
  23921. * @returns The rotation transform node
  23922. */
  23923. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23924. /**
  23925. * Translates the mesh
  23926. * @param axis The axis of translation
  23927. * @param distance The distance of translation
  23928. * @param space The space of the translation
  23929. * @returns The transform node
  23930. */
  23931. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23932. /**
  23933. * Sets the absolute position of the mesh
  23934. * @param absolutePosition The absolute position of the mesh
  23935. * @returns The transform node
  23936. */
  23937. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23938. /**
  23939. * Gets the class name of the mesh
  23940. * @returns The class name
  23941. */
  23942. getClassName(): string;
  23943. }
  23944. /**
  23945. * Represents a physics imposter
  23946. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23947. */
  23948. export class PhysicsImpostor {
  23949. /**
  23950. * The physics-enabled object used as the physics imposter
  23951. */
  23952. object: IPhysicsEnabledObject;
  23953. /**
  23954. * The type of the physics imposter
  23955. */
  23956. type: number;
  23957. private _options;
  23958. private _scene?;
  23959. /**
  23960. * The default object size of the imposter
  23961. */
  23962. static DEFAULT_OBJECT_SIZE: Vector3;
  23963. /**
  23964. * The identity quaternion of the imposter
  23965. */
  23966. static IDENTITY_QUATERNION: Quaternion;
  23967. /** @hidden */
  23968. _pluginData: any;
  23969. private _physicsEngine;
  23970. private _physicsBody;
  23971. private _bodyUpdateRequired;
  23972. private _onBeforePhysicsStepCallbacks;
  23973. private _onAfterPhysicsStepCallbacks;
  23974. /** @hidden */
  23975. _onPhysicsCollideCallbacks: Array<{
  23976. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23977. otherImpostors: Array<PhysicsImpostor>;
  23978. }>;
  23979. private _deltaPosition;
  23980. private _deltaRotation;
  23981. private _deltaRotationConjugated;
  23982. /** @hidden */
  23983. _isFromLine: boolean;
  23984. private _parent;
  23985. private _isDisposed;
  23986. private static _tmpVecs;
  23987. private static _tmpQuat;
  23988. /**
  23989. * Specifies if the physics imposter is disposed
  23990. */
  23991. get isDisposed(): boolean;
  23992. /**
  23993. * Gets the mass of the physics imposter
  23994. */
  23995. get mass(): number;
  23996. set mass(value: number);
  23997. /**
  23998. * Gets the coefficient of friction
  23999. */
  24000. get friction(): number;
  24001. /**
  24002. * Sets the coefficient of friction
  24003. */
  24004. set friction(value: number);
  24005. /**
  24006. * Gets the coefficient of restitution
  24007. */
  24008. get restitution(): number;
  24009. /**
  24010. * Sets the coefficient of restitution
  24011. */
  24012. set restitution(value: number);
  24013. /**
  24014. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24015. */
  24016. get pressure(): number;
  24017. /**
  24018. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24019. */
  24020. set pressure(value: number);
  24021. /**
  24022. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24023. */
  24024. get stiffness(): number;
  24025. /**
  24026. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24027. */
  24028. set stiffness(value: number);
  24029. /**
  24030. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24031. */
  24032. get velocityIterations(): number;
  24033. /**
  24034. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24035. */
  24036. set velocityIterations(value: number);
  24037. /**
  24038. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24039. */
  24040. get positionIterations(): number;
  24041. /**
  24042. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24043. */
  24044. set positionIterations(value: number);
  24045. /**
  24046. * The unique id of the physics imposter
  24047. * set by the physics engine when adding this impostor to the array
  24048. */
  24049. uniqueId: number;
  24050. /**
  24051. * @hidden
  24052. */
  24053. soft: boolean;
  24054. /**
  24055. * @hidden
  24056. */
  24057. segments: number;
  24058. private _joints;
  24059. /**
  24060. * Initializes the physics imposter
  24061. * @param object The physics-enabled object used as the physics imposter
  24062. * @param type The type of the physics imposter
  24063. * @param _options The options for the physics imposter
  24064. * @param _scene The Babylon scene
  24065. */
  24066. constructor(
  24067. /**
  24068. * The physics-enabled object used as the physics imposter
  24069. */
  24070. object: IPhysicsEnabledObject,
  24071. /**
  24072. * The type of the physics imposter
  24073. */
  24074. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24075. /**
  24076. * This function will completly initialize this impostor.
  24077. * It will create a new body - but only if this mesh has no parent.
  24078. * If it has, this impostor will not be used other than to define the impostor
  24079. * of the child mesh.
  24080. * @hidden
  24081. */
  24082. _init(): void;
  24083. private _getPhysicsParent;
  24084. /**
  24085. * Should a new body be generated.
  24086. * @returns boolean specifying if body initialization is required
  24087. */
  24088. isBodyInitRequired(): boolean;
  24089. /**
  24090. * Sets the updated scaling
  24091. * @param updated Specifies if the scaling is updated
  24092. */
  24093. setScalingUpdated(): void;
  24094. /**
  24095. * Force a regeneration of this or the parent's impostor's body.
  24096. * Use under cautious - This will remove all joints already implemented.
  24097. */
  24098. forceUpdate(): void;
  24099. /**
  24100. * Gets the body that holds this impostor. Either its own, or its parent.
  24101. */
  24102. get physicsBody(): any;
  24103. /**
  24104. * Get the parent of the physics imposter
  24105. * @returns Physics imposter or null
  24106. */
  24107. get parent(): Nullable<PhysicsImpostor>;
  24108. /**
  24109. * Sets the parent of the physics imposter
  24110. */
  24111. set parent(value: Nullable<PhysicsImpostor>);
  24112. /**
  24113. * Set the physics body. Used mainly by the physics engine/plugin
  24114. */
  24115. set physicsBody(physicsBody: any);
  24116. /**
  24117. * Resets the update flags
  24118. */
  24119. resetUpdateFlags(): void;
  24120. /**
  24121. * Gets the object extend size
  24122. * @returns the object extend size
  24123. */
  24124. getObjectExtendSize(): Vector3;
  24125. /**
  24126. * Gets the object center
  24127. * @returns The object center
  24128. */
  24129. getObjectCenter(): Vector3;
  24130. /**
  24131. * Get a specific parameter from the options parameters
  24132. * @param paramName The object parameter name
  24133. * @returns The object parameter
  24134. */
  24135. getParam(paramName: string): any;
  24136. /**
  24137. * Sets a specific parameter in the options given to the physics plugin
  24138. * @param paramName The parameter name
  24139. * @param value The value of the parameter
  24140. */
  24141. setParam(paramName: string, value: number): void;
  24142. /**
  24143. * Specifically change the body's mass option. Won't recreate the physics body object
  24144. * @param mass The mass of the physics imposter
  24145. */
  24146. setMass(mass: number): void;
  24147. /**
  24148. * Gets the linear velocity
  24149. * @returns linear velocity or null
  24150. */
  24151. getLinearVelocity(): Nullable<Vector3>;
  24152. /**
  24153. * Sets the linear velocity
  24154. * @param velocity linear velocity or null
  24155. */
  24156. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24157. /**
  24158. * Gets the angular velocity
  24159. * @returns angular velocity or null
  24160. */
  24161. getAngularVelocity(): Nullable<Vector3>;
  24162. /**
  24163. * Sets the angular velocity
  24164. * @param velocity The velocity or null
  24165. */
  24166. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24167. /**
  24168. * Execute a function with the physics plugin native code
  24169. * Provide a function the will have two variables - the world object and the physics body object
  24170. * @param func The function to execute with the physics plugin native code
  24171. */
  24172. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24173. /**
  24174. * Register a function that will be executed before the physics world is stepping forward
  24175. * @param func The function to execute before the physics world is stepped forward
  24176. */
  24177. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24178. /**
  24179. * Unregister a function that will be executed before the physics world is stepping forward
  24180. * @param func The function to execute before the physics world is stepped forward
  24181. */
  24182. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24183. /**
  24184. * Register a function that will be executed after the physics step
  24185. * @param func The function to execute after physics step
  24186. */
  24187. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24188. /**
  24189. * Unregisters a function that will be executed after the physics step
  24190. * @param func The function to execute after physics step
  24191. */
  24192. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24193. /**
  24194. * register a function that will be executed when this impostor collides against a different body
  24195. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24196. * @param func Callback that is executed on collision
  24197. */
  24198. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24199. /**
  24200. * Unregisters the physics imposter on contact
  24201. * @param collideAgainst The physics object to collide against
  24202. * @param func Callback to execute on collision
  24203. */
  24204. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24205. private _tmpQuat;
  24206. private _tmpQuat2;
  24207. /**
  24208. * Get the parent rotation
  24209. * @returns The parent rotation
  24210. */
  24211. getParentsRotation(): Quaternion;
  24212. /**
  24213. * this function is executed by the physics engine.
  24214. */
  24215. beforeStep: () => void;
  24216. /**
  24217. * this function is executed by the physics engine
  24218. */
  24219. afterStep: () => void;
  24220. /**
  24221. * Legacy collision detection event support
  24222. */
  24223. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24224. /**
  24225. * event and body object due to cannon's event-based architecture.
  24226. */
  24227. onCollide: (e: {
  24228. body: any;
  24229. }) => void;
  24230. /**
  24231. * Apply a force
  24232. * @param force The force to apply
  24233. * @param contactPoint The contact point for the force
  24234. * @returns The physics imposter
  24235. */
  24236. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24237. /**
  24238. * Apply an impulse
  24239. * @param force The impulse force
  24240. * @param contactPoint The contact point for the impulse force
  24241. * @returns The physics imposter
  24242. */
  24243. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24244. /**
  24245. * A help function to create a joint
  24246. * @param otherImpostor A physics imposter used to create a joint
  24247. * @param jointType The type of joint
  24248. * @param jointData The data for the joint
  24249. * @returns The physics imposter
  24250. */
  24251. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24252. /**
  24253. * Add a joint to this impostor with a different impostor
  24254. * @param otherImpostor A physics imposter used to add a joint
  24255. * @param joint The joint to add
  24256. * @returns The physics imposter
  24257. */
  24258. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24259. /**
  24260. * Add an anchor to a cloth impostor
  24261. * @param otherImpostor rigid impostor to anchor to
  24262. * @param width ratio across width from 0 to 1
  24263. * @param height ratio up height from 0 to 1
  24264. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24265. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24266. * @returns impostor the soft imposter
  24267. */
  24268. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24269. /**
  24270. * Add a hook to a rope impostor
  24271. * @param otherImpostor rigid impostor to anchor to
  24272. * @param length ratio across rope from 0 to 1
  24273. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24274. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24275. * @returns impostor the rope imposter
  24276. */
  24277. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24278. /**
  24279. * Will keep this body still, in a sleep mode.
  24280. * @returns the physics imposter
  24281. */
  24282. sleep(): PhysicsImpostor;
  24283. /**
  24284. * Wake the body up.
  24285. * @returns The physics imposter
  24286. */
  24287. wakeUp(): PhysicsImpostor;
  24288. /**
  24289. * Clones the physics imposter
  24290. * @param newObject The physics imposter clones to this physics-enabled object
  24291. * @returns A nullable physics imposter
  24292. */
  24293. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24294. /**
  24295. * Disposes the physics imposter
  24296. */
  24297. dispose(): void;
  24298. /**
  24299. * Sets the delta position
  24300. * @param position The delta position amount
  24301. */
  24302. setDeltaPosition(position: Vector3): void;
  24303. /**
  24304. * Sets the delta rotation
  24305. * @param rotation The delta rotation amount
  24306. */
  24307. setDeltaRotation(rotation: Quaternion): void;
  24308. /**
  24309. * Gets the box size of the physics imposter and stores the result in the input parameter
  24310. * @param result Stores the box size
  24311. * @returns The physics imposter
  24312. */
  24313. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24314. /**
  24315. * Gets the radius of the physics imposter
  24316. * @returns Radius of the physics imposter
  24317. */
  24318. getRadius(): number;
  24319. /**
  24320. * Sync a bone with this impostor
  24321. * @param bone The bone to sync to the impostor.
  24322. * @param boneMesh The mesh that the bone is influencing.
  24323. * @param jointPivot The pivot of the joint / bone in local space.
  24324. * @param distToJoint Optional distance from the impostor to the joint.
  24325. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24326. */
  24327. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24328. /**
  24329. * Sync impostor to a bone
  24330. * @param bone The bone that the impostor will be synced to.
  24331. * @param boneMesh The mesh that the bone is influencing.
  24332. * @param jointPivot The pivot of the joint / bone in local space.
  24333. * @param distToJoint Optional distance from the impostor to the joint.
  24334. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24335. * @param boneAxis Optional vector3 axis the bone is aligned with
  24336. */
  24337. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24338. /**
  24339. * No-Imposter type
  24340. */
  24341. static NoImpostor: number;
  24342. /**
  24343. * Sphere-Imposter type
  24344. */
  24345. static SphereImpostor: number;
  24346. /**
  24347. * Box-Imposter type
  24348. */
  24349. static BoxImpostor: number;
  24350. /**
  24351. * Plane-Imposter type
  24352. */
  24353. static PlaneImpostor: number;
  24354. /**
  24355. * Mesh-imposter type
  24356. */
  24357. static MeshImpostor: number;
  24358. /**
  24359. * Capsule-Impostor type (Ammo.js plugin only)
  24360. */
  24361. static CapsuleImpostor: number;
  24362. /**
  24363. * Cylinder-Imposter type
  24364. */
  24365. static CylinderImpostor: number;
  24366. /**
  24367. * Particle-Imposter type
  24368. */
  24369. static ParticleImpostor: number;
  24370. /**
  24371. * Heightmap-Imposter type
  24372. */
  24373. static HeightmapImpostor: number;
  24374. /**
  24375. * ConvexHull-Impostor type (Ammo.js plugin only)
  24376. */
  24377. static ConvexHullImpostor: number;
  24378. /**
  24379. * Custom-Imposter type (Ammo.js plugin only)
  24380. */
  24381. static CustomImpostor: number;
  24382. /**
  24383. * Rope-Imposter type
  24384. */
  24385. static RopeImpostor: number;
  24386. /**
  24387. * Cloth-Imposter type
  24388. */
  24389. static ClothImpostor: number;
  24390. /**
  24391. * Softbody-Imposter type
  24392. */
  24393. static SoftbodyImpostor: number;
  24394. }
  24395. }
  24396. declare module BABYLON {
  24397. /**
  24398. * @hidden
  24399. **/
  24400. export class _CreationDataStorage {
  24401. closePath?: boolean;
  24402. closeArray?: boolean;
  24403. idx: number[];
  24404. dashSize: number;
  24405. gapSize: number;
  24406. path3D: Path3D;
  24407. pathArray: Vector3[][];
  24408. arc: number;
  24409. radius: number;
  24410. cap: number;
  24411. tessellation: number;
  24412. }
  24413. /**
  24414. * @hidden
  24415. **/
  24416. class _InstanceDataStorage {
  24417. visibleInstances: any;
  24418. batchCache: _InstancesBatch;
  24419. instancesBufferSize: number;
  24420. instancesBuffer: Nullable<Buffer>;
  24421. instancesData: Float32Array;
  24422. overridenInstanceCount: number;
  24423. isFrozen: boolean;
  24424. previousBatch: Nullable<_InstancesBatch>;
  24425. hardwareInstancedRendering: boolean;
  24426. sideOrientation: number;
  24427. manualUpdate: boolean;
  24428. }
  24429. /**
  24430. * @hidden
  24431. **/
  24432. export class _InstancesBatch {
  24433. mustReturn: boolean;
  24434. visibleInstances: Nullable<InstancedMesh[]>[];
  24435. renderSelf: boolean[];
  24436. hardwareInstancedRendering: boolean[];
  24437. }
  24438. /**
  24439. * Class used to represent renderable models
  24440. */
  24441. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24442. /**
  24443. * Mesh side orientation : usually the external or front surface
  24444. */
  24445. static readonly FRONTSIDE: number;
  24446. /**
  24447. * Mesh side orientation : usually the internal or back surface
  24448. */
  24449. static readonly BACKSIDE: number;
  24450. /**
  24451. * Mesh side orientation : both internal and external or front and back surfaces
  24452. */
  24453. static readonly DOUBLESIDE: number;
  24454. /**
  24455. * Mesh side orientation : by default, `FRONTSIDE`
  24456. */
  24457. static readonly DEFAULTSIDE: number;
  24458. /**
  24459. * Mesh cap setting : no cap
  24460. */
  24461. static readonly NO_CAP: number;
  24462. /**
  24463. * Mesh cap setting : one cap at the beginning of the mesh
  24464. */
  24465. static readonly CAP_START: number;
  24466. /**
  24467. * Mesh cap setting : one cap at the end of the mesh
  24468. */
  24469. static readonly CAP_END: number;
  24470. /**
  24471. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24472. */
  24473. static readonly CAP_ALL: number;
  24474. /**
  24475. * Mesh pattern setting : no flip or rotate
  24476. */
  24477. static readonly NO_FLIP: number;
  24478. /**
  24479. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24480. */
  24481. static readonly FLIP_TILE: number;
  24482. /**
  24483. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24484. */
  24485. static readonly ROTATE_TILE: number;
  24486. /**
  24487. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24488. */
  24489. static readonly FLIP_ROW: number;
  24490. /**
  24491. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24492. */
  24493. static readonly ROTATE_ROW: number;
  24494. /**
  24495. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24496. */
  24497. static readonly FLIP_N_ROTATE_TILE: number;
  24498. /**
  24499. * Mesh pattern setting : rotate pattern and rotate
  24500. */
  24501. static readonly FLIP_N_ROTATE_ROW: number;
  24502. /**
  24503. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24504. */
  24505. static readonly CENTER: number;
  24506. /**
  24507. * Mesh tile positioning : part tiles on left
  24508. */
  24509. static readonly LEFT: number;
  24510. /**
  24511. * Mesh tile positioning : part tiles on right
  24512. */
  24513. static readonly RIGHT: number;
  24514. /**
  24515. * Mesh tile positioning : part tiles on top
  24516. */
  24517. static readonly TOP: number;
  24518. /**
  24519. * Mesh tile positioning : part tiles on bottom
  24520. */
  24521. static readonly BOTTOM: number;
  24522. /**
  24523. * Gets the default side orientation.
  24524. * @param orientation the orientation to value to attempt to get
  24525. * @returns the default orientation
  24526. * @hidden
  24527. */
  24528. static _GetDefaultSideOrientation(orientation?: number): number;
  24529. private _internalMeshDataInfo;
  24530. /**
  24531. * An event triggered before rendering the mesh
  24532. */
  24533. get onBeforeRenderObservable(): Observable<Mesh>;
  24534. /**
  24535. * An event triggered before binding the mesh
  24536. */
  24537. get onBeforeBindObservable(): Observable<Mesh>;
  24538. /**
  24539. * An event triggered after rendering the mesh
  24540. */
  24541. get onAfterRenderObservable(): Observable<Mesh>;
  24542. /**
  24543. * An event triggered before drawing the mesh
  24544. */
  24545. get onBeforeDrawObservable(): Observable<Mesh>;
  24546. private _onBeforeDrawObserver;
  24547. /**
  24548. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24549. */
  24550. set onBeforeDraw(callback: () => void);
  24551. get hasInstances(): boolean;
  24552. /**
  24553. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24554. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24555. */
  24556. delayLoadState: number;
  24557. /**
  24558. * Gets the list of instances created from this mesh
  24559. * it is not supposed to be modified manually.
  24560. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24561. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24562. */
  24563. instances: InstancedMesh[];
  24564. /**
  24565. * Gets the file containing delay loading data for this mesh
  24566. */
  24567. delayLoadingFile: string;
  24568. /** @hidden */
  24569. _binaryInfo: any;
  24570. /**
  24571. * User defined function used to change how LOD level selection is done
  24572. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24573. */
  24574. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24575. /**
  24576. * Gets or sets the morph target manager
  24577. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24578. */
  24579. get morphTargetManager(): Nullable<MorphTargetManager>;
  24580. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24581. /** @hidden */
  24582. _creationDataStorage: Nullable<_CreationDataStorage>;
  24583. /** @hidden */
  24584. _geometry: Nullable<Geometry>;
  24585. /** @hidden */
  24586. _delayInfo: Array<string>;
  24587. /** @hidden */
  24588. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24589. /** @hidden */
  24590. _instanceDataStorage: _InstanceDataStorage;
  24591. private _effectiveMaterial;
  24592. /** @hidden */
  24593. _shouldGenerateFlatShading: boolean;
  24594. /** @hidden */
  24595. _originalBuilderSideOrientation: number;
  24596. /**
  24597. * Use this property to change the original side orientation defined at construction time
  24598. */
  24599. overrideMaterialSideOrientation: Nullable<number>;
  24600. /**
  24601. * Gets the source mesh (the one used to clone this one from)
  24602. */
  24603. get source(): Nullable<Mesh>;
  24604. /**
  24605. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24606. */
  24607. get isUnIndexed(): boolean;
  24608. set isUnIndexed(value: boolean);
  24609. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24610. get worldMatrixInstancedBuffer(): Float32Array;
  24611. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24612. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24613. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24614. /**
  24615. * @constructor
  24616. * @param name The value used by scene.getMeshByName() to do a lookup.
  24617. * @param scene The scene to add this mesh to.
  24618. * @param parent The parent of this mesh, if it has one
  24619. * @param source An optional Mesh from which geometry is shared, cloned.
  24620. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24621. * When false, achieved by calling a clone(), also passing False.
  24622. * This will make creation of children, recursive.
  24623. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24624. */
  24625. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24626. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24627. doNotInstantiate: boolean;
  24628. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24629. /**
  24630. * Gets the class name
  24631. * @returns the string "Mesh".
  24632. */
  24633. getClassName(): string;
  24634. /** @hidden */
  24635. get _isMesh(): boolean;
  24636. /**
  24637. * Returns a description of this mesh
  24638. * @param fullDetails define if full details about this mesh must be used
  24639. * @returns a descriptive string representing this mesh
  24640. */
  24641. toString(fullDetails?: boolean): string;
  24642. /** @hidden */
  24643. _unBindEffect(): void;
  24644. /**
  24645. * Gets a boolean indicating if this mesh has LOD
  24646. */
  24647. get hasLODLevels(): boolean;
  24648. /**
  24649. * Gets the list of MeshLODLevel associated with the current mesh
  24650. * @returns an array of MeshLODLevel
  24651. */
  24652. getLODLevels(): MeshLODLevel[];
  24653. private _sortLODLevels;
  24654. /**
  24655. * Add a mesh as LOD level triggered at the given distance.
  24656. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24657. * @param distance The distance from the center of the object to show this level
  24658. * @param mesh The mesh to be added as LOD level (can be null)
  24659. * @return This mesh (for chaining)
  24660. */
  24661. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24662. /**
  24663. * Returns the LOD level mesh at the passed distance or null if not found.
  24664. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24665. * @param distance The distance from the center of the object to show this level
  24666. * @returns a Mesh or `null`
  24667. */
  24668. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24669. /**
  24670. * Remove a mesh from the LOD array
  24671. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24672. * @param mesh defines the mesh to be removed
  24673. * @return This mesh (for chaining)
  24674. */
  24675. removeLODLevel(mesh: Mesh): Mesh;
  24676. /**
  24677. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24678. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24679. * @param camera defines the camera to use to compute distance
  24680. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24681. * @return This mesh (for chaining)
  24682. */
  24683. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24684. /**
  24685. * Gets the mesh internal Geometry object
  24686. */
  24687. get geometry(): Nullable<Geometry>;
  24688. /**
  24689. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24690. * @returns the total number of vertices
  24691. */
  24692. getTotalVertices(): number;
  24693. /**
  24694. * Returns the content of an associated vertex buffer
  24695. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24696. * - VertexBuffer.PositionKind
  24697. * - VertexBuffer.UVKind
  24698. * - VertexBuffer.UV2Kind
  24699. * - VertexBuffer.UV3Kind
  24700. * - VertexBuffer.UV4Kind
  24701. * - VertexBuffer.UV5Kind
  24702. * - VertexBuffer.UV6Kind
  24703. * - VertexBuffer.ColorKind
  24704. * - VertexBuffer.MatricesIndicesKind
  24705. * - VertexBuffer.MatricesIndicesExtraKind
  24706. * - VertexBuffer.MatricesWeightsKind
  24707. * - VertexBuffer.MatricesWeightsExtraKind
  24708. * @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
  24709. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24710. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24711. */
  24712. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24713. /**
  24714. * Returns the mesh VertexBuffer object from the requested `kind`
  24715. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24716. * - VertexBuffer.PositionKind
  24717. * - VertexBuffer.NormalKind
  24718. * - VertexBuffer.UVKind
  24719. * - VertexBuffer.UV2Kind
  24720. * - VertexBuffer.UV3Kind
  24721. * - VertexBuffer.UV4Kind
  24722. * - VertexBuffer.UV5Kind
  24723. * - VertexBuffer.UV6Kind
  24724. * - VertexBuffer.ColorKind
  24725. * - VertexBuffer.MatricesIndicesKind
  24726. * - VertexBuffer.MatricesIndicesExtraKind
  24727. * - VertexBuffer.MatricesWeightsKind
  24728. * - VertexBuffer.MatricesWeightsExtraKind
  24729. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24730. */
  24731. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24732. /**
  24733. * Tests if a specific vertex buffer is associated with this mesh
  24734. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24735. * - VertexBuffer.PositionKind
  24736. * - VertexBuffer.NormalKind
  24737. * - VertexBuffer.UVKind
  24738. * - VertexBuffer.UV2Kind
  24739. * - VertexBuffer.UV3Kind
  24740. * - VertexBuffer.UV4Kind
  24741. * - VertexBuffer.UV5Kind
  24742. * - VertexBuffer.UV6Kind
  24743. * - VertexBuffer.ColorKind
  24744. * - VertexBuffer.MatricesIndicesKind
  24745. * - VertexBuffer.MatricesIndicesExtraKind
  24746. * - VertexBuffer.MatricesWeightsKind
  24747. * - VertexBuffer.MatricesWeightsExtraKind
  24748. * @returns a boolean
  24749. */
  24750. isVerticesDataPresent(kind: string): boolean;
  24751. /**
  24752. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24753. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24754. * - VertexBuffer.PositionKind
  24755. * - VertexBuffer.UVKind
  24756. * - VertexBuffer.UV2Kind
  24757. * - VertexBuffer.UV3Kind
  24758. * - VertexBuffer.UV4Kind
  24759. * - VertexBuffer.UV5Kind
  24760. * - VertexBuffer.UV6Kind
  24761. * - VertexBuffer.ColorKind
  24762. * - VertexBuffer.MatricesIndicesKind
  24763. * - VertexBuffer.MatricesIndicesExtraKind
  24764. * - VertexBuffer.MatricesWeightsKind
  24765. * - VertexBuffer.MatricesWeightsExtraKind
  24766. * @returns a boolean
  24767. */
  24768. isVertexBufferUpdatable(kind: string): boolean;
  24769. /**
  24770. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24771. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24772. * - VertexBuffer.PositionKind
  24773. * - VertexBuffer.NormalKind
  24774. * - VertexBuffer.UVKind
  24775. * - VertexBuffer.UV2Kind
  24776. * - VertexBuffer.UV3Kind
  24777. * - VertexBuffer.UV4Kind
  24778. * - VertexBuffer.UV5Kind
  24779. * - VertexBuffer.UV6Kind
  24780. * - VertexBuffer.ColorKind
  24781. * - VertexBuffer.MatricesIndicesKind
  24782. * - VertexBuffer.MatricesIndicesExtraKind
  24783. * - VertexBuffer.MatricesWeightsKind
  24784. * - VertexBuffer.MatricesWeightsExtraKind
  24785. * @returns an array of strings
  24786. */
  24787. getVerticesDataKinds(): string[];
  24788. /**
  24789. * Returns a positive integer : the total number of indices in this mesh geometry.
  24790. * @returns the numner of indices or zero if the mesh has no geometry.
  24791. */
  24792. getTotalIndices(): number;
  24793. /**
  24794. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24795. * @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.
  24796. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24797. * @returns the indices array or an empty array if the mesh has no geometry
  24798. */
  24799. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24800. get isBlocked(): boolean;
  24801. /**
  24802. * Determine if the current mesh is ready to be rendered
  24803. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24804. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24805. * @returns true if all associated assets are ready (material, textures, shaders)
  24806. */
  24807. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24808. /**
  24809. * 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.
  24810. */
  24811. get areNormalsFrozen(): boolean;
  24812. /**
  24813. * 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.
  24814. * @returns the current mesh
  24815. */
  24816. freezeNormals(): Mesh;
  24817. /**
  24818. * 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
  24819. * @returns the current mesh
  24820. */
  24821. unfreezeNormals(): Mesh;
  24822. /**
  24823. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24824. */
  24825. set overridenInstanceCount(count: number);
  24826. /** @hidden */
  24827. _preActivate(): Mesh;
  24828. /** @hidden */
  24829. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24830. /** @hidden */
  24831. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24832. /**
  24833. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24834. * This means the mesh underlying bounding box and sphere are recomputed.
  24835. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24836. * @returns the current mesh
  24837. */
  24838. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24839. /** @hidden */
  24840. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24841. /**
  24842. * This function will subdivide the mesh into multiple submeshes
  24843. * @param count defines the expected number of submeshes
  24844. */
  24845. subdivide(count: number): void;
  24846. /**
  24847. * Copy a FloatArray into a specific associated vertex buffer
  24848. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24849. * - VertexBuffer.PositionKind
  24850. * - VertexBuffer.UVKind
  24851. * - VertexBuffer.UV2Kind
  24852. * - VertexBuffer.UV3Kind
  24853. * - VertexBuffer.UV4Kind
  24854. * - VertexBuffer.UV5Kind
  24855. * - VertexBuffer.UV6Kind
  24856. * - VertexBuffer.ColorKind
  24857. * - VertexBuffer.MatricesIndicesKind
  24858. * - VertexBuffer.MatricesIndicesExtraKind
  24859. * - VertexBuffer.MatricesWeightsKind
  24860. * - VertexBuffer.MatricesWeightsExtraKind
  24861. * @param data defines the data source
  24862. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24863. * @param stride defines the data stride size (can be null)
  24864. * @returns the current mesh
  24865. */
  24866. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24867. /**
  24868. * Delete a vertex buffer associated with this mesh
  24869. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24870. * - VertexBuffer.PositionKind
  24871. * - VertexBuffer.UVKind
  24872. * - VertexBuffer.UV2Kind
  24873. * - VertexBuffer.UV3Kind
  24874. * - VertexBuffer.UV4Kind
  24875. * - VertexBuffer.UV5Kind
  24876. * - VertexBuffer.UV6Kind
  24877. * - VertexBuffer.ColorKind
  24878. * - VertexBuffer.MatricesIndicesKind
  24879. * - VertexBuffer.MatricesIndicesExtraKind
  24880. * - VertexBuffer.MatricesWeightsKind
  24881. * - VertexBuffer.MatricesWeightsExtraKind
  24882. */
  24883. removeVerticesData(kind: string): void;
  24884. /**
  24885. * Flags an associated vertex buffer as updatable
  24886. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24887. * - VertexBuffer.PositionKind
  24888. * - VertexBuffer.UVKind
  24889. * - VertexBuffer.UV2Kind
  24890. * - VertexBuffer.UV3Kind
  24891. * - VertexBuffer.UV4Kind
  24892. * - VertexBuffer.UV5Kind
  24893. * - VertexBuffer.UV6Kind
  24894. * - VertexBuffer.ColorKind
  24895. * - VertexBuffer.MatricesIndicesKind
  24896. * - VertexBuffer.MatricesIndicesExtraKind
  24897. * - VertexBuffer.MatricesWeightsKind
  24898. * - VertexBuffer.MatricesWeightsExtraKind
  24899. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24900. */
  24901. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24902. /**
  24903. * Sets the mesh global Vertex Buffer
  24904. * @param buffer defines the buffer to use
  24905. * @returns the current mesh
  24906. */
  24907. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24908. /**
  24909. * Update a specific associated vertex buffer
  24910. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24911. * - VertexBuffer.PositionKind
  24912. * - VertexBuffer.UVKind
  24913. * - VertexBuffer.UV2Kind
  24914. * - VertexBuffer.UV3Kind
  24915. * - VertexBuffer.UV4Kind
  24916. * - VertexBuffer.UV5Kind
  24917. * - VertexBuffer.UV6Kind
  24918. * - VertexBuffer.ColorKind
  24919. * - VertexBuffer.MatricesIndicesKind
  24920. * - VertexBuffer.MatricesIndicesExtraKind
  24921. * - VertexBuffer.MatricesWeightsKind
  24922. * - VertexBuffer.MatricesWeightsExtraKind
  24923. * @param data defines the data source
  24924. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24925. * @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)
  24926. * @returns the current mesh
  24927. */
  24928. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24929. /**
  24930. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24931. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24932. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24933. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24934. * @returns the current mesh
  24935. */
  24936. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24937. /**
  24938. * Creates a un-shared specific occurence of the geometry for the mesh.
  24939. * @returns the current mesh
  24940. */
  24941. makeGeometryUnique(): Mesh;
  24942. /**
  24943. * Set the index buffer of this mesh
  24944. * @param indices defines the source data
  24945. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24946. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24947. * @returns the current mesh
  24948. */
  24949. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24950. /**
  24951. * Update the current index buffer
  24952. * @param indices defines the source data
  24953. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24954. * @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)
  24955. * @returns the current mesh
  24956. */
  24957. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24958. /**
  24959. * Invert the geometry to move from a right handed system to a left handed one.
  24960. * @returns the current mesh
  24961. */
  24962. toLeftHanded(): Mesh;
  24963. /** @hidden */
  24964. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24965. /** @hidden */
  24966. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24967. /**
  24968. * Registers for this mesh a javascript function called just before the rendering process
  24969. * @param func defines the function to call before rendering this mesh
  24970. * @returns the current mesh
  24971. */
  24972. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24973. /**
  24974. * Disposes a previously registered javascript function called before the rendering
  24975. * @param func defines the function to remove
  24976. * @returns the current mesh
  24977. */
  24978. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24979. /**
  24980. * Registers for this mesh a javascript function called just after the rendering is complete
  24981. * @param func defines the function to call after rendering this mesh
  24982. * @returns the current mesh
  24983. */
  24984. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24985. /**
  24986. * Disposes a previously registered javascript function called after the rendering.
  24987. * @param func defines the function to remove
  24988. * @returns the current mesh
  24989. */
  24990. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24991. /** @hidden */
  24992. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24993. /** @hidden */
  24994. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24995. /** @hidden */
  24996. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24997. /** @hidden */
  24998. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24999. /** @hidden */
  25000. _rebuild(): void;
  25001. /** @hidden */
  25002. _freeze(): void;
  25003. /** @hidden */
  25004. _unFreeze(): void;
  25005. /**
  25006. * 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
  25007. * @param subMesh defines the subMesh to render
  25008. * @param enableAlphaMode defines if alpha mode can be changed
  25009. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25010. * @returns the current mesh
  25011. */
  25012. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25013. private _onBeforeDraw;
  25014. /**
  25015. * Renormalize the mesh and patch it up if there are no weights
  25016. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25017. * However in the case of zero weights then we set just a single influence to 1.
  25018. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25019. */
  25020. cleanMatrixWeights(): void;
  25021. private normalizeSkinFourWeights;
  25022. private normalizeSkinWeightsAndExtra;
  25023. /**
  25024. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25025. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25026. * the user know there was an issue with importing the mesh
  25027. * @returns a validation object with skinned, valid and report string
  25028. */
  25029. validateSkinning(): {
  25030. skinned: boolean;
  25031. valid: boolean;
  25032. report: string;
  25033. };
  25034. /** @hidden */
  25035. _checkDelayState(): Mesh;
  25036. private _queueLoad;
  25037. /**
  25038. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25039. * A mesh is in the frustum if its bounding box intersects the frustum
  25040. * @param frustumPlanes defines the frustum to test
  25041. * @returns true if the mesh is in the frustum planes
  25042. */
  25043. isInFrustum(frustumPlanes: Plane[]): boolean;
  25044. /**
  25045. * Sets the mesh material by the material or multiMaterial `id` property
  25046. * @param id is a string identifying the material or the multiMaterial
  25047. * @returns the current mesh
  25048. */
  25049. setMaterialByID(id: string): Mesh;
  25050. /**
  25051. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25052. * @returns an array of IAnimatable
  25053. */
  25054. getAnimatables(): IAnimatable[];
  25055. /**
  25056. * Modifies the mesh geometry according to the passed transformation matrix.
  25057. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25058. * The mesh normals are modified using the same transformation.
  25059. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25060. * @param transform defines the transform matrix to use
  25061. * @see http://doc.babylonjs.com/resources/baking_transformations
  25062. * @returns the current mesh
  25063. */
  25064. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25065. /**
  25066. * Modifies the mesh geometry according to its own current World Matrix.
  25067. * The mesh World Matrix is then reset.
  25068. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25069. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25070. * @see http://doc.babylonjs.com/resources/baking_transformations
  25071. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25072. * @returns the current mesh
  25073. */
  25074. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25075. /** @hidden */
  25076. get _positions(): Nullable<Vector3[]>;
  25077. /** @hidden */
  25078. _resetPointsArrayCache(): Mesh;
  25079. /** @hidden */
  25080. _generatePointsArray(): boolean;
  25081. /**
  25082. * Returns a new Mesh object generated from the current mesh properties.
  25083. * This method must not get confused with createInstance()
  25084. * @param name is a string, the name given to the new mesh
  25085. * @param newParent can be any Node object (default `null`)
  25086. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25087. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25088. * @returns a new mesh
  25089. */
  25090. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25091. /**
  25092. * Releases resources associated with this mesh.
  25093. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25094. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25095. */
  25096. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25097. /** @hidden */
  25098. _disposeInstanceSpecificData(): void;
  25099. /**
  25100. * Modifies the mesh geometry according to a displacement map.
  25101. * 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.
  25102. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25103. * @param url is a string, the URL from the image file is to be downloaded.
  25104. * @param minHeight is the lower limit of the displacement.
  25105. * @param maxHeight is the upper limit of the displacement.
  25106. * @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.
  25107. * @param uvOffset is an optional vector2 used to offset UV.
  25108. * @param uvScale is an optional vector2 used to scale UV.
  25109. * @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.
  25110. * @returns the Mesh.
  25111. */
  25112. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25113. /**
  25114. * Modifies the mesh geometry according to a displacementMap buffer.
  25115. * 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.
  25116. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25117. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25118. * @param heightMapWidth is the width of the buffer image.
  25119. * @param heightMapHeight is the height of the buffer image.
  25120. * @param minHeight is the lower limit of the displacement.
  25121. * @param maxHeight is the upper limit of the displacement.
  25122. * @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.
  25123. * @param uvOffset is an optional vector2 used to offset UV.
  25124. * @param uvScale is an optional vector2 used to scale UV.
  25125. * @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.
  25126. * @returns the Mesh.
  25127. */
  25128. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25129. /**
  25130. * Modify the mesh to get a flat shading rendering.
  25131. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25132. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25133. * @returns current mesh
  25134. */
  25135. convertToFlatShadedMesh(): Mesh;
  25136. /**
  25137. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25138. * In other words, more vertices, no more indices and a single bigger VBO.
  25139. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25140. * @returns current mesh
  25141. */
  25142. convertToUnIndexedMesh(): Mesh;
  25143. /**
  25144. * Inverses facet orientations.
  25145. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25146. * @param flipNormals will also inverts the normals
  25147. * @returns current mesh
  25148. */
  25149. flipFaces(flipNormals?: boolean): Mesh;
  25150. /**
  25151. * Increase the number of facets and hence vertices in a mesh
  25152. * Vertex normals are interpolated from existing vertex normals
  25153. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25154. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25155. */
  25156. increaseVertices(numberPerEdge: number): void;
  25157. /**
  25158. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25159. * This will undo any application of covertToFlatShadedMesh
  25160. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25161. */
  25162. forceSharedVertices(): void;
  25163. /** @hidden */
  25164. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25165. /** @hidden */
  25166. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25167. /**
  25168. * Creates a new InstancedMesh object from the mesh model.
  25169. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25170. * @param name defines the name of the new instance
  25171. * @returns a new InstancedMesh
  25172. */
  25173. createInstance(name: string): InstancedMesh;
  25174. /**
  25175. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25176. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25177. * @returns the current mesh
  25178. */
  25179. synchronizeInstances(): Mesh;
  25180. /**
  25181. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25182. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25183. * This should be used together with the simplification to avoid disappearing triangles.
  25184. * @param successCallback an optional success callback to be called after the optimization finished.
  25185. * @returns the current mesh
  25186. */
  25187. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25188. /**
  25189. * Serialize current mesh
  25190. * @param serializationObject defines the object which will receive the serialization data
  25191. */
  25192. serialize(serializationObject: any): void;
  25193. /** @hidden */
  25194. _syncGeometryWithMorphTargetManager(): void;
  25195. /** @hidden */
  25196. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25197. /**
  25198. * Returns a new Mesh object parsed from the source provided.
  25199. * @param parsedMesh is the source
  25200. * @param scene defines the hosting scene
  25201. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25202. * @returns a new Mesh
  25203. */
  25204. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25205. /**
  25206. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25207. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25208. * @param name defines the name of the mesh to create
  25209. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25210. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25211. * @param closePath creates a seam between the first and the last points of each path of the path array
  25212. * @param offset is taken in account only if the `pathArray` is containing a single path
  25213. * @param scene defines the hosting scene
  25214. * @param updatable defines if the mesh must be flagged as updatable
  25215. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25216. * @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)
  25217. * @returns a new Mesh
  25218. */
  25219. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25220. /**
  25221. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25222. * @param name defines the name of the mesh to create
  25223. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25224. * @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
  25225. * @param scene defines the hosting scene
  25226. * @param updatable defines if the mesh must be flagged as updatable
  25227. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25228. * @returns a new Mesh
  25229. */
  25230. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25231. /**
  25232. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25233. * @param name defines the name of the mesh to create
  25234. * @param size sets the size (float) of each box side (default 1)
  25235. * @param scene defines the hosting scene
  25236. * @param updatable defines if the mesh must be flagged as updatable
  25237. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25238. * @returns a new Mesh
  25239. */
  25240. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25241. /**
  25242. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25243. * @param name defines the name of the mesh to create
  25244. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25245. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25246. * @param scene defines the hosting scene
  25247. * @param updatable defines if the mesh must be flagged as updatable
  25248. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25249. * @returns a new Mesh
  25250. */
  25251. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25252. /**
  25253. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25254. * @param name defines the name of the mesh to create
  25255. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25256. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25257. * @param scene defines the hosting scene
  25258. * @returns a new Mesh
  25259. */
  25260. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25261. /**
  25262. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25263. * @param name defines the name of the mesh to create
  25264. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25265. * @param diameterTop set the top cap diameter (floats, default 1)
  25266. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25267. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25268. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25269. * @param scene defines the hosting scene
  25270. * @param updatable defines if the mesh must be flagged as updatable
  25271. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25272. * @returns a new Mesh
  25273. */
  25274. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25275. /**
  25276. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25277. * @param name defines the name of the mesh to create
  25278. * @param diameter sets the diameter size (float) of the torus (default 1)
  25279. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25280. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25281. * @param scene defines the hosting scene
  25282. * @param updatable defines if the mesh must be flagged as updatable
  25283. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25284. * @returns a new Mesh
  25285. */
  25286. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25287. /**
  25288. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25289. * @param name defines the name of the mesh to create
  25290. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25291. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25292. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25293. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25294. * @param p the number of windings on X axis (positive integers, default 2)
  25295. * @param q the number of windings on Y axis (positive integers, default 3)
  25296. * @param scene defines the hosting scene
  25297. * @param updatable defines if the mesh must be flagged as updatable
  25298. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25299. * @returns a new Mesh
  25300. */
  25301. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25302. /**
  25303. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25304. * @param name defines the name of the mesh to create
  25305. * @param points is an array successive Vector3
  25306. * @param scene defines the hosting scene
  25307. * @param updatable defines if the mesh must be flagged as updatable
  25308. * @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).
  25309. * @returns a new Mesh
  25310. */
  25311. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25312. /**
  25313. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25314. * @param name defines the name of the mesh to create
  25315. * @param points is an array successive Vector3
  25316. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25317. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25318. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25319. * @param scene defines the hosting scene
  25320. * @param updatable defines if the mesh must be flagged as updatable
  25321. * @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)
  25322. * @returns a new Mesh
  25323. */
  25324. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25325. /**
  25326. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25327. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25328. * 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.
  25329. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25330. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25331. * Remember you can only change the shape positions, not their number when updating a polygon.
  25332. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25333. * @param name defines the name of the mesh to create
  25334. * @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
  25335. * @param scene defines the hosting scene
  25336. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25337. * @param updatable defines if the mesh must be flagged as updatable
  25338. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25339. * @param earcutInjection can be used to inject your own earcut reference
  25340. * @returns a new Mesh
  25341. */
  25342. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25343. /**
  25344. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25345. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25346. * @param name defines the name of the mesh to create
  25347. * @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
  25348. * @param depth defines the height of extrusion
  25349. * @param scene defines the hosting scene
  25350. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25351. * @param updatable defines if the mesh must be flagged as updatable
  25352. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25353. * @param earcutInjection can be used to inject your own earcut reference
  25354. * @returns a new Mesh
  25355. */
  25356. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25357. /**
  25358. * Creates an extruded shape mesh.
  25359. * 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
  25360. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25361. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25362. * @param name defines the name of the mesh to create
  25363. * @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
  25364. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25365. * @param scale is the value to scale the shape
  25366. * @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
  25367. * @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
  25368. * @param scene defines the hosting scene
  25369. * @param updatable defines if the mesh must be flagged as updatable
  25370. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25371. * @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)
  25372. * @returns a new Mesh
  25373. */
  25374. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25375. /**
  25376. * Creates an custom extruded shape mesh.
  25377. * The custom extrusion is a parametric shape.
  25378. * It has no predefined shape. Its final shape will depend on the input parameters.
  25379. * Please consider using the same method from the MeshBuilder class instead
  25380. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25381. * @param name defines the name of the mesh to create
  25382. * @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
  25383. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25384. * @param scaleFunction is a custom Javascript function called on each path point
  25385. * @param rotationFunction is a custom Javascript function called on each path point
  25386. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25387. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25388. * @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
  25389. * @param scene defines the hosting scene
  25390. * @param updatable defines if the mesh must be flagged as updatable
  25391. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25392. * @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)
  25393. * @returns a new Mesh
  25394. */
  25395. 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;
  25396. /**
  25397. * Creates lathe mesh.
  25398. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25399. * Please consider using the same method from the MeshBuilder class instead
  25400. * @param name defines the name of the mesh to create
  25401. * @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
  25402. * @param radius is the radius value of the lathe
  25403. * @param tessellation is the side number of the lathe.
  25404. * @param scene defines the hosting scene
  25405. * @param updatable defines if the mesh must be flagged as updatable
  25406. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25407. * @returns a new Mesh
  25408. */
  25409. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25410. /**
  25411. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25412. * @param name defines the name of the mesh to create
  25413. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25414. * @param scene defines the hosting scene
  25415. * @param updatable defines if the mesh must be flagged as updatable
  25416. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25417. * @returns a new Mesh
  25418. */
  25419. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25420. /**
  25421. * Creates a ground mesh.
  25422. * Please consider using the same method from the MeshBuilder class instead
  25423. * @param name defines the name of the mesh to create
  25424. * @param width set the width of the ground
  25425. * @param height set the height of the ground
  25426. * @param subdivisions sets the number of subdivisions per side
  25427. * @param scene defines the hosting scene
  25428. * @param updatable defines if the mesh must be flagged as updatable
  25429. * @returns a new Mesh
  25430. */
  25431. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25432. /**
  25433. * Creates a tiled ground mesh.
  25434. * Please consider using the same method from the MeshBuilder class instead
  25435. * @param name defines the name of the mesh to create
  25436. * @param xmin set the ground minimum X coordinate
  25437. * @param zmin set the ground minimum Y coordinate
  25438. * @param xmax set the ground maximum X coordinate
  25439. * @param zmax set the ground maximum Z coordinate
  25440. * @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
  25441. * @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
  25442. * @param scene defines the hosting scene
  25443. * @param updatable defines if the mesh must be flagged as updatable
  25444. * @returns a new Mesh
  25445. */
  25446. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25447. w: number;
  25448. h: number;
  25449. }, precision: {
  25450. w: number;
  25451. h: number;
  25452. }, scene: Scene, updatable?: boolean): Mesh;
  25453. /**
  25454. * Creates a ground mesh from a height map.
  25455. * Please consider using the same method from the MeshBuilder class instead
  25456. * @see http://doc.babylonjs.com/babylon101/height_map
  25457. * @param name defines the name of the mesh to create
  25458. * @param url sets the URL of the height map image resource
  25459. * @param width set the ground width size
  25460. * @param height set the ground height size
  25461. * @param subdivisions sets the number of subdivision per side
  25462. * @param minHeight is the minimum altitude on the ground
  25463. * @param maxHeight is the maximum altitude on the ground
  25464. * @param scene defines the hosting scene
  25465. * @param updatable defines if the mesh must be flagged as updatable
  25466. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25467. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25468. * @returns a new Mesh
  25469. */
  25470. 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;
  25471. /**
  25472. * Creates a tube mesh.
  25473. * The tube is a parametric shape.
  25474. * It has no predefined shape. Its final shape will depend on the input parameters.
  25475. * Please consider using the same method from the MeshBuilder class instead
  25476. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25477. * @param name defines the name of the mesh to create
  25478. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25479. * @param radius sets the tube radius size
  25480. * @param tessellation is the number of sides on the tubular surface
  25481. * @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
  25482. * @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
  25483. * @param scene defines the hosting scene
  25484. * @param updatable defines if the mesh must be flagged as updatable
  25485. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25486. * @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)
  25487. * @returns a new Mesh
  25488. */
  25489. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25490. (i: number, distance: number): number;
  25491. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25492. /**
  25493. * Creates a polyhedron mesh.
  25494. * Please consider using the same method from the MeshBuilder class instead.
  25495. * * 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
  25496. * * The parameter `size` (positive float, default 1) sets the polygon size
  25497. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25498. * * 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`
  25499. * * 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
  25500. * * 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)`)
  25501. * * 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
  25502. * * 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
  25503. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25504. * * 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
  25505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25506. * @param name defines the name of the mesh to create
  25507. * @param options defines the options used to create the mesh
  25508. * @param scene defines the hosting scene
  25509. * @returns a new Mesh
  25510. */
  25511. static CreatePolyhedron(name: string, options: {
  25512. type?: number;
  25513. size?: number;
  25514. sizeX?: number;
  25515. sizeY?: number;
  25516. sizeZ?: number;
  25517. custom?: any;
  25518. faceUV?: Vector4[];
  25519. faceColors?: Color4[];
  25520. updatable?: boolean;
  25521. sideOrientation?: number;
  25522. }, scene: Scene): Mesh;
  25523. /**
  25524. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25525. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25526. * * 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`)
  25527. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25528. * * 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
  25529. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25530. * * 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
  25531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25532. * @param name defines the name of the mesh
  25533. * @param options defines the options used to create the mesh
  25534. * @param scene defines the hosting scene
  25535. * @returns a new Mesh
  25536. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25537. */
  25538. static CreateIcoSphere(name: string, options: {
  25539. radius?: number;
  25540. flat?: boolean;
  25541. subdivisions?: number;
  25542. sideOrientation?: number;
  25543. updatable?: boolean;
  25544. }, scene: Scene): Mesh;
  25545. /**
  25546. * Creates a decal mesh.
  25547. * Please consider using the same method from the MeshBuilder class instead.
  25548. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25549. * @param name defines the name of the mesh
  25550. * @param sourceMesh defines the mesh receiving the decal
  25551. * @param position sets the position of the decal in world coordinates
  25552. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25553. * @param size sets the decal scaling
  25554. * @param angle sets the angle to rotate the decal
  25555. * @returns a new Mesh
  25556. */
  25557. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25558. /**
  25559. * Prepare internal position array for software CPU skinning
  25560. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25561. */
  25562. setPositionsForCPUSkinning(): Float32Array;
  25563. /**
  25564. * Prepare internal normal array for software CPU skinning
  25565. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25566. */
  25567. setNormalsForCPUSkinning(): Float32Array;
  25568. /**
  25569. * Updates the vertex buffer by applying transformation from the bones
  25570. * @param skeleton defines the skeleton to apply to current mesh
  25571. * @returns the current mesh
  25572. */
  25573. applySkeleton(skeleton: Skeleton): Mesh;
  25574. /**
  25575. * 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
  25576. * @param meshes defines the list of meshes to scan
  25577. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25578. */
  25579. static MinMax(meshes: AbstractMesh[]): {
  25580. min: Vector3;
  25581. max: Vector3;
  25582. };
  25583. /**
  25584. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25585. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25586. * @returns a vector3
  25587. */
  25588. static Center(meshesOrMinMaxVector: {
  25589. min: Vector3;
  25590. max: Vector3;
  25591. } | AbstractMesh[]): Vector3;
  25592. /**
  25593. * Merge the array of meshes into a single mesh for performance reasons.
  25594. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25595. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25596. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25597. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25598. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25599. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25600. * @returns a new mesh
  25601. */
  25602. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25603. /** @hidden */
  25604. addInstance(instance: InstancedMesh): void;
  25605. /** @hidden */
  25606. removeInstance(instance: InstancedMesh): void;
  25607. }
  25608. }
  25609. declare module BABYLON {
  25610. /**
  25611. * This is the base class of all the camera used in the application.
  25612. * @see http://doc.babylonjs.com/features/cameras
  25613. */
  25614. export class Camera extends Node {
  25615. /** @hidden */
  25616. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25617. /**
  25618. * This is the default projection mode used by the cameras.
  25619. * It helps recreating a feeling of perspective and better appreciate depth.
  25620. * This is the best way to simulate real life cameras.
  25621. */
  25622. static readonly PERSPECTIVE_CAMERA: number;
  25623. /**
  25624. * This helps creating camera with an orthographic mode.
  25625. * 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.
  25626. */
  25627. static readonly ORTHOGRAPHIC_CAMERA: number;
  25628. /**
  25629. * This is the default FOV mode for perspective cameras.
  25630. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25631. */
  25632. static readonly FOVMODE_VERTICAL_FIXED: number;
  25633. /**
  25634. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25635. */
  25636. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25637. /**
  25638. * This specifies ther is no need for a camera rig.
  25639. * Basically only one eye is rendered corresponding to the camera.
  25640. */
  25641. static readonly RIG_MODE_NONE: number;
  25642. /**
  25643. * Simulates a camera Rig with one blue eye and one red eye.
  25644. * This can be use with 3d blue and red glasses.
  25645. */
  25646. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25647. /**
  25648. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25649. */
  25650. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25651. /**
  25652. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25653. */
  25654. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25655. /**
  25656. * Defines that both eyes of the camera will be rendered over under each other.
  25657. */
  25658. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25659. /**
  25660. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25661. */
  25662. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25663. /**
  25664. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25665. */
  25666. static readonly RIG_MODE_VR: number;
  25667. /**
  25668. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25669. */
  25670. static readonly RIG_MODE_WEBVR: number;
  25671. /**
  25672. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25673. */
  25674. static readonly RIG_MODE_CUSTOM: number;
  25675. /**
  25676. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25677. */
  25678. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25679. /**
  25680. * Define the input manager associated with the camera.
  25681. */
  25682. inputs: CameraInputsManager<Camera>;
  25683. /** @hidden */
  25684. _position: Vector3;
  25685. /**
  25686. * Define the current local position of the camera in the scene
  25687. */
  25688. get position(): Vector3;
  25689. set position(newPosition: Vector3);
  25690. /**
  25691. * The vector the camera should consider as up.
  25692. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25693. */
  25694. upVector: Vector3;
  25695. /**
  25696. * Define the current limit on the left side for an orthographic camera
  25697. * In scene unit
  25698. */
  25699. orthoLeft: Nullable<number>;
  25700. /**
  25701. * Define the current limit on the right side for an orthographic camera
  25702. * In scene unit
  25703. */
  25704. orthoRight: Nullable<number>;
  25705. /**
  25706. * Define the current limit on the bottom side for an orthographic camera
  25707. * In scene unit
  25708. */
  25709. orthoBottom: Nullable<number>;
  25710. /**
  25711. * Define the current limit on the top side for an orthographic camera
  25712. * In scene unit
  25713. */
  25714. orthoTop: Nullable<number>;
  25715. /**
  25716. * Field Of View is set in Radians. (default is 0.8)
  25717. */
  25718. fov: number;
  25719. /**
  25720. * Define the minimum distance the camera can see from.
  25721. * This is important to note that the depth buffer are not infinite and the closer it starts
  25722. * the more your scene might encounter depth fighting issue.
  25723. */
  25724. minZ: number;
  25725. /**
  25726. * Define the maximum distance the camera can see to.
  25727. * This is important to note that the depth buffer are not infinite and the further it end
  25728. * the more your scene might encounter depth fighting issue.
  25729. */
  25730. maxZ: number;
  25731. /**
  25732. * Define the default inertia of the camera.
  25733. * This helps giving a smooth feeling to the camera movement.
  25734. */
  25735. inertia: number;
  25736. /**
  25737. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25738. */
  25739. mode: number;
  25740. /**
  25741. * Define whether the camera is intermediate.
  25742. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25743. */
  25744. isIntermediate: boolean;
  25745. /**
  25746. * Define the viewport of the camera.
  25747. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25748. */
  25749. viewport: Viewport;
  25750. /**
  25751. * Restricts the camera to viewing objects with the same layerMask.
  25752. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25753. */
  25754. layerMask: number;
  25755. /**
  25756. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25757. */
  25758. fovMode: number;
  25759. /**
  25760. * Rig mode of the camera.
  25761. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25762. * This is normally controlled byt the camera themselves as internal use.
  25763. */
  25764. cameraRigMode: number;
  25765. /**
  25766. * Defines the distance between both "eyes" in case of a RIG
  25767. */
  25768. interaxialDistance: number;
  25769. /**
  25770. * Defines if stereoscopic rendering is done side by side or over under.
  25771. */
  25772. isStereoscopicSideBySide: boolean;
  25773. /**
  25774. * 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
  25775. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25776. * else in the scene. (Eg. security camera)
  25777. *
  25778. * 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)
  25779. */
  25780. customRenderTargets: RenderTargetTexture[];
  25781. /**
  25782. * When set, the camera will render to this render target instead of the default canvas
  25783. *
  25784. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25785. */
  25786. outputRenderTarget: Nullable<RenderTargetTexture>;
  25787. /**
  25788. * Observable triggered when the camera view matrix has changed.
  25789. */
  25790. onViewMatrixChangedObservable: Observable<Camera>;
  25791. /**
  25792. * Observable triggered when the camera Projection matrix has changed.
  25793. */
  25794. onProjectionMatrixChangedObservable: Observable<Camera>;
  25795. /**
  25796. * Observable triggered when the inputs have been processed.
  25797. */
  25798. onAfterCheckInputsObservable: Observable<Camera>;
  25799. /**
  25800. * Observable triggered when reset has been called and applied to the camera.
  25801. */
  25802. onRestoreStateObservable: Observable<Camera>;
  25803. /**
  25804. * Is this camera a part of a rig system?
  25805. */
  25806. isRigCamera: boolean;
  25807. /**
  25808. * If isRigCamera set to true this will be set with the parent camera.
  25809. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25810. */
  25811. rigParent?: Camera;
  25812. /** @hidden */
  25813. _cameraRigParams: any;
  25814. /** @hidden */
  25815. _rigCameras: Camera[];
  25816. /** @hidden */
  25817. _rigPostProcess: Nullable<PostProcess>;
  25818. protected _webvrViewMatrix: Matrix;
  25819. /** @hidden */
  25820. _skipRendering: boolean;
  25821. /** @hidden */
  25822. _projectionMatrix: Matrix;
  25823. /** @hidden */
  25824. _postProcesses: Nullable<PostProcess>[];
  25825. /** @hidden */
  25826. _activeMeshes: SmartArray<AbstractMesh>;
  25827. protected _globalPosition: Vector3;
  25828. /** @hidden */
  25829. _computedViewMatrix: Matrix;
  25830. private _doNotComputeProjectionMatrix;
  25831. private _transformMatrix;
  25832. private _frustumPlanes;
  25833. private _refreshFrustumPlanes;
  25834. private _storedFov;
  25835. private _stateStored;
  25836. /**
  25837. * Instantiates a new camera object.
  25838. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25839. * @see http://doc.babylonjs.com/features/cameras
  25840. * @param name Defines the name of the camera in the scene
  25841. * @param position Defines the position of the camera
  25842. * @param scene Defines the scene the camera belongs too
  25843. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25844. */
  25845. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25846. /**
  25847. * Store current camera state (fov, position, etc..)
  25848. * @returns the camera
  25849. */
  25850. storeState(): Camera;
  25851. /**
  25852. * Restores the camera state values if it has been stored. You must call storeState() first
  25853. */
  25854. protected _restoreStateValues(): boolean;
  25855. /**
  25856. * Restored camera state. You must call storeState() first.
  25857. * @returns true if restored and false otherwise
  25858. */
  25859. restoreState(): boolean;
  25860. /**
  25861. * Gets the class name of the camera.
  25862. * @returns the class name
  25863. */
  25864. getClassName(): string;
  25865. /** @hidden */
  25866. readonly _isCamera: boolean;
  25867. /**
  25868. * Gets a string representation of the camera useful for debug purpose.
  25869. * @param fullDetails Defines that a more verboe level of logging is required
  25870. * @returns the string representation
  25871. */
  25872. toString(fullDetails?: boolean): string;
  25873. /**
  25874. * Gets the current world space position of the camera.
  25875. */
  25876. get globalPosition(): Vector3;
  25877. /**
  25878. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25879. * @returns the active meshe list
  25880. */
  25881. getActiveMeshes(): SmartArray<AbstractMesh>;
  25882. /**
  25883. * Check whether a mesh is part of the current active mesh list of the camera
  25884. * @param mesh Defines the mesh to check
  25885. * @returns true if active, false otherwise
  25886. */
  25887. isActiveMesh(mesh: Mesh): boolean;
  25888. /**
  25889. * Is this camera ready to be used/rendered
  25890. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25891. * @return true if the camera is ready
  25892. */
  25893. isReady(completeCheck?: boolean): boolean;
  25894. /** @hidden */
  25895. _initCache(): void;
  25896. /** @hidden */
  25897. _updateCache(ignoreParentClass?: boolean): void;
  25898. /** @hidden */
  25899. _isSynchronized(): boolean;
  25900. /** @hidden */
  25901. _isSynchronizedViewMatrix(): boolean;
  25902. /** @hidden */
  25903. _isSynchronizedProjectionMatrix(): boolean;
  25904. /**
  25905. * Attach the input controls to a specific dom element to get the input from.
  25906. * @param element Defines the element the controls should be listened from
  25907. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25908. */
  25909. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25910. /**
  25911. * Detach the current controls from the specified dom element.
  25912. * @param element Defines the element to stop listening the inputs from
  25913. */
  25914. detachControl(element: HTMLElement): void;
  25915. /**
  25916. * Update the camera state according to the different inputs gathered during the frame.
  25917. */
  25918. update(): void;
  25919. /** @hidden */
  25920. _checkInputs(): void;
  25921. /** @hidden */
  25922. get rigCameras(): Camera[];
  25923. /**
  25924. * Gets the post process used by the rig cameras
  25925. */
  25926. get rigPostProcess(): Nullable<PostProcess>;
  25927. /**
  25928. * Internal, gets the first post proces.
  25929. * @returns the first post process to be run on this camera.
  25930. */
  25931. _getFirstPostProcess(): Nullable<PostProcess>;
  25932. private _cascadePostProcessesToRigCams;
  25933. /**
  25934. * Attach a post process to the camera.
  25935. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25936. * @param postProcess The post process to attach to the camera
  25937. * @param insertAt The position of the post process in case several of them are in use in the scene
  25938. * @returns the position the post process has been inserted at
  25939. */
  25940. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25941. /**
  25942. * Detach a post process to the camera.
  25943. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25944. * @param postProcess The post process to detach from the camera
  25945. */
  25946. detachPostProcess(postProcess: PostProcess): void;
  25947. /**
  25948. * Gets the current world matrix of the camera
  25949. */
  25950. getWorldMatrix(): Matrix;
  25951. /** @hidden */
  25952. _getViewMatrix(): Matrix;
  25953. /**
  25954. * Gets the current view matrix of the camera.
  25955. * @param force forces the camera to recompute the matrix without looking at the cached state
  25956. * @returns the view matrix
  25957. */
  25958. getViewMatrix(force?: boolean): Matrix;
  25959. /**
  25960. * Freeze the projection matrix.
  25961. * It will prevent the cache check of the camera projection compute and can speed up perf
  25962. * if no parameter of the camera are meant to change
  25963. * @param projection Defines manually a projection if necessary
  25964. */
  25965. freezeProjectionMatrix(projection?: Matrix): void;
  25966. /**
  25967. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25968. */
  25969. unfreezeProjectionMatrix(): void;
  25970. /**
  25971. * Gets the current projection matrix of the camera.
  25972. * @param force forces the camera to recompute the matrix without looking at the cached state
  25973. * @returns the projection matrix
  25974. */
  25975. getProjectionMatrix(force?: boolean): Matrix;
  25976. /**
  25977. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25978. * @returns a Matrix
  25979. */
  25980. getTransformationMatrix(): Matrix;
  25981. private _updateFrustumPlanes;
  25982. /**
  25983. * Checks if a cullable object (mesh...) is in the camera frustum
  25984. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25985. * @param target The object to check
  25986. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25987. * @returns true if the object is in frustum otherwise false
  25988. */
  25989. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25990. /**
  25991. * Checks if a cullable object (mesh...) is in the camera frustum
  25992. * Unlike isInFrustum this cheks the full bounding box
  25993. * @param target The object to check
  25994. * @returns true if the object is in frustum otherwise false
  25995. */
  25996. isCompletelyInFrustum(target: ICullable): boolean;
  25997. /**
  25998. * Gets a ray in the forward direction from the camera.
  25999. * @param length Defines the length of the ray to create
  26000. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26001. * @param origin Defines the start point of the ray which defaults to the camera position
  26002. * @returns the forward ray
  26003. */
  26004. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26005. /**
  26006. * Releases resources associated with this node.
  26007. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26008. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26009. */
  26010. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26011. /** @hidden */
  26012. _isLeftCamera: boolean;
  26013. /**
  26014. * Gets the left camera of a rig setup in case of Rigged Camera
  26015. */
  26016. get isLeftCamera(): boolean;
  26017. /** @hidden */
  26018. _isRightCamera: boolean;
  26019. /**
  26020. * Gets the right camera of a rig setup in case of Rigged Camera
  26021. */
  26022. get isRightCamera(): boolean;
  26023. /**
  26024. * Gets the left camera of a rig setup in case of Rigged Camera
  26025. */
  26026. get leftCamera(): Nullable<FreeCamera>;
  26027. /**
  26028. * Gets the right camera of a rig setup in case of Rigged Camera
  26029. */
  26030. get rightCamera(): Nullable<FreeCamera>;
  26031. /**
  26032. * Gets the left camera target of a rig setup in case of Rigged Camera
  26033. * @returns the target position
  26034. */
  26035. getLeftTarget(): Nullable<Vector3>;
  26036. /**
  26037. * Gets the right camera target of a rig setup in case of Rigged Camera
  26038. * @returns the target position
  26039. */
  26040. getRightTarget(): Nullable<Vector3>;
  26041. /**
  26042. * @hidden
  26043. */
  26044. setCameraRigMode(mode: number, rigParams: any): void;
  26045. /** @hidden */
  26046. static _setStereoscopicRigMode(camera: Camera): void;
  26047. /** @hidden */
  26048. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26049. /** @hidden */
  26050. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26051. /** @hidden */
  26052. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26053. /** @hidden */
  26054. _getVRProjectionMatrix(): Matrix;
  26055. protected _updateCameraRotationMatrix(): void;
  26056. protected _updateWebVRCameraRotationMatrix(): void;
  26057. /**
  26058. * This function MUST be overwritten by the different WebVR cameras available.
  26059. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26060. * @hidden
  26061. */
  26062. _getWebVRProjectionMatrix(): Matrix;
  26063. /**
  26064. * This function MUST be overwritten by the different WebVR cameras available.
  26065. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26066. * @hidden
  26067. */
  26068. _getWebVRViewMatrix(): Matrix;
  26069. /** @hidden */
  26070. setCameraRigParameter(name: string, value: any): void;
  26071. /**
  26072. * needs to be overridden by children so sub has required properties to be copied
  26073. * @hidden
  26074. */
  26075. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26076. /**
  26077. * May need to be overridden by children
  26078. * @hidden
  26079. */
  26080. _updateRigCameras(): void;
  26081. /** @hidden */
  26082. _setupInputs(): void;
  26083. /**
  26084. * Serialiaze the camera setup to a json represention
  26085. * @returns the JSON representation
  26086. */
  26087. serialize(): any;
  26088. /**
  26089. * Clones the current camera.
  26090. * @param name The cloned camera name
  26091. * @returns the cloned camera
  26092. */
  26093. clone(name: string): Camera;
  26094. /**
  26095. * Gets the direction of the camera relative to a given local axis.
  26096. * @param localAxis Defines the reference axis to provide a relative direction.
  26097. * @return the direction
  26098. */
  26099. getDirection(localAxis: Vector3): Vector3;
  26100. /**
  26101. * Returns the current camera absolute rotation
  26102. */
  26103. get absoluteRotation(): Quaternion;
  26104. /**
  26105. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26106. * @param localAxis Defines the reference axis to provide a relative direction.
  26107. * @param result Defines the vector to store the result in
  26108. */
  26109. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26110. /**
  26111. * Gets a camera constructor for a given camera type
  26112. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26113. * @param name The name of the camera the result will be able to instantiate
  26114. * @param scene The scene the result will construct the camera in
  26115. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26116. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26117. * @returns a factory method to construc the camera
  26118. */
  26119. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26120. /**
  26121. * Compute the world matrix of the camera.
  26122. * @returns the camera world matrix
  26123. */
  26124. computeWorldMatrix(): Matrix;
  26125. /**
  26126. * Parse a JSON and creates the camera from the parsed information
  26127. * @param parsedCamera The JSON to parse
  26128. * @param scene The scene to instantiate the camera in
  26129. * @returns the newly constructed camera
  26130. */
  26131. static Parse(parsedCamera: any, scene: Scene): Camera;
  26132. }
  26133. }
  26134. declare module BABYLON {
  26135. /**
  26136. * Class containing static functions to help procedurally build meshes
  26137. */
  26138. export class DiscBuilder {
  26139. /**
  26140. * Creates a plane polygonal mesh. By default, this is a disc
  26141. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26142. * * 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
  26143. * * 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
  26144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26145. * * 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
  26146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26147. * @param name defines the name of the mesh
  26148. * @param options defines the options used to create the mesh
  26149. * @param scene defines the hosting scene
  26150. * @returns the plane polygonal mesh
  26151. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26152. */
  26153. static CreateDisc(name: string, options: {
  26154. radius?: number;
  26155. tessellation?: number;
  26156. arc?: number;
  26157. updatable?: boolean;
  26158. sideOrientation?: number;
  26159. frontUVs?: Vector4;
  26160. backUVs?: Vector4;
  26161. }, scene?: Nullable<Scene>): Mesh;
  26162. }
  26163. }
  26164. declare module BABYLON {
  26165. /**
  26166. * Options to be used when creating a FresnelParameters.
  26167. */
  26168. export type IFresnelParametersCreationOptions = {
  26169. /**
  26170. * Define the color used on edges (grazing angle)
  26171. */
  26172. leftColor?: Color3;
  26173. /**
  26174. * Define the color used on center
  26175. */
  26176. rightColor?: Color3;
  26177. /**
  26178. * Define bias applied to computed fresnel term
  26179. */
  26180. bias?: number;
  26181. /**
  26182. * Defined the power exponent applied to fresnel term
  26183. */
  26184. power?: number;
  26185. /**
  26186. * Define if the fresnel effect is enable or not.
  26187. */
  26188. isEnabled?: boolean;
  26189. };
  26190. /**
  26191. * Serialized format for FresnelParameters.
  26192. */
  26193. export type IFresnelParametersSerialized = {
  26194. /**
  26195. * Define the color used on edges (grazing angle) [as an array]
  26196. */
  26197. leftColor: number[];
  26198. /**
  26199. * Define the color used on center [as an array]
  26200. */
  26201. rightColor: number[];
  26202. /**
  26203. * Define bias applied to computed fresnel term
  26204. */
  26205. bias: number;
  26206. /**
  26207. * Defined the power exponent applied to fresnel term
  26208. */
  26209. power?: number;
  26210. /**
  26211. * Define if the fresnel effect is enable or not.
  26212. */
  26213. isEnabled: boolean;
  26214. };
  26215. /**
  26216. * This represents all the required information to add a fresnel effect on a material:
  26217. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26218. */
  26219. export class FresnelParameters {
  26220. private _isEnabled;
  26221. /**
  26222. * Define if the fresnel effect is enable or not.
  26223. */
  26224. get isEnabled(): boolean;
  26225. set isEnabled(value: boolean);
  26226. /**
  26227. * Define the color used on edges (grazing angle)
  26228. */
  26229. leftColor: Color3;
  26230. /**
  26231. * Define the color used on center
  26232. */
  26233. rightColor: Color3;
  26234. /**
  26235. * Define bias applied to computed fresnel term
  26236. */
  26237. bias: number;
  26238. /**
  26239. * Defined the power exponent applied to fresnel term
  26240. */
  26241. power: number;
  26242. /**
  26243. * Creates a new FresnelParameters object.
  26244. *
  26245. * @param options provide your own settings to optionally to override defaults
  26246. */
  26247. constructor(options?: IFresnelParametersCreationOptions);
  26248. /**
  26249. * Clones the current fresnel and its valuues
  26250. * @returns a clone fresnel configuration
  26251. */
  26252. clone(): FresnelParameters;
  26253. /**
  26254. * Determines equality between FresnelParameters objects
  26255. * @param otherFresnelParameters defines the second operand
  26256. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  26257. */
  26258. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  26259. /**
  26260. * Serializes the current fresnel parameters to a JSON representation.
  26261. * @return the JSON serialization
  26262. */
  26263. serialize(): IFresnelParametersSerialized;
  26264. /**
  26265. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26266. * @param parsedFresnelParameters Define the JSON representation
  26267. * @returns the parsed parameters
  26268. */
  26269. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  26270. }
  26271. }
  26272. declare module BABYLON {
  26273. /**
  26274. * Base class of materials working in push mode in babylon JS
  26275. * @hidden
  26276. */
  26277. export class PushMaterial extends Material {
  26278. protected _activeEffect: Effect;
  26279. protected _normalMatrix: Matrix;
  26280. /**
  26281. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26282. * This means that the material can keep using a previous shader while a new one is being compiled.
  26283. * This is mostly used when shader parallel compilation is supported (true by default)
  26284. */
  26285. allowShaderHotSwapping: boolean;
  26286. constructor(name: string, scene: Scene);
  26287. getEffect(): Effect;
  26288. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26289. /**
  26290. * Binds the given world matrix to the active effect
  26291. *
  26292. * @param world the matrix to bind
  26293. */
  26294. bindOnlyWorldMatrix(world: Matrix): void;
  26295. /**
  26296. * Binds the given normal matrix to the active effect
  26297. *
  26298. * @param normalMatrix the matrix to bind
  26299. */
  26300. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26301. bind(world: Matrix, mesh?: Mesh): void;
  26302. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26303. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26304. }
  26305. }
  26306. declare module BABYLON {
  26307. /**
  26308. * This groups all the flags used to control the materials channel.
  26309. */
  26310. export class MaterialFlags {
  26311. private static _DiffuseTextureEnabled;
  26312. /**
  26313. * Are diffuse textures enabled in the application.
  26314. */
  26315. static get DiffuseTextureEnabled(): boolean;
  26316. static set DiffuseTextureEnabled(value: boolean);
  26317. private static _AmbientTextureEnabled;
  26318. /**
  26319. * Are ambient textures enabled in the application.
  26320. */
  26321. static get AmbientTextureEnabled(): boolean;
  26322. static set AmbientTextureEnabled(value: boolean);
  26323. private static _OpacityTextureEnabled;
  26324. /**
  26325. * Are opacity textures enabled in the application.
  26326. */
  26327. static get OpacityTextureEnabled(): boolean;
  26328. static set OpacityTextureEnabled(value: boolean);
  26329. private static _ReflectionTextureEnabled;
  26330. /**
  26331. * Are reflection textures enabled in the application.
  26332. */
  26333. static get ReflectionTextureEnabled(): boolean;
  26334. static set ReflectionTextureEnabled(value: boolean);
  26335. private static _EmissiveTextureEnabled;
  26336. /**
  26337. * Are emissive textures enabled in the application.
  26338. */
  26339. static get EmissiveTextureEnabled(): boolean;
  26340. static set EmissiveTextureEnabled(value: boolean);
  26341. private static _SpecularTextureEnabled;
  26342. /**
  26343. * Are specular textures enabled in the application.
  26344. */
  26345. static get SpecularTextureEnabled(): boolean;
  26346. static set SpecularTextureEnabled(value: boolean);
  26347. private static _BumpTextureEnabled;
  26348. /**
  26349. * Are bump textures enabled in the application.
  26350. */
  26351. static get BumpTextureEnabled(): boolean;
  26352. static set BumpTextureEnabled(value: boolean);
  26353. private static _LightmapTextureEnabled;
  26354. /**
  26355. * Are lightmap textures enabled in the application.
  26356. */
  26357. static get LightmapTextureEnabled(): boolean;
  26358. static set LightmapTextureEnabled(value: boolean);
  26359. private static _RefractionTextureEnabled;
  26360. /**
  26361. * Are refraction textures enabled in the application.
  26362. */
  26363. static get RefractionTextureEnabled(): boolean;
  26364. static set RefractionTextureEnabled(value: boolean);
  26365. private static _ColorGradingTextureEnabled;
  26366. /**
  26367. * Are color grading textures enabled in the application.
  26368. */
  26369. static get ColorGradingTextureEnabled(): boolean;
  26370. static set ColorGradingTextureEnabled(value: boolean);
  26371. private static _FresnelEnabled;
  26372. /**
  26373. * Are fresnels enabled in the application.
  26374. */
  26375. static get FresnelEnabled(): boolean;
  26376. static set FresnelEnabled(value: boolean);
  26377. private static _ClearCoatTextureEnabled;
  26378. /**
  26379. * Are clear coat textures enabled in the application.
  26380. */
  26381. static get ClearCoatTextureEnabled(): boolean;
  26382. static set ClearCoatTextureEnabled(value: boolean);
  26383. private static _ClearCoatBumpTextureEnabled;
  26384. /**
  26385. * Are clear coat bump textures enabled in the application.
  26386. */
  26387. static get ClearCoatBumpTextureEnabled(): boolean;
  26388. static set ClearCoatBumpTextureEnabled(value: boolean);
  26389. private static _ClearCoatTintTextureEnabled;
  26390. /**
  26391. * Are clear coat tint textures enabled in the application.
  26392. */
  26393. static get ClearCoatTintTextureEnabled(): boolean;
  26394. static set ClearCoatTintTextureEnabled(value: boolean);
  26395. private static _SheenTextureEnabled;
  26396. /**
  26397. * Are sheen textures enabled in the application.
  26398. */
  26399. static get SheenTextureEnabled(): boolean;
  26400. static set SheenTextureEnabled(value: boolean);
  26401. private static _AnisotropicTextureEnabled;
  26402. /**
  26403. * Are anisotropic textures enabled in the application.
  26404. */
  26405. static get AnisotropicTextureEnabled(): boolean;
  26406. static set AnisotropicTextureEnabled(value: boolean);
  26407. private static _ThicknessTextureEnabled;
  26408. /**
  26409. * Are thickness textures enabled in the application.
  26410. */
  26411. static get ThicknessTextureEnabled(): boolean;
  26412. static set ThicknessTextureEnabled(value: boolean);
  26413. }
  26414. }
  26415. declare module BABYLON {
  26416. /** @hidden */
  26417. export var defaultFragmentDeclaration: {
  26418. name: string;
  26419. shader: string;
  26420. };
  26421. }
  26422. declare module BABYLON {
  26423. /** @hidden */
  26424. export var defaultUboDeclaration: {
  26425. name: string;
  26426. shader: string;
  26427. };
  26428. }
  26429. declare module BABYLON {
  26430. /** @hidden */
  26431. export var lightFragmentDeclaration: {
  26432. name: string;
  26433. shader: string;
  26434. };
  26435. }
  26436. declare module BABYLON {
  26437. /** @hidden */
  26438. export var lightUboDeclaration: {
  26439. name: string;
  26440. shader: string;
  26441. };
  26442. }
  26443. declare module BABYLON {
  26444. /** @hidden */
  26445. export var lightsFragmentFunctions: {
  26446. name: string;
  26447. shader: string;
  26448. };
  26449. }
  26450. declare module BABYLON {
  26451. /** @hidden */
  26452. export var shadowsFragmentFunctions: {
  26453. name: string;
  26454. shader: string;
  26455. };
  26456. }
  26457. declare module BABYLON {
  26458. /** @hidden */
  26459. export var fresnelFunction: {
  26460. name: string;
  26461. shader: string;
  26462. };
  26463. }
  26464. declare module BABYLON {
  26465. /** @hidden */
  26466. export var reflectionFunction: {
  26467. name: string;
  26468. shader: string;
  26469. };
  26470. }
  26471. declare module BABYLON {
  26472. /** @hidden */
  26473. export var bumpFragmentFunctions: {
  26474. name: string;
  26475. shader: string;
  26476. };
  26477. }
  26478. declare module BABYLON {
  26479. /** @hidden */
  26480. export var logDepthDeclaration: {
  26481. name: string;
  26482. shader: string;
  26483. };
  26484. }
  26485. declare module BABYLON {
  26486. /** @hidden */
  26487. export var bumpFragment: {
  26488. name: string;
  26489. shader: string;
  26490. };
  26491. }
  26492. declare module BABYLON {
  26493. /** @hidden */
  26494. export var depthPrePass: {
  26495. name: string;
  26496. shader: string;
  26497. };
  26498. }
  26499. declare module BABYLON {
  26500. /** @hidden */
  26501. export var lightFragment: {
  26502. name: string;
  26503. shader: string;
  26504. };
  26505. }
  26506. declare module BABYLON {
  26507. /** @hidden */
  26508. export var logDepthFragment: {
  26509. name: string;
  26510. shader: string;
  26511. };
  26512. }
  26513. declare module BABYLON {
  26514. /** @hidden */
  26515. export var defaultPixelShader: {
  26516. name: string;
  26517. shader: string;
  26518. };
  26519. }
  26520. declare module BABYLON {
  26521. /** @hidden */
  26522. export var defaultVertexDeclaration: {
  26523. name: string;
  26524. shader: string;
  26525. };
  26526. }
  26527. declare module BABYLON {
  26528. /** @hidden */
  26529. export var bumpVertexDeclaration: {
  26530. name: string;
  26531. shader: string;
  26532. };
  26533. }
  26534. declare module BABYLON {
  26535. /** @hidden */
  26536. export var bumpVertex: {
  26537. name: string;
  26538. shader: string;
  26539. };
  26540. }
  26541. declare module BABYLON {
  26542. /** @hidden */
  26543. export var fogVertex: {
  26544. name: string;
  26545. shader: string;
  26546. };
  26547. }
  26548. declare module BABYLON {
  26549. /** @hidden */
  26550. export var shadowsVertex: {
  26551. name: string;
  26552. shader: string;
  26553. };
  26554. }
  26555. declare module BABYLON {
  26556. /** @hidden */
  26557. export var pointCloudVertex: {
  26558. name: string;
  26559. shader: string;
  26560. };
  26561. }
  26562. declare module BABYLON {
  26563. /** @hidden */
  26564. export var logDepthVertex: {
  26565. name: string;
  26566. shader: string;
  26567. };
  26568. }
  26569. declare module BABYLON {
  26570. /** @hidden */
  26571. export var defaultVertexShader: {
  26572. name: string;
  26573. shader: string;
  26574. };
  26575. }
  26576. declare module BABYLON {
  26577. /** @hidden */
  26578. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26579. MAINUV1: boolean;
  26580. MAINUV2: boolean;
  26581. DIFFUSE: boolean;
  26582. DIFFUSEDIRECTUV: number;
  26583. AMBIENT: boolean;
  26584. AMBIENTDIRECTUV: number;
  26585. OPACITY: boolean;
  26586. OPACITYDIRECTUV: number;
  26587. OPACITYRGB: boolean;
  26588. REFLECTION: boolean;
  26589. EMISSIVE: boolean;
  26590. EMISSIVEDIRECTUV: number;
  26591. SPECULAR: boolean;
  26592. SPECULARDIRECTUV: number;
  26593. BUMP: boolean;
  26594. BUMPDIRECTUV: number;
  26595. PARALLAX: boolean;
  26596. PARALLAXOCCLUSION: boolean;
  26597. SPECULAROVERALPHA: boolean;
  26598. CLIPPLANE: boolean;
  26599. CLIPPLANE2: boolean;
  26600. CLIPPLANE3: boolean;
  26601. CLIPPLANE4: boolean;
  26602. CLIPPLANE5: boolean;
  26603. CLIPPLANE6: boolean;
  26604. ALPHATEST: boolean;
  26605. DEPTHPREPASS: boolean;
  26606. ALPHAFROMDIFFUSE: boolean;
  26607. POINTSIZE: boolean;
  26608. FOG: boolean;
  26609. SPECULARTERM: boolean;
  26610. DIFFUSEFRESNEL: boolean;
  26611. OPACITYFRESNEL: boolean;
  26612. REFLECTIONFRESNEL: boolean;
  26613. REFRACTIONFRESNEL: boolean;
  26614. EMISSIVEFRESNEL: boolean;
  26615. FRESNEL: boolean;
  26616. NORMAL: boolean;
  26617. UV1: boolean;
  26618. UV2: boolean;
  26619. VERTEXCOLOR: boolean;
  26620. VERTEXALPHA: boolean;
  26621. NUM_BONE_INFLUENCERS: number;
  26622. BonesPerMesh: number;
  26623. BONETEXTURE: boolean;
  26624. INSTANCES: boolean;
  26625. GLOSSINESS: boolean;
  26626. ROUGHNESS: boolean;
  26627. EMISSIVEASILLUMINATION: boolean;
  26628. LINKEMISSIVEWITHDIFFUSE: boolean;
  26629. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26630. LIGHTMAP: boolean;
  26631. LIGHTMAPDIRECTUV: number;
  26632. OBJECTSPACE_NORMALMAP: boolean;
  26633. USELIGHTMAPASSHADOWMAP: boolean;
  26634. REFLECTIONMAP_3D: boolean;
  26635. REFLECTIONMAP_SPHERICAL: boolean;
  26636. REFLECTIONMAP_PLANAR: boolean;
  26637. REFLECTIONMAP_CUBIC: boolean;
  26638. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26639. REFLECTIONMAP_PROJECTION: boolean;
  26640. REFLECTIONMAP_SKYBOX: boolean;
  26641. REFLECTIONMAP_EXPLICIT: boolean;
  26642. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26643. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26644. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26645. INVERTCUBICMAP: boolean;
  26646. LOGARITHMICDEPTH: boolean;
  26647. REFRACTION: boolean;
  26648. REFRACTIONMAP_3D: boolean;
  26649. REFLECTIONOVERALPHA: boolean;
  26650. TWOSIDEDLIGHTING: boolean;
  26651. SHADOWFLOAT: boolean;
  26652. MORPHTARGETS: boolean;
  26653. MORPHTARGETS_NORMAL: boolean;
  26654. MORPHTARGETS_TANGENT: boolean;
  26655. MORPHTARGETS_UV: boolean;
  26656. NUM_MORPH_INFLUENCERS: number;
  26657. NONUNIFORMSCALING: boolean;
  26658. PREMULTIPLYALPHA: boolean;
  26659. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  26660. ALPHABLEND: boolean;
  26661. IMAGEPROCESSING: boolean;
  26662. VIGNETTE: boolean;
  26663. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26664. VIGNETTEBLENDMODEOPAQUE: boolean;
  26665. TONEMAPPING: boolean;
  26666. TONEMAPPING_ACES: boolean;
  26667. CONTRAST: boolean;
  26668. COLORCURVES: boolean;
  26669. COLORGRADING: boolean;
  26670. COLORGRADING3D: boolean;
  26671. SAMPLER3DGREENDEPTH: boolean;
  26672. SAMPLER3DBGRMAP: boolean;
  26673. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26674. MULTIVIEW: boolean;
  26675. /**
  26676. * If the reflection texture on this material is in linear color space
  26677. * @hidden
  26678. */
  26679. IS_REFLECTION_LINEAR: boolean;
  26680. /**
  26681. * If the refraction texture on this material is in linear color space
  26682. * @hidden
  26683. */
  26684. IS_REFRACTION_LINEAR: boolean;
  26685. EXPOSURE: boolean;
  26686. constructor();
  26687. setReflectionMode(modeToEnable: string): void;
  26688. }
  26689. /**
  26690. * This is the default material used in Babylon. It is the best trade off between quality
  26691. * and performances.
  26692. * @see http://doc.babylonjs.com/babylon101/materials
  26693. */
  26694. export class StandardMaterial extends PushMaterial {
  26695. private _diffuseTexture;
  26696. /**
  26697. * The basic texture of the material as viewed under a light.
  26698. */
  26699. diffuseTexture: Nullable<BaseTexture>;
  26700. private _ambientTexture;
  26701. /**
  26702. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26703. */
  26704. ambientTexture: Nullable<BaseTexture>;
  26705. private _opacityTexture;
  26706. /**
  26707. * Define the transparency of the material from a texture.
  26708. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26709. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26710. */
  26711. opacityTexture: Nullable<BaseTexture>;
  26712. private _reflectionTexture;
  26713. /**
  26714. * Define the texture used to display the reflection.
  26715. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26716. */
  26717. reflectionTexture: Nullable<BaseTexture>;
  26718. private _emissiveTexture;
  26719. /**
  26720. * Define texture of the material as if self lit.
  26721. * This will be mixed in the final result even in the absence of light.
  26722. */
  26723. emissiveTexture: Nullable<BaseTexture>;
  26724. private _specularTexture;
  26725. /**
  26726. * Define how the color and intensity of the highlight given by the light in the material.
  26727. */
  26728. specularTexture: Nullable<BaseTexture>;
  26729. private _bumpTexture;
  26730. /**
  26731. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26732. * 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.
  26733. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26734. */
  26735. bumpTexture: Nullable<BaseTexture>;
  26736. private _lightmapTexture;
  26737. /**
  26738. * Complex lighting can be computationally expensive to compute at runtime.
  26739. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26740. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26741. */
  26742. lightmapTexture: Nullable<BaseTexture>;
  26743. private _refractionTexture;
  26744. /**
  26745. * Define the texture used to display the refraction.
  26746. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26747. */
  26748. refractionTexture: Nullable<BaseTexture>;
  26749. /**
  26750. * The color of the material lit by the environmental background lighting.
  26751. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26752. */
  26753. ambientColor: Color3;
  26754. /**
  26755. * The basic color of the material as viewed under a light.
  26756. */
  26757. diffuseColor: Color3;
  26758. /**
  26759. * Define how the color and intensity of the highlight given by the light in the material.
  26760. */
  26761. specularColor: Color3;
  26762. /**
  26763. * Define the color of the material as if self lit.
  26764. * This will be mixed in the final result even in the absence of light.
  26765. */
  26766. emissiveColor: Color3;
  26767. /**
  26768. * Defines how sharp are the highlights in the material.
  26769. * The bigger the value the sharper giving a more glossy feeling to the result.
  26770. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26771. */
  26772. specularPower: number;
  26773. private _useAlphaFromDiffuseTexture;
  26774. /**
  26775. * Does the transparency come from the diffuse texture alpha channel.
  26776. */
  26777. useAlphaFromDiffuseTexture: boolean;
  26778. private _useEmissiveAsIllumination;
  26779. /**
  26780. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26781. */
  26782. useEmissiveAsIllumination: boolean;
  26783. private _linkEmissiveWithDiffuse;
  26784. /**
  26785. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26786. * the emissive level when the final color is close to one.
  26787. */
  26788. linkEmissiveWithDiffuse: boolean;
  26789. private _useSpecularOverAlpha;
  26790. /**
  26791. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26792. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26793. */
  26794. useSpecularOverAlpha: boolean;
  26795. private _useReflectionOverAlpha;
  26796. /**
  26797. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26798. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26799. */
  26800. useReflectionOverAlpha: boolean;
  26801. private _disableLighting;
  26802. /**
  26803. * Does lights from the scene impacts this material.
  26804. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26805. */
  26806. disableLighting: boolean;
  26807. private _useObjectSpaceNormalMap;
  26808. /**
  26809. * Allows using an object space normal map (instead of tangent space).
  26810. */
  26811. useObjectSpaceNormalMap: boolean;
  26812. private _useParallax;
  26813. /**
  26814. * Is parallax enabled or not.
  26815. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26816. */
  26817. useParallax: boolean;
  26818. private _useParallaxOcclusion;
  26819. /**
  26820. * Is parallax occlusion enabled or not.
  26821. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26822. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26823. */
  26824. useParallaxOcclusion: boolean;
  26825. /**
  26826. * 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.
  26827. */
  26828. parallaxScaleBias: number;
  26829. private _roughness;
  26830. /**
  26831. * Helps to define how blurry the reflections should appears in the material.
  26832. */
  26833. roughness: number;
  26834. /**
  26835. * In case of refraction, define the value of the index of refraction.
  26836. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26837. */
  26838. indexOfRefraction: number;
  26839. /**
  26840. * Invert the refraction texture alongside the y axis.
  26841. * It can be useful with procedural textures or probe for instance.
  26842. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26843. */
  26844. invertRefractionY: boolean;
  26845. /**
  26846. * Defines the alpha limits in alpha test mode.
  26847. */
  26848. alphaCutOff: number;
  26849. private _useLightmapAsShadowmap;
  26850. /**
  26851. * In case of light mapping, define whether the map contains light or shadow informations.
  26852. */
  26853. useLightmapAsShadowmap: boolean;
  26854. private _diffuseFresnelParameters;
  26855. /**
  26856. * Define the diffuse fresnel parameters of the material.
  26857. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26858. */
  26859. diffuseFresnelParameters: FresnelParameters;
  26860. private _opacityFresnelParameters;
  26861. /**
  26862. * Define the opacity fresnel parameters of the material.
  26863. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26864. */
  26865. opacityFresnelParameters: FresnelParameters;
  26866. private _reflectionFresnelParameters;
  26867. /**
  26868. * Define the reflection fresnel parameters of the material.
  26869. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26870. */
  26871. reflectionFresnelParameters: FresnelParameters;
  26872. private _refractionFresnelParameters;
  26873. /**
  26874. * Define the refraction fresnel parameters of the material.
  26875. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26876. */
  26877. refractionFresnelParameters: FresnelParameters;
  26878. private _emissiveFresnelParameters;
  26879. /**
  26880. * Define the emissive fresnel parameters of the material.
  26881. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26882. */
  26883. emissiveFresnelParameters: FresnelParameters;
  26884. private _useReflectionFresnelFromSpecular;
  26885. /**
  26886. * If true automatically deducts the fresnels values from the material specularity.
  26887. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26888. */
  26889. useReflectionFresnelFromSpecular: boolean;
  26890. private _useGlossinessFromSpecularMapAlpha;
  26891. /**
  26892. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26893. */
  26894. useGlossinessFromSpecularMapAlpha: boolean;
  26895. private _maxSimultaneousLights;
  26896. /**
  26897. * Defines the maximum number of lights that can be used in the material
  26898. */
  26899. maxSimultaneousLights: number;
  26900. private _invertNormalMapX;
  26901. /**
  26902. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26903. */
  26904. invertNormalMapX: boolean;
  26905. private _invertNormalMapY;
  26906. /**
  26907. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26908. */
  26909. invertNormalMapY: boolean;
  26910. private _twoSidedLighting;
  26911. /**
  26912. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26913. */
  26914. twoSidedLighting: boolean;
  26915. /**
  26916. * Default configuration related to image processing available in the standard Material.
  26917. */
  26918. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26919. /**
  26920. * Gets the image processing configuration used either in this material.
  26921. */
  26922. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26923. /**
  26924. * Sets the Default image processing configuration used either in the this material.
  26925. *
  26926. * If sets to null, the scene one is in use.
  26927. */
  26928. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26929. /**
  26930. * Keep track of the image processing observer to allow dispose and replace.
  26931. */
  26932. private _imageProcessingObserver;
  26933. /**
  26934. * Attaches a new image processing configuration to the Standard Material.
  26935. * @param configuration
  26936. */
  26937. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26938. /**
  26939. * Gets wether the color curves effect is enabled.
  26940. */
  26941. get cameraColorCurvesEnabled(): boolean;
  26942. /**
  26943. * Sets wether the color curves effect is enabled.
  26944. */
  26945. set cameraColorCurvesEnabled(value: boolean);
  26946. /**
  26947. * Gets wether the color grading effect is enabled.
  26948. */
  26949. get cameraColorGradingEnabled(): boolean;
  26950. /**
  26951. * Gets wether the color grading effect is enabled.
  26952. */
  26953. set cameraColorGradingEnabled(value: boolean);
  26954. /**
  26955. * Gets wether tonemapping is enabled or not.
  26956. */
  26957. get cameraToneMappingEnabled(): boolean;
  26958. /**
  26959. * Sets wether tonemapping is enabled or not
  26960. */
  26961. set cameraToneMappingEnabled(value: boolean);
  26962. /**
  26963. * The camera exposure used on this material.
  26964. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26965. * This corresponds to a photographic exposure.
  26966. */
  26967. get cameraExposure(): number;
  26968. /**
  26969. * The camera exposure used on this material.
  26970. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26971. * This corresponds to a photographic exposure.
  26972. */
  26973. set cameraExposure(value: number);
  26974. /**
  26975. * Gets The camera contrast used on this material.
  26976. */
  26977. get cameraContrast(): number;
  26978. /**
  26979. * Sets The camera contrast used on this material.
  26980. */
  26981. set cameraContrast(value: number);
  26982. /**
  26983. * Gets the Color Grading 2D Lookup Texture.
  26984. */
  26985. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26986. /**
  26987. * Sets the Color Grading 2D Lookup Texture.
  26988. */
  26989. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26990. /**
  26991. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26992. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26993. * 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;
  26994. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26995. */
  26996. get cameraColorCurves(): Nullable<ColorCurves>;
  26997. /**
  26998. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26999. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27000. * 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;
  27001. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27002. */
  27003. set cameraColorCurves(value: Nullable<ColorCurves>);
  27004. /**
  27005. * Custom callback helping to override the default shader used in the material.
  27006. */
  27007. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines, attributes?: string[]) => string;
  27008. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27009. protected _worldViewProjectionMatrix: Matrix;
  27010. protected _globalAmbientColor: Color3;
  27011. protected _useLogarithmicDepth: boolean;
  27012. protected _rebuildInParallel: boolean;
  27013. /**
  27014. * Instantiates a new standard material.
  27015. * This is the default material used in Babylon. It is the best trade off between quality
  27016. * and performances.
  27017. * @see http://doc.babylonjs.com/babylon101/materials
  27018. * @param name Define the name of the material in the scene
  27019. * @param scene Define the scene the material belong to
  27020. */
  27021. constructor(name: string, scene: Scene);
  27022. /**
  27023. * Gets a boolean indicating that current material needs to register RTT
  27024. */
  27025. get hasRenderTargetTextures(): boolean;
  27026. /**
  27027. * Gets the current class name of the material e.g. "StandardMaterial"
  27028. * Mainly use in serialization.
  27029. * @returns the class name
  27030. */
  27031. getClassName(): string;
  27032. /**
  27033. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27034. * You can try switching to logarithmic depth.
  27035. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27036. */
  27037. get useLogarithmicDepth(): boolean;
  27038. set useLogarithmicDepth(value: boolean);
  27039. /**
  27040. * Specifies if the material will require alpha blending
  27041. * @returns a boolean specifying if alpha blending is needed
  27042. */
  27043. needAlphaBlending(): boolean;
  27044. /**
  27045. * Specifies if this material should be rendered in alpha test mode
  27046. * @returns a boolean specifying if an alpha test is needed.
  27047. */
  27048. needAlphaTesting(): boolean;
  27049. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27050. /**
  27051. * Get the texture used for alpha test purpose.
  27052. * @returns the diffuse texture in case of the standard material.
  27053. */
  27054. getAlphaTestTexture(): Nullable<BaseTexture>;
  27055. /**
  27056. * Get if the submesh is ready to be used and all its information available.
  27057. * Child classes can use it to update shaders
  27058. * @param mesh defines the mesh to check
  27059. * @param subMesh defines which submesh to check
  27060. * @param useInstances specifies that instances should be used
  27061. * @returns a boolean indicating that the submesh is ready or not
  27062. */
  27063. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27064. /**
  27065. * Builds the material UBO layouts.
  27066. * Used internally during the effect preparation.
  27067. */
  27068. buildUniformLayout(): void;
  27069. /**
  27070. * Unbinds the material from the mesh
  27071. */
  27072. unbind(): void;
  27073. /**
  27074. * Binds the submesh to this material by preparing the effect and shader to draw
  27075. * @param world defines the world transformation matrix
  27076. * @param mesh defines the mesh containing the submesh
  27077. * @param subMesh defines the submesh to bind the material to
  27078. */
  27079. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27080. /**
  27081. * Get the list of animatables in the material.
  27082. * @returns the list of animatables object used in the material
  27083. */
  27084. getAnimatables(): IAnimatable[];
  27085. /**
  27086. * Gets the active textures from the material
  27087. * @returns an array of textures
  27088. */
  27089. getActiveTextures(): BaseTexture[];
  27090. /**
  27091. * Specifies if the material uses a texture
  27092. * @param texture defines the texture to check against the material
  27093. * @returns a boolean specifying if the material uses the texture
  27094. */
  27095. hasTexture(texture: BaseTexture): boolean;
  27096. /**
  27097. * Disposes the material
  27098. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27099. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27100. */
  27101. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27102. /**
  27103. * Makes a duplicate of the material, and gives it a new name
  27104. * @param name defines the new name for the duplicated material
  27105. * @returns the cloned material
  27106. */
  27107. clone(name: string): StandardMaterial;
  27108. /**
  27109. * Serializes this material in a JSON representation
  27110. * @returns the serialized material object
  27111. */
  27112. serialize(): any;
  27113. /**
  27114. * Creates a standard material from parsed material data
  27115. * @param source defines the JSON representation of the material
  27116. * @param scene defines the hosting scene
  27117. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27118. * @returns a new standard material
  27119. */
  27120. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27121. /**
  27122. * Are diffuse textures enabled in the application.
  27123. */
  27124. static get DiffuseTextureEnabled(): boolean;
  27125. static set DiffuseTextureEnabled(value: boolean);
  27126. /**
  27127. * Are ambient textures enabled in the application.
  27128. */
  27129. static get AmbientTextureEnabled(): boolean;
  27130. static set AmbientTextureEnabled(value: boolean);
  27131. /**
  27132. * Are opacity textures enabled in the application.
  27133. */
  27134. static get OpacityTextureEnabled(): boolean;
  27135. static set OpacityTextureEnabled(value: boolean);
  27136. /**
  27137. * Are reflection textures enabled in the application.
  27138. */
  27139. static get ReflectionTextureEnabled(): boolean;
  27140. static set ReflectionTextureEnabled(value: boolean);
  27141. /**
  27142. * Are emissive textures enabled in the application.
  27143. */
  27144. static get EmissiveTextureEnabled(): boolean;
  27145. static set EmissiveTextureEnabled(value: boolean);
  27146. /**
  27147. * Are specular textures enabled in the application.
  27148. */
  27149. static get SpecularTextureEnabled(): boolean;
  27150. static set SpecularTextureEnabled(value: boolean);
  27151. /**
  27152. * Are bump textures enabled in the application.
  27153. */
  27154. static get BumpTextureEnabled(): boolean;
  27155. static set BumpTextureEnabled(value: boolean);
  27156. /**
  27157. * Are lightmap textures enabled in the application.
  27158. */
  27159. static get LightmapTextureEnabled(): boolean;
  27160. static set LightmapTextureEnabled(value: boolean);
  27161. /**
  27162. * Are refraction textures enabled in the application.
  27163. */
  27164. static get RefractionTextureEnabled(): boolean;
  27165. static set RefractionTextureEnabled(value: boolean);
  27166. /**
  27167. * Are color grading textures enabled in the application.
  27168. */
  27169. static get ColorGradingTextureEnabled(): boolean;
  27170. static set ColorGradingTextureEnabled(value: boolean);
  27171. /**
  27172. * Are fresnels enabled in the application.
  27173. */
  27174. static get FresnelEnabled(): boolean;
  27175. static set FresnelEnabled(value: boolean);
  27176. }
  27177. }
  27178. declare module BABYLON {
  27179. /**
  27180. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27181. *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.
  27182. * The SPS is also a particle system. It provides some methods to manage the particles.
  27183. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27184. *
  27185. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27186. */
  27187. export class SolidParticleSystem implements IDisposable {
  27188. /**
  27189. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27190. * Example : var p = SPS.particles[i];
  27191. */
  27192. particles: SolidParticle[];
  27193. /**
  27194. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27195. */
  27196. nbParticles: number;
  27197. /**
  27198. * If the particles must ever face the camera (default false). Useful for planar particles.
  27199. */
  27200. billboard: boolean;
  27201. /**
  27202. * Recompute normals when adding a shape
  27203. */
  27204. recomputeNormals: boolean;
  27205. /**
  27206. * This a counter ofr your own usage. It's not set by any SPS functions.
  27207. */
  27208. counter: number;
  27209. /**
  27210. * The SPS name. This name is also given to the underlying mesh.
  27211. */
  27212. name: string;
  27213. /**
  27214. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27215. */
  27216. mesh: Mesh;
  27217. /**
  27218. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27219. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27220. */
  27221. vars: any;
  27222. /**
  27223. * This array is populated when the SPS is set as 'pickable'.
  27224. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27225. * Each element of this array is an object `{idx: int, faceId: int}`.
  27226. * `idx` is the picked particle index in the `SPS.particles` array
  27227. * `faceId` is the picked face index counted within this particle.
  27228. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27229. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27230. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27231. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27232. */
  27233. pickedParticles: {
  27234. idx: number;
  27235. faceId: number;
  27236. }[];
  27237. /**
  27238. * This array is populated when the SPS is set as 'pickable'
  27239. * Each key of this array is a submesh index.
  27240. * Each element of this array is a second array defined like this :
  27241. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27242. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27243. * `idx` is the picked particle index in the `SPS.particles` array
  27244. * `faceId` is the picked face index counted within this particle.
  27245. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27246. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27247. */
  27248. pickedBySubMesh: {
  27249. idx: number;
  27250. faceId: number;
  27251. }[][];
  27252. /**
  27253. * This array is populated when `enableDepthSort` is set to true.
  27254. * Each element of this array is an instance of the class DepthSortedParticle.
  27255. */
  27256. depthSortedParticles: DepthSortedParticle[];
  27257. /**
  27258. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27259. * @hidden
  27260. */
  27261. _bSphereOnly: boolean;
  27262. /**
  27263. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27264. * @hidden
  27265. */
  27266. _bSphereRadiusFactor: number;
  27267. private _scene;
  27268. private _positions;
  27269. private _indices;
  27270. private _normals;
  27271. private _colors;
  27272. private _uvs;
  27273. private _indices32;
  27274. private _positions32;
  27275. private _normals32;
  27276. private _fixedNormal32;
  27277. private _colors32;
  27278. private _uvs32;
  27279. private _index;
  27280. private _updatable;
  27281. private _pickable;
  27282. private _isVisibilityBoxLocked;
  27283. private _alwaysVisible;
  27284. private _depthSort;
  27285. private _expandable;
  27286. private _shapeCounter;
  27287. private _copy;
  27288. private _color;
  27289. private _computeParticleColor;
  27290. private _computeParticleTexture;
  27291. private _computeParticleRotation;
  27292. private _computeParticleVertex;
  27293. private _computeBoundingBox;
  27294. private _depthSortParticles;
  27295. private _camera;
  27296. private _mustUnrotateFixedNormals;
  27297. private _particlesIntersect;
  27298. private _needs32Bits;
  27299. private _isNotBuilt;
  27300. private _lastParticleId;
  27301. private _idxOfId;
  27302. private _multimaterialEnabled;
  27303. private _useModelMaterial;
  27304. private _indicesByMaterial;
  27305. private _materialIndexes;
  27306. private _depthSortFunction;
  27307. private _materialSortFunction;
  27308. private _materials;
  27309. private _multimaterial;
  27310. private _materialIndexesById;
  27311. private _defaultMaterial;
  27312. private _autoUpdateSubMeshes;
  27313. /**
  27314. * Creates a SPS (Solid Particle System) object.
  27315. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27316. * @param scene (Scene) is the scene in which the SPS is added.
  27317. * @param options defines the options of the sps e.g.
  27318. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27319. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27320. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27321. * * 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.
  27322. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27323. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27324. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27325. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27326. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27327. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27328. */
  27329. constructor(name: string, scene: Scene, options?: {
  27330. updatable?: boolean;
  27331. isPickable?: boolean;
  27332. enableDepthSort?: boolean;
  27333. particleIntersection?: boolean;
  27334. boundingSphereOnly?: boolean;
  27335. bSphereRadiusFactor?: number;
  27336. expandable?: boolean;
  27337. useModelMaterial?: boolean;
  27338. enableMultiMaterial?: boolean;
  27339. });
  27340. /**
  27341. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27342. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27343. * @returns the created mesh
  27344. */
  27345. buildMesh(): Mesh;
  27346. /**
  27347. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27348. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27349. * Thus the particles generated from `digest()` have their property `position` set yet.
  27350. * @param mesh ( Mesh ) is the mesh to be digested
  27351. * @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
  27352. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27353. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27354. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27355. * @returns the current SPS
  27356. */
  27357. digest(mesh: Mesh, options?: {
  27358. facetNb?: number;
  27359. number?: number;
  27360. delta?: number;
  27361. storage?: [];
  27362. }): SolidParticleSystem;
  27363. /**
  27364. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27365. * @hidden
  27366. */
  27367. private _unrotateFixedNormals;
  27368. /**
  27369. * Resets the temporary working copy particle
  27370. * @hidden
  27371. */
  27372. private _resetCopy;
  27373. /**
  27374. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27375. * @param p the current index in the positions array to be updated
  27376. * @param ind the current index in the indices array
  27377. * @param shape a Vector3 array, the shape geometry
  27378. * @param positions the positions array to be updated
  27379. * @param meshInd the shape indices array
  27380. * @param indices the indices array to be updated
  27381. * @param meshUV the shape uv array
  27382. * @param uvs the uv array to be updated
  27383. * @param meshCol the shape color array
  27384. * @param colors the color array to be updated
  27385. * @param meshNor the shape normals array
  27386. * @param normals the normals array to be updated
  27387. * @param idx the particle index
  27388. * @param idxInShape the particle index in its shape
  27389. * @param options the addShape() method passed options
  27390. * @model the particle model
  27391. * @hidden
  27392. */
  27393. private _meshBuilder;
  27394. /**
  27395. * Returns a shape Vector3 array from positions float array
  27396. * @param positions float array
  27397. * @returns a vector3 array
  27398. * @hidden
  27399. */
  27400. private _posToShape;
  27401. /**
  27402. * Returns a shapeUV array from a float uvs (array deep copy)
  27403. * @param uvs as a float array
  27404. * @returns a shapeUV array
  27405. * @hidden
  27406. */
  27407. private _uvsToShapeUV;
  27408. /**
  27409. * Adds a new particle object in the particles array
  27410. * @param idx particle index in particles array
  27411. * @param id particle id
  27412. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27413. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27414. * @param model particle ModelShape object
  27415. * @param shapeId model shape identifier
  27416. * @param idxInShape index of the particle in the current model
  27417. * @param bInfo model bounding info object
  27418. * @param storage target storage array, if any
  27419. * @hidden
  27420. */
  27421. private _addParticle;
  27422. /**
  27423. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27424. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27425. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27426. * @param nb (positive integer) the number of particles to be created from this model
  27427. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27428. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27429. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27430. * @returns the number of shapes in the system
  27431. */
  27432. addShape(mesh: Mesh, nb: number, options?: {
  27433. positionFunction?: any;
  27434. vertexFunction?: any;
  27435. storage?: [];
  27436. }): number;
  27437. /**
  27438. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27439. * @hidden
  27440. */
  27441. private _rebuildParticle;
  27442. /**
  27443. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27444. * @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.
  27445. * @returns the SPS.
  27446. */
  27447. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27448. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27449. * Returns an array with the removed particles.
  27450. * 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.
  27451. * The SPS can't be empty so at least one particle needs to remain in place.
  27452. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27453. * @param start index of the first particle to remove
  27454. * @param end index of the last particle to remove (included)
  27455. * @returns an array populated with the removed particles
  27456. */
  27457. removeParticles(start: number, end: number): SolidParticle[];
  27458. /**
  27459. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27460. * @param solidParticleArray an array populated with Solid Particles objects
  27461. * @returns the SPS
  27462. */
  27463. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27464. /**
  27465. * Creates a new particle and modifies the SPS mesh geometry :
  27466. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27467. * - calls _addParticle() to populate the particle array
  27468. * factorized code from addShape() and insertParticlesFromArray()
  27469. * @param idx particle index in the particles array
  27470. * @param i particle index in its shape
  27471. * @param modelShape particle ModelShape object
  27472. * @param shape shape vertex array
  27473. * @param meshInd shape indices array
  27474. * @param meshUV shape uv array
  27475. * @param meshCol shape color array
  27476. * @param meshNor shape normals array
  27477. * @param bbInfo shape bounding info
  27478. * @param storage target particle storage
  27479. * @options addShape() passed options
  27480. * @hidden
  27481. */
  27482. private _insertNewParticle;
  27483. /**
  27484. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27485. * This method calls `updateParticle()` for each particle of the SPS.
  27486. * For an animated SPS, it is usually called within the render loop.
  27487. * 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.
  27488. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27489. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27490. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27491. * @returns the SPS.
  27492. */
  27493. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27494. /**
  27495. * Disposes the SPS.
  27496. */
  27497. dispose(): void;
  27498. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  27499. * idx is the particle index in the SPS
  27500. * faceId is the picked face index counted within this particle.
  27501. * Returns null if the pickInfo can't identify a picked particle.
  27502. * @param pickingInfo (PickingInfo object)
  27503. * @returns {idx: number, faceId: number} or null
  27504. */
  27505. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  27506. idx: number;
  27507. faceId: number;
  27508. }>;
  27509. /**
  27510. * Returns a SolidParticle object from its identifier : particle.id
  27511. * @param id (integer) the particle Id
  27512. * @returns the searched particle or null if not found in the SPS.
  27513. */
  27514. getParticleById(id: number): Nullable<SolidParticle>;
  27515. /**
  27516. * Returns a new array populated with the particles having the passed shapeId.
  27517. * @param shapeId (integer) the shape identifier
  27518. * @returns a new solid particle array
  27519. */
  27520. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27521. /**
  27522. * Populates the passed array "ref" with the particles having the passed shapeId.
  27523. * @param shapeId the shape identifier
  27524. * @returns the SPS
  27525. * @param ref
  27526. */
  27527. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27528. /**
  27529. * Computes the required SubMeshes according the materials assigned to the particles.
  27530. * @returns the solid particle system.
  27531. * Does nothing if called before the SPS mesh is built.
  27532. */
  27533. computeSubMeshes(): SolidParticleSystem;
  27534. /**
  27535. * Sorts the solid particles by material when MultiMaterial is enabled.
  27536. * Updates the indices32 array.
  27537. * Updates the indicesByMaterial array.
  27538. * Updates the mesh indices array.
  27539. * @returns the SPS
  27540. * @hidden
  27541. */
  27542. private _sortParticlesByMaterial;
  27543. /**
  27544. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27545. * @hidden
  27546. */
  27547. private _setMaterialIndexesById;
  27548. /**
  27549. * Returns an array with unique values of Materials from the passed array
  27550. * @param array the material array to be checked and filtered
  27551. * @hidden
  27552. */
  27553. private _filterUniqueMaterialId;
  27554. /**
  27555. * Sets a new Standard Material as _defaultMaterial if not already set.
  27556. * @hidden
  27557. */
  27558. private _setDefaultMaterial;
  27559. /**
  27560. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27561. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27562. * @returns the SPS.
  27563. */
  27564. refreshVisibleSize(): SolidParticleSystem;
  27565. /**
  27566. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27567. * @param size the size (float) of the visibility box
  27568. * note : this doesn't lock the SPS mesh bounding box.
  27569. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27570. */
  27571. setVisibilityBox(size: number): void;
  27572. /**
  27573. * Gets whether the SPS as always visible or not
  27574. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27575. */
  27576. get isAlwaysVisible(): boolean;
  27577. /**
  27578. * Sets the SPS as always visible or not
  27579. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27580. */
  27581. set isAlwaysVisible(val: boolean);
  27582. /**
  27583. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27584. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27585. */
  27586. set isVisibilityBoxLocked(val: boolean);
  27587. /**
  27588. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27589. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27590. */
  27591. get isVisibilityBoxLocked(): boolean;
  27592. /**
  27593. * Tells to `setParticles()` to compute the particle rotations or not.
  27594. * Default value : true. The SPS is faster when it's set to false.
  27595. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27596. */
  27597. set computeParticleRotation(val: boolean);
  27598. /**
  27599. * Tells to `setParticles()` to compute the particle colors or not.
  27600. * Default value : true. The SPS is faster when it's set to false.
  27601. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27602. */
  27603. set computeParticleColor(val: boolean);
  27604. set computeParticleTexture(val: boolean);
  27605. /**
  27606. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27607. * Default value : false. The SPS is faster when it's set to false.
  27608. * Note : the particle custom vertex positions aren't stored values.
  27609. */
  27610. set computeParticleVertex(val: boolean);
  27611. /**
  27612. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27613. */
  27614. set computeBoundingBox(val: boolean);
  27615. /**
  27616. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27617. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27618. * Default : `true`
  27619. */
  27620. set depthSortParticles(val: boolean);
  27621. /**
  27622. * Gets if `setParticles()` computes the particle rotations or not.
  27623. * Default value : true. The SPS is faster when it's set to false.
  27624. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27625. */
  27626. get computeParticleRotation(): boolean;
  27627. /**
  27628. * Gets if `setParticles()` computes the particle colors or not.
  27629. * Default value : true. The SPS is faster when it's set to false.
  27630. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27631. */
  27632. get computeParticleColor(): boolean;
  27633. /**
  27634. * Gets if `setParticles()` computes the particle textures or not.
  27635. * Default value : true. The SPS is faster when it's set to false.
  27636. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27637. */
  27638. get computeParticleTexture(): boolean;
  27639. /**
  27640. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27641. * Default value : false. The SPS is faster when it's set to false.
  27642. * Note : the particle custom vertex positions aren't stored values.
  27643. */
  27644. get computeParticleVertex(): boolean;
  27645. /**
  27646. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27647. */
  27648. get computeBoundingBox(): boolean;
  27649. /**
  27650. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27651. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27652. * Default : `true`
  27653. */
  27654. get depthSortParticles(): boolean;
  27655. /**
  27656. * Gets if the SPS is created as expandable at construction time.
  27657. * Default : `false`
  27658. */
  27659. get expandable(): boolean;
  27660. /**
  27661. * Gets if the SPS supports the Multi Materials
  27662. */
  27663. get multimaterialEnabled(): boolean;
  27664. /**
  27665. * Gets if the SPS uses the model materials for its own multimaterial.
  27666. */
  27667. get useModelMaterial(): boolean;
  27668. /**
  27669. * The SPS used material array.
  27670. */
  27671. get materials(): Material[];
  27672. /**
  27673. * Sets the SPS MultiMaterial from the passed materials.
  27674. * Note : the passed array is internally copied and not used then by reference.
  27675. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27676. */
  27677. setMultiMaterial(materials: Material[]): void;
  27678. /**
  27679. * The SPS computed multimaterial object
  27680. */
  27681. get multimaterial(): MultiMaterial;
  27682. set multimaterial(mm: MultiMaterial);
  27683. /**
  27684. * If the subMeshes must be updated on the next call to setParticles()
  27685. */
  27686. get autoUpdateSubMeshes(): boolean;
  27687. set autoUpdateSubMeshes(val: boolean);
  27688. /**
  27689. * This function does nothing. It may be overwritten to set all the particle first values.
  27690. * The SPS doesn't call this function, you may have to call it by your own.
  27691. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27692. */
  27693. initParticles(): void;
  27694. /**
  27695. * This function does nothing. It may be overwritten to recycle a particle.
  27696. * The SPS doesn't call this function, you may have to call it by your own.
  27697. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27698. * @param particle The particle to recycle
  27699. * @returns the recycled particle
  27700. */
  27701. recycleParticle(particle: SolidParticle): SolidParticle;
  27702. /**
  27703. * Updates a particle : this function should be overwritten by the user.
  27704. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27705. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27706. * @example : just set a particle position or velocity and recycle conditions
  27707. * @param particle The particle to update
  27708. * @returns the updated particle
  27709. */
  27710. updateParticle(particle: SolidParticle): SolidParticle;
  27711. /**
  27712. * Updates a vertex of a particle : it can be overwritten by the user.
  27713. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27714. * @param particle the current particle
  27715. * @param vertex the current index of the current particle
  27716. * @param pt the index of the current vertex in the particle shape
  27717. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27718. * @example : just set a vertex particle position
  27719. * @returns the updated vertex
  27720. */
  27721. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27722. /**
  27723. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27724. * This does nothing and may be overwritten by the user.
  27725. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27726. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27727. * @param update the boolean update value actually passed to setParticles()
  27728. */
  27729. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27730. /**
  27731. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27732. * This will be passed three parameters.
  27733. * This does nothing and may be overwritten by the user.
  27734. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27735. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27736. * @param update the boolean update value actually passed to setParticles()
  27737. */
  27738. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27739. }
  27740. }
  27741. declare module BABYLON {
  27742. /**
  27743. * Represents one particle of a solid particle system.
  27744. */
  27745. export class SolidParticle {
  27746. /**
  27747. * particle global index
  27748. */
  27749. idx: number;
  27750. /**
  27751. * particle identifier
  27752. */
  27753. id: number;
  27754. /**
  27755. * The color of the particle
  27756. */
  27757. color: Nullable<Color4>;
  27758. /**
  27759. * The world space position of the particle.
  27760. */
  27761. position: Vector3;
  27762. /**
  27763. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27764. */
  27765. rotation: Vector3;
  27766. /**
  27767. * The world space rotation quaternion of the particle.
  27768. */
  27769. rotationQuaternion: Nullable<Quaternion>;
  27770. /**
  27771. * The scaling of the particle.
  27772. */
  27773. scaling: Vector3;
  27774. /**
  27775. * The uvs of the particle.
  27776. */
  27777. uvs: Vector4;
  27778. /**
  27779. * The current speed of the particle.
  27780. */
  27781. velocity: Vector3;
  27782. /**
  27783. * The pivot point in the particle local space.
  27784. */
  27785. pivot: Vector3;
  27786. /**
  27787. * Must the particle be translated from its pivot point in its local space ?
  27788. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27789. * Default : false
  27790. */
  27791. translateFromPivot: boolean;
  27792. /**
  27793. * Is the particle active or not ?
  27794. */
  27795. alive: boolean;
  27796. /**
  27797. * Is the particle visible or not ?
  27798. */
  27799. isVisible: boolean;
  27800. /**
  27801. * Index of this particle in the global "positions" array (Internal use)
  27802. * @hidden
  27803. */
  27804. _pos: number;
  27805. /**
  27806. * @hidden Index of this particle in the global "indices" array (Internal use)
  27807. */
  27808. _ind: number;
  27809. /**
  27810. * @hidden ModelShape of this particle (Internal use)
  27811. */
  27812. _model: ModelShape;
  27813. /**
  27814. * ModelShape id of this particle
  27815. */
  27816. shapeId: number;
  27817. /**
  27818. * Index of the particle in its shape id
  27819. */
  27820. idxInShape: number;
  27821. /**
  27822. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27823. */
  27824. _modelBoundingInfo: BoundingInfo;
  27825. /**
  27826. * @hidden Particle BoundingInfo object (Internal use)
  27827. */
  27828. _boundingInfo: BoundingInfo;
  27829. /**
  27830. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27831. */
  27832. _sps: SolidParticleSystem;
  27833. /**
  27834. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27835. */
  27836. _stillInvisible: boolean;
  27837. /**
  27838. * @hidden Last computed particle rotation matrix
  27839. */
  27840. _rotationMatrix: number[];
  27841. /**
  27842. * Parent particle Id, if any.
  27843. * Default null.
  27844. */
  27845. parentId: Nullable<number>;
  27846. /**
  27847. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27848. */
  27849. materialIndex: Nullable<number>;
  27850. /**
  27851. * Custom object or properties.
  27852. */
  27853. props: Nullable<any>;
  27854. /**
  27855. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27856. * The possible values are :
  27857. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27858. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27859. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27860. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27861. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27862. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27863. * */
  27864. cullingStrategy: number;
  27865. /**
  27866. * @hidden Internal global position in the SPS.
  27867. */
  27868. _globalPosition: Vector3;
  27869. /**
  27870. * Creates a Solid Particle object.
  27871. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27872. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27873. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27874. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27875. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27876. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27877. * @param shapeId (integer) is the model shape identifier in the SPS.
  27878. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27879. * @param sps defines the sps it is associated to
  27880. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27881. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27882. */
  27883. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27884. /**
  27885. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27886. * @param target the particle target
  27887. * @returns the current particle
  27888. */
  27889. copyToRef(target: SolidParticle): SolidParticle;
  27890. /**
  27891. * Legacy support, changed scale to scaling
  27892. */
  27893. get scale(): Vector3;
  27894. /**
  27895. * Legacy support, changed scale to scaling
  27896. */
  27897. set scale(scale: Vector3);
  27898. /**
  27899. * Legacy support, changed quaternion to rotationQuaternion
  27900. */
  27901. get quaternion(): Nullable<Quaternion>;
  27902. /**
  27903. * Legacy support, changed quaternion to rotationQuaternion
  27904. */
  27905. set quaternion(q: Nullable<Quaternion>);
  27906. /**
  27907. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27908. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27909. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27910. * @returns true if it intersects
  27911. */
  27912. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27913. /**
  27914. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27915. * A particle is in the frustum if its bounding box intersects the frustum
  27916. * @param frustumPlanes defines the frustum to test
  27917. * @returns true if the particle is in the frustum planes
  27918. */
  27919. isInFrustum(frustumPlanes: Plane[]): boolean;
  27920. /**
  27921. * get the rotation matrix of the particle
  27922. * @hidden
  27923. */
  27924. getRotationMatrix(m: Matrix): void;
  27925. }
  27926. /**
  27927. * Represents the shape of the model used by one particle of a solid particle system.
  27928. * SPS internal tool, don't use it manually.
  27929. */
  27930. export class ModelShape {
  27931. /**
  27932. * The shape id
  27933. * @hidden
  27934. */
  27935. shapeID: number;
  27936. /**
  27937. * flat array of model positions (internal use)
  27938. * @hidden
  27939. */
  27940. _shape: Vector3[];
  27941. /**
  27942. * flat array of model UVs (internal use)
  27943. * @hidden
  27944. */
  27945. _shapeUV: number[];
  27946. /**
  27947. * color array of the model
  27948. * @hidden
  27949. */
  27950. _shapeColors: number[];
  27951. /**
  27952. * indices array of the model
  27953. * @hidden
  27954. */
  27955. _indices: number[];
  27956. /**
  27957. * normals array of the model
  27958. * @hidden
  27959. */
  27960. _normals: number[];
  27961. /**
  27962. * length of the shape in the model indices array (internal use)
  27963. * @hidden
  27964. */
  27965. _indicesLength: number;
  27966. /**
  27967. * Custom position function (internal use)
  27968. * @hidden
  27969. */
  27970. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27971. /**
  27972. * Custom vertex function (internal use)
  27973. * @hidden
  27974. */
  27975. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27976. /**
  27977. * Model material (internal use)
  27978. * @hidden
  27979. */
  27980. _material: Nullable<Material>;
  27981. /**
  27982. * 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.
  27983. * SPS internal tool, don't use it manually.
  27984. * @hidden
  27985. */
  27986. 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>);
  27987. }
  27988. /**
  27989. * Represents a Depth Sorted Particle in the solid particle system.
  27990. * @hidden
  27991. */
  27992. export class DepthSortedParticle {
  27993. /**
  27994. * Particle index
  27995. */
  27996. idx: number;
  27997. /**
  27998. * Index of the particle in the "indices" array
  27999. */
  28000. ind: number;
  28001. /**
  28002. * Length of the particle shape in the "indices" array
  28003. */
  28004. indicesLength: number;
  28005. /**
  28006. * Squared distance from the particle to the camera
  28007. */
  28008. sqDistance: number;
  28009. /**
  28010. * Material index when used with MultiMaterials
  28011. */
  28012. materialIndex: number;
  28013. /**
  28014. * Creates a new sorted particle
  28015. * @param materialIndex
  28016. */
  28017. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28018. }
  28019. }
  28020. declare module BABYLON {
  28021. /**
  28022. * @hidden
  28023. */
  28024. export class _MeshCollisionData {
  28025. _checkCollisions: boolean;
  28026. _collisionMask: number;
  28027. _collisionGroup: number;
  28028. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28029. _collider: Nullable<Collider>;
  28030. _oldPositionForCollisions: Vector3;
  28031. _diffPositionForCollisions: Vector3;
  28032. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28033. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28034. }
  28035. }
  28036. declare module BABYLON {
  28037. /** @hidden */
  28038. class _FacetDataStorage {
  28039. facetPositions: Vector3[];
  28040. facetNormals: Vector3[];
  28041. facetPartitioning: number[][];
  28042. facetNb: number;
  28043. partitioningSubdivisions: number;
  28044. partitioningBBoxRatio: number;
  28045. facetDataEnabled: boolean;
  28046. facetParameters: any;
  28047. bbSize: Vector3;
  28048. subDiv: {
  28049. max: number;
  28050. X: number;
  28051. Y: number;
  28052. Z: number;
  28053. };
  28054. facetDepthSort: boolean;
  28055. facetDepthSortEnabled: boolean;
  28056. depthSortedIndices: IndicesArray;
  28057. depthSortedFacets: {
  28058. ind: number;
  28059. sqDistance: number;
  28060. }[];
  28061. facetDepthSortFunction: (f1: {
  28062. ind: number;
  28063. sqDistance: number;
  28064. }, f2: {
  28065. ind: number;
  28066. sqDistance: number;
  28067. }) => number;
  28068. facetDepthSortFrom: Vector3;
  28069. facetDepthSortOrigin: Vector3;
  28070. invertedMatrix: Matrix;
  28071. }
  28072. /**
  28073. * @hidden
  28074. **/
  28075. class _InternalAbstractMeshDataInfo {
  28076. _hasVertexAlpha: boolean;
  28077. _useVertexColors: boolean;
  28078. _numBoneInfluencers: number;
  28079. _applyFog: boolean;
  28080. _receiveShadows: boolean;
  28081. _facetData: _FacetDataStorage;
  28082. _visibility: number;
  28083. _skeleton: Nullable<Skeleton>;
  28084. _layerMask: number;
  28085. _computeBonesUsingShaders: boolean;
  28086. _isActive: boolean;
  28087. _onlyForInstances: boolean;
  28088. _isActiveIntermediate: boolean;
  28089. _onlyForInstancesIntermediate: boolean;
  28090. _actAsRegularMesh: boolean;
  28091. }
  28092. /**
  28093. * Class used to store all common mesh properties
  28094. */
  28095. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28096. /** No occlusion */
  28097. static OCCLUSION_TYPE_NONE: number;
  28098. /** Occlusion set to optimisitic */
  28099. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28100. /** Occlusion set to strict */
  28101. static OCCLUSION_TYPE_STRICT: number;
  28102. /** Use an accurante occlusion algorithm */
  28103. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28104. /** Use a conservative occlusion algorithm */
  28105. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28106. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28107. * Test order :
  28108. * Is the bounding sphere outside the frustum ?
  28109. * If not, are the bounding box vertices outside the frustum ?
  28110. * It not, then the cullable object is in the frustum.
  28111. */
  28112. static readonly CULLINGSTRATEGY_STANDARD: number;
  28113. /** Culling strategy : Bounding Sphere Only.
  28114. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28115. * It's also less accurate than the standard because some not visible objects can still be selected.
  28116. * Test : is the bounding sphere outside the frustum ?
  28117. * If not, then the cullable object is in the frustum.
  28118. */
  28119. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28120. /** Culling strategy : Optimistic Inclusion.
  28121. * This in an inclusion test first, then the standard exclusion test.
  28122. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28123. * 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.
  28124. * Anyway, it's as accurate as the standard strategy.
  28125. * Test :
  28126. * Is the cullable object bounding sphere center in the frustum ?
  28127. * If not, apply the default culling strategy.
  28128. */
  28129. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28130. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28131. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28132. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28133. * 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.
  28134. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28135. * Test :
  28136. * Is the cullable object bounding sphere center in the frustum ?
  28137. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28138. */
  28139. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28140. /**
  28141. * No billboard
  28142. */
  28143. static get BILLBOARDMODE_NONE(): number;
  28144. /** Billboard on X axis */
  28145. static get BILLBOARDMODE_X(): number;
  28146. /** Billboard on Y axis */
  28147. static get BILLBOARDMODE_Y(): number;
  28148. /** Billboard on Z axis */
  28149. static get BILLBOARDMODE_Z(): number;
  28150. /** Billboard on all axes */
  28151. static get BILLBOARDMODE_ALL(): number;
  28152. /** Billboard on using position instead of orientation */
  28153. static get BILLBOARDMODE_USE_POSITION(): number;
  28154. /** @hidden */
  28155. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28156. /**
  28157. * The culling strategy to use to check whether the mesh must be rendered or not.
  28158. * This value can be changed at any time and will be used on the next render mesh selection.
  28159. * The possible values are :
  28160. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28161. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28162. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28163. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28164. * Please read each static variable documentation to get details about the culling process.
  28165. * */
  28166. cullingStrategy: number;
  28167. /**
  28168. * Gets the number of facets in the mesh
  28169. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28170. */
  28171. get facetNb(): number;
  28172. /**
  28173. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28174. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28175. */
  28176. get partitioningSubdivisions(): number;
  28177. set partitioningSubdivisions(nb: number);
  28178. /**
  28179. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28180. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28181. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28182. */
  28183. get partitioningBBoxRatio(): number;
  28184. set partitioningBBoxRatio(ratio: number);
  28185. /**
  28186. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28187. * Works only for updatable meshes.
  28188. * Doesn't work with multi-materials
  28189. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28190. */
  28191. get mustDepthSortFacets(): boolean;
  28192. set mustDepthSortFacets(sort: boolean);
  28193. /**
  28194. * The location (Vector3) where the facet depth sort must be computed from.
  28195. * By default, the active camera position.
  28196. * Used only when facet depth sort is enabled
  28197. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28198. */
  28199. get facetDepthSortFrom(): Vector3;
  28200. set facetDepthSortFrom(location: Vector3);
  28201. /**
  28202. * gets a boolean indicating if facetData is enabled
  28203. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28204. */
  28205. get isFacetDataEnabled(): boolean;
  28206. /** @hidden */
  28207. _updateNonUniformScalingState(value: boolean): boolean;
  28208. /**
  28209. * An event triggered when this mesh collides with another one
  28210. */
  28211. onCollideObservable: Observable<AbstractMesh>;
  28212. /** Set a function to call when this mesh collides with another one */
  28213. set onCollide(callback: () => void);
  28214. /**
  28215. * An event triggered when the collision's position changes
  28216. */
  28217. onCollisionPositionChangeObservable: Observable<Vector3>;
  28218. /** Set a function to call when the collision's position changes */
  28219. set onCollisionPositionChange(callback: () => void);
  28220. /**
  28221. * An event triggered when material is changed
  28222. */
  28223. onMaterialChangedObservable: Observable<AbstractMesh>;
  28224. /**
  28225. * Gets or sets the orientation for POV movement & rotation
  28226. */
  28227. definedFacingForward: boolean;
  28228. /** @hidden */
  28229. _occlusionQuery: Nullable<WebGLQuery>;
  28230. /** @hidden */
  28231. _renderingGroup: Nullable<RenderingGroup>;
  28232. /**
  28233. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28234. */
  28235. get visibility(): number;
  28236. /**
  28237. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28238. */
  28239. set visibility(value: number);
  28240. /** Gets or sets the alpha index used to sort transparent meshes
  28241. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28242. */
  28243. alphaIndex: number;
  28244. /**
  28245. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28246. */
  28247. isVisible: boolean;
  28248. /**
  28249. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28250. */
  28251. isPickable: boolean;
  28252. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28253. showSubMeshesBoundingBox: boolean;
  28254. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28255. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28256. */
  28257. isBlocker: boolean;
  28258. /**
  28259. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28260. */
  28261. enablePointerMoveEvents: boolean;
  28262. /**
  28263. * Specifies the rendering group id for this mesh (0 by default)
  28264. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28265. */
  28266. renderingGroupId: number;
  28267. private _material;
  28268. /** Gets or sets current material */
  28269. get material(): Nullable<Material>;
  28270. set material(value: Nullable<Material>);
  28271. /**
  28272. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28273. * @see http://doc.babylonjs.com/babylon101/shadows
  28274. */
  28275. get receiveShadows(): boolean;
  28276. set receiveShadows(value: boolean);
  28277. /** Defines color to use when rendering outline */
  28278. outlineColor: Color3;
  28279. /** Define width to use when rendering outline */
  28280. outlineWidth: number;
  28281. /** Defines color to use when rendering overlay */
  28282. overlayColor: Color3;
  28283. /** Defines alpha to use when rendering overlay */
  28284. overlayAlpha: number;
  28285. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28286. get hasVertexAlpha(): boolean;
  28287. set hasVertexAlpha(value: boolean);
  28288. /** 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) */
  28289. get useVertexColors(): boolean;
  28290. set useVertexColors(value: boolean);
  28291. /**
  28292. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28293. */
  28294. get computeBonesUsingShaders(): boolean;
  28295. set computeBonesUsingShaders(value: boolean);
  28296. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28297. get numBoneInfluencers(): number;
  28298. set numBoneInfluencers(value: number);
  28299. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28300. get applyFog(): boolean;
  28301. set applyFog(value: boolean);
  28302. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28303. useOctreeForRenderingSelection: boolean;
  28304. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28305. useOctreeForPicking: boolean;
  28306. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28307. useOctreeForCollisions: boolean;
  28308. /**
  28309. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28310. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28311. */
  28312. get layerMask(): number;
  28313. set layerMask(value: number);
  28314. /**
  28315. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28316. */
  28317. alwaysSelectAsActiveMesh: boolean;
  28318. /**
  28319. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28320. */
  28321. doNotSyncBoundingInfo: boolean;
  28322. /**
  28323. * Gets or sets the current action manager
  28324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28325. */
  28326. actionManager: Nullable<AbstractActionManager>;
  28327. private _meshCollisionData;
  28328. /**
  28329. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28330. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28331. */
  28332. ellipsoid: Vector3;
  28333. /**
  28334. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28335. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28336. */
  28337. ellipsoidOffset: Vector3;
  28338. /**
  28339. * Gets or sets a collision mask used to mask collisions (default is -1).
  28340. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28341. */
  28342. get collisionMask(): number;
  28343. set collisionMask(mask: number);
  28344. /**
  28345. * Gets or sets the current collision group mask (-1 by default).
  28346. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28347. */
  28348. get collisionGroup(): number;
  28349. set collisionGroup(mask: number);
  28350. /**
  28351. * Gets or sets current surrounding meshes (null by default).
  28352. *
  28353. * By default collision detection is tested against every mesh in the scene.
  28354. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  28355. * meshes will be tested for the collision.
  28356. *
  28357. * Note: if set to an empty array no collision will happen when this mesh is moved.
  28358. */
  28359. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  28360. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  28361. /**
  28362. * Defines edge width used when edgesRenderer is enabled
  28363. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28364. */
  28365. edgesWidth: number;
  28366. /**
  28367. * Defines edge color used when edgesRenderer is enabled
  28368. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28369. */
  28370. edgesColor: Color4;
  28371. /** @hidden */
  28372. _edgesRenderer: Nullable<IEdgesRenderer>;
  28373. /** @hidden */
  28374. _masterMesh: Nullable<AbstractMesh>;
  28375. /** @hidden */
  28376. _boundingInfo: Nullable<BoundingInfo>;
  28377. /** @hidden */
  28378. _renderId: number;
  28379. /**
  28380. * Gets or sets the list of subMeshes
  28381. * @see http://doc.babylonjs.com/how_to/multi_materials
  28382. */
  28383. subMeshes: SubMesh[];
  28384. /** @hidden */
  28385. _intersectionsInProgress: AbstractMesh[];
  28386. /** @hidden */
  28387. _unIndexed: boolean;
  28388. /** @hidden */
  28389. _lightSources: Light[];
  28390. /** Gets the list of lights affecting that mesh */
  28391. get lightSources(): Light[];
  28392. /** @hidden */
  28393. get _positions(): Nullable<Vector3[]>;
  28394. /** @hidden */
  28395. _waitingData: {
  28396. lods: Nullable<any>;
  28397. actions: Nullable<any>;
  28398. freezeWorldMatrix: Nullable<boolean>;
  28399. };
  28400. /** @hidden */
  28401. _bonesTransformMatrices: Nullable<Float32Array>;
  28402. /** @hidden */
  28403. _transformMatrixTexture: Nullable<RawTexture>;
  28404. /**
  28405. * Gets or sets a skeleton to apply skining transformations
  28406. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28407. */
  28408. set skeleton(value: Nullable<Skeleton>);
  28409. get skeleton(): Nullable<Skeleton>;
  28410. /**
  28411. * An event triggered when the mesh is rebuilt.
  28412. */
  28413. onRebuildObservable: Observable<AbstractMesh>;
  28414. /**
  28415. * Creates a new AbstractMesh
  28416. * @param name defines the name of the mesh
  28417. * @param scene defines the hosting scene
  28418. */
  28419. constructor(name: string, scene?: Nullable<Scene>);
  28420. /**
  28421. * Returns the string "AbstractMesh"
  28422. * @returns "AbstractMesh"
  28423. */
  28424. getClassName(): string;
  28425. /**
  28426. * Gets a string representation of the current mesh
  28427. * @param fullDetails defines a boolean indicating if full details must be included
  28428. * @returns a string representation of the current mesh
  28429. */
  28430. toString(fullDetails?: boolean): string;
  28431. /**
  28432. * @hidden
  28433. */
  28434. protected _getEffectiveParent(): Nullable<Node>;
  28435. /** @hidden */
  28436. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28437. /** @hidden */
  28438. _rebuild(): void;
  28439. /** @hidden */
  28440. _resyncLightSources(): void;
  28441. /** @hidden */
  28442. _resyncLightSource(light: Light): void;
  28443. /** @hidden */
  28444. _unBindEffect(): void;
  28445. /** @hidden */
  28446. _removeLightSource(light: Light, dispose: boolean): void;
  28447. private _markSubMeshesAsDirty;
  28448. /** @hidden */
  28449. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28450. /** @hidden */
  28451. _markSubMeshesAsAttributesDirty(): void;
  28452. /** @hidden */
  28453. _markSubMeshesAsMiscDirty(): void;
  28454. /**
  28455. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28456. */
  28457. get scaling(): Vector3;
  28458. set scaling(newScaling: Vector3);
  28459. /**
  28460. * Returns true if the mesh is blocked. Implemented by child classes
  28461. */
  28462. get isBlocked(): boolean;
  28463. /**
  28464. * Returns the mesh itself by default. Implemented by child classes
  28465. * @param camera defines the camera to use to pick the right LOD level
  28466. * @returns the currentAbstractMesh
  28467. */
  28468. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28469. /**
  28470. * Returns 0 by default. Implemented by child classes
  28471. * @returns an integer
  28472. */
  28473. getTotalVertices(): number;
  28474. /**
  28475. * Returns a positive integer : the total number of indices in this mesh geometry.
  28476. * @returns the numner of indices or zero if the mesh has no geometry.
  28477. */
  28478. getTotalIndices(): number;
  28479. /**
  28480. * Returns null by default. Implemented by child classes
  28481. * @returns null
  28482. */
  28483. getIndices(): Nullable<IndicesArray>;
  28484. /**
  28485. * Returns the array of the requested vertex data kind. Implemented by child classes
  28486. * @param kind defines the vertex data kind to use
  28487. * @returns null
  28488. */
  28489. getVerticesData(kind: string): Nullable<FloatArray>;
  28490. /**
  28491. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28492. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28493. * Note that a new underlying VertexBuffer object is created each call.
  28494. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28495. * @param kind defines vertex data kind:
  28496. * * VertexBuffer.PositionKind
  28497. * * VertexBuffer.UVKind
  28498. * * VertexBuffer.UV2Kind
  28499. * * VertexBuffer.UV3Kind
  28500. * * VertexBuffer.UV4Kind
  28501. * * VertexBuffer.UV5Kind
  28502. * * VertexBuffer.UV6Kind
  28503. * * VertexBuffer.ColorKind
  28504. * * VertexBuffer.MatricesIndicesKind
  28505. * * VertexBuffer.MatricesIndicesExtraKind
  28506. * * VertexBuffer.MatricesWeightsKind
  28507. * * VertexBuffer.MatricesWeightsExtraKind
  28508. * @param data defines the data source
  28509. * @param updatable defines if the data must be flagged as updatable (or static)
  28510. * @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
  28511. * @returns the current mesh
  28512. */
  28513. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28514. /**
  28515. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28516. * If the mesh has no geometry, it is simply returned as it is.
  28517. * @param kind defines vertex data kind:
  28518. * * VertexBuffer.PositionKind
  28519. * * VertexBuffer.UVKind
  28520. * * VertexBuffer.UV2Kind
  28521. * * VertexBuffer.UV3Kind
  28522. * * VertexBuffer.UV4Kind
  28523. * * VertexBuffer.UV5Kind
  28524. * * VertexBuffer.UV6Kind
  28525. * * VertexBuffer.ColorKind
  28526. * * VertexBuffer.MatricesIndicesKind
  28527. * * VertexBuffer.MatricesIndicesExtraKind
  28528. * * VertexBuffer.MatricesWeightsKind
  28529. * * VertexBuffer.MatricesWeightsExtraKind
  28530. * @param data defines the data source
  28531. * @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
  28532. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28533. * @returns the current mesh
  28534. */
  28535. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28536. /**
  28537. * Sets the mesh indices,
  28538. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28539. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28540. * @param totalVertices Defines the total number of vertices
  28541. * @returns the current mesh
  28542. */
  28543. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28544. /**
  28545. * Gets a boolean indicating if specific vertex data is present
  28546. * @param kind defines the vertex data kind to use
  28547. * @returns true is data kind is present
  28548. */
  28549. isVerticesDataPresent(kind: string): boolean;
  28550. /**
  28551. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28552. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28553. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28554. * @returns a BoundingInfo
  28555. */
  28556. getBoundingInfo(): BoundingInfo;
  28557. /**
  28558. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28559. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28560. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28561. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28562. * @returns the current mesh
  28563. */
  28564. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28565. /**
  28566. * Overwrite the current bounding info
  28567. * @param boundingInfo defines the new bounding info
  28568. * @returns the current mesh
  28569. */
  28570. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28571. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28572. get useBones(): boolean;
  28573. /** @hidden */
  28574. _preActivate(): void;
  28575. /** @hidden */
  28576. _preActivateForIntermediateRendering(renderId: number): void;
  28577. /** @hidden */
  28578. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28579. /** @hidden */
  28580. _postActivate(): void;
  28581. /** @hidden */
  28582. _freeze(): void;
  28583. /** @hidden */
  28584. _unFreeze(): void;
  28585. /**
  28586. * Gets the current world matrix
  28587. * @returns a Matrix
  28588. */
  28589. getWorldMatrix(): Matrix;
  28590. /** @hidden */
  28591. _getWorldMatrixDeterminant(): number;
  28592. /**
  28593. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28594. */
  28595. get isAnInstance(): boolean;
  28596. /**
  28597. * Gets a boolean indicating if this mesh has instances
  28598. */
  28599. get hasInstances(): boolean;
  28600. /**
  28601. * Perform relative position change from the point of view of behind the front of the mesh.
  28602. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28603. * Supports definition of mesh facing forward or backward
  28604. * @param amountRight defines the distance on the right axis
  28605. * @param amountUp defines the distance on the up axis
  28606. * @param amountForward defines the distance on the forward axis
  28607. * @returns the current mesh
  28608. */
  28609. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28610. /**
  28611. * Calculate relative position change from the point of view of behind the front of the mesh.
  28612. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28613. * Supports definition of mesh facing forward or backward
  28614. * @param amountRight defines the distance on the right axis
  28615. * @param amountUp defines the distance on the up axis
  28616. * @param amountForward defines the distance on the forward axis
  28617. * @returns the new displacement vector
  28618. */
  28619. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28620. /**
  28621. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28622. * Supports definition of mesh facing forward or backward
  28623. * @param flipBack defines the flip
  28624. * @param twirlClockwise defines the twirl
  28625. * @param tiltRight defines the tilt
  28626. * @returns the current mesh
  28627. */
  28628. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28629. /**
  28630. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28631. * Supports definition of mesh facing forward or backward.
  28632. * @param flipBack defines the flip
  28633. * @param twirlClockwise defines the twirl
  28634. * @param tiltRight defines the tilt
  28635. * @returns the new rotation vector
  28636. */
  28637. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28638. /**
  28639. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28640. * This means the mesh underlying bounding box and sphere are recomputed.
  28641. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28642. * @returns the current mesh
  28643. */
  28644. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28645. /** @hidden */
  28646. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28647. /** @hidden */
  28648. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28649. /** @hidden */
  28650. _updateBoundingInfo(): AbstractMesh;
  28651. /** @hidden */
  28652. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28653. /** @hidden */
  28654. protected _afterComputeWorldMatrix(): void;
  28655. /** @hidden */
  28656. get _effectiveMesh(): AbstractMesh;
  28657. /**
  28658. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28659. * A mesh is in the frustum if its bounding box intersects the frustum
  28660. * @param frustumPlanes defines the frustum to test
  28661. * @returns true if the mesh is in the frustum planes
  28662. */
  28663. isInFrustum(frustumPlanes: Plane[]): boolean;
  28664. /**
  28665. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28666. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28667. * @param frustumPlanes defines the frustum to test
  28668. * @returns true if the mesh is completely in the frustum planes
  28669. */
  28670. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28671. /**
  28672. * True if the mesh intersects another mesh or a SolidParticle object
  28673. * @param mesh defines a target mesh or SolidParticle to test
  28674. * @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)
  28675. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28676. * @returns true if there is an intersection
  28677. */
  28678. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28679. /**
  28680. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28681. * @param point defines the point to test
  28682. * @returns true if there is an intersection
  28683. */
  28684. intersectsPoint(point: Vector3): boolean;
  28685. /**
  28686. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28687. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28688. */
  28689. get checkCollisions(): boolean;
  28690. set checkCollisions(collisionEnabled: boolean);
  28691. /**
  28692. * Gets Collider object used to compute collisions (not physics)
  28693. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28694. */
  28695. get collider(): Nullable<Collider>;
  28696. /**
  28697. * Move the mesh using collision engine
  28698. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28699. * @param displacement defines the requested displacement vector
  28700. * @returns the current mesh
  28701. */
  28702. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28703. private _onCollisionPositionChange;
  28704. /** @hidden */
  28705. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28706. /** @hidden */
  28707. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28708. /** @hidden */
  28709. _checkCollision(collider: Collider): AbstractMesh;
  28710. /** @hidden */
  28711. _generatePointsArray(): boolean;
  28712. /**
  28713. * Checks if the passed Ray intersects with the mesh
  28714. * @param ray defines the ray to use
  28715. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28716. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28717. * @returns the picking info
  28718. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28719. */
  28720. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28721. /**
  28722. * Clones the current mesh
  28723. * @param name defines the mesh name
  28724. * @param newParent defines the new mesh parent
  28725. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28726. * @returns the new mesh
  28727. */
  28728. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28729. /**
  28730. * Disposes all the submeshes of the current meshnp
  28731. * @returns the current mesh
  28732. */
  28733. releaseSubMeshes(): AbstractMesh;
  28734. /**
  28735. * Releases resources associated with this abstract mesh.
  28736. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28737. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28738. */
  28739. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28740. /**
  28741. * Adds the passed mesh as a child to the current mesh
  28742. * @param mesh defines the child mesh
  28743. * @returns the current mesh
  28744. */
  28745. addChild(mesh: AbstractMesh): AbstractMesh;
  28746. /**
  28747. * Removes the passed mesh from the current mesh children list
  28748. * @param mesh defines the child mesh
  28749. * @returns the current mesh
  28750. */
  28751. removeChild(mesh: AbstractMesh): AbstractMesh;
  28752. /** @hidden */
  28753. private _initFacetData;
  28754. /**
  28755. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28756. * This method can be called within the render loop.
  28757. * 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
  28758. * @returns the current mesh
  28759. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28760. */
  28761. updateFacetData(): AbstractMesh;
  28762. /**
  28763. * Returns the facetLocalNormals array.
  28764. * The normals are expressed in the mesh local spac
  28765. * @returns an array of Vector3
  28766. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28767. */
  28768. getFacetLocalNormals(): Vector3[];
  28769. /**
  28770. * Returns the facetLocalPositions array.
  28771. * The facet positions are expressed in the mesh local space
  28772. * @returns an array of Vector3
  28773. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28774. */
  28775. getFacetLocalPositions(): Vector3[];
  28776. /**
  28777. * Returns the facetLocalPartioning array
  28778. * @returns an array of array of numbers
  28779. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28780. */
  28781. getFacetLocalPartitioning(): number[][];
  28782. /**
  28783. * Returns the i-th facet position in the world system.
  28784. * This method allocates a new Vector3 per call
  28785. * @param i defines the facet index
  28786. * @returns a new Vector3
  28787. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28788. */
  28789. getFacetPosition(i: number): Vector3;
  28790. /**
  28791. * Sets the reference Vector3 with the i-th facet position in the world system
  28792. * @param i defines the facet index
  28793. * @param ref defines the target vector
  28794. * @returns the current mesh
  28795. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28796. */
  28797. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28798. /**
  28799. * Returns the i-th facet normal in the world system.
  28800. * This method allocates a new Vector3 per call
  28801. * @param i defines the facet index
  28802. * @returns a new Vector3
  28803. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28804. */
  28805. getFacetNormal(i: number): Vector3;
  28806. /**
  28807. * Sets the reference Vector3 with the i-th facet normal in the world system
  28808. * @param i defines the facet index
  28809. * @param ref defines the target vector
  28810. * @returns the current mesh
  28811. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28812. */
  28813. getFacetNormalToRef(i: number, ref: Vector3): this;
  28814. /**
  28815. * 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)
  28816. * @param x defines x coordinate
  28817. * @param y defines y coordinate
  28818. * @param z defines z coordinate
  28819. * @returns the array of facet indexes
  28820. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28821. */
  28822. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28823. /**
  28824. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28825. * @param projected sets as the (x,y,z) world projection on the facet
  28826. * @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
  28827. * @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
  28828. * @param x defines x coordinate
  28829. * @param y defines y coordinate
  28830. * @param z defines z coordinate
  28831. * @returns the face index if found (or null instead)
  28832. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28833. */
  28834. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28835. /**
  28836. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28837. * @param projected sets as the (x,y,z) local projection on the facet
  28838. * @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
  28839. * @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
  28840. * @param x defines x coordinate
  28841. * @param y defines y coordinate
  28842. * @param z defines z coordinate
  28843. * @returns the face index if found (or null instead)
  28844. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28845. */
  28846. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28847. /**
  28848. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28849. * @returns the parameters
  28850. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28851. */
  28852. getFacetDataParameters(): any;
  28853. /**
  28854. * Disables the feature FacetData and frees the related memory
  28855. * @returns the current mesh
  28856. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28857. */
  28858. disableFacetData(): AbstractMesh;
  28859. /**
  28860. * Updates the AbstractMesh indices array
  28861. * @param indices defines the data source
  28862. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28863. * @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)
  28864. * @returns the current mesh
  28865. */
  28866. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28867. /**
  28868. * Creates new normals data for the mesh
  28869. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28870. * @returns the current mesh
  28871. */
  28872. createNormals(updatable: boolean): AbstractMesh;
  28873. /**
  28874. * Align the mesh with a normal
  28875. * @param normal defines the normal to use
  28876. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28877. * @returns the current mesh
  28878. */
  28879. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28880. /** @hidden */
  28881. _checkOcclusionQuery(): boolean;
  28882. /**
  28883. * Disables the mesh edge rendering mode
  28884. * @returns the currentAbstractMesh
  28885. */
  28886. disableEdgesRendering(): AbstractMesh;
  28887. /**
  28888. * Enables the edge rendering mode on the mesh.
  28889. * This mode makes the mesh edges visible
  28890. * @param epsilon defines the maximal distance between two angles to detect a face
  28891. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28892. * @returns the currentAbstractMesh
  28893. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28894. */
  28895. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28896. }
  28897. }
  28898. declare module BABYLON {
  28899. /**
  28900. * Interface used to define ActionEvent
  28901. */
  28902. export interface IActionEvent {
  28903. /** The mesh or sprite that triggered the action */
  28904. source: any;
  28905. /** The X mouse cursor position at the time of the event */
  28906. pointerX: number;
  28907. /** The Y mouse cursor position at the time of the event */
  28908. pointerY: number;
  28909. /** The mesh that is currently pointed at (can be null) */
  28910. meshUnderPointer: Nullable<AbstractMesh>;
  28911. /** the original (browser) event that triggered the ActionEvent */
  28912. sourceEvent?: any;
  28913. /** additional data for the event */
  28914. additionalData?: any;
  28915. }
  28916. /**
  28917. * ActionEvent is the event being sent when an action is triggered.
  28918. */
  28919. export class ActionEvent implements IActionEvent {
  28920. /** The mesh or sprite that triggered the action */
  28921. source: any;
  28922. /** The X mouse cursor position at the time of the event */
  28923. pointerX: number;
  28924. /** The Y mouse cursor position at the time of the event */
  28925. pointerY: number;
  28926. /** The mesh that is currently pointed at (can be null) */
  28927. meshUnderPointer: Nullable<AbstractMesh>;
  28928. /** the original (browser) event that triggered the ActionEvent */
  28929. sourceEvent?: any;
  28930. /** additional data for the event */
  28931. additionalData?: any;
  28932. /**
  28933. * Creates a new ActionEvent
  28934. * @param source The mesh or sprite that triggered the action
  28935. * @param pointerX The X mouse cursor position at the time of the event
  28936. * @param pointerY The Y mouse cursor position at the time of the event
  28937. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28938. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28939. * @param additionalData additional data for the event
  28940. */
  28941. constructor(
  28942. /** The mesh or sprite that triggered the action */
  28943. source: any,
  28944. /** The X mouse cursor position at the time of the event */
  28945. pointerX: number,
  28946. /** The Y mouse cursor position at the time of the event */
  28947. pointerY: number,
  28948. /** The mesh that is currently pointed at (can be null) */
  28949. meshUnderPointer: Nullable<AbstractMesh>,
  28950. /** the original (browser) event that triggered the ActionEvent */
  28951. sourceEvent?: any,
  28952. /** additional data for the event */
  28953. additionalData?: any);
  28954. /**
  28955. * Helper function to auto-create an ActionEvent from a source mesh.
  28956. * @param source The source mesh that triggered the event
  28957. * @param evt The original (browser) event
  28958. * @param additionalData additional data for the event
  28959. * @returns the new ActionEvent
  28960. */
  28961. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28962. /**
  28963. * Helper function to auto-create an ActionEvent from a source sprite
  28964. * @param source The source sprite that triggered the event
  28965. * @param scene Scene associated with the sprite
  28966. * @param evt The original (browser) event
  28967. * @param additionalData additional data for the event
  28968. * @returns the new ActionEvent
  28969. */
  28970. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28971. /**
  28972. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28973. * @param scene the scene where the event occurred
  28974. * @param evt The original (browser) event
  28975. * @returns the new ActionEvent
  28976. */
  28977. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28978. /**
  28979. * Helper function to auto-create an ActionEvent from a primitive
  28980. * @param prim defines the target primitive
  28981. * @param pointerPos defines the pointer position
  28982. * @param evt The original (browser) event
  28983. * @param additionalData additional data for the event
  28984. * @returns the new ActionEvent
  28985. */
  28986. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28987. }
  28988. }
  28989. declare module BABYLON {
  28990. /**
  28991. * Abstract class used to decouple action Manager from scene and meshes.
  28992. * Do not instantiate.
  28993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28994. */
  28995. export abstract class AbstractActionManager implements IDisposable {
  28996. /** Gets the list of active triggers */
  28997. static Triggers: {
  28998. [key: string]: number;
  28999. };
  29000. /** Gets the cursor to use when hovering items */
  29001. hoverCursor: string;
  29002. /** Gets the list of actions */
  29003. actions: IAction[];
  29004. /**
  29005. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29006. */
  29007. isRecursive: boolean;
  29008. /**
  29009. * Releases all associated resources
  29010. */
  29011. abstract dispose(): void;
  29012. /**
  29013. * Does this action manager has pointer triggers
  29014. */
  29015. abstract get hasPointerTriggers(): boolean;
  29016. /**
  29017. * Does this action manager has pick triggers
  29018. */
  29019. abstract get hasPickTriggers(): boolean;
  29020. /**
  29021. * Process a specific trigger
  29022. * @param trigger defines the trigger to process
  29023. * @param evt defines the event details to be processed
  29024. */
  29025. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29026. /**
  29027. * Does this action manager handles actions of any of the given triggers
  29028. * @param triggers defines the triggers to be tested
  29029. * @return a boolean indicating whether one (or more) of the triggers is handled
  29030. */
  29031. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29032. /**
  29033. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29034. * speed.
  29035. * @param triggerA defines the trigger to be tested
  29036. * @param triggerB defines the trigger to be tested
  29037. * @return a boolean indicating whether one (or more) of the triggers is handled
  29038. */
  29039. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29040. /**
  29041. * Does this action manager handles actions of a given trigger
  29042. * @param trigger defines the trigger to be tested
  29043. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29044. * @return whether the trigger is handled
  29045. */
  29046. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29047. /**
  29048. * Serialize this manager to a JSON object
  29049. * @param name defines the property name to store this manager
  29050. * @returns a JSON representation of this manager
  29051. */
  29052. abstract serialize(name: string): any;
  29053. /**
  29054. * Registers an action to this action manager
  29055. * @param action defines the action to be registered
  29056. * @return the action amended (prepared) after registration
  29057. */
  29058. abstract registerAction(action: IAction): Nullable<IAction>;
  29059. /**
  29060. * Unregisters an action to this action manager
  29061. * @param action defines the action to be unregistered
  29062. * @return a boolean indicating whether the action has been unregistered
  29063. */
  29064. abstract unregisterAction(action: IAction): Boolean;
  29065. /**
  29066. * Does exist one action manager with at least one trigger
  29067. **/
  29068. static get HasTriggers(): boolean;
  29069. /**
  29070. * Does exist one action manager with at least one pick trigger
  29071. **/
  29072. static get HasPickTriggers(): boolean;
  29073. /**
  29074. * Does exist one action manager that handles actions of a given trigger
  29075. * @param trigger defines the trigger to be tested
  29076. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29077. **/
  29078. static HasSpecificTrigger(trigger: number): boolean;
  29079. }
  29080. }
  29081. declare module BABYLON {
  29082. /**
  29083. * Defines how a node can be built from a string name.
  29084. */
  29085. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29086. /**
  29087. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29088. */
  29089. export class Node implements IBehaviorAware<Node> {
  29090. /** @hidden */
  29091. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  29092. private static _NodeConstructors;
  29093. /**
  29094. * Add a new node constructor
  29095. * @param type defines the type name of the node to construct
  29096. * @param constructorFunc defines the constructor function
  29097. */
  29098. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29099. /**
  29100. * Returns a node constructor based on type name
  29101. * @param type defines the type name
  29102. * @param name defines the new node name
  29103. * @param scene defines the hosting scene
  29104. * @param options defines optional options to transmit to constructors
  29105. * @returns the new constructor or null
  29106. */
  29107. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29108. /**
  29109. * Gets or sets the name of the node
  29110. */
  29111. name: string;
  29112. /**
  29113. * Gets or sets the id of the node
  29114. */
  29115. id: string;
  29116. /**
  29117. * Gets or sets the unique id of the node
  29118. */
  29119. uniqueId: number;
  29120. /**
  29121. * Gets or sets a string used to store user defined state for the node
  29122. */
  29123. state: string;
  29124. /**
  29125. * Gets or sets an object used to store user defined information for the node
  29126. */
  29127. metadata: any;
  29128. /**
  29129. * For internal use only. Please do not use.
  29130. */
  29131. reservedDataStore: any;
  29132. /**
  29133. * List of inspectable custom properties (used by the Inspector)
  29134. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29135. */
  29136. inspectableCustomProperties: IInspectable[];
  29137. private _doNotSerialize;
  29138. /**
  29139. * Gets or sets a boolean used to define if the node must be serialized
  29140. */
  29141. get doNotSerialize(): boolean;
  29142. set doNotSerialize(value: boolean);
  29143. /** @hidden */
  29144. _isDisposed: boolean;
  29145. /**
  29146. * Gets a list of Animations associated with the node
  29147. */
  29148. animations: Animation[];
  29149. protected _ranges: {
  29150. [name: string]: Nullable<AnimationRange>;
  29151. };
  29152. /**
  29153. * Callback raised when the node is ready to be used
  29154. */
  29155. onReady: Nullable<(node: Node) => void>;
  29156. private _isEnabled;
  29157. private _isParentEnabled;
  29158. private _isReady;
  29159. /** @hidden */
  29160. _currentRenderId: number;
  29161. private _parentUpdateId;
  29162. /** @hidden */
  29163. _childUpdateId: number;
  29164. /** @hidden */
  29165. _waitingParentId: Nullable<string>;
  29166. /** @hidden */
  29167. _scene: Scene;
  29168. /** @hidden */
  29169. _cache: any;
  29170. private _parentNode;
  29171. private _children;
  29172. /** @hidden */
  29173. _worldMatrix: Matrix;
  29174. /** @hidden */
  29175. _worldMatrixDeterminant: number;
  29176. /** @hidden */
  29177. _worldMatrixDeterminantIsDirty: boolean;
  29178. /** @hidden */
  29179. private _sceneRootNodesIndex;
  29180. /**
  29181. * Gets a boolean indicating if the node has been disposed
  29182. * @returns true if the node was disposed
  29183. */
  29184. isDisposed(): boolean;
  29185. /**
  29186. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29187. * @see https://doc.babylonjs.com/how_to/parenting
  29188. */
  29189. set parent(parent: Nullable<Node>);
  29190. get parent(): Nullable<Node>;
  29191. /** @hidden */
  29192. _addToSceneRootNodes(): void;
  29193. /** @hidden */
  29194. _removeFromSceneRootNodes(): void;
  29195. private _animationPropertiesOverride;
  29196. /**
  29197. * Gets or sets the animation properties override
  29198. */
  29199. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29200. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29201. /**
  29202. * Gets a string idenfifying the name of the class
  29203. * @returns "Node" string
  29204. */
  29205. getClassName(): string;
  29206. /** @hidden */
  29207. readonly _isNode: boolean;
  29208. /**
  29209. * An event triggered when the mesh is disposed
  29210. */
  29211. onDisposeObservable: Observable<Node>;
  29212. private _onDisposeObserver;
  29213. /**
  29214. * Sets a callback that will be raised when the node will be disposed
  29215. */
  29216. set onDispose(callback: () => void);
  29217. /**
  29218. * Creates a new Node
  29219. * @param name the name and id to be given to this node
  29220. * @param scene the scene this node will be added to
  29221. */
  29222. constructor(name: string, scene?: Nullable<Scene>);
  29223. /**
  29224. * Gets the scene of the node
  29225. * @returns a scene
  29226. */
  29227. getScene(): Scene;
  29228. /**
  29229. * Gets the engine of the node
  29230. * @returns a Engine
  29231. */
  29232. getEngine(): Engine;
  29233. private _behaviors;
  29234. /**
  29235. * Attach a behavior to the node
  29236. * @see http://doc.babylonjs.com/features/behaviour
  29237. * @param behavior defines the behavior to attach
  29238. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29239. * @returns the current Node
  29240. */
  29241. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29242. /**
  29243. * Remove an attached behavior
  29244. * @see http://doc.babylonjs.com/features/behaviour
  29245. * @param behavior defines the behavior to attach
  29246. * @returns the current Node
  29247. */
  29248. removeBehavior(behavior: Behavior<Node>): Node;
  29249. /**
  29250. * Gets the list of attached behaviors
  29251. * @see http://doc.babylonjs.com/features/behaviour
  29252. */
  29253. get behaviors(): Behavior<Node>[];
  29254. /**
  29255. * Gets an attached behavior by name
  29256. * @param name defines the name of the behavior to look for
  29257. * @see http://doc.babylonjs.com/features/behaviour
  29258. * @returns null if behavior was not found else the requested behavior
  29259. */
  29260. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29261. /**
  29262. * Returns the latest update of the World matrix
  29263. * @returns a Matrix
  29264. */
  29265. getWorldMatrix(): Matrix;
  29266. /** @hidden */
  29267. _getWorldMatrixDeterminant(): number;
  29268. /**
  29269. * Returns directly the latest state of the mesh World matrix.
  29270. * A Matrix is returned.
  29271. */
  29272. get worldMatrixFromCache(): Matrix;
  29273. /** @hidden */
  29274. _initCache(): void;
  29275. /** @hidden */
  29276. updateCache(force?: boolean): void;
  29277. /** @hidden */
  29278. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29279. /** @hidden */
  29280. _updateCache(ignoreParentClass?: boolean): void;
  29281. /** @hidden */
  29282. _isSynchronized(): boolean;
  29283. /** @hidden */
  29284. _markSyncedWithParent(): void;
  29285. /** @hidden */
  29286. isSynchronizedWithParent(): boolean;
  29287. /** @hidden */
  29288. isSynchronized(): boolean;
  29289. /**
  29290. * Is this node ready to be used/rendered
  29291. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29292. * @return true if the node is ready
  29293. */
  29294. isReady(completeCheck?: boolean): boolean;
  29295. /**
  29296. * Is this node enabled?
  29297. * 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
  29298. * @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
  29299. * @return whether this node (and its parent) is enabled
  29300. */
  29301. isEnabled(checkAncestors?: boolean): boolean;
  29302. /** @hidden */
  29303. protected _syncParentEnabledState(): void;
  29304. /**
  29305. * Set the enabled state of this node
  29306. * @param value defines the new enabled state
  29307. */
  29308. setEnabled(value: boolean): void;
  29309. /**
  29310. * Is this node a descendant of the given node?
  29311. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29312. * @param ancestor defines the parent node to inspect
  29313. * @returns a boolean indicating if this node is a descendant of the given node
  29314. */
  29315. isDescendantOf(ancestor: Node): boolean;
  29316. /** @hidden */
  29317. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29318. /**
  29319. * Will return all nodes that have this node as ascendant
  29320. * @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
  29321. * @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
  29322. * @return all children nodes of all types
  29323. */
  29324. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29325. /**
  29326. * Get all child-meshes of this node
  29327. * @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)
  29328. * @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
  29329. * @returns an array of AbstractMesh
  29330. */
  29331. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29332. /**
  29333. * Get all direct children of this node
  29334. * @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
  29335. * @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)
  29336. * @returns an array of Node
  29337. */
  29338. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29339. /** @hidden */
  29340. _setReady(state: boolean): void;
  29341. /**
  29342. * Get an animation by name
  29343. * @param name defines the name of the animation to look for
  29344. * @returns null if not found else the requested animation
  29345. */
  29346. getAnimationByName(name: string): Nullable<Animation>;
  29347. /**
  29348. * Creates an animation range for this node
  29349. * @param name defines the name of the range
  29350. * @param from defines the starting key
  29351. * @param to defines the end key
  29352. */
  29353. createAnimationRange(name: string, from: number, to: number): void;
  29354. /**
  29355. * Delete a specific animation range
  29356. * @param name defines the name of the range to delete
  29357. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29358. */
  29359. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29360. /**
  29361. * Get an animation range by name
  29362. * @param name defines the name of the animation range to look for
  29363. * @returns null if not found else the requested animation range
  29364. */
  29365. getAnimationRange(name: string): Nullable<AnimationRange>;
  29366. /**
  29367. * Gets the list of all animation ranges defined on this node
  29368. * @returns an array
  29369. */
  29370. getAnimationRanges(): Nullable<AnimationRange>[];
  29371. /**
  29372. * Will start the animation sequence
  29373. * @param name defines the range frames for animation sequence
  29374. * @param loop defines if the animation should loop (false by default)
  29375. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29376. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29377. * @returns the object created for this animation. If range does not exist, it will return null
  29378. */
  29379. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29380. /**
  29381. * Serialize animation ranges into a JSON compatible object
  29382. * @returns serialization object
  29383. */
  29384. serializeAnimationRanges(): any;
  29385. /**
  29386. * Computes the world matrix of the node
  29387. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29388. * @returns the world matrix
  29389. */
  29390. computeWorldMatrix(force?: boolean): Matrix;
  29391. /**
  29392. * Releases resources associated with this node.
  29393. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29394. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29395. */
  29396. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29397. /**
  29398. * Parse animation range data from a serialization object and store them into a given node
  29399. * @param node defines where to store the animation ranges
  29400. * @param parsedNode defines the serialization object to read data from
  29401. * @param scene defines the hosting scene
  29402. */
  29403. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29404. /**
  29405. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29406. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29407. * @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
  29408. * @returns the new bounding vectors
  29409. */
  29410. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29411. min: Vector3;
  29412. max: Vector3;
  29413. };
  29414. }
  29415. }
  29416. declare module BABYLON {
  29417. /**
  29418. * @hidden
  29419. */
  29420. export class _IAnimationState {
  29421. key: number;
  29422. repeatCount: number;
  29423. workValue?: any;
  29424. loopMode?: number;
  29425. offsetValue?: any;
  29426. highLimitValue?: any;
  29427. }
  29428. /**
  29429. * Class used to store any kind of animation
  29430. */
  29431. export class Animation {
  29432. /**Name of the animation */
  29433. name: string;
  29434. /**Property to animate */
  29435. targetProperty: string;
  29436. /**The frames per second of the animation */
  29437. framePerSecond: number;
  29438. /**The data type of the animation */
  29439. dataType: number;
  29440. /**The loop mode of the animation */
  29441. loopMode?: number | undefined;
  29442. /**Specifies if blending should be enabled */
  29443. enableBlending?: boolean | undefined;
  29444. /**
  29445. * Use matrix interpolation instead of using direct key value when animating matrices
  29446. */
  29447. static AllowMatricesInterpolation: boolean;
  29448. /**
  29449. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29450. */
  29451. static AllowMatrixDecomposeForInterpolation: boolean;
  29452. /**
  29453. * Stores the key frames of the animation
  29454. */
  29455. private _keys;
  29456. /**
  29457. * Stores the easing function of the animation
  29458. */
  29459. private _easingFunction;
  29460. /**
  29461. * @hidden Internal use only
  29462. */
  29463. _runtimeAnimations: RuntimeAnimation[];
  29464. /**
  29465. * The set of event that will be linked to this animation
  29466. */
  29467. private _events;
  29468. /**
  29469. * Stores an array of target property paths
  29470. */
  29471. targetPropertyPath: string[];
  29472. /**
  29473. * Stores the blending speed of the animation
  29474. */
  29475. blendingSpeed: number;
  29476. /**
  29477. * Stores the animation ranges for the animation
  29478. */
  29479. private _ranges;
  29480. /**
  29481. * @hidden Internal use
  29482. */
  29483. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29484. /**
  29485. * Sets up an animation
  29486. * @param property The property to animate
  29487. * @param animationType The animation type to apply
  29488. * @param framePerSecond The frames per second of the animation
  29489. * @param easingFunction The easing function used in the animation
  29490. * @returns The created animation
  29491. */
  29492. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29493. /**
  29494. * Create and start an animation on a node
  29495. * @param name defines the name of the global animation that will be run on all nodes
  29496. * @param node defines the root node where the animation will take place
  29497. * @param targetProperty defines property to animate
  29498. * @param framePerSecond defines the number of frame per second yo use
  29499. * @param totalFrame defines the number of frames in total
  29500. * @param from defines the initial value
  29501. * @param to defines the final value
  29502. * @param loopMode defines which loop mode you want to use (off by default)
  29503. * @param easingFunction defines the easing function to use (linear by default)
  29504. * @param onAnimationEnd defines the callback to call when animation end
  29505. * @returns the animatable created for this animation
  29506. */
  29507. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29508. /**
  29509. * Create and start an animation on a node and its descendants
  29510. * @param name defines the name of the global animation that will be run on all nodes
  29511. * @param node defines the root node where the animation will take place
  29512. * @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
  29513. * @param targetProperty defines property to animate
  29514. * @param framePerSecond defines the number of frame per second to use
  29515. * @param totalFrame defines the number of frames in total
  29516. * @param from defines the initial value
  29517. * @param to defines the final value
  29518. * @param loopMode defines which loop mode you want to use (off by default)
  29519. * @param easingFunction defines the easing function to use (linear by default)
  29520. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29521. * @returns the list of animatables created for all nodes
  29522. * @example https://www.babylonjs-playground.com/#MH0VLI
  29523. */
  29524. 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[]>;
  29525. /**
  29526. * Creates a new animation, merges it with the existing animations and starts it
  29527. * @param name Name of the animation
  29528. * @param node Node which contains the scene that begins the animations
  29529. * @param targetProperty Specifies which property to animate
  29530. * @param framePerSecond The frames per second of the animation
  29531. * @param totalFrame The total number of frames
  29532. * @param from The frame at the beginning of the animation
  29533. * @param to The frame at the end of the animation
  29534. * @param loopMode Specifies the loop mode of the animation
  29535. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29536. * @param onAnimationEnd Callback to run once the animation is complete
  29537. * @returns Nullable animation
  29538. */
  29539. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29540. /**
  29541. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  29542. * @param sourceAnimation defines the Animation containing keyframes to convert
  29543. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  29544. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  29545. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  29546. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  29547. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  29548. */
  29549. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  29550. /**
  29551. * Transition property of an host to the target Value
  29552. * @param property The property to transition
  29553. * @param targetValue The target Value of the property
  29554. * @param host The object where the property to animate belongs
  29555. * @param scene Scene used to run the animation
  29556. * @param frameRate Framerate (in frame/s) to use
  29557. * @param transition The transition type we want to use
  29558. * @param duration The duration of the animation, in milliseconds
  29559. * @param onAnimationEnd Callback trigger at the end of the animation
  29560. * @returns Nullable animation
  29561. */
  29562. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29563. /**
  29564. * Return the array of runtime animations currently using this animation
  29565. */
  29566. get runtimeAnimations(): RuntimeAnimation[];
  29567. /**
  29568. * Specifies if any of the runtime animations are currently running
  29569. */
  29570. get hasRunningRuntimeAnimations(): boolean;
  29571. /**
  29572. * Initializes the animation
  29573. * @param name Name of the animation
  29574. * @param targetProperty Property to animate
  29575. * @param framePerSecond The frames per second of the animation
  29576. * @param dataType The data type of the animation
  29577. * @param loopMode The loop mode of the animation
  29578. * @param enableBlending Specifies if blending should be enabled
  29579. */
  29580. constructor(
  29581. /**Name of the animation */
  29582. name: string,
  29583. /**Property to animate */
  29584. targetProperty: string,
  29585. /**The frames per second of the animation */
  29586. framePerSecond: number,
  29587. /**The data type of the animation */
  29588. dataType: number,
  29589. /**The loop mode of the animation */
  29590. loopMode?: number | undefined,
  29591. /**Specifies if blending should be enabled */
  29592. enableBlending?: boolean | undefined);
  29593. /**
  29594. * Converts the animation to a string
  29595. * @param fullDetails support for multiple levels of logging within scene loading
  29596. * @returns String form of the animation
  29597. */
  29598. toString(fullDetails?: boolean): string;
  29599. /**
  29600. * Add an event to this animation
  29601. * @param event Event to add
  29602. */
  29603. addEvent(event: AnimationEvent): void;
  29604. /**
  29605. * Remove all events found at the given frame
  29606. * @param frame The frame to remove events from
  29607. */
  29608. removeEvents(frame: number): void;
  29609. /**
  29610. * Retrieves all the events from the animation
  29611. * @returns Events from the animation
  29612. */
  29613. getEvents(): AnimationEvent[];
  29614. /**
  29615. * Creates an animation range
  29616. * @param name Name of the animation range
  29617. * @param from Starting frame of the animation range
  29618. * @param to Ending frame of the animation
  29619. */
  29620. createRange(name: string, from: number, to: number): void;
  29621. /**
  29622. * Deletes an animation range by name
  29623. * @param name Name of the animation range to delete
  29624. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29625. */
  29626. deleteRange(name: string, deleteFrames?: boolean): void;
  29627. /**
  29628. * Gets the animation range by name, or null if not defined
  29629. * @param name Name of the animation range
  29630. * @returns Nullable animation range
  29631. */
  29632. getRange(name: string): Nullable<AnimationRange>;
  29633. /**
  29634. * Gets the key frames from the animation
  29635. * @returns The key frames of the animation
  29636. */
  29637. getKeys(): Array<IAnimationKey>;
  29638. /**
  29639. * Gets the highest frame rate of the animation
  29640. * @returns Highest frame rate of the animation
  29641. */
  29642. getHighestFrame(): number;
  29643. /**
  29644. * Gets the easing function of the animation
  29645. * @returns Easing function of the animation
  29646. */
  29647. getEasingFunction(): IEasingFunction;
  29648. /**
  29649. * Sets the easing function of the animation
  29650. * @param easingFunction A custom mathematical formula for animation
  29651. */
  29652. setEasingFunction(easingFunction: EasingFunction): void;
  29653. /**
  29654. * Interpolates a scalar linearly
  29655. * @param startValue Start value of the animation curve
  29656. * @param endValue End value of the animation curve
  29657. * @param gradient Scalar amount to interpolate
  29658. * @returns Interpolated scalar value
  29659. */
  29660. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29661. /**
  29662. * Interpolates a scalar cubically
  29663. * @param startValue Start value of the animation curve
  29664. * @param outTangent End tangent of the animation
  29665. * @param endValue End value of the animation curve
  29666. * @param inTangent Start tangent of the animation curve
  29667. * @param gradient Scalar amount to interpolate
  29668. * @returns Interpolated scalar value
  29669. */
  29670. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29671. /**
  29672. * Interpolates a quaternion using a spherical linear interpolation
  29673. * @param startValue Start value of the animation curve
  29674. * @param endValue End value of the animation curve
  29675. * @param gradient Scalar amount to interpolate
  29676. * @returns Interpolated quaternion value
  29677. */
  29678. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29679. /**
  29680. * Interpolates a quaternion cubically
  29681. * @param startValue Start value of the animation curve
  29682. * @param outTangent End tangent of the animation curve
  29683. * @param endValue End value of the animation curve
  29684. * @param inTangent Start tangent of the animation curve
  29685. * @param gradient Scalar amount to interpolate
  29686. * @returns Interpolated quaternion value
  29687. */
  29688. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29689. /**
  29690. * Interpolates a Vector3 linearl
  29691. * @param startValue Start value of the animation curve
  29692. * @param endValue End value of the animation curve
  29693. * @param gradient Scalar amount to interpolate
  29694. * @returns Interpolated scalar value
  29695. */
  29696. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29697. /**
  29698. * Interpolates a Vector3 cubically
  29699. * @param startValue Start value of the animation curve
  29700. * @param outTangent End tangent of the animation
  29701. * @param endValue End value of the animation curve
  29702. * @param inTangent Start tangent of the animation curve
  29703. * @param gradient Scalar amount to interpolate
  29704. * @returns InterpolatedVector3 value
  29705. */
  29706. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29707. /**
  29708. * Interpolates a Vector2 linearly
  29709. * @param startValue Start value of the animation curve
  29710. * @param endValue End value of the animation curve
  29711. * @param gradient Scalar amount to interpolate
  29712. * @returns Interpolated Vector2 value
  29713. */
  29714. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29715. /**
  29716. * Interpolates a Vector2 cubically
  29717. * @param startValue Start value of the animation curve
  29718. * @param outTangent End tangent of the animation
  29719. * @param endValue End value of the animation curve
  29720. * @param inTangent Start tangent of the animation curve
  29721. * @param gradient Scalar amount to interpolate
  29722. * @returns Interpolated Vector2 value
  29723. */
  29724. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29725. /**
  29726. * Interpolates a size linearly
  29727. * @param startValue Start value of the animation curve
  29728. * @param endValue End value of the animation curve
  29729. * @param gradient Scalar amount to interpolate
  29730. * @returns Interpolated Size value
  29731. */
  29732. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29733. /**
  29734. * Interpolates a Color3 linearly
  29735. * @param startValue Start value of the animation curve
  29736. * @param endValue End value of the animation curve
  29737. * @param gradient Scalar amount to interpolate
  29738. * @returns Interpolated Color3 value
  29739. */
  29740. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29741. /**
  29742. * Interpolates a Color4 linearly
  29743. * @param startValue Start value of the animation curve
  29744. * @param endValue End value of the animation curve
  29745. * @param gradient Scalar amount to interpolate
  29746. * @returns Interpolated Color3 value
  29747. */
  29748. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29749. /**
  29750. * @hidden Internal use only
  29751. */
  29752. _getKeyValue(value: any): any;
  29753. /**
  29754. * @hidden Internal use only
  29755. */
  29756. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29757. /**
  29758. * Defines the function to use to interpolate matrices
  29759. * @param startValue defines the start matrix
  29760. * @param endValue defines the end matrix
  29761. * @param gradient defines the gradient between both matrices
  29762. * @param result defines an optional target matrix where to store the interpolation
  29763. * @returns the interpolated matrix
  29764. */
  29765. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29766. /**
  29767. * Makes a copy of the animation
  29768. * @returns Cloned animation
  29769. */
  29770. clone(): Animation;
  29771. /**
  29772. * Sets the key frames of the animation
  29773. * @param values The animation key frames to set
  29774. */
  29775. setKeys(values: Array<IAnimationKey>): void;
  29776. /**
  29777. * Serializes the animation to an object
  29778. * @returns Serialized object
  29779. */
  29780. serialize(): any;
  29781. /**
  29782. * Float animation type
  29783. */
  29784. static readonly ANIMATIONTYPE_FLOAT: number;
  29785. /**
  29786. * Vector3 animation type
  29787. */
  29788. static readonly ANIMATIONTYPE_VECTOR3: number;
  29789. /**
  29790. * Quaternion animation type
  29791. */
  29792. static readonly ANIMATIONTYPE_QUATERNION: number;
  29793. /**
  29794. * Matrix animation type
  29795. */
  29796. static readonly ANIMATIONTYPE_MATRIX: number;
  29797. /**
  29798. * Color3 animation type
  29799. */
  29800. static readonly ANIMATIONTYPE_COLOR3: number;
  29801. /**
  29802. * Color3 animation type
  29803. */
  29804. static readonly ANIMATIONTYPE_COLOR4: number;
  29805. /**
  29806. * Vector2 animation type
  29807. */
  29808. static readonly ANIMATIONTYPE_VECTOR2: number;
  29809. /**
  29810. * Size animation type
  29811. */
  29812. static readonly ANIMATIONTYPE_SIZE: number;
  29813. /**
  29814. * Relative Loop Mode
  29815. */
  29816. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29817. /**
  29818. * Cycle Loop Mode
  29819. */
  29820. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29821. /**
  29822. * Constant Loop Mode
  29823. */
  29824. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29825. /** @hidden */
  29826. static _UniversalLerp(left: any, right: any, amount: number): any;
  29827. /**
  29828. * Parses an animation object and creates an animation
  29829. * @param parsedAnimation Parsed animation object
  29830. * @returns Animation object
  29831. */
  29832. static Parse(parsedAnimation: any): Animation;
  29833. /**
  29834. * Appends the serialized animations from the source animations
  29835. * @param source Source containing the animations
  29836. * @param destination Target to store the animations
  29837. */
  29838. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29839. }
  29840. }
  29841. declare module BABYLON {
  29842. /**
  29843. * Interface containing an array of animations
  29844. */
  29845. export interface IAnimatable {
  29846. /**
  29847. * Array of animations
  29848. */
  29849. animations: Nullable<Array<Animation>>;
  29850. }
  29851. }
  29852. declare module BABYLON {
  29853. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29854. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29855. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29856. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29857. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29858. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29859. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29860. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29861. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29862. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29863. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29864. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29865. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29866. /**
  29867. * Decorator used to define property that can be serialized as reference to a camera
  29868. * @param sourceName defines the name of the property to decorate
  29869. */
  29870. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29871. /**
  29872. * Class used to help serialization objects
  29873. */
  29874. export class SerializationHelper {
  29875. /** @hidden */
  29876. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29877. /** @hidden */
  29878. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29879. /** @hidden */
  29880. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29881. /** @hidden */
  29882. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29883. /**
  29884. * Appends the serialized animations from the source animations
  29885. * @param source Source containing the animations
  29886. * @param destination Target to store the animations
  29887. */
  29888. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29889. /**
  29890. * Static function used to serialized a specific entity
  29891. * @param entity defines the entity to serialize
  29892. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29893. * @returns a JSON compatible object representing the serialization of the entity
  29894. */
  29895. static Serialize<T>(entity: T, serializationObject?: any): any;
  29896. /**
  29897. * Creates a new entity from a serialization data object
  29898. * @param creationFunction defines a function used to instanciated the new entity
  29899. * @param source defines the source serialization data
  29900. * @param scene defines the hosting scene
  29901. * @param rootUrl defines the root url for resources
  29902. * @returns a new entity
  29903. */
  29904. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29905. /**
  29906. * Clones an object
  29907. * @param creationFunction defines the function used to instanciate the new object
  29908. * @param source defines the source object
  29909. * @returns the cloned object
  29910. */
  29911. static Clone<T>(creationFunction: () => T, source: T): T;
  29912. /**
  29913. * Instanciates a new object based on a source one (some data will be shared between both object)
  29914. * @param creationFunction defines the function used to instanciate the new object
  29915. * @param source defines the source object
  29916. * @returns the new object
  29917. */
  29918. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29919. }
  29920. }
  29921. declare module BABYLON {
  29922. /**
  29923. * Class used to manipulate GUIDs
  29924. */
  29925. export class GUID {
  29926. /**
  29927. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29928. * Be aware Math.random() could cause collisions, but:
  29929. * "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"
  29930. * @returns a pseudo random id
  29931. */
  29932. static RandomId(): string;
  29933. }
  29934. }
  29935. declare module BABYLON {
  29936. /**
  29937. * Base class of all the textures in babylon.
  29938. * It groups all the common properties the materials, post process, lights... might need
  29939. * in order to make a correct use of the texture.
  29940. */
  29941. export class BaseTexture implements IAnimatable {
  29942. /**
  29943. * Default anisotropic filtering level for the application.
  29944. * It is set to 4 as a good tradeoff between perf and quality.
  29945. */
  29946. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29947. /**
  29948. * Gets or sets the unique id of the texture
  29949. */
  29950. uniqueId: number;
  29951. /**
  29952. * Define the name of the texture.
  29953. */
  29954. name: string;
  29955. /**
  29956. * Gets or sets an object used to store user defined information.
  29957. */
  29958. metadata: any;
  29959. /**
  29960. * For internal use only. Please do not use.
  29961. */
  29962. reservedDataStore: any;
  29963. private _hasAlpha;
  29964. /**
  29965. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29966. */
  29967. set hasAlpha(value: boolean);
  29968. get hasAlpha(): boolean;
  29969. /**
  29970. * Defines if the alpha value should be determined via the rgb values.
  29971. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29972. */
  29973. getAlphaFromRGB: boolean;
  29974. /**
  29975. * Intensity or strength of the texture.
  29976. * It is commonly used by materials to fine tune the intensity of the texture
  29977. */
  29978. level: number;
  29979. /**
  29980. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29981. * This is part of the texture as textures usually maps to one uv set.
  29982. */
  29983. coordinatesIndex: number;
  29984. private _coordinatesMode;
  29985. /**
  29986. * How a texture is mapped.
  29987. *
  29988. * | Value | Type | Description |
  29989. * | ----- | ----------------------------------- | ----------- |
  29990. * | 0 | EXPLICIT_MODE | |
  29991. * | 1 | SPHERICAL_MODE | |
  29992. * | 2 | PLANAR_MODE | |
  29993. * | 3 | CUBIC_MODE | |
  29994. * | 4 | PROJECTION_MODE | |
  29995. * | 5 | SKYBOX_MODE | |
  29996. * | 6 | INVCUBIC_MODE | |
  29997. * | 7 | EQUIRECTANGULAR_MODE | |
  29998. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29999. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30000. */
  30001. set coordinatesMode(value: number);
  30002. get coordinatesMode(): number;
  30003. /**
  30004. * | Value | Type | Description |
  30005. * | ----- | ------------------ | ----------- |
  30006. * | 0 | CLAMP_ADDRESSMODE | |
  30007. * | 1 | WRAP_ADDRESSMODE | |
  30008. * | 2 | MIRROR_ADDRESSMODE | |
  30009. */
  30010. wrapU: number;
  30011. /**
  30012. * | Value | Type | Description |
  30013. * | ----- | ------------------ | ----------- |
  30014. * | 0 | CLAMP_ADDRESSMODE | |
  30015. * | 1 | WRAP_ADDRESSMODE | |
  30016. * | 2 | MIRROR_ADDRESSMODE | |
  30017. */
  30018. wrapV: number;
  30019. /**
  30020. * | Value | Type | Description |
  30021. * | ----- | ------------------ | ----------- |
  30022. * | 0 | CLAMP_ADDRESSMODE | |
  30023. * | 1 | WRAP_ADDRESSMODE | |
  30024. * | 2 | MIRROR_ADDRESSMODE | |
  30025. */
  30026. wrapR: number;
  30027. /**
  30028. * With compliant hardware and browser (supporting anisotropic filtering)
  30029. * this defines the level of anisotropic filtering in the texture.
  30030. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30031. */
  30032. anisotropicFilteringLevel: number;
  30033. /**
  30034. * Define if the texture is a cube texture or if false a 2d texture.
  30035. */
  30036. get isCube(): boolean;
  30037. set isCube(value: boolean);
  30038. /**
  30039. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30040. */
  30041. get is3D(): boolean;
  30042. set is3D(value: boolean);
  30043. /**
  30044. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30045. */
  30046. get is2DArray(): boolean;
  30047. set is2DArray(value: boolean);
  30048. /**
  30049. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30050. * HDR texture are usually stored in linear space.
  30051. * This only impacts the PBR and Background materials
  30052. */
  30053. gammaSpace: boolean;
  30054. /**
  30055. * Gets or sets whether or not the texture contains RGBD data.
  30056. */
  30057. get isRGBD(): boolean;
  30058. set isRGBD(value: boolean);
  30059. /**
  30060. * Is Z inverted in the texture (useful in a cube texture).
  30061. */
  30062. invertZ: boolean;
  30063. /**
  30064. * Are mip maps generated for this texture or not.
  30065. */
  30066. get noMipmap(): boolean;
  30067. /**
  30068. * @hidden
  30069. */
  30070. lodLevelInAlpha: boolean;
  30071. /**
  30072. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30073. */
  30074. get lodGenerationOffset(): number;
  30075. set lodGenerationOffset(value: number);
  30076. /**
  30077. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30078. */
  30079. get lodGenerationScale(): number;
  30080. set lodGenerationScale(value: number);
  30081. /**
  30082. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30083. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30084. * average roughness values.
  30085. */
  30086. get linearSpecularLOD(): boolean;
  30087. set linearSpecularLOD(value: boolean);
  30088. /**
  30089. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30090. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30091. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30092. */
  30093. get irradianceTexture(): Nullable<BaseTexture>;
  30094. set irradianceTexture(value: Nullable<BaseTexture>);
  30095. /**
  30096. * Define if the texture is a render target.
  30097. */
  30098. isRenderTarget: boolean;
  30099. /**
  30100. * Define the unique id of the texture in the scene.
  30101. */
  30102. get uid(): string;
  30103. /**
  30104. * Return a string representation of the texture.
  30105. * @returns the texture as a string
  30106. */
  30107. toString(): string;
  30108. /**
  30109. * Get the class name of the texture.
  30110. * @returns "BaseTexture"
  30111. */
  30112. getClassName(): string;
  30113. /**
  30114. * Define the list of animation attached to the texture.
  30115. */
  30116. animations: Animation[];
  30117. /**
  30118. * An event triggered when the texture is disposed.
  30119. */
  30120. onDisposeObservable: Observable<BaseTexture>;
  30121. private _onDisposeObserver;
  30122. /**
  30123. * Callback triggered when the texture has been disposed.
  30124. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30125. */
  30126. set onDispose(callback: () => void);
  30127. /**
  30128. * Define the current state of the loading sequence when in delayed load mode.
  30129. */
  30130. delayLoadState: number;
  30131. private _scene;
  30132. /** @hidden */
  30133. _texture: Nullable<InternalTexture>;
  30134. private _uid;
  30135. /**
  30136. * Define if the texture is preventinga material to render or not.
  30137. * If not and the texture is not ready, the engine will use a default black texture instead.
  30138. */
  30139. get isBlocking(): boolean;
  30140. /**
  30141. * Instantiates a new BaseTexture.
  30142. * Base class of all the textures in babylon.
  30143. * It groups all the common properties the materials, post process, lights... might need
  30144. * in order to make a correct use of the texture.
  30145. * @param scene Define the scene the texture blongs to
  30146. */
  30147. constructor(scene: Nullable<Scene>);
  30148. /**
  30149. * Get the scene the texture belongs to.
  30150. * @returns the scene or null if undefined
  30151. */
  30152. getScene(): Nullable<Scene>;
  30153. /**
  30154. * Get the texture transform matrix used to offset tile the texture for istance.
  30155. * @returns the transformation matrix
  30156. */
  30157. getTextureMatrix(): Matrix;
  30158. /**
  30159. * Get the texture reflection matrix used to rotate/transform the reflection.
  30160. * @returns the reflection matrix
  30161. */
  30162. getReflectionTextureMatrix(): Matrix;
  30163. /**
  30164. * Get the underlying lower level texture from Babylon.
  30165. * @returns the insternal texture
  30166. */
  30167. getInternalTexture(): Nullable<InternalTexture>;
  30168. /**
  30169. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30170. * @returns true if ready or not blocking
  30171. */
  30172. isReadyOrNotBlocking(): boolean;
  30173. /**
  30174. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30175. * @returns true if fully ready
  30176. */
  30177. isReady(): boolean;
  30178. private _cachedSize;
  30179. /**
  30180. * Get the size of the texture.
  30181. * @returns the texture size.
  30182. */
  30183. getSize(): ISize;
  30184. /**
  30185. * Get the base size of the texture.
  30186. * It can be different from the size if the texture has been resized for POT for instance
  30187. * @returns the base size
  30188. */
  30189. getBaseSize(): ISize;
  30190. /**
  30191. * Update the sampling mode of the texture.
  30192. * Default is Trilinear mode.
  30193. *
  30194. * | Value | Type | Description |
  30195. * | ----- | ------------------ | ----------- |
  30196. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30197. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30198. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30199. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30200. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30201. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30202. * | 7 | NEAREST_LINEAR | |
  30203. * | 8 | NEAREST_NEAREST | |
  30204. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30205. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30206. * | 11 | LINEAR_LINEAR | |
  30207. * | 12 | LINEAR_NEAREST | |
  30208. *
  30209. * > _mag_: magnification filter (close to the viewer)
  30210. * > _min_: minification filter (far from the viewer)
  30211. * > _mip_: filter used between mip map levels
  30212. *@param samplingMode Define the new sampling mode of the texture
  30213. */
  30214. updateSamplingMode(samplingMode: number): void;
  30215. /**
  30216. * Scales the texture if is `canRescale()`
  30217. * @param ratio the resize factor we want to use to rescale
  30218. */
  30219. scale(ratio: number): void;
  30220. /**
  30221. * Get if the texture can rescale.
  30222. */
  30223. get canRescale(): boolean;
  30224. /** @hidden */
  30225. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30226. /** @hidden */
  30227. _rebuild(): void;
  30228. /**
  30229. * Triggers the load sequence in delayed load mode.
  30230. */
  30231. delayLoad(): void;
  30232. /**
  30233. * Clones the texture.
  30234. * @returns the cloned texture
  30235. */
  30236. clone(): Nullable<BaseTexture>;
  30237. /**
  30238. * Get the texture underlying type (INT, FLOAT...)
  30239. */
  30240. get textureType(): number;
  30241. /**
  30242. * Get the texture underlying format (RGB, RGBA...)
  30243. */
  30244. get textureFormat(): number;
  30245. /**
  30246. * Indicates that textures need to be re-calculated for all materials
  30247. */
  30248. protected _markAllSubMeshesAsTexturesDirty(): void;
  30249. /**
  30250. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30251. * This will returns an RGBA array buffer containing either in values (0-255) or
  30252. * float values (0-1) depending of the underlying buffer type.
  30253. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30254. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30255. * @param buffer defines a user defined buffer to fill with data (can be null)
  30256. * @returns The Array buffer containing the pixels data.
  30257. */
  30258. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30259. /**
  30260. * Release and destroy the underlying lower level texture aka internalTexture.
  30261. */
  30262. releaseInternalTexture(): void;
  30263. /** @hidden */
  30264. get _lodTextureHigh(): Nullable<BaseTexture>;
  30265. /** @hidden */
  30266. get _lodTextureMid(): Nullable<BaseTexture>;
  30267. /** @hidden */
  30268. get _lodTextureLow(): Nullable<BaseTexture>;
  30269. /**
  30270. * Dispose the texture and release its associated resources.
  30271. */
  30272. dispose(): void;
  30273. /**
  30274. * Serialize the texture into a JSON representation that can be parsed later on.
  30275. * @returns the JSON representation of the texture
  30276. */
  30277. serialize(): any;
  30278. /**
  30279. * Helper function to be called back once a list of texture contains only ready textures.
  30280. * @param textures Define the list of textures to wait for
  30281. * @param callback Define the callback triggered once the entire list will be ready
  30282. */
  30283. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30284. }
  30285. }
  30286. declare module BABYLON {
  30287. /**
  30288. * Options to be used when creating an effect.
  30289. */
  30290. export interface IEffectCreationOptions {
  30291. /**
  30292. * Atrributes that will be used in the shader.
  30293. */
  30294. attributes: string[];
  30295. /**
  30296. * Uniform varible names that will be set in the shader.
  30297. */
  30298. uniformsNames: string[];
  30299. /**
  30300. * Uniform buffer variable names that will be set in the shader.
  30301. */
  30302. uniformBuffersNames: string[];
  30303. /**
  30304. * Sampler texture variable names that will be set in the shader.
  30305. */
  30306. samplers: string[];
  30307. /**
  30308. * Define statements that will be set in the shader.
  30309. */
  30310. defines: any;
  30311. /**
  30312. * Possible fallbacks for this effect to improve performance when needed.
  30313. */
  30314. fallbacks: Nullable<IEffectFallbacks>;
  30315. /**
  30316. * Callback that will be called when the shader is compiled.
  30317. */
  30318. onCompiled: Nullable<(effect: Effect) => void>;
  30319. /**
  30320. * Callback that will be called if an error occurs during shader compilation.
  30321. */
  30322. onError: Nullable<(effect: Effect, errors: string) => void>;
  30323. /**
  30324. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30325. */
  30326. indexParameters?: any;
  30327. /**
  30328. * Max number of lights that can be used in the shader.
  30329. */
  30330. maxSimultaneousLights?: number;
  30331. /**
  30332. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30333. */
  30334. transformFeedbackVaryings?: Nullable<string[]>;
  30335. }
  30336. /**
  30337. * Effect containing vertex and fragment shader that can be executed on an object.
  30338. */
  30339. export class Effect implements IDisposable {
  30340. /**
  30341. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30342. */
  30343. static ShadersRepository: string;
  30344. /**
  30345. * Enable logging of the shader code when a compilation error occurs
  30346. */
  30347. static LogShaderCodeOnCompilationError: boolean;
  30348. /**
  30349. * Name of the effect.
  30350. */
  30351. name: any;
  30352. /**
  30353. * String container all the define statements that should be set on the shader.
  30354. */
  30355. defines: string;
  30356. /**
  30357. * Callback that will be called when the shader is compiled.
  30358. */
  30359. onCompiled: Nullable<(effect: Effect) => void>;
  30360. /**
  30361. * Callback that will be called if an error occurs during shader compilation.
  30362. */
  30363. onError: Nullable<(effect: Effect, errors: string) => void>;
  30364. /**
  30365. * Callback that will be called when effect is bound.
  30366. */
  30367. onBind: Nullable<(effect: Effect) => void>;
  30368. /**
  30369. * Unique ID of the effect.
  30370. */
  30371. uniqueId: number;
  30372. /**
  30373. * Observable that will be called when the shader is compiled.
  30374. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30375. */
  30376. onCompileObservable: Observable<Effect>;
  30377. /**
  30378. * Observable that will be called if an error occurs during shader compilation.
  30379. */
  30380. onErrorObservable: Observable<Effect>;
  30381. /** @hidden */
  30382. _onBindObservable: Nullable<Observable<Effect>>;
  30383. /**
  30384. * @hidden
  30385. * Specifies if the effect was previously ready
  30386. */
  30387. _wasPreviouslyReady: boolean;
  30388. /**
  30389. * Observable that will be called when effect is bound.
  30390. */
  30391. get onBindObservable(): Observable<Effect>;
  30392. /** @hidden */
  30393. _bonesComputationForcedToCPU: boolean;
  30394. private static _uniqueIdSeed;
  30395. private _engine;
  30396. private _uniformBuffersNames;
  30397. private _uniformsNames;
  30398. private _samplerList;
  30399. private _samplers;
  30400. private _isReady;
  30401. private _compilationError;
  30402. private _allFallbacksProcessed;
  30403. private _attributesNames;
  30404. private _attributes;
  30405. private _attributeLocationByName;
  30406. private _uniforms;
  30407. /**
  30408. * Key for the effect.
  30409. * @hidden
  30410. */
  30411. _key: string;
  30412. private _indexParameters;
  30413. private _fallbacks;
  30414. private _vertexSourceCode;
  30415. private _fragmentSourceCode;
  30416. private _vertexSourceCodeOverride;
  30417. private _fragmentSourceCodeOverride;
  30418. private _transformFeedbackVaryings;
  30419. /**
  30420. * Compiled shader to webGL program.
  30421. * @hidden
  30422. */
  30423. _pipelineContext: Nullable<IPipelineContext>;
  30424. private _valueCache;
  30425. private static _baseCache;
  30426. /**
  30427. * Instantiates an effect.
  30428. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30429. * @param baseName Name of the effect.
  30430. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30431. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30432. * @param samplers List of sampler variables that will be passed to the shader.
  30433. * @param engine Engine to be used to render the effect
  30434. * @param defines Define statements to be added to the shader.
  30435. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30436. * @param onCompiled Callback that will be called when the shader is compiled.
  30437. * @param onError Callback that will be called if an error occurs during shader compilation.
  30438. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30439. */
  30440. 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);
  30441. private _useFinalCode;
  30442. /**
  30443. * Unique key for this effect
  30444. */
  30445. get key(): string;
  30446. /**
  30447. * If the effect has been compiled and prepared.
  30448. * @returns if the effect is compiled and prepared.
  30449. */
  30450. isReady(): boolean;
  30451. private _isReadyInternal;
  30452. /**
  30453. * The engine the effect was initialized with.
  30454. * @returns the engine.
  30455. */
  30456. getEngine(): Engine;
  30457. /**
  30458. * The pipeline context for this effect
  30459. * @returns the associated pipeline context
  30460. */
  30461. getPipelineContext(): Nullable<IPipelineContext>;
  30462. /**
  30463. * The set of names of attribute variables for the shader.
  30464. * @returns An array of attribute names.
  30465. */
  30466. getAttributesNames(): string[];
  30467. /**
  30468. * Returns the attribute at the given index.
  30469. * @param index The index of the attribute.
  30470. * @returns The location of the attribute.
  30471. */
  30472. getAttributeLocation(index: number): number;
  30473. /**
  30474. * Returns the attribute based on the name of the variable.
  30475. * @param name of the attribute to look up.
  30476. * @returns the attribute location.
  30477. */
  30478. getAttributeLocationByName(name: string): number;
  30479. /**
  30480. * The number of attributes.
  30481. * @returns the numnber of attributes.
  30482. */
  30483. getAttributesCount(): number;
  30484. /**
  30485. * Gets the index of a uniform variable.
  30486. * @param uniformName of the uniform to look up.
  30487. * @returns the index.
  30488. */
  30489. getUniformIndex(uniformName: string): number;
  30490. /**
  30491. * Returns the attribute based on the name of the variable.
  30492. * @param uniformName of the uniform to look up.
  30493. * @returns the location of the uniform.
  30494. */
  30495. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30496. /**
  30497. * Returns an array of sampler variable names
  30498. * @returns The array of sampler variable neames.
  30499. */
  30500. getSamplers(): string[];
  30501. /**
  30502. * The error from the last compilation.
  30503. * @returns the error string.
  30504. */
  30505. getCompilationError(): string;
  30506. /**
  30507. * Gets a boolean indicating that all fallbacks were used during compilation
  30508. * @returns true if all fallbacks were used
  30509. */
  30510. allFallbacksProcessed(): boolean;
  30511. /**
  30512. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30513. * @param func The callback to be used.
  30514. */
  30515. executeWhenCompiled(func: (effect: Effect) => void): void;
  30516. private _checkIsReady;
  30517. private _loadShader;
  30518. /**
  30519. * Recompiles the webGL program
  30520. * @param vertexSourceCode The source code for the vertex shader.
  30521. * @param fragmentSourceCode The source code for the fragment shader.
  30522. * @param onCompiled Callback called when completed.
  30523. * @param onError Callback called on error.
  30524. * @hidden
  30525. */
  30526. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30527. /**
  30528. * Prepares the effect
  30529. * @hidden
  30530. */
  30531. _prepareEffect(): void;
  30532. private _getShaderCodeAndErrorLine;
  30533. private _processCompilationErrors;
  30534. /**
  30535. * Checks if the effect is supported. (Must be called after compilation)
  30536. */
  30537. get isSupported(): boolean;
  30538. /**
  30539. * Binds a texture to the engine to be used as output of the shader.
  30540. * @param channel Name of the output variable.
  30541. * @param texture Texture to bind.
  30542. * @hidden
  30543. */
  30544. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30545. /**
  30546. * Sets a texture on the engine to be used in the shader.
  30547. * @param channel Name of the sampler variable.
  30548. * @param texture Texture to set.
  30549. */
  30550. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30551. /**
  30552. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30553. * @param channel Name of the sampler variable.
  30554. * @param texture Texture to set.
  30555. */
  30556. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30557. /**
  30558. * Sets an array of textures on the engine to be used in the shader.
  30559. * @param channel Name of the variable.
  30560. * @param textures Textures to set.
  30561. */
  30562. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30563. /**
  30564. * 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)
  30565. * @param channel Name of the sampler variable.
  30566. * @param postProcess Post process to get the input texture from.
  30567. */
  30568. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30569. /**
  30570. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30571. * 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)
  30572. * @param channel Name of the sampler variable.
  30573. * @param postProcess Post process to get the output texture from.
  30574. */
  30575. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30576. /** @hidden */
  30577. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30578. /** @hidden */
  30579. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30580. /** @hidden */
  30581. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30582. /** @hidden */
  30583. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30584. /**
  30585. * Binds a buffer to a uniform.
  30586. * @param buffer Buffer to bind.
  30587. * @param name Name of the uniform variable to bind to.
  30588. */
  30589. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30590. /**
  30591. * Binds block to a uniform.
  30592. * @param blockName Name of the block to bind.
  30593. * @param index Index to bind.
  30594. */
  30595. bindUniformBlock(blockName: string, index: number): void;
  30596. /**
  30597. * Sets an interger value on a uniform variable.
  30598. * @param uniformName Name of the variable.
  30599. * @param value Value to be set.
  30600. * @returns this effect.
  30601. */
  30602. setInt(uniformName: string, value: number): Effect;
  30603. /**
  30604. * Sets an int array on a uniform variable.
  30605. * @param uniformName Name of the variable.
  30606. * @param array array to be set.
  30607. * @returns this effect.
  30608. */
  30609. setIntArray(uniformName: string, array: Int32Array): Effect;
  30610. /**
  30611. * 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)
  30612. * @param uniformName Name of the variable.
  30613. * @param array array to be set.
  30614. * @returns this effect.
  30615. */
  30616. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30617. /**
  30618. * 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)
  30619. * @param uniformName Name of the variable.
  30620. * @param array array to be set.
  30621. * @returns this effect.
  30622. */
  30623. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30624. /**
  30625. * 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)
  30626. * @param uniformName Name of the variable.
  30627. * @param array array to be set.
  30628. * @returns this effect.
  30629. */
  30630. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30631. /**
  30632. * Sets an float array on a uniform variable.
  30633. * @param uniformName Name of the variable.
  30634. * @param array array to be set.
  30635. * @returns this effect.
  30636. */
  30637. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30638. /**
  30639. * 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)
  30640. * @param uniformName Name of the variable.
  30641. * @param array array to be set.
  30642. * @returns this effect.
  30643. */
  30644. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30645. /**
  30646. * 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)
  30647. * @param uniformName Name of the variable.
  30648. * @param array array to be set.
  30649. * @returns this effect.
  30650. */
  30651. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30652. /**
  30653. * 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)
  30654. * @param uniformName Name of the variable.
  30655. * @param array array to be set.
  30656. * @returns this effect.
  30657. */
  30658. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30659. /**
  30660. * Sets an array on a uniform variable.
  30661. * @param uniformName Name of the variable.
  30662. * @param array array to be set.
  30663. * @returns this effect.
  30664. */
  30665. setArray(uniformName: string, array: number[]): Effect;
  30666. /**
  30667. * 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)
  30668. * @param uniformName Name of the variable.
  30669. * @param array array to be set.
  30670. * @returns this effect.
  30671. */
  30672. setArray2(uniformName: string, array: number[]): Effect;
  30673. /**
  30674. * 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)
  30675. * @param uniformName Name of the variable.
  30676. * @param array array to be set.
  30677. * @returns this effect.
  30678. */
  30679. setArray3(uniformName: string, array: number[]): Effect;
  30680. /**
  30681. * 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)
  30682. * @param uniformName Name of the variable.
  30683. * @param array array to be set.
  30684. * @returns this effect.
  30685. */
  30686. setArray4(uniformName: string, array: number[]): Effect;
  30687. /**
  30688. * Sets matrices on a uniform variable.
  30689. * @param uniformName Name of the variable.
  30690. * @param matrices matrices to be set.
  30691. * @returns this effect.
  30692. */
  30693. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30694. /**
  30695. * Sets matrix on a uniform variable.
  30696. * @param uniformName Name of the variable.
  30697. * @param matrix matrix to be set.
  30698. * @returns this effect.
  30699. */
  30700. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30701. /**
  30702. * 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)
  30703. * @param uniformName Name of the variable.
  30704. * @param matrix matrix to be set.
  30705. * @returns this effect.
  30706. */
  30707. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30708. /**
  30709. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30710. * @param uniformName Name of the variable.
  30711. * @param matrix matrix to be set.
  30712. * @returns this effect.
  30713. */
  30714. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30715. /**
  30716. * Sets a float on a uniform variable.
  30717. * @param uniformName Name of the variable.
  30718. * @param value value to be set.
  30719. * @returns this effect.
  30720. */
  30721. setFloat(uniformName: string, value: number): Effect;
  30722. /**
  30723. * Sets a boolean on a uniform variable.
  30724. * @param uniformName Name of the variable.
  30725. * @param bool value to be set.
  30726. * @returns this effect.
  30727. */
  30728. setBool(uniformName: string, bool: boolean): Effect;
  30729. /**
  30730. * Sets a Vector2 on a uniform variable.
  30731. * @param uniformName Name of the variable.
  30732. * @param vector2 vector2 to be set.
  30733. * @returns this effect.
  30734. */
  30735. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30736. /**
  30737. * Sets a float2 on a uniform variable.
  30738. * @param uniformName Name of the variable.
  30739. * @param x First float in float2.
  30740. * @param y Second float in float2.
  30741. * @returns this effect.
  30742. */
  30743. setFloat2(uniformName: string, x: number, y: number): Effect;
  30744. /**
  30745. * Sets a Vector3 on a uniform variable.
  30746. * @param uniformName Name of the variable.
  30747. * @param vector3 Value to be set.
  30748. * @returns this effect.
  30749. */
  30750. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30751. /**
  30752. * Sets a float3 on a uniform variable.
  30753. * @param uniformName Name of the variable.
  30754. * @param x First float in float3.
  30755. * @param y Second float in float3.
  30756. * @param z Third float in float3.
  30757. * @returns this effect.
  30758. */
  30759. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30760. /**
  30761. * Sets a Vector4 on a uniform variable.
  30762. * @param uniformName Name of the variable.
  30763. * @param vector4 Value to be set.
  30764. * @returns this effect.
  30765. */
  30766. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30767. /**
  30768. * Sets a float4 on a uniform variable.
  30769. * @param uniformName Name of the variable.
  30770. * @param x First float in float4.
  30771. * @param y Second float in float4.
  30772. * @param z Third float in float4.
  30773. * @param w Fourth float in float4.
  30774. * @returns this effect.
  30775. */
  30776. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30777. /**
  30778. * Sets a Color3 on a uniform variable.
  30779. * @param uniformName Name of the variable.
  30780. * @param color3 Value to be set.
  30781. * @returns this effect.
  30782. */
  30783. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30784. /**
  30785. * Sets a Color4 on a uniform variable.
  30786. * @param uniformName Name of the variable.
  30787. * @param color3 Value to be set.
  30788. * @param alpha Alpha value to be set.
  30789. * @returns this effect.
  30790. */
  30791. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30792. /**
  30793. * Sets a Color4 on a uniform variable
  30794. * @param uniformName defines the name of the variable
  30795. * @param color4 defines the value to be set
  30796. * @returns this effect.
  30797. */
  30798. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30799. /** Release all associated resources */
  30800. dispose(): void;
  30801. /**
  30802. * This function will add a new shader to the shader store
  30803. * @param name the name of the shader
  30804. * @param pixelShader optional pixel shader content
  30805. * @param vertexShader optional vertex shader content
  30806. */
  30807. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30808. /**
  30809. * Store of each shader (The can be looked up using effect.key)
  30810. */
  30811. static ShadersStore: {
  30812. [key: string]: string;
  30813. };
  30814. /**
  30815. * Store of each included file for a shader (The can be looked up using effect.key)
  30816. */
  30817. static IncludesShadersStore: {
  30818. [key: string]: string;
  30819. };
  30820. /**
  30821. * Resets the cache of effects.
  30822. */
  30823. static ResetCache(): void;
  30824. }
  30825. }
  30826. declare module BABYLON {
  30827. /**
  30828. * Interface used to describe the capabilities of the engine relatively to the current browser
  30829. */
  30830. export interface EngineCapabilities {
  30831. /** Maximum textures units per fragment shader */
  30832. maxTexturesImageUnits: number;
  30833. /** Maximum texture units per vertex shader */
  30834. maxVertexTextureImageUnits: number;
  30835. /** Maximum textures units in the entire pipeline */
  30836. maxCombinedTexturesImageUnits: number;
  30837. /** Maximum texture size */
  30838. maxTextureSize: number;
  30839. /** Maximum texture samples */
  30840. maxSamples?: number;
  30841. /** Maximum cube texture size */
  30842. maxCubemapTextureSize: number;
  30843. /** Maximum render texture size */
  30844. maxRenderTextureSize: number;
  30845. /** Maximum number of vertex attributes */
  30846. maxVertexAttribs: number;
  30847. /** Maximum number of varyings */
  30848. maxVaryingVectors: number;
  30849. /** Maximum number of uniforms per vertex shader */
  30850. maxVertexUniformVectors: number;
  30851. /** Maximum number of uniforms per fragment shader */
  30852. maxFragmentUniformVectors: number;
  30853. /** Defines if standard derivates (dx/dy) are supported */
  30854. standardDerivatives: boolean;
  30855. /** Defines if s3tc texture compression is supported */
  30856. s3tc?: WEBGL_compressed_texture_s3tc;
  30857. /** Defines if pvrtc texture compression is supported */
  30858. pvrtc: any;
  30859. /** Defines if etc1 texture compression is supported */
  30860. etc1: any;
  30861. /** Defines if etc2 texture compression is supported */
  30862. etc2: any;
  30863. /** Defines if astc texture compression is supported */
  30864. astc: any;
  30865. /** Defines if float textures are supported */
  30866. textureFloat: boolean;
  30867. /** Defines if vertex array objects are supported */
  30868. vertexArrayObject: boolean;
  30869. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30870. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30871. /** Gets the maximum level of anisotropy supported */
  30872. maxAnisotropy: number;
  30873. /** Defines if instancing is supported */
  30874. instancedArrays: boolean;
  30875. /** Defines if 32 bits indices are supported */
  30876. uintIndices: boolean;
  30877. /** Defines if high precision shaders are supported */
  30878. highPrecisionShaderSupported: boolean;
  30879. /** Defines if depth reading in the fragment shader is supported */
  30880. fragmentDepthSupported: boolean;
  30881. /** Defines if float texture linear filtering is supported*/
  30882. textureFloatLinearFiltering: boolean;
  30883. /** Defines if rendering to float textures is supported */
  30884. textureFloatRender: boolean;
  30885. /** Defines if half float textures are supported*/
  30886. textureHalfFloat: boolean;
  30887. /** Defines if half float texture linear filtering is supported*/
  30888. textureHalfFloatLinearFiltering: boolean;
  30889. /** Defines if rendering to half float textures is supported */
  30890. textureHalfFloatRender: boolean;
  30891. /** Defines if textureLOD shader command is supported */
  30892. textureLOD: boolean;
  30893. /** Defines if draw buffers extension is supported */
  30894. drawBuffersExtension: boolean;
  30895. /** Defines if depth textures are supported */
  30896. depthTextureExtension: boolean;
  30897. /** Defines if float color buffer are supported */
  30898. colorBufferFloat: boolean;
  30899. /** Gets disjoint timer query extension (null if not supported) */
  30900. timerQuery?: EXT_disjoint_timer_query;
  30901. /** Defines if timestamp can be used with timer query */
  30902. canUseTimestampForTimerQuery: boolean;
  30903. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30904. multiview?: any;
  30905. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30906. oculusMultiview?: any;
  30907. /** Function used to let the system compiles shaders in background */
  30908. parallelShaderCompile?: {
  30909. COMPLETION_STATUS_KHR: number;
  30910. };
  30911. /** Max number of texture samples for MSAA */
  30912. maxMSAASamples: number;
  30913. /** Defines if the blend min max extension is supported */
  30914. blendMinMax: boolean;
  30915. }
  30916. }
  30917. declare module BABYLON {
  30918. /**
  30919. * @hidden
  30920. **/
  30921. export class DepthCullingState {
  30922. private _isDepthTestDirty;
  30923. private _isDepthMaskDirty;
  30924. private _isDepthFuncDirty;
  30925. private _isCullFaceDirty;
  30926. private _isCullDirty;
  30927. private _isZOffsetDirty;
  30928. private _isFrontFaceDirty;
  30929. private _depthTest;
  30930. private _depthMask;
  30931. private _depthFunc;
  30932. private _cull;
  30933. private _cullFace;
  30934. private _zOffset;
  30935. private _frontFace;
  30936. /**
  30937. * Initializes the state.
  30938. */
  30939. constructor();
  30940. get isDirty(): boolean;
  30941. get zOffset(): number;
  30942. set zOffset(value: number);
  30943. get cullFace(): Nullable<number>;
  30944. set cullFace(value: Nullable<number>);
  30945. get cull(): Nullable<boolean>;
  30946. set cull(value: Nullable<boolean>);
  30947. get depthFunc(): Nullable<number>;
  30948. set depthFunc(value: Nullable<number>);
  30949. get depthMask(): boolean;
  30950. set depthMask(value: boolean);
  30951. get depthTest(): boolean;
  30952. set depthTest(value: boolean);
  30953. get frontFace(): Nullable<number>;
  30954. set frontFace(value: Nullable<number>);
  30955. reset(): void;
  30956. apply(gl: WebGLRenderingContext): void;
  30957. }
  30958. }
  30959. declare module BABYLON {
  30960. /**
  30961. * @hidden
  30962. **/
  30963. export class StencilState {
  30964. /** 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 */
  30965. static readonly ALWAYS: number;
  30966. /** Passed to stencilOperation to specify that stencil value must be kept */
  30967. static readonly KEEP: number;
  30968. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30969. static readonly REPLACE: number;
  30970. private _isStencilTestDirty;
  30971. private _isStencilMaskDirty;
  30972. private _isStencilFuncDirty;
  30973. private _isStencilOpDirty;
  30974. private _stencilTest;
  30975. private _stencilMask;
  30976. private _stencilFunc;
  30977. private _stencilFuncRef;
  30978. private _stencilFuncMask;
  30979. private _stencilOpStencilFail;
  30980. private _stencilOpDepthFail;
  30981. private _stencilOpStencilDepthPass;
  30982. get isDirty(): boolean;
  30983. get stencilFunc(): number;
  30984. set stencilFunc(value: number);
  30985. get stencilFuncRef(): number;
  30986. set stencilFuncRef(value: number);
  30987. get stencilFuncMask(): number;
  30988. set stencilFuncMask(value: number);
  30989. get stencilOpStencilFail(): number;
  30990. set stencilOpStencilFail(value: number);
  30991. get stencilOpDepthFail(): number;
  30992. set stencilOpDepthFail(value: number);
  30993. get stencilOpStencilDepthPass(): number;
  30994. set stencilOpStencilDepthPass(value: number);
  30995. get stencilMask(): number;
  30996. set stencilMask(value: number);
  30997. get stencilTest(): boolean;
  30998. set stencilTest(value: boolean);
  30999. constructor();
  31000. reset(): void;
  31001. apply(gl: WebGLRenderingContext): void;
  31002. }
  31003. }
  31004. declare module BABYLON {
  31005. /**
  31006. * @hidden
  31007. **/
  31008. export class AlphaState {
  31009. private _isAlphaBlendDirty;
  31010. private _isBlendFunctionParametersDirty;
  31011. private _isBlendEquationParametersDirty;
  31012. private _isBlendConstantsDirty;
  31013. private _alphaBlend;
  31014. private _blendFunctionParameters;
  31015. private _blendEquationParameters;
  31016. private _blendConstants;
  31017. /**
  31018. * Initializes the state.
  31019. */
  31020. constructor();
  31021. get isDirty(): boolean;
  31022. get alphaBlend(): boolean;
  31023. set alphaBlend(value: boolean);
  31024. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31025. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31026. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31027. reset(): void;
  31028. apply(gl: WebGLRenderingContext): void;
  31029. }
  31030. }
  31031. declare module BABYLON {
  31032. /** @hidden */
  31033. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31034. attributeProcessor(attribute: string): string;
  31035. varyingProcessor(varying: string, isFragment: boolean): string;
  31036. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31037. }
  31038. }
  31039. declare module BABYLON {
  31040. /**
  31041. * Interface for attribute information associated with buffer instanciation
  31042. */
  31043. export interface InstancingAttributeInfo {
  31044. /**
  31045. * Name of the GLSL attribute
  31046. * if attribute index is not specified, this is used to retrieve the index from the effect
  31047. */
  31048. attributeName: string;
  31049. /**
  31050. * Index/offset of the attribute in the vertex shader
  31051. * if not specified, this will be computes from the name.
  31052. */
  31053. index?: number;
  31054. /**
  31055. * size of the attribute, 1, 2, 3 or 4
  31056. */
  31057. attributeSize: number;
  31058. /**
  31059. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31060. */
  31061. offset: number;
  31062. /**
  31063. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31064. * default to 1
  31065. */
  31066. divisor?: number;
  31067. /**
  31068. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31069. * default is FLOAT
  31070. */
  31071. attributeType?: number;
  31072. /**
  31073. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31074. */
  31075. normalized?: boolean;
  31076. }
  31077. }
  31078. declare module BABYLON {
  31079. interface ThinEngine {
  31080. /**
  31081. * Update a video texture
  31082. * @param texture defines the texture to update
  31083. * @param video defines the video element to use
  31084. * @param invertY defines if data must be stored with Y axis inverted
  31085. */
  31086. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31087. }
  31088. }
  31089. declare module BABYLON {
  31090. /**
  31091. * Settings for finer control over video usage
  31092. */
  31093. export interface VideoTextureSettings {
  31094. /**
  31095. * Applies `autoplay` to video, if specified
  31096. */
  31097. autoPlay?: boolean;
  31098. /**
  31099. * Applies `loop` to video, if specified
  31100. */
  31101. loop?: boolean;
  31102. /**
  31103. * Automatically updates internal texture from video at every frame in the render loop
  31104. */
  31105. autoUpdateTexture: boolean;
  31106. /**
  31107. * Image src displayed during the video loading or until the user interacts with the video.
  31108. */
  31109. poster?: string;
  31110. }
  31111. /**
  31112. * If you want to display a video in your scene, this is the special texture for that.
  31113. * This special texture works similar to other textures, with the exception of a few parameters.
  31114. * @see https://doc.babylonjs.com/how_to/video_texture
  31115. */
  31116. export class VideoTexture extends Texture {
  31117. /**
  31118. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31119. */
  31120. readonly autoUpdateTexture: boolean;
  31121. /**
  31122. * The video instance used by the texture internally
  31123. */
  31124. readonly video: HTMLVideoElement;
  31125. private _onUserActionRequestedObservable;
  31126. /**
  31127. * Event triggerd when a dom action is required by the user to play the video.
  31128. * This happens due to recent changes in browser policies preventing video to auto start.
  31129. */
  31130. get onUserActionRequestedObservable(): Observable<Texture>;
  31131. private _generateMipMaps;
  31132. private _engine;
  31133. private _stillImageCaptured;
  31134. private _displayingPosterTexture;
  31135. private _settings;
  31136. private _createInternalTextureOnEvent;
  31137. private _frameId;
  31138. private _currentSrc;
  31139. /**
  31140. * Creates a video texture.
  31141. * If you want to display a video in your scene, this is the special texture for that.
  31142. * This special texture works similar to other textures, with the exception of a few parameters.
  31143. * @see https://doc.babylonjs.com/how_to/video_texture
  31144. * @param name optional name, will detect from video source, if not defined
  31145. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31146. * @param scene is obviously the current scene.
  31147. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31148. * @param invertY is false by default but can be used to invert video on Y axis
  31149. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31150. * @param settings allows finer control over video usage
  31151. */
  31152. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31153. private _getName;
  31154. private _getVideo;
  31155. private _createInternalTexture;
  31156. private reset;
  31157. /**
  31158. * @hidden Internal method to initiate `update`.
  31159. */
  31160. _rebuild(): void;
  31161. /**
  31162. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31163. */
  31164. update(): void;
  31165. /**
  31166. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31167. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31168. */
  31169. updateTexture(isVisible: boolean): void;
  31170. protected _updateInternalTexture: () => void;
  31171. /**
  31172. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31173. * @param url New url.
  31174. */
  31175. updateURL(url: string): void;
  31176. /**
  31177. * Clones the texture.
  31178. * @returns the cloned texture
  31179. */
  31180. clone(): VideoTexture;
  31181. /**
  31182. * Dispose the texture and release its associated resources.
  31183. */
  31184. dispose(): void;
  31185. /**
  31186. * Creates a video texture straight from a stream.
  31187. * @param scene Define the scene the texture should be created in
  31188. * @param stream Define the stream the texture should be created from
  31189. * @returns The created video texture as a promise
  31190. */
  31191. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31192. /**
  31193. * Creates a video texture straight from your WebCam video feed.
  31194. * @param scene Define the scene the texture should be created in
  31195. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31196. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31197. * @returns The created video texture as a promise
  31198. */
  31199. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31200. minWidth: number;
  31201. maxWidth: number;
  31202. minHeight: number;
  31203. maxHeight: number;
  31204. deviceId: string;
  31205. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31206. /**
  31207. * Creates a video texture straight from your WebCam video feed.
  31208. * @param scene Define the scene the texture should be created in
  31209. * @param onReady Define a callback to triggered once the texture will be ready
  31210. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31211. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31212. */
  31213. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31214. minWidth: number;
  31215. maxWidth: number;
  31216. minHeight: number;
  31217. maxHeight: number;
  31218. deviceId: string;
  31219. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31220. }
  31221. }
  31222. declare module BABYLON {
  31223. /**
  31224. * Defines the interface used by objects working like Scene
  31225. * @hidden
  31226. */
  31227. export interface ISceneLike {
  31228. _addPendingData(data: any): void;
  31229. _removePendingData(data: any): void;
  31230. offlineProvider: IOfflineProvider;
  31231. }
  31232. /** Interface defining initialization parameters for Engine class */
  31233. export interface EngineOptions extends WebGLContextAttributes {
  31234. /**
  31235. * Defines if the engine should no exceed a specified device ratio
  31236. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31237. */
  31238. limitDeviceRatio?: number;
  31239. /**
  31240. * Defines if webvr should be enabled automatically
  31241. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31242. */
  31243. autoEnableWebVR?: boolean;
  31244. /**
  31245. * Defines if webgl2 should be turned off even if supported
  31246. * @see http://doc.babylonjs.com/features/webgl2
  31247. */
  31248. disableWebGL2Support?: boolean;
  31249. /**
  31250. * Defines if webaudio should be initialized as well
  31251. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31252. */
  31253. audioEngine?: boolean;
  31254. /**
  31255. * Defines if animations should run using a deterministic lock step
  31256. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31257. */
  31258. deterministicLockstep?: boolean;
  31259. /** Defines the maximum steps to use with deterministic lock step mode */
  31260. lockstepMaxSteps?: number;
  31261. /** Defines the seconds between each deterministic lock step */
  31262. timeStep?: number;
  31263. /**
  31264. * Defines that engine should ignore context lost events
  31265. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31266. */
  31267. doNotHandleContextLost?: boolean;
  31268. /**
  31269. * Defines that engine should ignore modifying touch action attribute and style
  31270. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31271. */
  31272. doNotHandleTouchAction?: boolean;
  31273. /**
  31274. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31275. */
  31276. useHighPrecisionFloats?: boolean;
  31277. }
  31278. /**
  31279. * The base engine class (root of all engines)
  31280. */
  31281. export class ThinEngine {
  31282. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31283. static ExceptionList: ({
  31284. key: string;
  31285. capture: string;
  31286. captureConstraint: number;
  31287. targets: string[];
  31288. } | {
  31289. key: string;
  31290. capture: null;
  31291. captureConstraint: null;
  31292. targets: string[];
  31293. })[];
  31294. /** @hidden */
  31295. static _TextureLoaders: IInternalTextureLoader[];
  31296. /**
  31297. * Returns the current npm package of the sdk
  31298. */
  31299. static get NpmPackage(): string;
  31300. /**
  31301. * Returns the current version of the framework
  31302. */
  31303. static get Version(): string;
  31304. /**
  31305. * Returns a string describing the current engine
  31306. */
  31307. get description(): string;
  31308. /**
  31309. * Gets or sets the epsilon value used by collision engine
  31310. */
  31311. static CollisionsEpsilon: number;
  31312. /**
  31313. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31314. */
  31315. static get ShadersRepository(): string;
  31316. static set ShadersRepository(value: string);
  31317. /** @hidden */
  31318. _shaderProcessor: IShaderProcessor;
  31319. /**
  31320. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31321. */
  31322. forcePOTTextures: boolean;
  31323. /**
  31324. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31325. */
  31326. isFullscreen: boolean;
  31327. /**
  31328. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31329. */
  31330. cullBackFaces: boolean;
  31331. /**
  31332. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31333. */
  31334. renderEvenInBackground: boolean;
  31335. /**
  31336. * Gets or sets a boolean indicating that cache can be kept between frames
  31337. */
  31338. preventCacheWipeBetweenFrames: boolean;
  31339. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31340. validateShaderPrograms: boolean;
  31341. /**
  31342. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31343. * This can provide greater z depth for distant objects.
  31344. */
  31345. useReverseDepthBuffer: boolean;
  31346. /**
  31347. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31348. */
  31349. disableUniformBuffers: boolean;
  31350. /** @hidden */
  31351. _uniformBuffers: UniformBuffer[];
  31352. /**
  31353. * Gets a boolean indicating that the engine supports uniform buffers
  31354. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31355. */
  31356. get supportsUniformBuffers(): boolean;
  31357. /** @hidden */
  31358. _gl: WebGLRenderingContext;
  31359. /** @hidden */
  31360. _webGLVersion: number;
  31361. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31362. protected _windowIsBackground: boolean;
  31363. protected _creationOptions: EngineOptions;
  31364. protected _highPrecisionShadersAllowed: boolean;
  31365. /** @hidden */
  31366. get _shouldUseHighPrecisionShader(): boolean;
  31367. /**
  31368. * Gets a boolean indicating that only power of 2 textures are supported
  31369. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31370. */
  31371. get needPOTTextures(): boolean;
  31372. /** @hidden */
  31373. _badOS: boolean;
  31374. /** @hidden */
  31375. _badDesktopOS: boolean;
  31376. private _hardwareScalingLevel;
  31377. /** @hidden */
  31378. _caps: EngineCapabilities;
  31379. private _isStencilEnable;
  31380. private _glVersion;
  31381. private _glRenderer;
  31382. private _glVendor;
  31383. /** @hidden */
  31384. _videoTextureSupported: boolean;
  31385. protected _renderingQueueLaunched: boolean;
  31386. protected _activeRenderLoops: (() => void)[];
  31387. /**
  31388. * Observable signaled when a context lost event is raised
  31389. */
  31390. onContextLostObservable: Observable<ThinEngine>;
  31391. /**
  31392. * Observable signaled when a context restored event is raised
  31393. */
  31394. onContextRestoredObservable: Observable<ThinEngine>;
  31395. private _onContextLost;
  31396. private _onContextRestored;
  31397. protected _contextWasLost: boolean;
  31398. /** @hidden */
  31399. _doNotHandleContextLost: boolean;
  31400. /**
  31401. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31402. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31403. */
  31404. get doNotHandleContextLost(): boolean;
  31405. set doNotHandleContextLost(value: boolean);
  31406. /**
  31407. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31408. */
  31409. disableVertexArrayObjects: boolean;
  31410. /** @hidden */
  31411. protected _colorWrite: boolean;
  31412. /** @hidden */
  31413. protected _colorWriteChanged: boolean;
  31414. /** @hidden */
  31415. protected _depthCullingState: DepthCullingState;
  31416. /** @hidden */
  31417. protected _stencilState: StencilState;
  31418. /** @hidden */
  31419. _alphaState: AlphaState;
  31420. /** @hidden */
  31421. _alphaMode: number;
  31422. /** @hidden */
  31423. _alphaEquation: number;
  31424. /** @hidden */
  31425. _internalTexturesCache: InternalTexture[];
  31426. /** @hidden */
  31427. protected _activeChannel: number;
  31428. private _currentTextureChannel;
  31429. /** @hidden */
  31430. protected _boundTexturesCache: {
  31431. [key: string]: Nullable<InternalTexture>;
  31432. };
  31433. /** @hidden */
  31434. protected _currentEffect: Nullable<Effect>;
  31435. /** @hidden */
  31436. protected _currentProgram: Nullable<WebGLProgram>;
  31437. private _compiledEffects;
  31438. private _vertexAttribArraysEnabled;
  31439. /** @hidden */
  31440. protected _cachedViewport: Nullable<IViewportLike>;
  31441. private _cachedVertexArrayObject;
  31442. /** @hidden */
  31443. protected _cachedVertexBuffers: any;
  31444. /** @hidden */
  31445. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31446. /** @hidden */
  31447. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31448. /** @hidden */
  31449. _currentRenderTarget: Nullable<InternalTexture>;
  31450. private _uintIndicesCurrentlySet;
  31451. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31452. /** @hidden */
  31453. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31454. private _currentBufferPointers;
  31455. private _currentInstanceLocations;
  31456. private _currentInstanceBuffers;
  31457. private _textureUnits;
  31458. /** @hidden */
  31459. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31460. /** @hidden */
  31461. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31462. /** @hidden */
  31463. _boundRenderFunction: any;
  31464. private _vaoRecordInProgress;
  31465. private _mustWipeVertexAttributes;
  31466. private _emptyTexture;
  31467. private _emptyCubeTexture;
  31468. private _emptyTexture3D;
  31469. private _emptyTexture2DArray;
  31470. /** @hidden */
  31471. _frameHandler: number;
  31472. private _nextFreeTextureSlots;
  31473. private _maxSimultaneousTextures;
  31474. private _activeRequests;
  31475. /** @hidden */
  31476. _transformTextureUrl: Nullable<(url: string) => string>;
  31477. protected get _supportsHardwareTextureRescaling(): boolean;
  31478. private _framebufferDimensionsObject;
  31479. /**
  31480. * sets the object from which width and height will be taken from when getting render width and height
  31481. * Will fallback to the gl object
  31482. * @param dimensions the framebuffer width and height that will be used.
  31483. */
  31484. set framebufferDimensionsObject(dimensions: Nullable<{
  31485. framebufferWidth: number;
  31486. framebufferHeight: number;
  31487. }>);
  31488. /**
  31489. * Gets the current viewport
  31490. */
  31491. get currentViewport(): Nullable<IViewportLike>;
  31492. /**
  31493. * Gets the default empty texture
  31494. */
  31495. get emptyTexture(): InternalTexture;
  31496. /**
  31497. * Gets the default empty 3D texture
  31498. */
  31499. get emptyTexture3D(): InternalTexture;
  31500. /**
  31501. * Gets the default empty 2D array texture
  31502. */
  31503. get emptyTexture2DArray(): InternalTexture;
  31504. /**
  31505. * Gets the default empty cube texture
  31506. */
  31507. get emptyCubeTexture(): InternalTexture;
  31508. /**
  31509. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31510. */
  31511. readonly premultipliedAlpha: boolean;
  31512. /**
  31513. * Observable event triggered before each texture is initialized
  31514. */
  31515. onBeforeTextureInitObservable: Observable<Texture>;
  31516. /**
  31517. * Creates a new engine
  31518. * @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
  31519. * @param antialias defines enable antialiasing (default: false)
  31520. * @param options defines further options to be sent to the getContext() function
  31521. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31522. */
  31523. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31524. private _rebuildInternalTextures;
  31525. private _rebuildEffects;
  31526. /**
  31527. * Gets a boolean indicating if all created effects are ready
  31528. * @returns true if all effects are ready
  31529. */
  31530. areAllEffectsReady(): boolean;
  31531. protected _rebuildBuffers(): void;
  31532. protected _initGLContext(): void;
  31533. /**
  31534. * Gets version of the current webGL context
  31535. */
  31536. get webGLVersion(): number;
  31537. /**
  31538. * Gets a string idenfifying the name of the class
  31539. * @returns "Engine" string
  31540. */
  31541. getClassName(): string;
  31542. /**
  31543. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31544. */
  31545. get isStencilEnable(): boolean;
  31546. /** @hidden */
  31547. _prepareWorkingCanvas(): void;
  31548. /**
  31549. * Reset the texture cache to empty state
  31550. */
  31551. resetTextureCache(): void;
  31552. /**
  31553. * Gets an object containing information about the current webGL context
  31554. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31555. */
  31556. getGlInfo(): {
  31557. vendor: string;
  31558. renderer: string;
  31559. version: string;
  31560. };
  31561. /**
  31562. * Defines the hardware scaling level.
  31563. * By default the hardware scaling level is computed from the window device ratio.
  31564. * 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.
  31565. * @param level defines the level to use
  31566. */
  31567. setHardwareScalingLevel(level: number): void;
  31568. /**
  31569. * Gets the current hardware scaling level.
  31570. * By default the hardware scaling level is computed from the window device ratio.
  31571. * 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.
  31572. * @returns a number indicating the current hardware scaling level
  31573. */
  31574. getHardwareScalingLevel(): number;
  31575. /**
  31576. * Gets the list of loaded textures
  31577. * @returns an array containing all loaded textures
  31578. */
  31579. getLoadedTexturesCache(): InternalTexture[];
  31580. /**
  31581. * Gets the object containing all engine capabilities
  31582. * @returns the EngineCapabilities object
  31583. */
  31584. getCaps(): EngineCapabilities;
  31585. /**
  31586. * stop executing a render loop function and remove it from the execution array
  31587. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31588. */
  31589. stopRenderLoop(renderFunction?: () => void): void;
  31590. /** @hidden */
  31591. _renderLoop(): void;
  31592. /**
  31593. * Gets the HTML canvas attached with the current webGL context
  31594. * @returns a HTML canvas
  31595. */
  31596. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31597. /**
  31598. * Gets host window
  31599. * @returns the host window object
  31600. */
  31601. getHostWindow(): Nullable<Window>;
  31602. /**
  31603. * Gets the current render width
  31604. * @param useScreen defines if screen size must be used (or the current render target if any)
  31605. * @returns a number defining the current render width
  31606. */
  31607. getRenderWidth(useScreen?: boolean): number;
  31608. /**
  31609. * Gets the current render height
  31610. * @param useScreen defines if screen size must be used (or the current render target if any)
  31611. * @returns a number defining the current render height
  31612. */
  31613. getRenderHeight(useScreen?: boolean): number;
  31614. /**
  31615. * Can be used to override the current requestAnimationFrame requester.
  31616. * @hidden
  31617. */
  31618. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31619. /**
  31620. * Register and execute a render loop. The engine can have more than one render function
  31621. * @param renderFunction defines the function to continuously execute
  31622. */
  31623. runRenderLoop(renderFunction: () => void): void;
  31624. /**
  31625. * Clear the current render buffer or the current render target (if any is set up)
  31626. * @param color defines the color to use
  31627. * @param backBuffer defines if the back buffer must be cleared
  31628. * @param depth defines if the depth buffer must be cleared
  31629. * @param stencil defines if the stencil buffer must be cleared
  31630. */
  31631. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31632. private _viewportCached;
  31633. /** @hidden */
  31634. _viewport(x: number, y: number, width: number, height: number): void;
  31635. /**
  31636. * Set the WebGL's viewport
  31637. * @param viewport defines the viewport element to be used
  31638. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31639. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31640. */
  31641. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31642. /**
  31643. * Begin a new frame
  31644. */
  31645. beginFrame(): void;
  31646. /**
  31647. * Enf the current frame
  31648. */
  31649. endFrame(): void;
  31650. /**
  31651. * Resize the view according to the canvas' size
  31652. */
  31653. resize(): void;
  31654. /**
  31655. * Force a specific size of the canvas
  31656. * @param width defines the new canvas' width
  31657. * @param height defines the new canvas' height
  31658. */
  31659. setSize(width: number, height: number): void;
  31660. /**
  31661. * Binds the frame buffer to the specified texture.
  31662. * @param texture The texture to render to or null for the default canvas
  31663. * @param faceIndex The face of the texture to render to in case of cube texture
  31664. * @param requiredWidth The width of the target to render to
  31665. * @param requiredHeight The height of the target to render to
  31666. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31667. * @param lodLevel defines the lod level to bind to the frame buffer
  31668. * @param layer defines the 2d array index to bind to frame buffer to
  31669. */
  31670. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31671. /** @hidden */
  31672. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31673. /**
  31674. * Unbind the current render target texture from the webGL context
  31675. * @param texture defines the render target texture to unbind
  31676. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31677. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31678. */
  31679. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31680. /**
  31681. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31682. */
  31683. flushFramebuffer(): void;
  31684. /**
  31685. * Unbind the current render target and bind the default framebuffer
  31686. */
  31687. restoreDefaultFramebuffer(): void;
  31688. /** @hidden */
  31689. protected _resetVertexBufferBinding(): void;
  31690. /**
  31691. * Creates a vertex buffer
  31692. * @param data the data for the vertex buffer
  31693. * @returns the new WebGL static buffer
  31694. */
  31695. createVertexBuffer(data: DataArray): DataBuffer;
  31696. private _createVertexBuffer;
  31697. /**
  31698. * Creates a dynamic vertex buffer
  31699. * @param data the data for the dynamic vertex buffer
  31700. * @returns the new WebGL dynamic buffer
  31701. */
  31702. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31703. protected _resetIndexBufferBinding(): void;
  31704. /**
  31705. * Creates a new index buffer
  31706. * @param indices defines the content of the index buffer
  31707. * @param updatable defines if the index buffer must be updatable
  31708. * @returns a new webGL buffer
  31709. */
  31710. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31711. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31712. /**
  31713. * Bind a webGL buffer to the webGL context
  31714. * @param buffer defines the buffer to bind
  31715. */
  31716. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31717. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31718. private bindBuffer;
  31719. /**
  31720. * update the bound buffer with the given data
  31721. * @param data defines the data to update
  31722. */
  31723. updateArrayBuffer(data: Float32Array): void;
  31724. private _vertexAttribPointer;
  31725. /** @hidden */
  31726. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31727. private _bindVertexBuffersAttributes;
  31728. /**
  31729. * Records a vertex array object
  31730. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31731. * @param vertexBuffers defines the list of vertex buffers to store
  31732. * @param indexBuffer defines the index buffer to store
  31733. * @param effect defines the effect to store
  31734. * @returns the new vertex array object
  31735. */
  31736. recordVertexArrayObject(vertexBuffers: {
  31737. [key: string]: VertexBuffer;
  31738. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31739. /**
  31740. * Bind a specific vertex array object
  31741. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31742. * @param vertexArrayObject defines the vertex array object to bind
  31743. * @param indexBuffer defines the index buffer to bind
  31744. */
  31745. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31746. /**
  31747. * Bind webGl buffers directly to the webGL context
  31748. * @param vertexBuffer defines the vertex buffer to bind
  31749. * @param indexBuffer defines the index buffer to bind
  31750. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31751. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31752. * @param effect defines the effect associated with the vertex buffer
  31753. */
  31754. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31755. private _unbindVertexArrayObject;
  31756. /**
  31757. * Bind a list of vertex buffers to the webGL context
  31758. * @param vertexBuffers defines the list of vertex buffers to bind
  31759. * @param indexBuffer defines the index buffer to bind
  31760. * @param effect defines the effect associated with the vertex buffers
  31761. */
  31762. bindBuffers(vertexBuffers: {
  31763. [key: string]: Nullable<VertexBuffer>;
  31764. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31765. /**
  31766. * Unbind all instance attributes
  31767. */
  31768. unbindInstanceAttributes(): void;
  31769. /**
  31770. * Release and free the memory of a vertex array object
  31771. * @param vao defines the vertex array object to delete
  31772. */
  31773. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31774. /** @hidden */
  31775. _releaseBuffer(buffer: DataBuffer): boolean;
  31776. protected _deleteBuffer(buffer: DataBuffer): void;
  31777. /**
  31778. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31779. * @param instancesBuffer defines the webGL buffer to update and bind
  31780. * @param data defines the data to store in the buffer
  31781. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31782. */
  31783. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31784. /**
  31785. * Bind the content of a webGL buffer used with instantiation
  31786. * @param instancesBuffer defines the webGL buffer to bind
  31787. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31788. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31789. */
  31790. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31791. /**
  31792. * Disable the instance attribute corresponding to the name in parameter
  31793. * @param name defines the name of the attribute to disable
  31794. */
  31795. disableInstanceAttributeByName(name: string): void;
  31796. /**
  31797. * Disable the instance attribute corresponding to the location in parameter
  31798. * @param attributeLocation defines the attribute location of the attribute to disable
  31799. */
  31800. disableInstanceAttribute(attributeLocation: number): void;
  31801. /**
  31802. * Disable the attribute corresponding to the location in parameter
  31803. * @param attributeLocation defines the attribute location of the attribute to disable
  31804. */
  31805. disableAttributeByIndex(attributeLocation: number): void;
  31806. /**
  31807. * Send a draw order
  31808. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31809. * @param indexStart defines the starting index
  31810. * @param indexCount defines the number of index to draw
  31811. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31812. */
  31813. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31814. /**
  31815. * Draw a list of points
  31816. * @param verticesStart defines the index of first vertex to draw
  31817. * @param verticesCount defines the count of vertices to draw
  31818. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31819. */
  31820. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31821. /**
  31822. * Draw a list of unindexed primitives
  31823. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31824. * @param verticesStart defines the index of first vertex to draw
  31825. * @param verticesCount defines the count of vertices to draw
  31826. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31827. */
  31828. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31829. /**
  31830. * Draw a list of indexed primitives
  31831. * @param fillMode defines the primitive to use
  31832. * @param indexStart defines the starting index
  31833. * @param indexCount defines the number of index to draw
  31834. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31835. */
  31836. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31837. /**
  31838. * Draw a list of unindexed primitives
  31839. * @param fillMode defines the primitive to use
  31840. * @param verticesStart defines the index of first vertex to draw
  31841. * @param verticesCount defines the count of vertices to draw
  31842. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31843. */
  31844. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31845. private _drawMode;
  31846. /** @hidden */
  31847. protected _reportDrawCall(): void;
  31848. /** @hidden */
  31849. _releaseEffect(effect: Effect): void;
  31850. /** @hidden */
  31851. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31852. /**
  31853. * Create a new effect (used to store vertex/fragment shaders)
  31854. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31855. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31856. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31857. * @param samplers defines an array of string used to represent textures
  31858. * @param defines defines the string containing the defines to use to compile the shaders
  31859. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31860. * @param onCompiled defines a function to call when the effect creation is successful
  31861. * @param onError defines a function to call when the effect creation has failed
  31862. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31863. * @returns the new Effect
  31864. */
  31865. 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;
  31866. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31867. private _compileShader;
  31868. private _compileRawShader;
  31869. /** @hidden */
  31870. _getShaderSource(shader: WebGLShader): Nullable<string>;
  31871. /**
  31872. * Directly creates a webGL program
  31873. * @param pipelineContext defines the pipeline context to attach to
  31874. * @param vertexCode defines the vertex shader code to use
  31875. * @param fragmentCode defines the fragment shader code to use
  31876. * @param context defines the webGL context to use (if not set, the current one will be used)
  31877. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31878. * @returns the new webGL program
  31879. */
  31880. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31881. /**
  31882. * Creates a webGL program
  31883. * @param pipelineContext defines the pipeline context to attach to
  31884. * @param vertexCode defines the vertex shader code to use
  31885. * @param fragmentCode defines the fragment shader code to use
  31886. * @param defines defines the string containing the defines to use to compile the shaders
  31887. * @param context defines the webGL context to use (if not set, the current one will be used)
  31888. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31889. * @returns the new webGL program
  31890. */
  31891. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31892. /**
  31893. * Creates a new pipeline context
  31894. * @returns the new pipeline
  31895. */
  31896. createPipelineContext(): IPipelineContext;
  31897. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31898. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31899. /** @hidden */
  31900. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31901. /** @hidden */
  31902. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31903. /** @hidden */
  31904. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31905. /**
  31906. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31907. * @param pipelineContext defines the pipeline context to use
  31908. * @param uniformsNames defines the list of uniform names
  31909. * @returns an array of webGL uniform locations
  31910. */
  31911. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31912. /**
  31913. * Gets the lsit of active attributes for a given webGL program
  31914. * @param pipelineContext defines the pipeline context to use
  31915. * @param attributesNames defines the list of attribute names to get
  31916. * @returns an array of indices indicating the offset of each attribute
  31917. */
  31918. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31919. /**
  31920. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31921. * @param effect defines the effect to activate
  31922. */
  31923. enableEffect(effect: Nullable<Effect>): void;
  31924. /**
  31925. * Set the value of an uniform to a number (int)
  31926. * @param uniform defines the webGL uniform location where to store the value
  31927. * @param value defines the int number to store
  31928. */
  31929. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31930. /**
  31931. * Set the value of an uniform to an array of int32
  31932. * @param uniform defines the webGL uniform location where to store the value
  31933. * @param array defines the array of int32 to store
  31934. */
  31935. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31936. /**
  31937. * Set the value of an uniform to an array of int32 (stored as vec2)
  31938. * @param uniform defines the webGL uniform location where to store the value
  31939. * @param array defines the array of int32 to store
  31940. */
  31941. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31942. /**
  31943. * Set the value of an uniform to an array of int32 (stored as vec3)
  31944. * @param uniform defines the webGL uniform location where to store the value
  31945. * @param array defines the array of int32 to store
  31946. */
  31947. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31948. /**
  31949. * Set the value of an uniform to an array of int32 (stored as vec4)
  31950. * @param uniform defines the webGL uniform location where to store the value
  31951. * @param array defines the array of int32 to store
  31952. */
  31953. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31954. /**
  31955. * Set the value of an uniform to an array of number
  31956. * @param uniform defines the webGL uniform location where to store the value
  31957. * @param array defines the array of number to store
  31958. */
  31959. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31960. /**
  31961. * Set the value of an uniform to an array of number (stored as vec2)
  31962. * @param uniform defines the webGL uniform location where to store the value
  31963. * @param array defines the array of number to store
  31964. */
  31965. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31966. /**
  31967. * Set the value of an uniform to an array of number (stored as vec3)
  31968. * @param uniform defines the webGL uniform location where to store the value
  31969. * @param array defines the array of number to store
  31970. */
  31971. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31972. /**
  31973. * Set the value of an uniform to an array of number (stored as vec4)
  31974. * @param uniform defines the webGL uniform location where to store the value
  31975. * @param array defines the array of number to store
  31976. */
  31977. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31978. /**
  31979. * Set the value of an uniform to an array of float32 (stored as matrices)
  31980. * @param uniform defines the webGL uniform location where to store the value
  31981. * @param matrices defines the array of float32 to store
  31982. */
  31983. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31984. /**
  31985. * Set the value of an uniform to a matrix (3x3)
  31986. * @param uniform defines the webGL uniform location where to store the value
  31987. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31988. */
  31989. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31990. /**
  31991. * Set the value of an uniform to a matrix (2x2)
  31992. * @param uniform defines the webGL uniform location where to store the value
  31993. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31994. */
  31995. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31996. /**
  31997. * Set the value of an uniform to a number (float)
  31998. * @param uniform defines the webGL uniform location where to store the value
  31999. * @param value defines the float number to store
  32000. */
  32001. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32002. /**
  32003. * Set the value of an uniform to a vec2
  32004. * @param uniform defines the webGL uniform location where to store the value
  32005. * @param x defines the 1st component of the value
  32006. * @param y defines the 2nd component of the value
  32007. */
  32008. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32009. /**
  32010. * Set the value of an uniform to a vec3
  32011. * @param uniform defines the webGL uniform location where to store the value
  32012. * @param x defines the 1st component of the value
  32013. * @param y defines the 2nd component of the value
  32014. * @param z defines the 3rd component of the value
  32015. */
  32016. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32017. /**
  32018. * Set the value of an uniform to a vec4
  32019. * @param uniform defines the webGL uniform location where to store the value
  32020. * @param x defines the 1st component of the value
  32021. * @param y defines the 2nd component of the value
  32022. * @param z defines the 3rd component of the value
  32023. * @param w defines the 4th component of the value
  32024. */
  32025. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32026. /**
  32027. * Apply all cached states (depth, culling, stencil and alpha)
  32028. */
  32029. applyStates(): void;
  32030. /**
  32031. * Enable or disable color writing
  32032. * @param enable defines the state to set
  32033. */
  32034. setColorWrite(enable: boolean): void;
  32035. /**
  32036. * Gets a boolean indicating if color writing is enabled
  32037. * @returns the current color writing state
  32038. */
  32039. getColorWrite(): boolean;
  32040. /**
  32041. * Gets the depth culling state manager
  32042. */
  32043. get depthCullingState(): DepthCullingState;
  32044. /**
  32045. * Gets the alpha state manager
  32046. */
  32047. get alphaState(): AlphaState;
  32048. /**
  32049. * Gets the stencil state manager
  32050. */
  32051. get stencilState(): StencilState;
  32052. /**
  32053. * Clears the list of texture accessible through engine.
  32054. * This can help preventing texture load conflict due to name collision.
  32055. */
  32056. clearInternalTexturesCache(): void;
  32057. /**
  32058. * Force the entire cache to be cleared
  32059. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32060. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32061. */
  32062. wipeCaches(bruteForce?: boolean): void;
  32063. /** @hidden */
  32064. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32065. min: number;
  32066. mag: number;
  32067. };
  32068. /** @hidden */
  32069. _createTexture(): WebGLTexture;
  32070. /**
  32071. * Usually called from Texture.ts.
  32072. * Passed information to create a WebGLTexture
  32073. * @param url defines a value which contains one of the following:
  32074. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32075. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32076. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32077. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32078. * @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)
  32079. * @param scene needed for loading to the correct scene
  32080. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32081. * @param onLoad optional callback to be called upon successful completion
  32082. * @param onError optional callback to be called upon failure
  32083. * @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
  32084. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32085. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32086. * @param forcedExtension defines the extension to use to pick the right loader
  32087. * @param mimeType defines an optional mime type
  32088. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32089. */
  32090. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  32091. /**
  32092. * Loads an image as an HTMLImageElement.
  32093. * @param input url string, ArrayBuffer, or Blob to load
  32094. * @param onLoad callback called when the image successfully loads
  32095. * @param onError callback called when the image fails to load
  32096. * @param offlineProvider offline provider for caching
  32097. * @param mimeType optional mime type
  32098. * @returns the HTMLImageElement of the loaded image
  32099. * @hidden
  32100. */
  32101. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  32102. /**
  32103. * @hidden
  32104. */
  32105. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32106. /**
  32107. * Creates a raw texture
  32108. * @param data defines the data to store in the texture
  32109. * @param width defines the width of the texture
  32110. * @param height defines the height of the texture
  32111. * @param format defines the format of the data
  32112. * @param generateMipMaps defines if the engine should generate the mip levels
  32113. * @param invertY defines if data must be stored with Y axis inverted
  32114. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32115. * @param compression defines the compression used (null by default)
  32116. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32117. * @returns the raw texture inside an InternalTexture
  32118. */
  32119. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32120. /**
  32121. * Creates a new raw cube texture
  32122. * @param data defines the array of data to use to create each face
  32123. * @param size defines the size of the textures
  32124. * @param format defines the format of the data
  32125. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32126. * @param generateMipMaps defines if the engine should generate the mip levels
  32127. * @param invertY defines if data must be stored with Y axis inverted
  32128. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32129. * @param compression defines the compression used (null by default)
  32130. * @returns the cube texture as an InternalTexture
  32131. */
  32132. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32133. /**
  32134. * Creates a new raw 3D texture
  32135. * @param data defines the data used to create the texture
  32136. * @param width defines the width of the texture
  32137. * @param height defines the height of the texture
  32138. * @param depth defines the depth of the texture
  32139. * @param format defines the format of the texture
  32140. * @param generateMipMaps defines if the engine must generate mip levels
  32141. * @param invertY defines if data must be stored with Y axis inverted
  32142. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32143. * @param compression defines the compressed used (can be null)
  32144. * @param textureType defines the compressed used (can be null)
  32145. * @returns a new raw 3D texture (stored in an InternalTexture)
  32146. */
  32147. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32148. /**
  32149. * Creates a new raw 2D array texture
  32150. * @param data defines the data used to create the texture
  32151. * @param width defines the width of the texture
  32152. * @param height defines the height of the texture
  32153. * @param depth defines the number of layers of the texture
  32154. * @param format defines the format of the texture
  32155. * @param generateMipMaps defines if the engine must generate mip levels
  32156. * @param invertY defines if data must be stored with Y axis inverted
  32157. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32158. * @param compression defines the compressed used (can be null)
  32159. * @param textureType defines the compressed used (can be null)
  32160. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32161. */
  32162. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32163. private _unpackFlipYCached;
  32164. /**
  32165. * In case you are sharing the context with other applications, it might
  32166. * be interested to not cache the unpack flip y state to ensure a consistent
  32167. * value would be set.
  32168. */
  32169. enableUnpackFlipYCached: boolean;
  32170. /** @hidden */
  32171. _unpackFlipY(value: boolean): void;
  32172. /** @hidden */
  32173. _getUnpackAlignement(): number;
  32174. private _getTextureTarget;
  32175. /**
  32176. * Update the sampling mode of a given texture
  32177. * @param samplingMode defines the required sampling mode
  32178. * @param texture defines the texture to update
  32179. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32180. */
  32181. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32182. /**
  32183. * Update the sampling mode of a given texture
  32184. * @param texture defines the texture to update
  32185. * @param wrapU defines the texture wrap mode of the u coordinates
  32186. * @param wrapV defines the texture wrap mode of the v coordinates
  32187. * @param wrapR defines the texture wrap mode of the r coordinates
  32188. */
  32189. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32190. /** @hidden */
  32191. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32192. width: number;
  32193. height: number;
  32194. layers?: number;
  32195. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32196. /** @hidden */
  32197. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32198. /** @hidden */
  32199. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32200. /**
  32201. * Update a portion of an internal texture
  32202. * @param texture defines the texture to update
  32203. * @param imageData defines the data to store into the texture
  32204. * @param xOffset defines the x coordinates of the update rectangle
  32205. * @param yOffset defines the y coordinates of the update rectangle
  32206. * @param width defines the width of the update rectangle
  32207. * @param height defines the height of the update rectangle
  32208. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32209. * @param lod defines the lod level to update (0 by default)
  32210. */
  32211. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32212. /** @hidden */
  32213. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32214. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32215. private _prepareWebGLTexture;
  32216. /** @hidden */
  32217. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32218. private _getDepthStencilBuffer;
  32219. /** @hidden */
  32220. _releaseFramebufferObjects(texture: InternalTexture): void;
  32221. /** @hidden */
  32222. _releaseTexture(texture: InternalTexture): void;
  32223. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32224. protected _setProgram(program: WebGLProgram): void;
  32225. protected _boundUniforms: {
  32226. [key: number]: WebGLUniformLocation;
  32227. };
  32228. /**
  32229. * Binds an effect to the webGL context
  32230. * @param effect defines the effect to bind
  32231. */
  32232. bindSamplers(effect: Effect): void;
  32233. private _activateCurrentTexture;
  32234. /** @hidden */
  32235. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32236. /** @hidden */
  32237. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32238. /**
  32239. * Unbind all textures from the webGL context
  32240. */
  32241. unbindAllTextures(): void;
  32242. /**
  32243. * Sets a texture to the according uniform.
  32244. * @param channel The texture channel
  32245. * @param uniform The uniform to set
  32246. * @param texture The texture to apply
  32247. */
  32248. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32249. private _bindSamplerUniformToChannel;
  32250. private _getTextureWrapMode;
  32251. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32252. /**
  32253. * Sets an array of texture to the webGL context
  32254. * @param channel defines the channel where the texture array must be set
  32255. * @param uniform defines the associated uniform location
  32256. * @param textures defines the array of textures to bind
  32257. */
  32258. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32259. /** @hidden */
  32260. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32261. private _setTextureParameterFloat;
  32262. private _setTextureParameterInteger;
  32263. /**
  32264. * Unbind all vertex attributes from the webGL context
  32265. */
  32266. unbindAllAttributes(): void;
  32267. /**
  32268. * 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
  32269. */
  32270. releaseEffects(): void;
  32271. /**
  32272. * Dispose and release all associated resources
  32273. */
  32274. dispose(): void;
  32275. /**
  32276. * Attach a new callback raised when context lost event is fired
  32277. * @param callback defines the callback to call
  32278. */
  32279. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32280. /**
  32281. * Attach a new callback raised when context restored event is fired
  32282. * @param callback defines the callback to call
  32283. */
  32284. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32285. /**
  32286. * Get the current error code of the webGL context
  32287. * @returns the error code
  32288. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32289. */
  32290. getError(): number;
  32291. private _canRenderToFloatFramebuffer;
  32292. private _canRenderToHalfFloatFramebuffer;
  32293. private _canRenderToFramebuffer;
  32294. /** @hidden */
  32295. _getWebGLTextureType(type: number): number;
  32296. /** @hidden */
  32297. _getInternalFormat(format: number): number;
  32298. /** @hidden */
  32299. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32300. /** @hidden */
  32301. _getRGBAMultiSampleBufferFormat(type: number): number;
  32302. /** @hidden */
  32303. _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;
  32304. /**
  32305. * Loads a file from a url
  32306. * @param url url to load
  32307. * @param onSuccess callback called when the file successfully loads
  32308. * @param onProgress callback called while file is loading (if the server supports this mode)
  32309. * @param offlineProvider defines the offline provider for caching
  32310. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32311. * @param onError callback called when the file fails to load
  32312. * @returns a file request object
  32313. * @hidden
  32314. */
  32315. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  32316. /**
  32317. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32318. * @param x defines the x coordinate of the rectangle where pixels must be read
  32319. * @param y defines the y coordinate of the rectangle where pixels must be read
  32320. * @param width defines the width of the rectangle where pixels must be read
  32321. * @param height defines the height of the rectangle where pixels must be read
  32322. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32323. * @returns a Uint8Array containing RGBA colors
  32324. */
  32325. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32326. private static _isSupported;
  32327. /**
  32328. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32329. * @returns true if the engine can be created
  32330. * @ignorenaming
  32331. */
  32332. static isSupported(): boolean;
  32333. /**
  32334. * Find the next highest power of two.
  32335. * @param x Number to start search from.
  32336. * @return Next highest power of two.
  32337. */
  32338. static CeilingPOT(x: number): number;
  32339. /**
  32340. * Find the next lowest power of two.
  32341. * @param x Number to start search from.
  32342. * @return Next lowest power of two.
  32343. */
  32344. static FloorPOT(x: number): number;
  32345. /**
  32346. * Find the nearest power of two.
  32347. * @param x Number to start search from.
  32348. * @return Next nearest power of two.
  32349. */
  32350. static NearestPOT(x: number): number;
  32351. /**
  32352. * Get the closest exponent of two
  32353. * @param value defines the value to approximate
  32354. * @param max defines the maximum value to return
  32355. * @param mode defines how to define the closest value
  32356. * @returns closest exponent of two of the given value
  32357. */
  32358. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32359. /**
  32360. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32361. * @param func - the function to be called
  32362. * @param requester - the object that will request the next frame. Falls back to window.
  32363. * @returns frame number
  32364. */
  32365. static QueueNewFrame(func: () => void, requester?: any): number;
  32366. /**
  32367. * Gets host document
  32368. * @returns the host document object
  32369. */
  32370. getHostDocument(): Nullable<Document>;
  32371. }
  32372. }
  32373. declare module BABYLON {
  32374. /**
  32375. * Class representing spherical harmonics coefficients to the 3rd degree
  32376. */
  32377. export class SphericalHarmonics {
  32378. /**
  32379. * Defines whether or not the harmonics have been prescaled for rendering.
  32380. */
  32381. preScaled: boolean;
  32382. /**
  32383. * The l0,0 coefficients of the spherical harmonics
  32384. */
  32385. l00: Vector3;
  32386. /**
  32387. * The l1,-1 coefficients of the spherical harmonics
  32388. */
  32389. l1_1: Vector3;
  32390. /**
  32391. * The l1,0 coefficients of the spherical harmonics
  32392. */
  32393. l10: Vector3;
  32394. /**
  32395. * The l1,1 coefficients of the spherical harmonics
  32396. */
  32397. l11: Vector3;
  32398. /**
  32399. * The l2,-2 coefficients of the spherical harmonics
  32400. */
  32401. l2_2: Vector3;
  32402. /**
  32403. * The l2,-1 coefficients of the spherical harmonics
  32404. */
  32405. l2_1: Vector3;
  32406. /**
  32407. * The l2,0 coefficients of the spherical harmonics
  32408. */
  32409. l20: Vector3;
  32410. /**
  32411. * The l2,1 coefficients of the spherical harmonics
  32412. */
  32413. l21: Vector3;
  32414. /**
  32415. * The l2,2 coefficients of the spherical harmonics
  32416. */
  32417. l22: Vector3;
  32418. /**
  32419. * Adds a light to the spherical harmonics
  32420. * @param direction the direction of the light
  32421. * @param color the color of the light
  32422. * @param deltaSolidAngle the delta solid angle of the light
  32423. */
  32424. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32425. /**
  32426. * Scales the spherical harmonics by the given amount
  32427. * @param scale the amount to scale
  32428. */
  32429. scaleInPlace(scale: number): void;
  32430. /**
  32431. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32432. *
  32433. * ```
  32434. * E_lm = A_l * L_lm
  32435. * ```
  32436. *
  32437. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32438. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32439. * the scaling factors are given in equation 9.
  32440. */
  32441. convertIncidentRadianceToIrradiance(): void;
  32442. /**
  32443. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32444. *
  32445. * ```
  32446. * L = (1/pi) * E * rho
  32447. * ```
  32448. *
  32449. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32450. */
  32451. convertIrradianceToLambertianRadiance(): void;
  32452. /**
  32453. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32454. * required operations at run time.
  32455. *
  32456. * This is simply done by scaling back the SH with Ylm constants parameter.
  32457. * The trigonometric part being applied by the shader at run time.
  32458. */
  32459. preScaleForRendering(): void;
  32460. /**
  32461. * Constructs a spherical harmonics from an array.
  32462. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32463. * @returns the spherical harmonics
  32464. */
  32465. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32466. /**
  32467. * Gets the spherical harmonics from polynomial
  32468. * @param polynomial the spherical polynomial
  32469. * @returns the spherical harmonics
  32470. */
  32471. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32472. }
  32473. /**
  32474. * Class representing spherical polynomial coefficients to the 3rd degree
  32475. */
  32476. export class SphericalPolynomial {
  32477. private _harmonics;
  32478. /**
  32479. * The spherical harmonics used to create the polynomials.
  32480. */
  32481. get preScaledHarmonics(): SphericalHarmonics;
  32482. /**
  32483. * The x coefficients of the spherical polynomial
  32484. */
  32485. x: Vector3;
  32486. /**
  32487. * The y coefficients of the spherical polynomial
  32488. */
  32489. y: Vector3;
  32490. /**
  32491. * The z coefficients of the spherical polynomial
  32492. */
  32493. z: Vector3;
  32494. /**
  32495. * The xx coefficients of the spherical polynomial
  32496. */
  32497. xx: Vector3;
  32498. /**
  32499. * The yy coefficients of the spherical polynomial
  32500. */
  32501. yy: Vector3;
  32502. /**
  32503. * The zz coefficients of the spherical polynomial
  32504. */
  32505. zz: Vector3;
  32506. /**
  32507. * The xy coefficients of the spherical polynomial
  32508. */
  32509. xy: Vector3;
  32510. /**
  32511. * The yz coefficients of the spherical polynomial
  32512. */
  32513. yz: Vector3;
  32514. /**
  32515. * The zx coefficients of the spherical polynomial
  32516. */
  32517. zx: Vector3;
  32518. /**
  32519. * Adds an ambient color to the spherical polynomial
  32520. * @param color the color to add
  32521. */
  32522. addAmbient(color: Color3): void;
  32523. /**
  32524. * Scales the spherical polynomial by the given amount
  32525. * @param scale the amount to scale
  32526. */
  32527. scaleInPlace(scale: number): void;
  32528. /**
  32529. * Gets the spherical polynomial from harmonics
  32530. * @param harmonics the spherical harmonics
  32531. * @returns the spherical polynomial
  32532. */
  32533. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32534. /**
  32535. * Constructs a spherical polynomial from an array.
  32536. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32537. * @returns the spherical polynomial
  32538. */
  32539. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32540. }
  32541. }
  32542. declare module BABYLON {
  32543. /**
  32544. * Defines the source of the internal texture
  32545. */
  32546. export enum InternalTextureSource {
  32547. /**
  32548. * The source of the texture data is unknown
  32549. */
  32550. Unknown = 0,
  32551. /**
  32552. * Texture data comes from an URL
  32553. */
  32554. Url = 1,
  32555. /**
  32556. * Texture data is only used for temporary storage
  32557. */
  32558. Temp = 2,
  32559. /**
  32560. * Texture data comes from raw data (ArrayBuffer)
  32561. */
  32562. Raw = 3,
  32563. /**
  32564. * Texture content is dynamic (video or dynamic texture)
  32565. */
  32566. Dynamic = 4,
  32567. /**
  32568. * Texture content is generated by rendering to it
  32569. */
  32570. RenderTarget = 5,
  32571. /**
  32572. * Texture content is part of a multi render target process
  32573. */
  32574. MultiRenderTarget = 6,
  32575. /**
  32576. * Texture data comes from a cube data file
  32577. */
  32578. Cube = 7,
  32579. /**
  32580. * Texture data comes from a raw cube data
  32581. */
  32582. CubeRaw = 8,
  32583. /**
  32584. * Texture data come from a prefiltered cube data file
  32585. */
  32586. CubePrefiltered = 9,
  32587. /**
  32588. * Texture content is raw 3D data
  32589. */
  32590. Raw3D = 10,
  32591. /**
  32592. * Texture content is raw 2D array data
  32593. */
  32594. Raw2DArray = 11,
  32595. /**
  32596. * Texture content is a depth texture
  32597. */
  32598. Depth = 12,
  32599. /**
  32600. * Texture data comes from a raw cube data encoded with RGBD
  32601. */
  32602. CubeRawRGBD = 13
  32603. }
  32604. /**
  32605. * Class used to store data associated with WebGL texture data for the engine
  32606. * This class should not be used directly
  32607. */
  32608. export class InternalTexture {
  32609. /** @hidden */
  32610. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32611. /**
  32612. * Defines if the texture is ready
  32613. */
  32614. isReady: boolean;
  32615. /**
  32616. * Defines if the texture is a cube texture
  32617. */
  32618. isCube: boolean;
  32619. /**
  32620. * Defines if the texture contains 3D data
  32621. */
  32622. is3D: boolean;
  32623. /**
  32624. * Defines if the texture contains 2D array data
  32625. */
  32626. is2DArray: boolean;
  32627. /**
  32628. * Defines if the texture contains multiview data
  32629. */
  32630. isMultiview: boolean;
  32631. /**
  32632. * Gets the URL used to load this texture
  32633. */
  32634. url: string;
  32635. /**
  32636. * Gets the sampling mode of the texture
  32637. */
  32638. samplingMode: number;
  32639. /**
  32640. * Gets a boolean indicating if the texture needs mipmaps generation
  32641. */
  32642. generateMipMaps: boolean;
  32643. /**
  32644. * Gets the number of samples used by the texture (WebGL2+ only)
  32645. */
  32646. samples: number;
  32647. /**
  32648. * Gets the type of the texture (int, float...)
  32649. */
  32650. type: number;
  32651. /**
  32652. * Gets the format of the texture (RGB, RGBA...)
  32653. */
  32654. format: number;
  32655. /**
  32656. * Observable called when the texture is loaded
  32657. */
  32658. onLoadedObservable: Observable<InternalTexture>;
  32659. /**
  32660. * Gets the width of the texture
  32661. */
  32662. width: number;
  32663. /**
  32664. * Gets the height of the texture
  32665. */
  32666. height: number;
  32667. /**
  32668. * Gets the depth of the texture
  32669. */
  32670. depth: number;
  32671. /**
  32672. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32673. */
  32674. baseWidth: number;
  32675. /**
  32676. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32677. */
  32678. baseHeight: number;
  32679. /**
  32680. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32681. */
  32682. baseDepth: number;
  32683. /**
  32684. * Gets a boolean indicating if the texture is inverted on Y axis
  32685. */
  32686. invertY: boolean;
  32687. /** @hidden */
  32688. _invertVScale: boolean;
  32689. /** @hidden */
  32690. _associatedChannel: number;
  32691. /** @hidden */
  32692. _source: InternalTextureSource;
  32693. /** @hidden */
  32694. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32695. /** @hidden */
  32696. _bufferView: Nullable<ArrayBufferView>;
  32697. /** @hidden */
  32698. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32699. /** @hidden */
  32700. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32701. /** @hidden */
  32702. _size: number;
  32703. /** @hidden */
  32704. _extension: string;
  32705. /** @hidden */
  32706. _files: Nullable<string[]>;
  32707. /** @hidden */
  32708. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32709. /** @hidden */
  32710. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32711. /** @hidden */
  32712. _framebuffer: Nullable<WebGLFramebuffer>;
  32713. /** @hidden */
  32714. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32715. /** @hidden */
  32716. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32717. /** @hidden */
  32718. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32719. /** @hidden */
  32720. _attachments: Nullable<number[]>;
  32721. /** @hidden */
  32722. _cachedCoordinatesMode: Nullable<number>;
  32723. /** @hidden */
  32724. _cachedWrapU: Nullable<number>;
  32725. /** @hidden */
  32726. _cachedWrapV: Nullable<number>;
  32727. /** @hidden */
  32728. _cachedWrapR: Nullable<number>;
  32729. /** @hidden */
  32730. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32731. /** @hidden */
  32732. _isDisabled: boolean;
  32733. /** @hidden */
  32734. _compression: Nullable<string>;
  32735. /** @hidden */
  32736. _generateStencilBuffer: boolean;
  32737. /** @hidden */
  32738. _generateDepthBuffer: boolean;
  32739. /** @hidden */
  32740. _comparisonFunction: number;
  32741. /** @hidden */
  32742. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32743. /** @hidden */
  32744. _lodGenerationScale: number;
  32745. /** @hidden */
  32746. _lodGenerationOffset: number;
  32747. /** @hidden */
  32748. _depthStencilTexture: Nullable<InternalTexture>;
  32749. /** @hidden */
  32750. _colorTextureArray: Nullable<WebGLTexture>;
  32751. /** @hidden */
  32752. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32753. /** @hidden */
  32754. _lodTextureHigh: Nullable<BaseTexture>;
  32755. /** @hidden */
  32756. _lodTextureMid: Nullable<BaseTexture>;
  32757. /** @hidden */
  32758. _lodTextureLow: Nullable<BaseTexture>;
  32759. /** @hidden */
  32760. _isRGBD: boolean;
  32761. /** @hidden */
  32762. _linearSpecularLOD: boolean;
  32763. /** @hidden */
  32764. _irradianceTexture: Nullable<BaseTexture>;
  32765. /** @hidden */
  32766. _webGLTexture: Nullable<WebGLTexture>;
  32767. /** @hidden */
  32768. _references: number;
  32769. private _engine;
  32770. /**
  32771. * Gets the Engine the texture belongs to.
  32772. * @returns The babylon engine
  32773. */
  32774. getEngine(): ThinEngine;
  32775. /**
  32776. * Gets the data source type of the texture
  32777. */
  32778. get source(): InternalTextureSource;
  32779. /**
  32780. * Creates a new InternalTexture
  32781. * @param engine defines the engine to use
  32782. * @param source defines the type of data that will be used
  32783. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32784. */
  32785. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32786. /**
  32787. * Increments the number of references (ie. the number of Texture that point to it)
  32788. */
  32789. incrementReferences(): void;
  32790. /**
  32791. * Change the size of the texture (not the size of the content)
  32792. * @param width defines the new width
  32793. * @param height defines the new height
  32794. * @param depth defines the new depth (1 by default)
  32795. */
  32796. updateSize(width: int, height: int, depth?: int): void;
  32797. /** @hidden */
  32798. _rebuild(): void;
  32799. /** @hidden */
  32800. _swapAndDie(target: InternalTexture): void;
  32801. /**
  32802. * Dispose the current allocated resources
  32803. */
  32804. dispose(): void;
  32805. }
  32806. }
  32807. declare module BABYLON {
  32808. /**
  32809. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32810. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32811. */
  32812. export class Analyser {
  32813. /**
  32814. * Gets or sets the smoothing
  32815. * @ignorenaming
  32816. */
  32817. SMOOTHING: number;
  32818. /**
  32819. * Gets or sets the FFT table size
  32820. * @ignorenaming
  32821. */
  32822. FFT_SIZE: number;
  32823. /**
  32824. * Gets or sets the bar graph amplitude
  32825. * @ignorenaming
  32826. */
  32827. BARGRAPHAMPLITUDE: number;
  32828. /**
  32829. * Gets or sets the position of the debug canvas
  32830. * @ignorenaming
  32831. */
  32832. DEBUGCANVASPOS: {
  32833. x: number;
  32834. y: number;
  32835. };
  32836. /**
  32837. * Gets or sets the debug canvas size
  32838. * @ignorenaming
  32839. */
  32840. DEBUGCANVASSIZE: {
  32841. width: number;
  32842. height: number;
  32843. };
  32844. private _byteFreqs;
  32845. private _byteTime;
  32846. private _floatFreqs;
  32847. private _webAudioAnalyser;
  32848. private _debugCanvas;
  32849. private _debugCanvasContext;
  32850. private _scene;
  32851. private _registerFunc;
  32852. private _audioEngine;
  32853. /**
  32854. * Creates a new analyser
  32855. * @param scene defines hosting scene
  32856. */
  32857. constructor(scene: Scene);
  32858. /**
  32859. * Get the number of data values you will have to play with for the visualization
  32860. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32861. * @returns a number
  32862. */
  32863. getFrequencyBinCount(): number;
  32864. /**
  32865. * Gets the current frequency data as a byte array
  32866. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32867. * @returns a Uint8Array
  32868. */
  32869. getByteFrequencyData(): Uint8Array;
  32870. /**
  32871. * Gets the current waveform as a byte array
  32872. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32873. * @returns a Uint8Array
  32874. */
  32875. getByteTimeDomainData(): Uint8Array;
  32876. /**
  32877. * Gets the current frequency data as a float array
  32878. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32879. * @returns a Float32Array
  32880. */
  32881. getFloatFrequencyData(): Float32Array;
  32882. /**
  32883. * Renders the debug canvas
  32884. */
  32885. drawDebugCanvas(): void;
  32886. /**
  32887. * Stops rendering the debug canvas and removes it
  32888. */
  32889. stopDebugCanvas(): void;
  32890. /**
  32891. * Connects two audio nodes
  32892. * @param inputAudioNode defines first node to connect
  32893. * @param outputAudioNode defines second node to connect
  32894. */
  32895. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32896. /**
  32897. * Releases all associated resources
  32898. */
  32899. dispose(): void;
  32900. }
  32901. }
  32902. declare module BABYLON {
  32903. /**
  32904. * This represents an audio engine and it is responsible
  32905. * to play, synchronize and analyse sounds throughout the application.
  32906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32907. */
  32908. export interface IAudioEngine extends IDisposable {
  32909. /**
  32910. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32911. */
  32912. readonly canUseWebAudio: boolean;
  32913. /**
  32914. * Gets the current AudioContext if available.
  32915. */
  32916. readonly audioContext: Nullable<AudioContext>;
  32917. /**
  32918. * The master gain node defines the global audio volume of your audio engine.
  32919. */
  32920. readonly masterGain: GainNode;
  32921. /**
  32922. * Gets whether or not mp3 are supported by your browser.
  32923. */
  32924. readonly isMP3supported: boolean;
  32925. /**
  32926. * Gets whether or not ogg are supported by your browser.
  32927. */
  32928. readonly isOGGsupported: boolean;
  32929. /**
  32930. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32931. * @ignoreNaming
  32932. */
  32933. WarnedWebAudioUnsupported: boolean;
  32934. /**
  32935. * Defines if the audio engine relies on a custom unlocked button.
  32936. * In this case, the embedded button will not be displayed.
  32937. */
  32938. useCustomUnlockedButton: boolean;
  32939. /**
  32940. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32941. */
  32942. readonly unlocked: boolean;
  32943. /**
  32944. * Event raised when audio has been unlocked on the browser.
  32945. */
  32946. onAudioUnlockedObservable: Observable<AudioEngine>;
  32947. /**
  32948. * Event raised when audio has been locked on the browser.
  32949. */
  32950. onAudioLockedObservable: Observable<AudioEngine>;
  32951. /**
  32952. * Flags the audio engine in Locked state.
  32953. * This happens due to new browser policies preventing audio to autoplay.
  32954. */
  32955. lock(): void;
  32956. /**
  32957. * Unlocks the audio engine once a user action has been done on the dom.
  32958. * This is helpful to resume play once browser policies have been satisfied.
  32959. */
  32960. unlock(): void;
  32961. /**
  32962. * Gets the global volume sets on the master gain.
  32963. * @returns the global volume if set or -1 otherwise
  32964. */
  32965. getGlobalVolume(): number;
  32966. /**
  32967. * Sets the global volume of your experience (sets on the master gain).
  32968. * @param newVolume Defines the new global volume of the application
  32969. */
  32970. setGlobalVolume(newVolume: number): void;
  32971. /**
  32972. * Connect the audio engine to an audio analyser allowing some amazing
  32973. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32975. * @param analyser The analyser to connect to the engine
  32976. */
  32977. connectToAnalyser(analyser: Analyser): void;
  32978. }
  32979. /**
  32980. * This represents the default audio engine used in babylon.
  32981. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32982. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32983. */
  32984. export class AudioEngine implements IAudioEngine {
  32985. private _audioContext;
  32986. private _audioContextInitialized;
  32987. private _muteButton;
  32988. private _hostElement;
  32989. /**
  32990. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32991. */
  32992. canUseWebAudio: boolean;
  32993. /**
  32994. * The master gain node defines the global audio volume of your audio engine.
  32995. */
  32996. masterGain: GainNode;
  32997. /**
  32998. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32999. * @ignoreNaming
  33000. */
  33001. WarnedWebAudioUnsupported: boolean;
  33002. /**
  33003. * Gets whether or not mp3 are supported by your browser.
  33004. */
  33005. isMP3supported: boolean;
  33006. /**
  33007. * Gets whether or not ogg are supported by your browser.
  33008. */
  33009. isOGGsupported: boolean;
  33010. /**
  33011. * Gets whether audio has been unlocked on the device.
  33012. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33013. * a user interaction has happened.
  33014. */
  33015. unlocked: boolean;
  33016. /**
  33017. * Defines if the audio engine relies on a custom unlocked button.
  33018. * In this case, the embedded button will not be displayed.
  33019. */
  33020. useCustomUnlockedButton: boolean;
  33021. /**
  33022. * Event raised when audio has been unlocked on the browser.
  33023. */
  33024. onAudioUnlockedObservable: Observable<AudioEngine>;
  33025. /**
  33026. * Event raised when audio has been locked on the browser.
  33027. */
  33028. onAudioLockedObservable: Observable<AudioEngine>;
  33029. /**
  33030. * Gets the current AudioContext if available.
  33031. */
  33032. get audioContext(): Nullable<AudioContext>;
  33033. private _connectedAnalyser;
  33034. /**
  33035. * Instantiates a new audio engine.
  33036. *
  33037. * There should be only one per page as some browsers restrict the number
  33038. * of audio contexts you can create.
  33039. * @param hostElement defines the host element where to display the mute icon if necessary
  33040. */
  33041. constructor(hostElement?: Nullable<HTMLElement>);
  33042. /**
  33043. * Flags the audio engine in Locked state.
  33044. * This happens due to new browser policies preventing audio to autoplay.
  33045. */
  33046. lock(): void;
  33047. /**
  33048. * Unlocks the audio engine once a user action has been done on the dom.
  33049. * This is helpful to resume play once browser policies have been satisfied.
  33050. */
  33051. unlock(): void;
  33052. private _resumeAudioContext;
  33053. private _initializeAudioContext;
  33054. private _tryToRun;
  33055. private _triggerRunningState;
  33056. private _triggerSuspendedState;
  33057. private _displayMuteButton;
  33058. private _moveButtonToTopLeft;
  33059. private _onResize;
  33060. private _hideMuteButton;
  33061. /**
  33062. * Destroy and release the resources associated with the audio ccontext.
  33063. */
  33064. dispose(): void;
  33065. /**
  33066. * Gets the global volume sets on the master gain.
  33067. * @returns the global volume if set or -1 otherwise
  33068. */
  33069. getGlobalVolume(): number;
  33070. /**
  33071. * Sets the global volume of your experience (sets on the master gain).
  33072. * @param newVolume Defines the new global volume of the application
  33073. */
  33074. setGlobalVolume(newVolume: number): void;
  33075. /**
  33076. * Connect the audio engine to an audio analyser allowing some amazing
  33077. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33078. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33079. * @param analyser The analyser to connect to the engine
  33080. */
  33081. connectToAnalyser(analyser: Analyser): void;
  33082. }
  33083. }
  33084. declare module BABYLON {
  33085. /**
  33086. * Interface used to present a loading screen while loading a scene
  33087. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33088. */
  33089. export interface ILoadingScreen {
  33090. /**
  33091. * Function called to display the loading screen
  33092. */
  33093. displayLoadingUI: () => void;
  33094. /**
  33095. * Function called to hide the loading screen
  33096. */
  33097. hideLoadingUI: () => void;
  33098. /**
  33099. * Gets or sets the color to use for the background
  33100. */
  33101. loadingUIBackgroundColor: string;
  33102. /**
  33103. * Gets or sets the text to display while loading
  33104. */
  33105. loadingUIText: string;
  33106. }
  33107. /**
  33108. * Class used for the default loading screen
  33109. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33110. */
  33111. export class DefaultLoadingScreen implements ILoadingScreen {
  33112. private _renderingCanvas;
  33113. private _loadingText;
  33114. private _loadingDivBackgroundColor;
  33115. private _loadingDiv;
  33116. private _loadingTextDiv;
  33117. /** Gets or sets the logo url to use for the default loading screen */
  33118. static DefaultLogoUrl: string;
  33119. /** Gets or sets the spinner url to use for the default loading screen */
  33120. static DefaultSpinnerUrl: string;
  33121. /**
  33122. * Creates a new default loading screen
  33123. * @param _renderingCanvas defines the canvas used to render the scene
  33124. * @param _loadingText defines the default text to display
  33125. * @param _loadingDivBackgroundColor defines the default background color
  33126. */
  33127. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33128. /**
  33129. * Function called to display the loading screen
  33130. */
  33131. displayLoadingUI(): void;
  33132. /**
  33133. * Function called to hide the loading screen
  33134. */
  33135. hideLoadingUI(): void;
  33136. /**
  33137. * Gets or sets the text to display while loading
  33138. */
  33139. set loadingUIText(text: string);
  33140. get loadingUIText(): string;
  33141. /**
  33142. * Gets or sets the color to use for the background
  33143. */
  33144. get loadingUIBackgroundColor(): string;
  33145. set loadingUIBackgroundColor(color: string);
  33146. private _resizeLoadingUI;
  33147. }
  33148. }
  33149. declare module BABYLON {
  33150. /**
  33151. * Interface for any object that can request an animation frame
  33152. */
  33153. export interface ICustomAnimationFrameRequester {
  33154. /**
  33155. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33156. */
  33157. renderFunction?: Function;
  33158. /**
  33159. * Called to request the next frame to render to
  33160. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33161. */
  33162. requestAnimationFrame: Function;
  33163. /**
  33164. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33165. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33166. */
  33167. requestID?: number;
  33168. }
  33169. }
  33170. declare module BABYLON {
  33171. /**
  33172. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33173. */
  33174. export class PerformanceMonitor {
  33175. private _enabled;
  33176. private _rollingFrameTime;
  33177. private _lastFrameTimeMs;
  33178. /**
  33179. * constructor
  33180. * @param frameSampleSize The number of samples required to saturate the sliding window
  33181. */
  33182. constructor(frameSampleSize?: number);
  33183. /**
  33184. * Samples current frame
  33185. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33186. */
  33187. sampleFrame(timeMs?: number): void;
  33188. /**
  33189. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33190. */
  33191. get averageFrameTime(): number;
  33192. /**
  33193. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33194. */
  33195. get averageFrameTimeVariance(): number;
  33196. /**
  33197. * Returns the frame time of the most recent frame
  33198. */
  33199. get instantaneousFrameTime(): number;
  33200. /**
  33201. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33202. */
  33203. get averageFPS(): number;
  33204. /**
  33205. * Returns the average framerate in frames per second using the most recent frame time
  33206. */
  33207. get instantaneousFPS(): number;
  33208. /**
  33209. * Returns true if enough samples have been taken to completely fill the sliding window
  33210. */
  33211. get isSaturated(): boolean;
  33212. /**
  33213. * Enables contributions to the sliding window sample set
  33214. */
  33215. enable(): void;
  33216. /**
  33217. * Disables contributions to the sliding window sample set
  33218. * Samples will not be interpolated over the disabled period
  33219. */
  33220. disable(): void;
  33221. /**
  33222. * Returns true if sampling is enabled
  33223. */
  33224. get isEnabled(): boolean;
  33225. /**
  33226. * Resets performance monitor
  33227. */
  33228. reset(): void;
  33229. }
  33230. /**
  33231. * RollingAverage
  33232. *
  33233. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33234. */
  33235. export class RollingAverage {
  33236. /**
  33237. * Current average
  33238. */
  33239. average: number;
  33240. /**
  33241. * Current variance
  33242. */
  33243. variance: number;
  33244. protected _samples: Array<number>;
  33245. protected _sampleCount: number;
  33246. protected _pos: number;
  33247. protected _m2: number;
  33248. /**
  33249. * constructor
  33250. * @param length The number of samples required to saturate the sliding window
  33251. */
  33252. constructor(length: number);
  33253. /**
  33254. * Adds a sample to the sample set
  33255. * @param v The sample value
  33256. */
  33257. add(v: number): void;
  33258. /**
  33259. * Returns previously added values or null if outside of history or outside the sliding window domain
  33260. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33261. * @return Value previously recorded with add() or null if outside of range
  33262. */
  33263. history(i: number): number;
  33264. /**
  33265. * Returns true if enough samples have been taken to completely fill the sliding window
  33266. * @return true if sample-set saturated
  33267. */
  33268. isSaturated(): boolean;
  33269. /**
  33270. * Resets the rolling average (equivalent to 0 samples taken so far)
  33271. */
  33272. reset(): void;
  33273. /**
  33274. * Wraps a value around the sample range boundaries
  33275. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33276. * @return Wrapped position in sample range
  33277. */
  33278. protected _wrapPosition(i: number): number;
  33279. }
  33280. }
  33281. declare module BABYLON {
  33282. /**
  33283. * This class is used to track a performance counter which is number based.
  33284. * The user has access to many properties which give statistics of different nature.
  33285. *
  33286. * The implementer can track two kinds of Performance Counter: time and count.
  33287. * 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.
  33288. * 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.
  33289. */
  33290. export class PerfCounter {
  33291. /**
  33292. * Gets or sets a global boolean to turn on and off all the counters
  33293. */
  33294. static Enabled: boolean;
  33295. /**
  33296. * Returns the smallest value ever
  33297. */
  33298. get min(): number;
  33299. /**
  33300. * Returns the biggest value ever
  33301. */
  33302. get max(): number;
  33303. /**
  33304. * Returns the average value since the performance counter is running
  33305. */
  33306. get average(): number;
  33307. /**
  33308. * Returns the average value of the last second the counter was monitored
  33309. */
  33310. get lastSecAverage(): number;
  33311. /**
  33312. * Returns the current value
  33313. */
  33314. get current(): number;
  33315. /**
  33316. * Gets the accumulated total
  33317. */
  33318. get total(): number;
  33319. /**
  33320. * Gets the total value count
  33321. */
  33322. get count(): number;
  33323. /**
  33324. * Creates a new counter
  33325. */
  33326. constructor();
  33327. /**
  33328. * Call this method to start monitoring a new frame.
  33329. * 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.
  33330. */
  33331. fetchNewFrame(): void;
  33332. /**
  33333. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33334. * @param newCount the count value to add to the monitored count
  33335. * @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.
  33336. */
  33337. addCount(newCount: number, fetchResult: boolean): void;
  33338. /**
  33339. * Start monitoring this performance counter
  33340. */
  33341. beginMonitoring(): void;
  33342. /**
  33343. * Compute the time lapsed since the previous beginMonitoring() call.
  33344. * @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
  33345. */
  33346. endMonitoring(newFrame?: boolean): void;
  33347. private _fetchResult;
  33348. private _startMonitoringTime;
  33349. private _min;
  33350. private _max;
  33351. private _average;
  33352. private _current;
  33353. private _totalValueCount;
  33354. private _totalAccumulated;
  33355. private _lastSecAverage;
  33356. private _lastSecAccumulated;
  33357. private _lastSecTime;
  33358. private _lastSecValueCount;
  33359. }
  33360. }
  33361. declare module BABYLON {
  33362. interface ThinEngine {
  33363. /**
  33364. * Sets alpha constants used by some alpha blending modes
  33365. * @param r defines the red component
  33366. * @param g defines the green component
  33367. * @param b defines the blue component
  33368. * @param a defines the alpha component
  33369. */
  33370. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33371. /**
  33372. * Sets the current alpha mode
  33373. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33374. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33375. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33376. */
  33377. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33378. /**
  33379. * Gets the current alpha mode
  33380. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33381. * @returns the current alpha mode
  33382. */
  33383. getAlphaMode(): number;
  33384. /**
  33385. * Sets the current alpha equation
  33386. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33387. */
  33388. setAlphaEquation(equation: number): void;
  33389. /**
  33390. * Gets the current alpha equation.
  33391. * @returns the current alpha equation
  33392. */
  33393. getAlphaEquation(): number;
  33394. }
  33395. }
  33396. declare module BABYLON {
  33397. /**
  33398. * Defines the interface used by display changed events
  33399. */
  33400. export interface IDisplayChangedEventArgs {
  33401. /** Gets the vrDisplay object (if any) */
  33402. vrDisplay: Nullable<any>;
  33403. /** Gets a boolean indicating if webVR is supported */
  33404. vrSupported: boolean;
  33405. }
  33406. /**
  33407. * Defines the interface used by objects containing a viewport (like a camera)
  33408. */
  33409. interface IViewportOwnerLike {
  33410. /**
  33411. * Gets or sets the viewport
  33412. */
  33413. viewport: IViewportLike;
  33414. }
  33415. /**
  33416. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33417. */
  33418. export class Engine extends ThinEngine {
  33419. /** Defines that alpha blending is disabled */
  33420. static readonly ALPHA_DISABLE: number;
  33421. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33422. static readonly ALPHA_ADD: number;
  33423. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33424. static readonly ALPHA_COMBINE: number;
  33425. /** Defines that alpha blending to DEST - SRC * DEST */
  33426. static readonly ALPHA_SUBTRACT: number;
  33427. /** Defines that alpha blending to SRC * DEST */
  33428. static readonly ALPHA_MULTIPLY: number;
  33429. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33430. static readonly ALPHA_MAXIMIZED: number;
  33431. /** Defines that alpha blending to SRC + DEST */
  33432. static readonly ALPHA_ONEONE: number;
  33433. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33434. static readonly ALPHA_PREMULTIPLIED: number;
  33435. /**
  33436. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33437. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33438. */
  33439. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33440. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33441. static readonly ALPHA_INTERPOLATE: number;
  33442. /**
  33443. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33444. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33445. */
  33446. static readonly ALPHA_SCREENMODE: number;
  33447. /** Defines that the ressource is not delayed*/
  33448. static readonly DELAYLOADSTATE_NONE: number;
  33449. /** Defines that the ressource was successfully delay loaded */
  33450. static readonly DELAYLOADSTATE_LOADED: number;
  33451. /** Defines that the ressource is currently delay loading */
  33452. static readonly DELAYLOADSTATE_LOADING: number;
  33453. /** Defines that the ressource is delayed and has not started loading */
  33454. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33455. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33456. static readonly NEVER: number;
  33457. /** 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 */
  33458. static readonly ALWAYS: number;
  33459. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33460. static readonly LESS: number;
  33461. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33462. static readonly EQUAL: number;
  33463. /** 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 */
  33464. static readonly LEQUAL: number;
  33465. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33466. static readonly GREATER: number;
  33467. /** 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 */
  33468. static readonly GEQUAL: number;
  33469. /** 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 */
  33470. static readonly NOTEQUAL: number;
  33471. /** Passed to stencilOperation to specify that stencil value must be kept */
  33472. static readonly KEEP: number;
  33473. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33474. static readonly REPLACE: number;
  33475. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33476. static readonly INCR: number;
  33477. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33478. static readonly DECR: number;
  33479. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33480. static readonly INVERT: number;
  33481. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33482. static readonly INCR_WRAP: number;
  33483. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33484. static readonly DECR_WRAP: number;
  33485. /** Texture is not repeating outside of 0..1 UVs */
  33486. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33487. /** Texture is repeating outside of 0..1 UVs */
  33488. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33489. /** Texture is repeating and mirrored */
  33490. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33491. /** ALPHA */
  33492. static readonly TEXTUREFORMAT_ALPHA: number;
  33493. /** LUMINANCE */
  33494. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33495. /** LUMINANCE_ALPHA */
  33496. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33497. /** RGB */
  33498. static readonly TEXTUREFORMAT_RGB: number;
  33499. /** RGBA */
  33500. static readonly TEXTUREFORMAT_RGBA: number;
  33501. /** RED */
  33502. static readonly TEXTUREFORMAT_RED: number;
  33503. /** RED (2nd reference) */
  33504. static readonly TEXTUREFORMAT_R: number;
  33505. /** RG */
  33506. static readonly TEXTUREFORMAT_RG: number;
  33507. /** RED_INTEGER */
  33508. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33509. /** RED_INTEGER (2nd reference) */
  33510. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33511. /** RG_INTEGER */
  33512. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33513. /** RGB_INTEGER */
  33514. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33515. /** RGBA_INTEGER */
  33516. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33517. /** UNSIGNED_BYTE */
  33518. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33519. /** UNSIGNED_BYTE (2nd reference) */
  33520. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33521. /** FLOAT */
  33522. static readonly TEXTURETYPE_FLOAT: number;
  33523. /** HALF_FLOAT */
  33524. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33525. /** BYTE */
  33526. static readonly TEXTURETYPE_BYTE: number;
  33527. /** SHORT */
  33528. static readonly TEXTURETYPE_SHORT: number;
  33529. /** UNSIGNED_SHORT */
  33530. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33531. /** INT */
  33532. static readonly TEXTURETYPE_INT: number;
  33533. /** UNSIGNED_INT */
  33534. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33535. /** UNSIGNED_SHORT_4_4_4_4 */
  33536. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33537. /** UNSIGNED_SHORT_5_5_5_1 */
  33538. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33539. /** UNSIGNED_SHORT_5_6_5 */
  33540. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33541. /** UNSIGNED_INT_2_10_10_10_REV */
  33542. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33543. /** UNSIGNED_INT_24_8 */
  33544. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33545. /** UNSIGNED_INT_10F_11F_11F_REV */
  33546. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33547. /** UNSIGNED_INT_5_9_9_9_REV */
  33548. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33549. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33550. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33551. /** nearest is mag = nearest and min = nearest and mip = linear */
  33552. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33553. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33554. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33555. /** Trilinear is mag = linear and min = linear and mip = linear */
  33556. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33557. /** nearest is mag = nearest and min = nearest and mip = linear */
  33558. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33559. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33560. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33561. /** Trilinear is mag = linear and min = linear and mip = linear */
  33562. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33563. /** mag = nearest and min = nearest and mip = nearest */
  33564. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33565. /** mag = nearest and min = linear and mip = nearest */
  33566. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33567. /** mag = nearest and min = linear and mip = linear */
  33568. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33569. /** mag = nearest and min = linear and mip = none */
  33570. static readonly TEXTURE_NEAREST_LINEAR: number;
  33571. /** mag = nearest and min = nearest and mip = none */
  33572. static readonly TEXTURE_NEAREST_NEAREST: number;
  33573. /** mag = linear and min = nearest and mip = nearest */
  33574. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33575. /** mag = linear and min = nearest and mip = linear */
  33576. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33577. /** mag = linear and min = linear and mip = none */
  33578. static readonly TEXTURE_LINEAR_LINEAR: number;
  33579. /** mag = linear and min = nearest and mip = none */
  33580. static readonly TEXTURE_LINEAR_NEAREST: number;
  33581. /** Explicit coordinates mode */
  33582. static readonly TEXTURE_EXPLICIT_MODE: number;
  33583. /** Spherical coordinates mode */
  33584. static readonly TEXTURE_SPHERICAL_MODE: number;
  33585. /** Planar coordinates mode */
  33586. static readonly TEXTURE_PLANAR_MODE: number;
  33587. /** Cubic coordinates mode */
  33588. static readonly TEXTURE_CUBIC_MODE: number;
  33589. /** Projection coordinates mode */
  33590. static readonly TEXTURE_PROJECTION_MODE: number;
  33591. /** Skybox coordinates mode */
  33592. static readonly TEXTURE_SKYBOX_MODE: number;
  33593. /** Inverse Cubic coordinates mode */
  33594. static readonly TEXTURE_INVCUBIC_MODE: number;
  33595. /** Equirectangular coordinates mode */
  33596. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33597. /** Equirectangular Fixed coordinates mode */
  33598. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33599. /** Equirectangular Fixed Mirrored coordinates mode */
  33600. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33601. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33602. static readonly SCALEMODE_FLOOR: number;
  33603. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33604. static readonly SCALEMODE_NEAREST: number;
  33605. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33606. static readonly SCALEMODE_CEILING: number;
  33607. /**
  33608. * Returns the current npm package of the sdk
  33609. */
  33610. static get NpmPackage(): string;
  33611. /**
  33612. * Returns the current version of the framework
  33613. */
  33614. static get Version(): string;
  33615. /** Gets the list of created engines */
  33616. static get Instances(): Engine[];
  33617. /**
  33618. * Gets the latest created engine
  33619. */
  33620. static get LastCreatedEngine(): Nullable<Engine>;
  33621. /**
  33622. * Gets the latest created scene
  33623. */
  33624. static get LastCreatedScene(): Nullable<Scene>;
  33625. /**
  33626. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33627. * @param flag defines which part of the materials must be marked as dirty
  33628. * @param predicate defines a predicate used to filter which materials should be affected
  33629. */
  33630. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33631. /**
  33632. * Method called to create the default loading screen.
  33633. * This can be overriden in your own app.
  33634. * @param canvas The rendering canvas element
  33635. * @returns The loading screen
  33636. */
  33637. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33638. /**
  33639. * Method called to create the default rescale post process on each engine.
  33640. */
  33641. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33642. /**
  33643. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33644. **/
  33645. enableOfflineSupport: boolean;
  33646. /**
  33647. * 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)
  33648. **/
  33649. disableManifestCheck: boolean;
  33650. /**
  33651. * Gets the list of created scenes
  33652. */
  33653. scenes: Scene[];
  33654. /**
  33655. * Event raised when a new scene is created
  33656. */
  33657. onNewSceneAddedObservable: Observable<Scene>;
  33658. /**
  33659. * Gets the list of created postprocesses
  33660. */
  33661. postProcesses: PostProcess[];
  33662. /**
  33663. * Gets a boolean indicating if the pointer is currently locked
  33664. */
  33665. isPointerLock: boolean;
  33666. /**
  33667. * Observable event triggered each time the rendering canvas is resized
  33668. */
  33669. onResizeObservable: Observable<Engine>;
  33670. /**
  33671. * Observable event triggered each time the canvas loses focus
  33672. */
  33673. onCanvasBlurObservable: Observable<Engine>;
  33674. /**
  33675. * Observable event triggered each time the canvas gains focus
  33676. */
  33677. onCanvasFocusObservable: Observable<Engine>;
  33678. /**
  33679. * Observable event triggered each time the canvas receives pointerout event
  33680. */
  33681. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33682. /**
  33683. * Observable raised when the engine begins a new frame
  33684. */
  33685. onBeginFrameObservable: Observable<Engine>;
  33686. /**
  33687. * If set, will be used to request the next animation frame for the render loop
  33688. */
  33689. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33690. /**
  33691. * Observable raised when the engine ends the current frame
  33692. */
  33693. onEndFrameObservable: Observable<Engine>;
  33694. /**
  33695. * Observable raised when the engine is about to compile a shader
  33696. */
  33697. onBeforeShaderCompilationObservable: Observable<Engine>;
  33698. /**
  33699. * Observable raised when the engine has jsut compiled a shader
  33700. */
  33701. onAfterShaderCompilationObservable: Observable<Engine>;
  33702. /**
  33703. * Gets the audio engine
  33704. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33705. * @ignorenaming
  33706. */
  33707. static audioEngine: IAudioEngine;
  33708. /**
  33709. * Default AudioEngine factory responsible of creating the Audio Engine.
  33710. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33711. */
  33712. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33713. /**
  33714. * Default offline support factory responsible of creating a tool used to store data locally.
  33715. * By default, this will create a Database object if the workload has been embedded.
  33716. */
  33717. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33718. private _loadingScreen;
  33719. private _pointerLockRequested;
  33720. private _dummyFramebuffer;
  33721. private _rescalePostProcess;
  33722. private _deterministicLockstep;
  33723. private _lockstepMaxSteps;
  33724. private _timeStep;
  33725. protected get _supportsHardwareTextureRescaling(): boolean;
  33726. private _fps;
  33727. private _deltaTime;
  33728. /** @hidden */
  33729. _drawCalls: PerfCounter;
  33730. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  33731. canvasTabIndex: number;
  33732. /**
  33733. * Turn this value on if you want to pause FPS computation when in background
  33734. */
  33735. disablePerformanceMonitorInBackground: boolean;
  33736. private _performanceMonitor;
  33737. /**
  33738. * Gets the performance monitor attached to this engine
  33739. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33740. */
  33741. get performanceMonitor(): PerformanceMonitor;
  33742. private _onFocus;
  33743. private _onBlur;
  33744. private _onCanvasPointerOut;
  33745. private _onCanvasBlur;
  33746. private _onCanvasFocus;
  33747. private _onFullscreenChange;
  33748. private _onPointerLockChange;
  33749. /**
  33750. * Gets the HTML element used to attach event listeners
  33751. * @returns a HTML element
  33752. */
  33753. getInputElement(): Nullable<HTMLElement>;
  33754. /**
  33755. * Creates a new engine
  33756. * @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
  33757. * @param antialias defines enable antialiasing (default: false)
  33758. * @param options defines further options to be sent to the getContext() function
  33759. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33760. */
  33761. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33762. /**
  33763. * Gets current aspect ratio
  33764. * @param viewportOwner defines the camera to use to get the aspect ratio
  33765. * @param useScreen defines if screen size must be used (or the current render target if any)
  33766. * @returns a number defining the aspect ratio
  33767. */
  33768. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33769. /**
  33770. * Gets current screen aspect ratio
  33771. * @returns a number defining the aspect ratio
  33772. */
  33773. getScreenAspectRatio(): number;
  33774. /**
  33775. * Gets the client rect of the HTML canvas attached with the current webGL context
  33776. * @returns a client rectanglee
  33777. */
  33778. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33779. /**
  33780. * Gets the client rect of the HTML element used for events
  33781. * @returns a client rectanglee
  33782. */
  33783. getInputElementClientRect(): Nullable<ClientRect>;
  33784. /**
  33785. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33786. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33787. * @returns true if engine is in deterministic lock step mode
  33788. */
  33789. isDeterministicLockStep(): boolean;
  33790. /**
  33791. * Gets the max steps when engine is running in deterministic lock step
  33792. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33793. * @returns the max steps
  33794. */
  33795. getLockstepMaxSteps(): number;
  33796. /**
  33797. * Returns the time in ms between steps when using deterministic lock step.
  33798. * @returns time step in (ms)
  33799. */
  33800. getTimeStep(): number;
  33801. /**
  33802. * Force the mipmap generation for the given render target texture
  33803. * @param texture defines the render target texture to use
  33804. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33805. */
  33806. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33807. /** States */
  33808. /**
  33809. * Set various states to the webGL context
  33810. * @param culling defines backface culling state
  33811. * @param zOffset defines the value to apply to zOffset (0 by default)
  33812. * @param force defines if states must be applied even if cache is up to date
  33813. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33814. */
  33815. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33816. /**
  33817. * Set the z offset to apply to current rendering
  33818. * @param value defines the offset to apply
  33819. */
  33820. setZOffset(value: number): void;
  33821. /**
  33822. * Gets the current value of the zOffset
  33823. * @returns the current zOffset state
  33824. */
  33825. getZOffset(): number;
  33826. /**
  33827. * Enable or disable depth buffering
  33828. * @param enable defines the state to set
  33829. */
  33830. setDepthBuffer(enable: boolean): void;
  33831. /**
  33832. * Gets a boolean indicating if depth writing is enabled
  33833. * @returns the current depth writing state
  33834. */
  33835. getDepthWrite(): boolean;
  33836. /**
  33837. * Enable or disable depth writing
  33838. * @param enable defines the state to set
  33839. */
  33840. setDepthWrite(enable: boolean): void;
  33841. /**
  33842. * Gets a boolean indicating if stencil buffer is enabled
  33843. * @returns the current stencil buffer state
  33844. */
  33845. getStencilBuffer(): boolean;
  33846. /**
  33847. * Enable or disable the stencil buffer
  33848. * @param enable defines if the stencil buffer must be enabled or disabled
  33849. */
  33850. setStencilBuffer(enable: boolean): void;
  33851. /**
  33852. * Gets the current stencil mask
  33853. * @returns a number defining the new stencil mask to use
  33854. */
  33855. getStencilMask(): number;
  33856. /**
  33857. * Sets the current stencil mask
  33858. * @param mask defines the new stencil mask to use
  33859. */
  33860. setStencilMask(mask: number): void;
  33861. /**
  33862. * Gets the current stencil function
  33863. * @returns a number defining the stencil function to use
  33864. */
  33865. getStencilFunction(): number;
  33866. /**
  33867. * Gets the current stencil reference value
  33868. * @returns a number defining the stencil reference value to use
  33869. */
  33870. getStencilFunctionReference(): number;
  33871. /**
  33872. * Gets the current stencil mask
  33873. * @returns a number defining the stencil mask to use
  33874. */
  33875. getStencilFunctionMask(): number;
  33876. /**
  33877. * Sets the current stencil function
  33878. * @param stencilFunc defines the new stencil function to use
  33879. */
  33880. setStencilFunction(stencilFunc: number): void;
  33881. /**
  33882. * Sets the current stencil reference
  33883. * @param reference defines the new stencil reference to use
  33884. */
  33885. setStencilFunctionReference(reference: number): void;
  33886. /**
  33887. * Sets the current stencil mask
  33888. * @param mask defines the new stencil mask to use
  33889. */
  33890. setStencilFunctionMask(mask: number): void;
  33891. /**
  33892. * Gets the current stencil operation when stencil fails
  33893. * @returns a number defining stencil operation to use when stencil fails
  33894. */
  33895. getStencilOperationFail(): number;
  33896. /**
  33897. * Gets the current stencil operation when depth fails
  33898. * @returns a number defining stencil operation to use when depth fails
  33899. */
  33900. getStencilOperationDepthFail(): number;
  33901. /**
  33902. * Gets the current stencil operation when stencil passes
  33903. * @returns a number defining stencil operation to use when stencil passes
  33904. */
  33905. getStencilOperationPass(): number;
  33906. /**
  33907. * Sets the stencil operation to use when stencil fails
  33908. * @param operation defines the stencil operation to use when stencil fails
  33909. */
  33910. setStencilOperationFail(operation: number): void;
  33911. /**
  33912. * Sets the stencil operation to use when depth fails
  33913. * @param operation defines the stencil operation to use when depth fails
  33914. */
  33915. setStencilOperationDepthFail(operation: number): void;
  33916. /**
  33917. * Sets the stencil operation to use when stencil passes
  33918. * @param operation defines the stencil operation to use when stencil passes
  33919. */
  33920. setStencilOperationPass(operation: number): void;
  33921. /**
  33922. * Sets a boolean indicating if the dithering state is enabled or disabled
  33923. * @param value defines the dithering state
  33924. */
  33925. setDitheringState(value: boolean): void;
  33926. /**
  33927. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33928. * @param value defines the rasterizer state
  33929. */
  33930. setRasterizerState(value: boolean): void;
  33931. /**
  33932. * Gets the current depth function
  33933. * @returns a number defining the depth function
  33934. */
  33935. getDepthFunction(): Nullable<number>;
  33936. /**
  33937. * Sets the current depth function
  33938. * @param depthFunc defines the function to use
  33939. */
  33940. setDepthFunction(depthFunc: number): void;
  33941. /**
  33942. * Sets the current depth function to GREATER
  33943. */
  33944. setDepthFunctionToGreater(): void;
  33945. /**
  33946. * Sets the current depth function to GEQUAL
  33947. */
  33948. setDepthFunctionToGreaterOrEqual(): void;
  33949. /**
  33950. * Sets the current depth function to LESS
  33951. */
  33952. setDepthFunctionToLess(): void;
  33953. /**
  33954. * Sets the current depth function to LEQUAL
  33955. */
  33956. setDepthFunctionToLessOrEqual(): void;
  33957. private _cachedStencilBuffer;
  33958. private _cachedStencilFunction;
  33959. private _cachedStencilMask;
  33960. private _cachedStencilOperationPass;
  33961. private _cachedStencilOperationFail;
  33962. private _cachedStencilOperationDepthFail;
  33963. private _cachedStencilReference;
  33964. /**
  33965. * Caches the the state of the stencil buffer
  33966. */
  33967. cacheStencilState(): void;
  33968. /**
  33969. * Restores the state of the stencil buffer
  33970. */
  33971. restoreStencilState(): void;
  33972. /**
  33973. * Directly set the WebGL Viewport
  33974. * @param x defines the x coordinate of the viewport (in screen space)
  33975. * @param y defines the y coordinate of the viewport (in screen space)
  33976. * @param width defines the width of the viewport (in screen space)
  33977. * @param height defines the height of the viewport (in screen space)
  33978. * @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
  33979. */
  33980. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33981. /**
  33982. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33983. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33984. * @param y defines the y-coordinate of the corner of the clear rectangle
  33985. * @param width defines the width of the clear rectangle
  33986. * @param height defines the height of the clear rectangle
  33987. * @param clearColor defines the clear color
  33988. */
  33989. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33990. /**
  33991. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33992. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33993. * @param y defines the y-coordinate of the corner of the clear rectangle
  33994. * @param width defines the width of the clear rectangle
  33995. * @param height defines the height of the clear rectangle
  33996. */
  33997. enableScissor(x: number, y: number, width: number, height: number): void;
  33998. /**
  33999. * Disable previously set scissor test rectangle
  34000. */
  34001. disableScissor(): void;
  34002. protected _reportDrawCall(): void;
  34003. /**
  34004. * Initializes a webVR display and starts listening to display change events
  34005. * The onVRDisplayChangedObservable will be notified upon these changes
  34006. * @returns The onVRDisplayChangedObservable
  34007. */
  34008. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34009. /** @hidden */
  34010. _prepareVRComponent(): void;
  34011. /** @hidden */
  34012. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34013. /** @hidden */
  34014. _submitVRFrame(): void;
  34015. /**
  34016. * Call this function to leave webVR mode
  34017. * Will do nothing if webVR is not supported or if there is no webVR device
  34018. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34019. */
  34020. disableVR(): void;
  34021. /**
  34022. * Gets a boolean indicating that the system is in VR mode and is presenting
  34023. * @returns true if VR mode is engaged
  34024. */
  34025. isVRPresenting(): boolean;
  34026. /** @hidden */
  34027. _requestVRFrame(): void;
  34028. /** @hidden */
  34029. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34030. /**
  34031. * Gets the source code of the vertex shader associated with a specific webGL program
  34032. * @param program defines the program to use
  34033. * @returns a string containing the source code of the vertex shader associated with the program
  34034. */
  34035. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34036. /**
  34037. * Gets the source code of the fragment shader associated with a specific webGL program
  34038. * @param program defines the program to use
  34039. * @returns a string containing the source code of the fragment shader associated with the program
  34040. */
  34041. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34042. /**
  34043. * Sets a depth stencil texture from a render target to the according uniform.
  34044. * @param channel The texture channel
  34045. * @param uniform The uniform to set
  34046. * @param texture The render target texture containing the depth stencil texture to apply
  34047. */
  34048. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34049. /**
  34050. * Sets a texture to the webGL context from a postprocess
  34051. * @param channel defines the channel to use
  34052. * @param postProcess defines the source postprocess
  34053. */
  34054. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34055. /**
  34056. * Binds the output of the passed in post process to the texture channel specified
  34057. * @param channel The channel the texture should be bound to
  34058. * @param postProcess The post process which's output should be bound
  34059. */
  34060. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34061. /** @hidden */
  34062. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34063. protected _rebuildBuffers(): void;
  34064. /** @hidden */
  34065. _renderFrame(): void;
  34066. _renderLoop(): void;
  34067. /** @hidden */
  34068. _renderViews(): boolean;
  34069. /**
  34070. * Toggle full screen mode
  34071. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34072. */
  34073. switchFullscreen(requestPointerLock: boolean): void;
  34074. /**
  34075. * Enters full screen mode
  34076. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34077. */
  34078. enterFullscreen(requestPointerLock: boolean): void;
  34079. /**
  34080. * Exits full screen mode
  34081. */
  34082. exitFullscreen(): void;
  34083. /**
  34084. * Enters Pointerlock mode
  34085. */
  34086. enterPointerlock(): void;
  34087. /**
  34088. * Exits Pointerlock mode
  34089. */
  34090. exitPointerlock(): void;
  34091. /**
  34092. * Begin a new frame
  34093. */
  34094. beginFrame(): void;
  34095. /**
  34096. * Enf the current frame
  34097. */
  34098. endFrame(): void;
  34099. resize(): void;
  34100. /**
  34101. * Force a specific size of the canvas
  34102. * @param width defines the new canvas' width
  34103. * @param height defines the new canvas' height
  34104. */
  34105. setSize(width: number, height: number): void;
  34106. /**
  34107. * Updates a dynamic vertex buffer.
  34108. * @param vertexBuffer the vertex buffer to update
  34109. * @param data the data used to update the vertex buffer
  34110. * @param byteOffset the byte offset of the data
  34111. * @param byteLength the byte length of the data
  34112. */
  34113. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34114. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34115. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34116. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34117. _releaseTexture(texture: InternalTexture): void;
  34118. /**
  34119. * @hidden
  34120. * Rescales a texture
  34121. * @param source input texutre
  34122. * @param destination destination texture
  34123. * @param scene scene to use to render the resize
  34124. * @param internalFormat format to use when resizing
  34125. * @param onComplete callback to be called when resize has completed
  34126. */
  34127. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34128. /**
  34129. * Gets the current framerate
  34130. * @returns a number representing the framerate
  34131. */
  34132. getFps(): number;
  34133. /**
  34134. * Gets the time spent between current and previous frame
  34135. * @returns a number representing the delta time in ms
  34136. */
  34137. getDeltaTime(): number;
  34138. private _measureFps;
  34139. /** @hidden */
  34140. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34141. /**
  34142. * Update a dynamic index buffer
  34143. * @param indexBuffer defines the target index buffer
  34144. * @param indices defines the data to update
  34145. * @param offset defines the offset in the target index buffer where update should start
  34146. */
  34147. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34148. /**
  34149. * Updates the sample count of a render target texture
  34150. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34151. * @param texture defines the texture to update
  34152. * @param samples defines the sample count to set
  34153. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34154. */
  34155. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34156. /**
  34157. * Updates a depth texture Comparison Mode and Function.
  34158. * If the comparison Function is equal to 0, the mode will be set to none.
  34159. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34160. * @param texture The texture to set the comparison function for
  34161. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34162. */
  34163. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34164. /**
  34165. * Creates a webGL buffer to use with instanciation
  34166. * @param capacity defines the size of the buffer
  34167. * @returns the webGL buffer
  34168. */
  34169. createInstancesBuffer(capacity: number): DataBuffer;
  34170. /**
  34171. * Delete a webGL buffer used with instanciation
  34172. * @param buffer defines the webGL buffer to delete
  34173. */
  34174. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34175. private _clientWaitAsync;
  34176. /** @hidden */
  34177. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34178. /** @hidden */
  34179. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34180. dispose(): void;
  34181. private _disableTouchAction;
  34182. /**
  34183. * Display the loading screen
  34184. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34185. */
  34186. displayLoadingUI(): void;
  34187. /**
  34188. * Hide the loading screen
  34189. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34190. */
  34191. hideLoadingUI(): void;
  34192. /**
  34193. * Gets the current loading screen object
  34194. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34195. */
  34196. get loadingScreen(): ILoadingScreen;
  34197. /**
  34198. * Sets the current loading screen object
  34199. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34200. */
  34201. set loadingScreen(loadingScreen: ILoadingScreen);
  34202. /**
  34203. * Sets the current loading screen text
  34204. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34205. */
  34206. set loadingUIText(text: string);
  34207. /**
  34208. * Sets the current loading screen background color
  34209. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34210. */
  34211. set loadingUIBackgroundColor(color: string);
  34212. /** Pointerlock and fullscreen */
  34213. /**
  34214. * Ask the browser to promote the current element to pointerlock mode
  34215. * @param element defines the DOM element to promote
  34216. */
  34217. static _RequestPointerlock(element: HTMLElement): void;
  34218. /**
  34219. * Asks the browser to exit pointerlock mode
  34220. */
  34221. static _ExitPointerlock(): void;
  34222. /**
  34223. * Ask the browser to promote the current element to fullscreen rendering mode
  34224. * @param element defines the DOM element to promote
  34225. */
  34226. static _RequestFullscreen(element: HTMLElement): void;
  34227. /**
  34228. * Asks the browser to exit fullscreen mode
  34229. */
  34230. static _ExitFullscreen(): void;
  34231. }
  34232. }
  34233. declare module BABYLON {
  34234. /**
  34235. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34236. * during the life time of the application.
  34237. */
  34238. export class EngineStore {
  34239. /** Gets the list of created engines */
  34240. static Instances: Engine[];
  34241. /** @hidden */
  34242. static _LastCreatedScene: Nullable<Scene>;
  34243. /**
  34244. * Gets the latest created engine
  34245. */
  34246. static get LastCreatedEngine(): Nullable<Engine>;
  34247. /**
  34248. * Gets the latest created scene
  34249. */
  34250. static get LastCreatedScene(): Nullable<Scene>;
  34251. /**
  34252. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34253. * @ignorenaming
  34254. */
  34255. static UseFallbackTexture: boolean;
  34256. /**
  34257. * Texture content used if a texture cannot loaded
  34258. * @ignorenaming
  34259. */
  34260. static FallbackTexture: string;
  34261. }
  34262. }
  34263. declare module BABYLON {
  34264. /**
  34265. * Helper class that provides a small promise polyfill
  34266. */
  34267. export class PromisePolyfill {
  34268. /**
  34269. * Static function used to check if the polyfill is required
  34270. * If this is the case then the function will inject the polyfill to window.Promise
  34271. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34272. */
  34273. static Apply(force?: boolean): void;
  34274. }
  34275. }
  34276. declare module BABYLON {
  34277. /**
  34278. * Interface for screenshot methods with describe argument called `size` as object with options
  34279. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34280. */
  34281. export interface IScreenshotSize {
  34282. /**
  34283. * number in pixels for canvas height
  34284. */
  34285. height?: number;
  34286. /**
  34287. * multiplier allowing render at a higher or lower resolution
  34288. * If value is defined then height and width will be ignored and taken from camera
  34289. */
  34290. precision?: number;
  34291. /**
  34292. * number in pixels for canvas width
  34293. */
  34294. width?: number;
  34295. }
  34296. }
  34297. declare module BABYLON {
  34298. interface IColor4Like {
  34299. r: float;
  34300. g: float;
  34301. b: float;
  34302. a: float;
  34303. }
  34304. /**
  34305. * Class containing a set of static utilities functions
  34306. */
  34307. export class Tools {
  34308. /**
  34309. * Gets or sets the base URL to use to load assets
  34310. */
  34311. static get BaseUrl(): string;
  34312. static set BaseUrl(value: string);
  34313. /**
  34314. * Enable/Disable Custom HTTP Request Headers globally.
  34315. * default = false
  34316. * @see CustomRequestHeaders
  34317. */
  34318. static UseCustomRequestHeaders: boolean;
  34319. /**
  34320. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34321. * i.e. when loading files, where the server/service expects an Authorization header
  34322. */
  34323. static CustomRequestHeaders: {
  34324. [key: string]: string;
  34325. };
  34326. /**
  34327. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34328. */
  34329. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34330. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34331. /**
  34332. * Default behaviour for cors in the application.
  34333. * It can be a string if the expected behavior is identical in the entire app.
  34334. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34335. */
  34336. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34337. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34338. /**
  34339. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34340. * @ignorenaming
  34341. */
  34342. static get UseFallbackTexture(): boolean;
  34343. static set UseFallbackTexture(value: boolean);
  34344. /**
  34345. * Use this object to register external classes like custom textures or material
  34346. * to allow the laoders to instantiate them
  34347. */
  34348. static get RegisteredExternalClasses(): {
  34349. [key: string]: Object;
  34350. };
  34351. static set RegisteredExternalClasses(classes: {
  34352. [key: string]: Object;
  34353. });
  34354. /**
  34355. * Texture content used if a texture cannot loaded
  34356. * @ignorenaming
  34357. */
  34358. static get fallbackTexture(): string;
  34359. static set fallbackTexture(value: string);
  34360. /**
  34361. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34362. * @param u defines the coordinate on X axis
  34363. * @param v defines the coordinate on Y axis
  34364. * @param width defines the width of the source data
  34365. * @param height defines the height of the source data
  34366. * @param pixels defines the source byte array
  34367. * @param color defines the output color
  34368. */
  34369. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34370. /**
  34371. * Interpolates between a and b via alpha
  34372. * @param a The lower value (returned when alpha = 0)
  34373. * @param b The upper value (returned when alpha = 1)
  34374. * @param alpha The interpolation-factor
  34375. * @return The mixed value
  34376. */
  34377. static Mix(a: number, b: number, alpha: number): number;
  34378. /**
  34379. * Tries to instantiate a new object from a given class name
  34380. * @param className defines the class name to instantiate
  34381. * @returns the new object or null if the system was not able to do the instantiation
  34382. */
  34383. static Instantiate(className: string): any;
  34384. /**
  34385. * Provides a slice function that will work even on IE
  34386. * @param data defines the array to slice
  34387. * @param start defines the start of the data (optional)
  34388. * @param end defines the end of the data (optional)
  34389. * @returns the new sliced array
  34390. */
  34391. static Slice<T>(data: T, start?: number, end?: number): T;
  34392. /**
  34393. * Polyfill for setImmediate
  34394. * @param action defines the action to execute after the current execution block
  34395. */
  34396. static SetImmediate(action: () => void): void;
  34397. /**
  34398. * Function indicating if a number is an exponent of 2
  34399. * @param value defines the value to test
  34400. * @returns true if the value is an exponent of 2
  34401. */
  34402. static IsExponentOfTwo(value: number): boolean;
  34403. private static _tmpFloatArray;
  34404. /**
  34405. * Returns the nearest 32-bit single precision float representation of a Number
  34406. * @param value A Number. If the parameter is of a different type, it will get converted
  34407. * to a number or to NaN if it cannot be converted
  34408. * @returns number
  34409. */
  34410. static FloatRound(value: number): number;
  34411. /**
  34412. * Extracts the filename from a path
  34413. * @param path defines the path to use
  34414. * @returns the filename
  34415. */
  34416. static GetFilename(path: string): string;
  34417. /**
  34418. * Extracts the "folder" part of a path (everything before the filename).
  34419. * @param uri The URI to extract the info from
  34420. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34421. * @returns The "folder" part of the path
  34422. */
  34423. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34424. /**
  34425. * Extracts text content from a DOM element hierarchy
  34426. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34427. */
  34428. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34429. /**
  34430. * Convert an angle in radians to degrees
  34431. * @param angle defines the angle to convert
  34432. * @returns the angle in degrees
  34433. */
  34434. static ToDegrees(angle: number): number;
  34435. /**
  34436. * Convert an angle in degrees to radians
  34437. * @param angle defines the angle to convert
  34438. * @returns the angle in radians
  34439. */
  34440. static ToRadians(angle: number): number;
  34441. /**
  34442. * Returns an array if obj is not an array
  34443. * @param obj defines the object to evaluate as an array
  34444. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34445. * @returns either obj directly if obj is an array or a new array containing obj
  34446. */
  34447. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34448. /**
  34449. * Gets the pointer prefix to use
  34450. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34451. */
  34452. static GetPointerPrefix(): string;
  34453. /**
  34454. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34455. * @param url define the url we are trying
  34456. * @param element define the dom element where to configure the cors policy
  34457. */
  34458. static SetCorsBehavior(url: string | string[], element: {
  34459. crossOrigin: string | null;
  34460. }): void;
  34461. /**
  34462. * Removes unwanted characters from an url
  34463. * @param url defines the url to clean
  34464. * @returns the cleaned url
  34465. */
  34466. static CleanUrl(url: string): string;
  34467. /**
  34468. * Gets or sets a function used to pre-process url before using them to load assets
  34469. */
  34470. static get PreprocessUrl(): (url: string) => string;
  34471. static set PreprocessUrl(processor: (url: string) => string);
  34472. /**
  34473. * Loads an image as an HTMLImageElement.
  34474. * @param input url string, ArrayBuffer, or Blob to load
  34475. * @param onLoad callback called when the image successfully loads
  34476. * @param onError callback called when the image fails to load
  34477. * @param offlineProvider offline provider for caching
  34478. * @param mimeType optional mime type
  34479. * @returns the HTMLImageElement of the loaded image
  34480. */
  34481. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34482. /**
  34483. * Loads a file from a url
  34484. * @param url url string, ArrayBuffer, or Blob to load
  34485. * @param onSuccess callback called when the file successfully loads
  34486. * @param onProgress callback called while file is loading (if the server supports this mode)
  34487. * @param offlineProvider defines the offline provider for caching
  34488. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34489. * @param onError callback called when the file fails to load
  34490. * @returns a file request object
  34491. */
  34492. 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;
  34493. /**
  34494. * Loads a file from a url
  34495. * @param url the file url to load
  34496. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34497. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34498. */
  34499. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34500. /**
  34501. * Load a script (identified by an url). When the url returns, the
  34502. * content of this file is added into a new script element, attached to the DOM (body element)
  34503. * @param scriptUrl defines the url of the script to laod
  34504. * @param onSuccess defines the callback called when the script is loaded
  34505. * @param onError defines the callback to call if an error occurs
  34506. * @param scriptId defines the id of the script element
  34507. */
  34508. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34509. /**
  34510. * Load an asynchronous script (identified by an url). When the url returns, the
  34511. * content of this file is added into a new script element, attached to the DOM (body element)
  34512. * @param scriptUrl defines the url of the script to laod
  34513. * @param scriptId defines the id of the script element
  34514. * @returns a promise request object
  34515. */
  34516. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34517. /**
  34518. * Loads a file from a blob
  34519. * @param fileToLoad defines the blob to use
  34520. * @param callback defines the callback to call when data is loaded
  34521. * @param progressCallback defines the callback to call during loading process
  34522. * @returns a file request object
  34523. */
  34524. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34525. /**
  34526. * Reads a file from a File object
  34527. * @param file defines the file to load
  34528. * @param onSuccess defines the callback to call when data is loaded
  34529. * @param onProgress defines the callback to call during loading process
  34530. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34531. * @param onError defines the callback to call when an error occurs
  34532. * @returns a file request object
  34533. */
  34534. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34535. /**
  34536. * Creates a data url from a given string content
  34537. * @param content defines the content to convert
  34538. * @returns the new data url link
  34539. */
  34540. static FileAsURL(content: string): string;
  34541. /**
  34542. * Format the given number to a specific decimal format
  34543. * @param value defines the number to format
  34544. * @param decimals defines the number of decimals to use
  34545. * @returns the formatted string
  34546. */
  34547. static Format(value: number, decimals?: number): string;
  34548. /**
  34549. * Tries to copy an object by duplicating every property
  34550. * @param source defines the source object
  34551. * @param destination defines the target object
  34552. * @param doNotCopyList defines a list of properties to avoid
  34553. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34554. */
  34555. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34556. /**
  34557. * Gets a boolean indicating if the given object has no own property
  34558. * @param obj defines the object to test
  34559. * @returns true if object has no own property
  34560. */
  34561. static IsEmpty(obj: any): boolean;
  34562. /**
  34563. * Function used to register events at window level
  34564. * @param windowElement defines the Window object to use
  34565. * @param events defines the events to register
  34566. */
  34567. static RegisterTopRootEvents(windowElement: Window, events: {
  34568. name: string;
  34569. handler: Nullable<(e: FocusEvent) => any>;
  34570. }[]): void;
  34571. /**
  34572. * Function used to unregister events from window level
  34573. * @param windowElement defines the Window object to use
  34574. * @param events defines the events to unregister
  34575. */
  34576. static UnregisterTopRootEvents(windowElement: Window, events: {
  34577. name: string;
  34578. handler: Nullable<(e: FocusEvent) => any>;
  34579. }[]): void;
  34580. /**
  34581. * @ignore
  34582. */
  34583. static _ScreenshotCanvas: HTMLCanvasElement;
  34584. /**
  34585. * Dumps the current bound framebuffer
  34586. * @param width defines the rendering width
  34587. * @param height defines the rendering height
  34588. * @param engine defines the hosting engine
  34589. * @param successCallback defines the callback triggered once the data are available
  34590. * @param mimeType defines the mime type of the result
  34591. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34592. */
  34593. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34594. /**
  34595. * Converts the canvas data to blob.
  34596. * This acts as a polyfill for browsers not supporting the to blob function.
  34597. * @param canvas Defines the canvas to extract the data from
  34598. * @param successCallback Defines the callback triggered once the data are available
  34599. * @param mimeType Defines the mime type of the result
  34600. */
  34601. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34602. /**
  34603. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34604. * @param successCallback defines the callback triggered once the data are available
  34605. * @param mimeType defines the mime type of the result
  34606. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34607. */
  34608. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34609. /**
  34610. * Downloads a blob in the browser
  34611. * @param blob defines the blob to download
  34612. * @param fileName defines the name of the downloaded file
  34613. */
  34614. static Download(blob: Blob, fileName: string): void;
  34615. /**
  34616. * Captures a screenshot of the current rendering
  34617. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34618. * @param engine defines the rendering engine
  34619. * @param camera defines the source camera
  34620. * @param size This parameter can be set to a single number or to an object with the
  34621. * following (optional) properties: precision, width, height. If a single number is passed,
  34622. * it will be used for both width and height. If an object is passed, the screenshot size
  34623. * will be derived from the parameters. The precision property is a multiplier allowing
  34624. * rendering at a higher or lower resolution
  34625. * @param successCallback defines the callback receives a single parameter which contains the
  34626. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34627. * src parameter of an <img> to display it
  34628. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34629. * Check your browser for supported MIME types
  34630. */
  34631. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34632. /**
  34633. * Captures a screenshot of the current rendering
  34634. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34635. * @param engine defines the rendering engine
  34636. * @param camera defines the source camera
  34637. * @param size This parameter can be set to a single number or to an object with the
  34638. * following (optional) properties: precision, width, height. If a single number is passed,
  34639. * it will be used for both width and height. If an object is passed, the screenshot size
  34640. * will be derived from the parameters. The precision property is a multiplier allowing
  34641. * rendering at a higher or lower resolution
  34642. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34643. * Check your browser for supported MIME types
  34644. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34645. * to the src parameter of an <img> to display it
  34646. */
  34647. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34648. /**
  34649. * Generates an image screenshot from the specified camera.
  34650. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34651. * @param engine The engine to use for rendering
  34652. * @param camera The camera to use for rendering
  34653. * @param size This parameter can be set to a single number or to an object with the
  34654. * following (optional) properties: precision, width, height. If a single number is passed,
  34655. * it will be used for both width and height. If an object is passed, the screenshot size
  34656. * will be derived from the parameters. The precision property is a multiplier allowing
  34657. * rendering at a higher or lower resolution
  34658. * @param successCallback The callback receives a single parameter which contains the
  34659. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34660. * src parameter of an <img> to display it
  34661. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34662. * Check your browser for supported MIME types
  34663. * @param samples Texture samples (default: 1)
  34664. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34665. * @param fileName A name for for the downloaded file.
  34666. */
  34667. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34668. /**
  34669. * Generates an image screenshot from the specified camera.
  34670. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34671. * @param engine The engine to use for rendering
  34672. * @param camera The camera to use for rendering
  34673. * @param size This parameter can be set to a single number or to an object with the
  34674. * following (optional) properties: precision, width, height. If a single number is passed,
  34675. * it will be used for both width and height. If an object is passed, the screenshot size
  34676. * will be derived from the parameters. The precision property is a multiplier allowing
  34677. * rendering at a higher or lower resolution
  34678. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34679. * Check your browser for supported MIME types
  34680. * @param samples Texture samples (default: 1)
  34681. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34682. * @param fileName A name for for the downloaded file.
  34683. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34684. * to the src parameter of an <img> to display it
  34685. */
  34686. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34687. /**
  34688. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34689. * Be aware Math.random() could cause collisions, but:
  34690. * "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"
  34691. * @returns a pseudo random id
  34692. */
  34693. static RandomId(): string;
  34694. /**
  34695. * Test if the given uri is a base64 string
  34696. * @param uri The uri to test
  34697. * @return True if the uri is a base64 string or false otherwise
  34698. */
  34699. static IsBase64(uri: string): boolean;
  34700. /**
  34701. * Decode the given base64 uri.
  34702. * @param uri The uri to decode
  34703. * @return The decoded base64 data.
  34704. */
  34705. static DecodeBase64(uri: string): ArrayBuffer;
  34706. /**
  34707. * Gets the absolute url.
  34708. * @param url the input url
  34709. * @return the absolute url
  34710. */
  34711. static GetAbsoluteUrl(url: string): string;
  34712. /**
  34713. * No log
  34714. */
  34715. static readonly NoneLogLevel: number;
  34716. /**
  34717. * Only message logs
  34718. */
  34719. static readonly MessageLogLevel: number;
  34720. /**
  34721. * Only warning logs
  34722. */
  34723. static readonly WarningLogLevel: number;
  34724. /**
  34725. * Only error logs
  34726. */
  34727. static readonly ErrorLogLevel: number;
  34728. /**
  34729. * All logs
  34730. */
  34731. static readonly AllLogLevel: number;
  34732. /**
  34733. * Gets a value indicating the number of loading errors
  34734. * @ignorenaming
  34735. */
  34736. static get errorsCount(): number;
  34737. /**
  34738. * Callback called when a new log is added
  34739. */
  34740. static OnNewCacheEntry: (entry: string) => void;
  34741. /**
  34742. * Log a message to the console
  34743. * @param message defines the message to log
  34744. */
  34745. static Log(message: string): void;
  34746. /**
  34747. * Write a warning message to the console
  34748. * @param message defines the message to log
  34749. */
  34750. static Warn(message: string): void;
  34751. /**
  34752. * Write an error message to the console
  34753. * @param message defines the message to log
  34754. */
  34755. static Error(message: string): void;
  34756. /**
  34757. * Gets current log cache (list of logs)
  34758. */
  34759. static get LogCache(): string;
  34760. /**
  34761. * Clears the log cache
  34762. */
  34763. static ClearLogCache(): void;
  34764. /**
  34765. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34766. */
  34767. static set LogLevels(level: number);
  34768. /**
  34769. * Checks if the window object exists
  34770. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34771. */
  34772. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34773. /**
  34774. * No performance log
  34775. */
  34776. static readonly PerformanceNoneLogLevel: number;
  34777. /**
  34778. * Use user marks to log performance
  34779. */
  34780. static readonly PerformanceUserMarkLogLevel: number;
  34781. /**
  34782. * Log performance to the console
  34783. */
  34784. static readonly PerformanceConsoleLogLevel: number;
  34785. private static _performance;
  34786. /**
  34787. * Sets the current performance log level
  34788. */
  34789. static set PerformanceLogLevel(level: number);
  34790. private static _StartPerformanceCounterDisabled;
  34791. private static _EndPerformanceCounterDisabled;
  34792. private static _StartUserMark;
  34793. private static _EndUserMark;
  34794. private static _StartPerformanceConsole;
  34795. private static _EndPerformanceConsole;
  34796. /**
  34797. * Starts a performance counter
  34798. */
  34799. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34800. /**
  34801. * Ends a specific performance coutner
  34802. */
  34803. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34804. /**
  34805. * Gets either window.performance.now() if supported or Date.now() else
  34806. */
  34807. static get Now(): number;
  34808. /**
  34809. * This method will return the name of the class used to create the instance of the given object.
  34810. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34811. * @param object the object to get the class name from
  34812. * @param isType defines if the object is actually a type
  34813. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34814. */
  34815. static GetClassName(object: any, isType?: boolean): string;
  34816. /**
  34817. * Gets the first element of an array satisfying a given predicate
  34818. * @param array defines the array to browse
  34819. * @param predicate defines the predicate to use
  34820. * @returns null if not found or the element
  34821. */
  34822. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34823. /**
  34824. * This method will return the name of the full name of the class, including its owning module (if any).
  34825. * 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).
  34826. * @param object the object to get the class name from
  34827. * @param isType defines if the object is actually a type
  34828. * @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.
  34829. * @ignorenaming
  34830. */
  34831. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34832. /**
  34833. * Returns a promise that resolves after the given amount of time.
  34834. * @param delay Number of milliseconds to delay
  34835. * @returns Promise that resolves after the given amount of time
  34836. */
  34837. static DelayAsync(delay: number): Promise<void>;
  34838. /**
  34839. * Utility function to detect if the current user agent is Safari
  34840. * @returns whether or not the current user agent is safari
  34841. */
  34842. static IsSafari(): boolean;
  34843. }
  34844. /**
  34845. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34846. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34847. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34848. * @param name The name of the class, case should be preserved
  34849. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34850. */
  34851. export function className(name: string, module?: string): (target: Object) => void;
  34852. /**
  34853. * An implementation of a loop for asynchronous functions.
  34854. */
  34855. export class AsyncLoop {
  34856. /**
  34857. * Defines the number of iterations for the loop
  34858. */
  34859. iterations: number;
  34860. /**
  34861. * Defines the current index of the loop.
  34862. */
  34863. index: number;
  34864. private _done;
  34865. private _fn;
  34866. private _successCallback;
  34867. /**
  34868. * Constructor.
  34869. * @param iterations the number of iterations.
  34870. * @param func the function to run each iteration
  34871. * @param successCallback the callback that will be called upon succesful execution
  34872. * @param offset starting offset.
  34873. */
  34874. constructor(
  34875. /**
  34876. * Defines the number of iterations for the loop
  34877. */
  34878. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34879. /**
  34880. * Execute the next iteration. Must be called after the last iteration was finished.
  34881. */
  34882. executeNext(): void;
  34883. /**
  34884. * Break the loop and run the success callback.
  34885. */
  34886. breakLoop(): void;
  34887. /**
  34888. * Create and run an async loop.
  34889. * @param iterations the number of iterations.
  34890. * @param fn the function to run each iteration
  34891. * @param successCallback the callback that will be called upon succesful execution
  34892. * @param offset starting offset.
  34893. * @returns the created async loop object
  34894. */
  34895. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34896. /**
  34897. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34898. * @param iterations total number of iterations
  34899. * @param syncedIterations number of synchronous iterations in each async iteration.
  34900. * @param fn the function to call each iteration.
  34901. * @param callback a success call back that will be called when iterating stops.
  34902. * @param breakFunction a break condition (optional)
  34903. * @param timeout timeout settings for the setTimeout function. default - 0.
  34904. * @returns the created async loop object
  34905. */
  34906. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34907. }
  34908. }
  34909. declare module BABYLON {
  34910. /**
  34911. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34912. * The underlying implementation relies on an associative array to ensure the best performances.
  34913. * The value can be anything including 'null' but except 'undefined'
  34914. */
  34915. export class StringDictionary<T> {
  34916. /**
  34917. * This will clear this dictionary and copy the content from the 'source' one.
  34918. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34919. * @param source the dictionary to take the content from and copy to this dictionary
  34920. */
  34921. copyFrom(source: StringDictionary<T>): void;
  34922. /**
  34923. * Get a value based from its key
  34924. * @param key the given key to get the matching value from
  34925. * @return the value if found, otherwise undefined is returned
  34926. */
  34927. get(key: string): T | undefined;
  34928. /**
  34929. * Get a value from its key or add it if it doesn't exist.
  34930. * This method will ensure you that a given key/data will be present in the dictionary.
  34931. * @param key the given key to get the matching value from
  34932. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34933. * The factory will only be invoked if there's no data for the given key.
  34934. * @return the value corresponding to the key.
  34935. */
  34936. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34937. /**
  34938. * Get a value from its key if present in the dictionary otherwise add it
  34939. * @param key the key to get the value from
  34940. * @param val if there's no such key/value pair in the dictionary add it with this value
  34941. * @return the value corresponding to the key
  34942. */
  34943. getOrAdd(key: string, val: T): T;
  34944. /**
  34945. * Check if there's a given key in the dictionary
  34946. * @param key the key to check for
  34947. * @return true if the key is present, false otherwise
  34948. */
  34949. contains(key: string): boolean;
  34950. /**
  34951. * Add a new key and its corresponding value
  34952. * @param key the key to add
  34953. * @param value the value corresponding to the key
  34954. * @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
  34955. */
  34956. add(key: string, value: T): boolean;
  34957. /**
  34958. * Update a specific value associated to a key
  34959. * @param key defines the key to use
  34960. * @param value defines the value to store
  34961. * @returns true if the value was updated (or false if the key was not found)
  34962. */
  34963. set(key: string, value: T): boolean;
  34964. /**
  34965. * Get the element of the given key and remove it from the dictionary
  34966. * @param key defines the key to search
  34967. * @returns the value associated with the key or null if not found
  34968. */
  34969. getAndRemove(key: string): Nullable<T>;
  34970. /**
  34971. * Remove a key/value from the dictionary.
  34972. * @param key the key to remove
  34973. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34974. */
  34975. remove(key: string): boolean;
  34976. /**
  34977. * Clear the whole content of the dictionary
  34978. */
  34979. clear(): void;
  34980. /**
  34981. * Gets the current count
  34982. */
  34983. get count(): number;
  34984. /**
  34985. * Execute a callback on each key/val of the dictionary.
  34986. * Note that you can remove any element in this dictionary in the callback implementation
  34987. * @param callback the callback to execute on a given key/value pair
  34988. */
  34989. forEach(callback: (key: string, val: T) => void): void;
  34990. /**
  34991. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34992. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34993. * Note that you can remove any element in this dictionary in the callback implementation
  34994. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34995. * @returns the first item
  34996. */
  34997. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34998. private _count;
  34999. private _data;
  35000. }
  35001. }
  35002. declare module BABYLON {
  35003. /** @hidden */
  35004. export interface ICollisionCoordinator {
  35005. createCollider(): Collider;
  35006. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35007. init(scene: Scene): void;
  35008. }
  35009. /** @hidden */
  35010. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35011. private _scene;
  35012. private _scaledPosition;
  35013. private _scaledVelocity;
  35014. private _finalPosition;
  35015. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35016. createCollider(): Collider;
  35017. init(scene: Scene): void;
  35018. private _collideWithWorld;
  35019. }
  35020. }
  35021. declare module BABYLON {
  35022. /**
  35023. * Class used to manage all inputs for the scene.
  35024. */
  35025. export class InputManager {
  35026. /** The distance in pixel that you have to move to prevent some events */
  35027. static DragMovementThreshold: number;
  35028. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35029. static LongPressDelay: number;
  35030. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35031. static DoubleClickDelay: number;
  35032. /** If you need to check double click without raising a single click at first click, enable this flag */
  35033. static ExclusiveDoubleClickMode: boolean;
  35034. private _wheelEventName;
  35035. private _onPointerMove;
  35036. private _onPointerDown;
  35037. private _onPointerUp;
  35038. private _initClickEvent;
  35039. private _initActionManager;
  35040. private _delayedSimpleClick;
  35041. private _delayedSimpleClickTimeout;
  35042. private _previousDelayedSimpleClickTimeout;
  35043. private _meshPickProceed;
  35044. private _previousButtonPressed;
  35045. private _currentPickResult;
  35046. private _previousPickResult;
  35047. private _totalPointersPressed;
  35048. private _doubleClickOccured;
  35049. private _pointerOverMesh;
  35050. private _pickedDownMesh;
  35051. private _pickedUpMesh;
  35052. private _pointerX;
  35053. private _pointerY;
  35054. private _unTranslatedPointerX;
  35055. private _unTranslatedPointerY;
  35056. private _startingPointerPosition;
  35057. private _previousStartingPointerPosition;
  35058. private _startingPointerTime;
  35059. private _previousStartingPointerTime;
  35060. private _pointerCaptures;
  35061. private _onKeyDown;
  35062. private _onKeyUp;
  35063. private _onCanvasFocusObserver;
  35064. private _onCanvasBlurObserver;
  35065. private _scene;
  35066. /**
  35067. * Creates a new InputManager
  35068. * @param scene defines the hosting scene
  35069. */
  35070. constructor(scene: Scene);
  35071. /**
  35072. * Gets the mesh that is currently under the pointer
  35073. */
  35074. get meshUnderPointer(): Nullable<AbstractMesh>;
  35075. /**
  35076. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35077. */
  35078. get unTranslatedPointer(): Vector2;
  35079. /**
  35080. * Gets or sets the current on-screen X position of the pointer
  35081. */
  35082. get pointerX(): number;
  35083. set pointerX(value: number);
  35084. /**
  35085. * Gets or sets the current on-screen Y position of the pointer
  35086. */
  35087. get pointerY(): number;
  35088. set pointerY(value: number);
  35089. private _updatePointerPosition;
  35090. private _processPointerMove;
  35091. private _setRayOnPointerInfo;
  35092. private _checkPrePointerObservable;
  35093. /**
  35094. * Use this method to simulate a pointer move on a mesh
  35095. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35096. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35097. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35098. */
  35099. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35100. /**
  35101. * Use this method to simulate a pointer down on a mesh
  35102. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35103. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35104. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35105. */
  35106. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35107. private _processPointerDown;
  35108. /** @hidden */
  35109. _isPointerSwiping(): boolean;
  35110. /**
  35111. * Use this method to simulate a pointer up on a mesh
  35112. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35113. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35114. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35115. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35116. */
  35117. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35118. private _processPointerUp;
  35119. /**
  35120. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35121. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35122. * @returns true if the pointer was captured
  35123. */
  35124. isPointerCaptured(pointerId?: number): boolean;
  35125. /**
  35126. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35127. * @param attachUp defines if you want to attach events to pointerup
  35128. * @param attachDown defines if you want to attach events to pointerdown
  35129. * @param attachMove defines if you want to attach events to pointermove
  35130. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35131. */
  35132. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35133. /**
  35134. * Detaches all event handlers
  35135. */
  35136. detachControl(): void;
  35137. /**
  35138. * Force the value of meshUnderPointer
  35139. * @param mesh defines the mesh to use
  35140. */
  35141. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35142. /**
  35143. * Gets the mesh under the pointer
  35144. * @returns a Mesh or null if no mesh is under the pointer
  35145. */
  35146. getPointerOverMesh(): Nullable<AbstractMesh>;
  35147. }
  35148. }
  35149. declare module BABYLON {
  35150. /**
  35151. * Helper class used to generate session unique ID
  35152. */
  35153. export class UniqueIdGenerator {
  35154. private static _UniqueIdCounter;
  35155. /**
  35156. * Gets an unique (relatively to the current scene) Id
  35157. */
  35158. static get UniqueId(): number;
  35159. }
  35160. }
  35161. declare module BABYLON {
  35162. /**
  35163. * This class defines the direct association between an animation and a target
  35164. */
  35165. export class TargetedAnimation {
  35166. /**
  35167. * Animation to perform
  35168. */
  35169. animation: Animation;
  35170. /**
  35171. * Target to animate
  35172. */
  35173. target: any;
  35174. /**
  35175. * Serialize the object
  35176. * @returns the JSON object representing the current entity
  35177. */
  35178. serialize(): any;
  35179. }
  35180. /**
  35181. * Use this class to create coordinated animations on multiple targets
  35182. */
  35183. export class AnimationGroup implements IDisposable {
  35184. /** The name of the animation group */
  35185. name: string;
  35186. private _scene;
  35187. private _targetedAnimations;
  35188. private _animatables;
  35189. private _from;
  35190. private _to;
  35191. private _isStarted;
  35192. private _isPaused;
  35193. private _speedRatio;
  35194. private _loopAnimation;
  35195. private _isAdditive;
  35196. /**
  35197. * Gets or sets the unique id of the node
  35198. */
  35199. uniqueId: number;
  35200. /**
  35201. * This observable will notify when one animation have ended
  35202. */
  35203. onAnimationEndObservable: Observable<TargetedAnimation>;
  35204. /**
  35205. * Observer raised when one animation loops
  35206. */
  35207. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35208. /**
  35209. * Observer raised when all animations have looped
  35210. */
  35211. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35212. /**
  35213. * This observable will notify when all animations have ended.
  35214. */
  35215. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35216. /**
  35217. * This observable will notify when all animations have paused.
  35218. */
  35219. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35220. /**
  35221. * This observable will notify when all animations are playing.
  35222. */
  35223. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35224. /**
  35225. * Gets the first frame
  35226. */
  35227. get from(): number;
  35228. /**
  35229. * Gets the last frame
  35230. */
  35231. get to(): number;
  35232. /**
  35233. * Define if the animations are started
  35234. */
  35235. get isStarted(): boolean;
  35236. /**
  35237. * Gets a value indicating that the current group is playing
  35238. */
  35239. get isPlaying(): boolean;
  35240. /**
  35241. * Gets or sets the speed ratio to use for all animations
  35242. */
  35243. get speedRatio(): number;
  35244. /**
  35245. * Gets or sets the speed ratio to use for all animations
  35246. */
  35247. set speedRatio(value: number);
  35248. /**
  35249. * Gets or sets if all animations should loop or not
  35250. */
  35251. get loopAnimation(): boolean;
  35252. set loopAnimation(value: boolean);
  35253. /**
  35254. * Gets or sets if all animations should be evaluated additively
  35255. */
  35256. get isAdditive(): boolean;
  35257. set isAdditive(value: boolean);
  35258. /**
  35259. * Gets the targeted animations for this animation group
  35260. */
  35261. get targetedAnimations(): Array<TargetedAnimation>;
  35262. /**
  35263. * returning the list of animatables controlled by this animation group.
  35264. */
  35265. get animatables(): Array<Animatable>;
  35266. /**
  35267. * Instantiates a new Animation Group.
  35268. * This helps managing several animations at once.
  35269. * @see http://doc.babylonjs.com/how_to/group
  35270. * @param name Defines the name of the group
  35271. * @param scene Defines the scene the group belongs to
  35272. */
  35273. constructor(
  35274. /** The name of the animation group */
  35275. name: string, scene?: Nullable<Scene>);
  35276. /**
  35277. * Add an animation (with its target) in the group
  35278. * @param animation defines the animation we want to add
  35279. * @param target defines the target of the animation
  35280. * @returns the TargetedAnimation object
  35281. */
  35282. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35283. /**
  35284. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35285. * It can add constant keys at begin or end
  35286. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35287. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35288. * @returns the animation group
  35289. */
  35290. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35291. private _animationLoopCount;
  35292. private _animationLoopFlags;
  35293. private _processLoop;
  35294. /**
  35295. * Start all animations on given targets
  35296. * @param loop defines if animations must loop
  35297. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35298. * @param from defines the from key (optional)
  35299. * @param to defines the to key (optional)
  35300. * @param isAdditive defines the additive state for the resulting animatables (optional)
  35301. * @returns the current animation group
  35302. */
  35303. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  35304. /**
  35305. * Pause all animations
  35306. * @returns the animation group
  35307. */
  35308. pause(): AnimationGroup;
  35309. /**
  35310. * Play all animations to initial state
  35311. * This function will start() the animations if they were not started or will restart() them if they were paused
  35312. * @param loop defines if animations must loop
  35313. * @returns the animation group
  35314. */
  35315. play(loop?: boolean): AnimationGroup;
  35316. /**
  35317. * Reset all animations to initial state
  35318. * @returns the animation group
  35319. */
  35320. reset(): AnimationGroup;
  35321. /**
  35322. * Restart animations from key 0
  35323. * @returns the animation group
  35324. */
  35325. restart(): AnimationGroup;
  35326. /**
  35327. * Stop all animations
  35328. * @returns the animation group
  35329. */
  35330. stop(): AnimationGroup;
  35331. /**
  35332. * Set animation weight for all animatables
  35333. * @param weight defines the weight to use
  35334. * @return the animationGroup
  35335. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35336. */
  35337. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35338. /**
  35339. * Synchronize and normalize all animatables with a source animatable
  35340. * @param root defines the root animatable to synchronize with
  35341. * @return the animationGroup
  35342. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35343. */
  35344. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35345. /**
  35346. * Goes to a specific frame in this animation group
  35347. * @param frame the frame number to go to
  35348. * @return the animationGroup
  35349. */
  35350. goToFrame(frame: number): AnimationGroup;
  35351. /**
  35352. * Dispose all associated resources
  35353. */
  35354. dispose(): void;
  35355. private _checkAnimationGroupEnded;
  35356. /**
  35357. * Clone the current animation group and returns a copy
  35358. * @param newName defines the name of the new group
  35359. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35360. * @returns the new aniamtion group
  35361. */
  35362. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35363. /**
  35364. * Serializes the animationGroup to an object
  35365. * @returns Serialized object
  35366. */
  35367. serialize(): any;
  35368. /**
  35369. * Returns a new AnimationGroup object parsed from the source provided.
  35370. * @param parsedAnimationGroup defines the source
  35371. * @param scene defines the scene that will receive the animationGroup
  35372. * @returns a new AnimationGroup
  35373. */
  35374. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35375. /**
  35376. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  35377. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  35378. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  35379. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  35380. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  35381. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  35382. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  35383. */
  35384. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  35385. /**
  35386. * Returns the string "AnimationGroup"
  35387. * @returns "AnimationGroup"
  35388. */
  35389. getClassName(): string;
  35390. /**
  35391. * Creates a detailled string about the object
  35392. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35393. * @returns a string representing the object
  35394. */
  35395. toString(fullDetails?: boolean): string;
  35396. }
  35397. }
  35398. declare module BABYLON {
  35399. /**
  35400. * Define an interface for all classes that will hold resources
  35401. */
  35402. export interface IDisposable {
  35403. /**
  35404. * Releases all held resources
  35405. */
  35406. dispose(): void;
  35407. }
  35408. /** Interface defining initialization parameters for Scene class */
  35409. export interface SceneOptions {
  35410. /**
  35411. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35412. * It will improve performance when the number of geometries becomes important.
  35413. */
  35414. useGeometryUniqueIdsMap?: boolean;
  35415. /**
  35416. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35417. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35418. */
  35419. useMaterialMeshMap?: boolean;
  35420. /**
  35421. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35422. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35423. */
  35424. useClonedMeshMap?: boolean;
  35425. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35426. virtual?: boolean;
  35427. }
  35428. /**
  35429. * Represents a scene to be rendered by the engine.
  35430. * @see http://doc.babylonjs.com/features/scene
  35431. */
  35432. export class Scene extends AbstractScene implements IAnimatable {
  35433. /** The fog is deactivated */
  35434. static readonly FOGMODE_NONE: number;
  35435. /** The fog density is following an exponential function */
  35436. static readonly FOGMODE_EXP: number;
  35437. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35438. static readonly FOGMODE_EXP2: number;
  35439. /** The fog density is following a linear function. */
  35440. static readonly FOGMODE_LINEAR: number;
  35441. /**
  35442. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35443. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35444. */
  35445. static MinDeltaTime: number;
  35446. /**
  35447. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35448. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35449. */
  35450. static MaxDeltaTime: number;
  35451. /**
  35452. * Factory used to create the default material.
  35453. * @param name The name of the material to create
  35454. * @param scene The scene to create the material for
  35455. * @returns The default material
  35456. */
  35457. static DefaultMaterialFactory(scene: Scene): Material;
  35458. /**
  35459. * Factory used to create the a collision coordinator.
  35460. * @returns The collision coordinator
  35461. */
  35462. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35463. /** @hidden */
  35464. _inputManager: InputManager;
  35465. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35466. cameraToUseForPointers: Nullable<Camera>;
  35467. /** @hidden */
  35468. readonly _isScene: boolean;
  35469. /** @hidden */
  35470. _blockEntityCollection: boolean;
  35471. /**
  35472. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35473. */
  35474. autoClear: boolean;
  35475. /**
  35476. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35477. */
  35478. autoClearDepthAndStencil: boolean;
  35479. /**
  35480. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35481. */
  35482. clearColor: Color4;
  35483. /**
  35484. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35485. */
  35486. ambientColor: Color3;
  35487. /**
  35488. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35489. * It should only be one of the following (if not the default embedded one):
  35490. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35491. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35492. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35493. * The material properties need to be setup according to the type of texture in use.
  35494. */
  35495. environmentBRDFTexture: BaseTexture;
  35496. /** @hidden */
  35497. protected _environmentTexture: Nullable<BaseTexture>;
  35498. /**
  35499. * Texture used in all pbr material as the reflection texture.
  35500. * As in the majority of the scene they are the same (exception for multi room and so on),
  35501. * this is easier to reference from here than from all the materials.
  35502. */
  35503. get environmentTexture(): Nullable<BaseTexture>;
  35504. /**
  35505. * Texture used in all pbr material as the reflection texture.
  35506. * As in the majority of the scene they are the same (exception for multi room and so on),
  35507. * this is easier to set here than in all the materials.
  35508. */
  35509. set environmentTexture(value: Nullable<BaseTexture>);
  35510. /** @hidden */
  35511. protected _environmentIntensity: number;
  35512. /**
  35513. * Intensity of the environment in all pbr material.
  35514. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35515. * As in the majority of the scene they are the same (exception for multi room and so on),
  35516. * this is easier to reference from here than from all the materials.
  35517. */
  35518. get environmentIntensity(): number;
  35519. /**
  35520. * Intensity of the environment in all pbr material.
  35521. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35522. * As in the majority of the scene they are the same (exception for multi room and so on),
  35523. * this is easier to set here than in all the materials.
  35524. */
  35525. set environmentIntensity(value: number);
  35526. /** @hidden */
  35527. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35528. /**
  35529. * Default image processing configuration used either in the rendering
  35530. * Forward main pass or through the imageProcessingPostProcess if present.
  35531. * As in the majority of the scene they are the same (exception for multi camera),
  35532. * this is easier to reference from here than from all the materials and post process.
  35533. *
  35534. * No setter as we it is a shared configuration, you can set the values instead.
  35535. */
  35536. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35537. private _forceWireframe;
  35538. /**
  35539. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35540. */
  35541. set forceWireframe(value: boolean);
  35542. get forceWireframe(): boolean;
  35543. private _skipFrustumClipping;
  35544. /**
  35545. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35546. */
  35547. set skipFrustumClipping(value: boolean);
  35548. get skipFrustumClipping(): boolean;
  35549. private _forcePointsCloud;
  35550. /**
  35551. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35552. */
  35553. set forcePointsCloud(value: boolean);
  35554. get forcePointsCloud(): boolean;
  35555. /**
  35556. * Gets or sets the active clipplane 1
  35557. */
  35558. clipPlane: Nullable<Plane>;
  35559. /**
  35560. * Gets or sets the active clipplane 2
  35561. */
  35562. clipPlane2: Nullable<Plane>;
  35563. /**
  35564. * Gets or sets the active clipplane 3
  35565. */
  35566. clipPlane3: Nullable<Plane>;
  35567. /**
  35568. * Gets or sets the active clipplane 4
  35569. */
  35570. clipPlane4: Nullable<Plane>;
  35571. /**
  35572. * Gets or sets the active clipplane 5
  35573. */
  35574. clipPlane5: Nullable<Plane>;
  35575. /**
  35576. * Gets or sets the active clipplane 6
  35577. */
  35578. clipPlane6: Nullable<Plane>;
  35579. /**
  35580. * Gets or sets a boolean indicating if animations are enabled
  35581. */
  35582. animationsEnabled: boolean;
  35583. private _animationPropertiesOverride;
  35584. /**
  35585. * Gets or sets the animation properties override
  35586. */
  35587. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35588. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35589. /**
  35590. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35591. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35592. */
  35593. useConstantAnimationDeltaTime: boolean;
  35594. /**
  35595. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35596. * Please note that it requires to run a ray cast through the scene on every frame
  35597. */
  35598. constantlyUpdateMeshUnderPointer: boolean;
  35599. /**
  35600. * Defines the HTML cursor to use when hovering over interactive elements
  35601. */
  35602. hoverCursor: string;
  35603. /**
  35604. * Defines the HTML default cursor to use (empty by default)
  35605. */
  35606. defaultCursor: string;
  35607. /**
  35608. * Defines whether cursors are handled by the scene.
  35609. */
  35610. doNotHandleCursors: boolean;
  35611. /**
  35612. * This is used to call preventDefault() on pointer down
  35613. * in order to block unwanted artifacts like system double clicks
  35614. */
  35615. preventDefaultOnPointerDown: boolean;
  35616. /**
  35617. * This is used to call preventDefault() on pointer up
  35618. * in order to block unwanted artifacts like system double clicks
  35619. */
  35620. preventDefaultOnPointerUp: boolean;
  35621. /**
  35622. * Gets or sets user defined metadata
  35623. */
  35624. metadata: any;
  35625. /**
  35626. * For internal use only. Please do not use.
  35627. */
  35628. reservedDataStore: any;
  35629. /**
  35630. * Gets the name of the plugin used to load this scene (null by default)
  35631. */
  35632. loadingPluginName: string;
  35633. /**
  35634. * Use this array to add regular expressions used to disable offline support for specific urls
  35635. */
  35636. disableOfflineSupportExceptionRules: RegExp[];
  35637. /**
  35638. * An event triggered when the scene is disposed.
  35639. */
  35640. onDisposeObservable: Observable<Scene>;
  35641. private _onDisposeObserver;
  35642. /** Sets a function to be executed when this scene is disposed. */
  35643. set onDispose(callback: () => void);
  35644. /**
  35645. * An event triggered before rendering the scene (right after animations and physics)
  35646. */
  35647. onBeforeRenderObservable: Observable<Scene>;
  35648. private _onBeforeRenderObserver;
  35649. /** Sets a function to be executed before rendering this scene */
  35650. set beforeRender(callback: Nullable<() => void>);
  35651. /**
  35652. * An event triggered after rendering the scene
  35653. */
  35654. onAfterRenderObservable: Observable<Scene>;
  35655. /**
  35656. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35657. */
  35658. onAfterRenderCameraObservable: Observable<Camera>;
  35659. private _onAfterRenderObserver;
  35660. /** Sets a function to be executed after rendering this scene */
  35661. set afterRender(callback: Nullable<() => void>);
  35662. /**
  35663. * An event triggered before animating the scene
  35664. */
  35665. onBeforeAnimationsObservable: Observable<Scene>;
  35666. /**
  35667. * An event triggered after animations processing
  35668. */
  35669. onAfterAnimationsObservable: Observable<Scene>;
  35670. /**
  35671. * An event triggered before draw calls are ready to be sent
  35672. */
  35673. onBeforeDrawPhaseObservable: Observable<Scene>;
  35674. /**
  35675. * An event triggered after draw calls have been sent
  35676. */
  35677. onAfterDrawPhaseObservable: Observable<Scene>;
  35678. /**
  35679. * An event triggered when the scene is ready
  35680. */
  35681. onReadyObservable: Observable<Scene>;
  35682. /**
  35683. * An event triggered before rendering a camera
  35684. */
  35685. onBeforeCameraRenderObservable: Observable<Camera>;
  35686. private _onBeforeCameraRenderObserver;
  35687. /** Sets a function to be executed before rendering a camera*/
  35688. set beforeCameraRender(callback: () => void);
  35689. /**
  35690. * An event triggered after rendering a camera
  35691. */
  35692. onAfterCameraRenderObservable: Observable<Camera>;
  35693. private _onAfterCameraRenderObserver;
  35694. /** Sets a function to be executed after rendering a camera*/
  35695. set afterCameraRender(callback: () => void);
  35696. /**
  35697. * An event triggered when active meshes evaluation is about to start
  35698. */
  35699. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35700. /**
  35701. * An event triggered when active meshes evaluation is done
  35702. */
  35703. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35704. /**
  35705. * An event triggered when particles rendering is about to start
  35706. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35707. */
  35708. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35709. /**
  35710. * An event triggered when particles rendering is done
  35711. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35712. */
  35713. onAfterParticlesRenderingObservable: Observable<Scene>;
  35714. /**
  35715. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35716. */
  35717. onDataLoadedObservable: Observable<Scene>;
  35718. /**
  35719. * An event triggered when a camera is created
  35720. */
  35721. onNewCameraAddedObservable: Observable<Camera>;
  35722. /**
  35723. * An event triggered when a camera is removed
  35724. */
  35725. onCameraRemovedObservable: Observable<Camera>;
  35726. /**
  35727. * An event triggered when a light is created
  35728. */
  35729. onNewLightAddedObservable: Observable<Light>;
  35730. /**
  35731. * An event triggered when a light is removed
  35732. */
  35733. onLightRemovedObservable: Observable<Light>;
  35734. /**
  35735. * An event triggered when a geometry is created
  35736. */
  35737. onNewGeometryAddedObservable: Observable<Geometry>;
  35738. /**
  35739. * An event triggered when a geometry is removed
  35740. */
  35741. onGeometryRemovedObservable: Observable<Geometry>;
  35742. /**
  35743. * An event triggered when a transform node is created
  35744. */
  35745. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35746. /**
  35747. * An event triggered when a transform node is removed
  35748. */
  35749. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35750. /**
  35751. * An event triggered when a mesh is created
  35752. */
  35753. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35754. /**
  35755. * An event triggered when a mesh is removed
  35756. */
  35757. onMeshRemovedObservable: Observable<AbstractMesh>;
  35758. /**
  35759. * An event triggered when a skeleton is created
  35760. */
  35761. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35762. /**
  35763. * An event triggered when a skeleton is removed
  35764. */
  35765. onSkeletonRemovedObservable: Observable<Skeleton>;
  35766. /**
  35767. * An event triggered when a material is created
  35768. */
  35769. onNewMaterialAddedObservable: Observable<Material>;
  35770. /**
  35771. * An event triggered when a material is removed
  35772. */
  35773. onMaterialRemovedObservable: Observable<Material>;
  35774. /**
  35775. * An event triggered when a texture is created
  35776. */
  35777. onNewTextureAddedObservable: Observable<BaseTexture>;
  35778. /**
  35779. * An event triggered when a texture is removed
  35780. */
  35781. onTextureRemovedObservable: Observable<BaseTexture>;
  35782. /**
  35783. * An event triggered when render targets are about to be rendered
  35784. * Can happen multiple times per frame.
  35785. */
  35786. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35787. /**
  35788. * An event triggered when render targets were rendered.
  35789. * Can happen multiple times per frame.
  35790. */
  35791. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35792. /**
  35793. * An event triggered before calculating deterministic simulation step
  35794. */
  35795. onBeforeStepObservable: Observable<Scene>;
  35796. /**
  35797. * An event triggered after calculating deterministic simulation step
  35798. */
  35799. onAfterStepObservable: Observable<Scene>;
  35800. /**
  35801. * An event triggered when the activeCamera property is updated
  35802. */
  35803. onActiveCameraChanged: Observable<Scene>;
  35804. /**
  35805. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35806. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35807. * 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)
  35808. */
  35809. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35810. /**
  35811. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35812. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35813. * 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)
  35814. */
  35815. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35816. /**
  35817. * This Observable will when a mesh has been imported into the scene.
  35818. */
  35819. onMeshImportedObservable: Observable<AbstractMesh>;
  35820. /**
  35821. * This Observable will when an animation file has been imported into the scene.
  35822. */
  35823. onAnimationFileImportedObservable: Observable<Scene>;
  35824. /**
  35825. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35826. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35827. */
  35828. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35829. /** @hidden */
  35830. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35831. /**
  35832. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35833. */
  35834. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35835. /**
  35836. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35837. */
  35838. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35839. /**
  35840. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35841. */
  35842. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35843. /** Callback called when a pointer move is detected */
  35844. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35845. /** Callback called when a pointer down is detected */
  35846. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35847. /** Callback called when a pointer up is detected */
  35848. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35849. /** Callback called when a pointer pick is detected */
  35850. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35851. /**
  35852. * 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).
  35853. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35854. */
  35855. onPrePointerObservable: Observable<PointerInfoPre>;
  35856. /**
  35857. * Observable event triggered each time an input event is received from the rendering canvas
  35858. */
  35859. onPointerObservable: Observable<PointerInfo>;
  35860. /**
  35861. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35862. */
  35863. get unTranslatedPointer(): Vector2;
  35864. /**
  35865. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35866. */
  35867. static get DragMovementThreshold(): number;
  35868. static set DragMovementThreshold(value: number);
  35869. /**
  35870. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35871. */
  35872. static get LongPressDelay(): number;
  35873. static set LongPressDelay(value: number);
  35874. /**
  35875. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35876. */
  35877. static get DoubleClickDelay(): number;
  35878. static set DoubleClickDelay(value: number);
  35879. /** If you need to check double click without raising a single click at first click, enable this flag */
  35880. static get ExclusiveDoubleClickMode(): boolean;
  35881. static set ExclusiveDoubleClickMode(value: boolean);
  35882. /** @hidden */
  35883. _mirroredCameraPosition: Nullable<Vector3>;
  35884. /**
  35885. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35886. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35887. */
  35888. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35889. /**
  35890. * Observable event triggered each time an keyboard event is received from the hosting window
  35891. */
  35892. onKeyboardObservable: Observable<KeyboardInfo>;
  35893. private _useRightHandedSystem;
  35894. /**
  35895. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35896. */
  35897. set useRightHandedSystem(value: boolean);
  35898. get useRightHandedSystem(): boolean;
  35899. private _timeAccumulator;
  35900. private _currentStepId;
  35901. private _currentInternalStep;
  35902. /**
  35903. * Sets the step Id used by deterministic lock step
  35904. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35905. * @param newStepId defines the step Id
  35906. */
  35907. setStepId(newStepId: number): void;
  35908. /**
  35909. * Gets the step Id used by deterministic lock step
  35910. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35911. * @returns the step Id
  35912. */
  35913. getStepId(): number;
  35914. /**
  35915. * Gets the internal step used by deterministic lock step
  35916. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35917. * @returns the internal step
  35918. */
  35919. getInternalStep(): number;
  35920. private _fogEnabled;
  35921. /**
  35922. * Gets or sets a boolean indicating if fog is enabled on this scene
  35923. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35924. * (Default is true)
  35925. */
  35926. set fogEnabled(value: boolean);
  35927. get fogEnabled(): boolean;
  35928. private _fogMode;
  35929. /**
  35930. * Gets or sets the fog mode to use
  35931. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35932. * | mode | value |
  35933. * | --- | --- |
  35934. * | FOGMODE_NONE | 0 |
  35935. * | FOGMODE_EXP | 1 |
  35936. * | FOGMODE_EXP2 | 2 |
  35937. * | FOGMODE_LINEAR | 3 |
  35938. */
  35939. set fogMode(value: number);
  35940. get fogMode(): number;
  35941. /**
  35942. * Gets or sets the fog color to use
  35943. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35944. * (Default is Color3(0.2, 0.2, 0.3))
  35945. */
  35946. fogColor: Color3;
  35947. /**
  35948. * Gets or sets the fog density to use
  35949. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35950. * (Default is 0.1)
  35951. */
  35952. fogDensity: number;
  35953. /**
  35954. * Gets or sets the fog start distance to use
  35955. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35956. * (Default is 0)
  35957. */
  35958. fogStart: number;
  35959. /**
  35960. * Gets or sets the fog end distance to use
  35961. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35962. * (Default is 1000)
  35963. */
  35964. fogEnd: number;
  35965. private _shadowsEnabled;
  35966. /**
  35967. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35968. */
  35969. set shadowsEnabled(value: boolean);
  35970. get shadowsEnabled(): boolean;
  35971. private _lightsEnabled;
  35972. /**
  35973. * Gets or sets a boolean indicating if lights are enabled on this scene
  35974. */
  35975. set lightsEnabled(value: boolean);
  35976. get lightsEnabled(): boolean;
  35977. /** All of the active cameras added to this scene. */
  35978. activeCameras: Camera[];
  35979. /** @hidden */
  35980. _activeCamera: Nullable<Camera>;
  35981. /** Gets or sets the current active camera */
  35982. get activeCamera(): Nullable<Camera>;
  35983. set activeCamera(value: Nullable<Camera>);
  35984. private _defaultMaterial;
  35985. /** The default material used on meshes when no material is affected */
  35986. get defaultMaterial(): Material;
  35987. /** The default material used on meshes when no material is affected */
  35988. set defaultMaterial(value: Material);
  35989. private _texturesEnabled;
  35990. /**
  35991. * Gets or sets a boolean indicating if textures are enabled on this scene
  35992. */
  35993. set texturesEnabled(value: boolean);
  35994. get texturesEnabled(): boolean;
  35995. /**
  35996. * Gets or sets a boolean indicating if particles are enabled on this scene
  35997. */
  35998. particlesEnabled: boolean;
  35999. /**
  36000. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36001. */
  36002. spritesEnabled: boolean;
  36003. private _skeletonsEnabled;
  36004. /**
  36005. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36006. */
  36007. set skeletonsEnabled(value: boolean);
  36008. get skeletonsEnabled(): boolean;
  36009. /**
  36010. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36011. */
  36012. lensFlaresEnabled: boolean;
  36013. /**
  36014. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36015. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36016. */
  36017. collisionsEnabled: boolean;
  36018. private _collisionCoordinator;
  36019. /** @hidden */
  36020. get collisionCoordinator(): ICollisionCoordinator;
  36021. /**
  36022. * Defines the gravity applied to this scene (used only for collisions)
  36023. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36024. */
  36025. gravity: Vector3;
  36026. /**
  36027. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36028. */
  36029. postProcessesEnabled: boolean;
  36030. /**
  36031. * The list of postprocesses added to the scene
  36032. */
  36033. postProcesses: PostProcess[];
  36034. /**
  36035. * Gets the current postprocess manager
  36036. */
  36037. postProcessManager: PostProcessManager;
  36038. /**
  36039. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36040. */
  36041. renderTargetsEnabled: boolean;
  36042. /**
  36043. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36044. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36045. */
  36046. dumpNextRenderTargets: boolean;
  36047. /**
  36048. * The list of user defined render targets added to the scene
  36049. */
  36050. customRenderTargets: RenderTargetTexture[];
  36051. /**
  36052. * Defines if texture loading must be delayed
  36053. * If true, textures will only be loaded when they need to be rendered
  36054. */
  36055. useDelayedTextureLoading: boolean;
  36056. /**
  36057. * Gets the list of meshes imported to the scene through SceneLoader
  36058. */
  36059. importedMeshesFiles: String[];
  36060. /**
  36061. * Gets or sets a boolean indicating if probes are enabled on this scene
  36062. */
  36063. probesEnabled: boolean;
  36064. /**
  36065. * Gets or sets the current offline provider to use to store scene data
  36066. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36067. */
  36068. offlineProvider: IOfflineProvider;
  36069. /**
  36070. * Gets or sets the action manager associated with the scene
  36071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36072. */
  36073. actionManager: AbstractActionManager;
  36074. private _meshesForIntersections;
  36075. /**
  36076. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36077. */
  36078. proceduralTexturesEnabled: boolean;
  36079. private _engine;
  36080. private _totalVertices;
  36081. /** @hidden */
  36082. _activeIndices: PerfCounter;
  36083. /** @hidden */
  36084. _activeParticles: PerfCounter;
  36085. /** @hidden */
  36086. _activeBones: PerfCounter;
  36087. private _animationRatio;
  36088. /** @hidden */
  36089. _animationTimeLast: number;
  36090. /** @hidden */
  36091. _animationTime: number;
  36092. /**
  36093. * Gets or sets a general scale for animation speed
  36094. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36095. */
  36096. animationTimeScale: number;
  36097. /** @hidden */
  36098. _cachedMaterial: Nullable<Material>;
  36099. /** @hidden */
  36100. _cachedEffect: Nullable<Effect>;
  36101. /** @hidden */
  36102. _cachedVisibility: Nullable<number>;
  36103. private _renderId;
  36104. private _frameId;
  36105. private _executeWhenReadyTimeoutId;
  36106. private _intermediateRendering;
  36107. private _viewUpdateFlag;
  36108. private _projectionUpdateFlag;
  36109. /** @hidden */
  36110. _toBeDisposed: Nullable<IDisposable>[];
  36111. private _activeRequests;
  36112. /** @hidden */
  36113. _pendingData: any[];
  36114. private _isDisposed;
  36115. /**
  36116. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36117. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36118. */
  36119. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36120. private _activeMeshes;
  36121. private _processedMaterials;
  36122. private _renderTargets;
  36123. /** @hidden */
  36124. _activeParticleSystems: SmartArray<IParticleSystem>;
  36125. private _activeSkeletons;
  36126. private _softwareSkinnedMeshes;
  36127. private _renderingManager;
  36128. /** @hidden */
  36129. _activeAnimatables: Animatable[];
  36130. private _transformMatrix;
  36131. private _sceneUbo;
  36132. /** @hidden */
  36133. _viewMatrix: Matrix;
  36134. private _projectionMatrix;
  36135. /** @hidden */
  36136. _forcedViewPosition: Nullable<Vector3>;
  36137. /** @hidden */
  36138. _frustumPlanes: Plane[];
  36139. /**
  36140. * Gets the list of frustum planes (built from the active camera)
  36141. */
  36142. get frustumPlanes(): Plane[];
  36143. /**
  36144. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36145. * This is useful if there are more lights that the maximum simulteanous authorized
  36146. */
  36147. requireLightSorting: boolean;
  36148. /** @hidden */
  36149. readonly useMaterialMeshMap: boolean;
  36150. /** @hidden */
  36151. readonly useClonedMeshMap: boolean;
  36152. private _externalData;
  36153. private _uid;
  36154. /**
  36155. * @hidden
  36156. * Backing store of defined scene components.
  36157. */
  36158. _components: ISceneComponent[];
  36159. /**
  36160. * @hidden
  36161. * Backing store of defined scene components.
  36162. */
  36163. _serializableComponents: ISceneSerializableComponent[];
  36164. /**
  36165. * List of components to register on the next registration step.
  36166. */
  36167. private _transientComponents;
  36168. /**
  36169. * Registers the transient components if needed.
  36170. */
  36171. private _registerTransientComponents;
  36172. /**
  36173. * @hidden
  36174. * Add a component to the scene.
  36175. * Note that the ccomponent could be registered on th next frame if this is called after
  36176. * the register component stage.
  36177. * @param component Defines the component to add to the scene
  36178. */
  36179. _addComponent(component: ISceneComponent): void;
  36180. /**
  36181. * @hidden
  36182. * Gets a component from the scene.
  36183. * @param name defines the name of the component to retrieve
  36184. * @returns the component or null if not present
  36185. */
  36186. _getComponent(name: string): Nullable<ISceneComponent>;
  36187. /**
  36188. * @hidden
  36189. * Defines the actions happening before camera updates.
  36190. */
  36191. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36192. /**
  36193. * @hidden
  36194. * Defines the actions happening before clear the canvas.
  36195. */
  36196. _beforeClearStage: Stage<SimpleStageAction>;
  36197. /**
  36198. * @hidden
  36199. * Defines the actions when collecting render targets for the frame.
  36200. */
  36201. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36202. /**
  36203. * @hidden
  36204. * Defines the actions happening for one camera in the frame.
  36205. */
  36206. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36207. /**
  36208. * @hidden
  36209. * Defines the actions happening during the per mesh ready checks.
  36210. */
  36211. _isReadyForMeshStage: Stage<MeshStageAction>;
  36212. /**
  36213. * @hidden
  36214. * Defines the actions happening before evaluate active mesh checks.
  36215. */
  36216. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36217. /**
  36218. * @hidden
  36219. * Defines the actions happening during the evaluate sub mesh checks.
  36220. */
  36221. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36222. /**
  36223. * @hidden
  36224. * Defines the actions happening during the active mesh stage.
  36225. */
  36226. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36227. /**
  36228. * @hidden
  36229. * Defines the actions happening during the per camera render target step.
  36230. */
  36231. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36232. /**
  36233. * @hidden
  36234. * Defines the actions happening just before the active camera is drawing.
  36235. */
  36236. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36237. /**
  36238. * @hidden
  36239. * Defines the actions happening just before a render target is drawing.
  36240. */
  36241. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36242. /**
  36243. * @hidden
  36244. * Defines the actions happening just before a rendering group is drawing.
  36245. */
  36246. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36247. /**
  36248. * @hidden
  36249. * Defines the actions happening just before a mesh is drawing.
  36250. */
  36251. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36252. /**
  36253. * @hidden
  36254. * Defines the actions happening just after a mesh has been drawn.
  36255. */
  36256. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36257. /**
  36258. * @hidden
  36259. * Defines the actions happening just after a rendering group has been drawn.
  36260. */
  36261. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36262. /**
  36263. * @hidden
  36264. * Defines the actions happening just after the active camera has been drawn.
  36265. */
  36266. _afterCameraDrawStage: Stage<CameraStageAction>;
  36267. /**
  36268. * @hidden
  36269. * Defines the actions happening just after a render target has been drawn.
  36270. */
  36271. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36272. /**
  36273. * @hidden
  36274. * Defines the actions happening just after rendering all cameras and computing intersections.
  36275. */
  36276. _afterRenderStage: Stage<SimpleStageAction>;
  36277. /**
  36278. * @hidden
  36279. * Defines the actions happening when a pointer move event happens.
  36280. */
  36281. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36282. /**
  36283. * @hidden
  36284. * Defines the actions happening when a pointer down event happens.
  36285. */
  36286. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36287. /**
  36288. * @hidden
  36289. * Defines the actions happening when a pointer up event happens.
  36290. */
  36291. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36292. /**
  36293. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36294. */
  36295. private geometriesByUniqueId;
  36296. /**
  36297. * Creates a new Scene
  36298. * @param engine defines the engine to use to render this scene
  36299. * @param options defines the scene options
  36300. */
  36301. constructor(engine: Engine, options?: SceneOptions);
  36302. /**
  36303. * Gets a string idenfifying the name of the class
  36304. * @returns "Scene" string
  36305. */
  36306. getClassName(): string;
  36307. private _defaultMeshCandidates;
  36308. /**
  36309. * @hidden
  36310. */
  36311. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36312. private _defaultSubMeshCandidates;
  36313. /**
  36314. * @hidden
  36315. */
  36316. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36317. /**
  36318. * Sets the default candidate providers for the scene.
  36319. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36320. * and getCollidingSubMeshCandidates to their default function
  36321. */
  36322. setDefaultCandidateProviders(): void;
  36323. /**
  36324. * Gets the mesh that is currently under the pointer
  36325. */
  36326. get meshUnderPointer(): Nullable<AbstractMesh>;
  36327. /**
  36328. * Gets or sets the current on-screen X position of the pointer
  36329. */
  36330. get pointerX(): number;
  36331. set pointerX(value: number);
  36332. /**
  36333. * Gets or sets the current on-screen Y position of the pointer
  36334. */
  36335. get pointerY(): number;
  36336. set pointerY(value: number);
  36337. /**
  36338. * Gets the cached material (ie. the latest rendered one)
  36339. * @returns the cached material
  36340. */
  36341. getCachedMaterial(): Nullable<Material>;
  36342. /**
  36343. * Gets the cached effect (ie. the latest rendered one)
  36344. * @returns the cached effect
  36345. */
  36346. getCachedEffect(): Nullable<Effect>;
  36347. /**
  36348. * Gets the cached visibility state (ie. the latest rendered one)
  36349. * @returns the cached visibility state
  36350. */
  36351. getCachedVisibility(): Nullable<number>;
  36352. /**
  36353. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36354. * @param material defines the current material
  36355. * @param effect defines the current effect
  36356. * @param visibility defines the current visibility state
  36357. * @returns true if one parameter is not cached
  36358. */
  36359. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36360. /**
  36361. * Gets the engine associated with the scene
  36362. * @returns an Engine
  36363. */
  36364. getEngine(): Engine;
  36365. /**
  36366. * Gets the total number of vertices rendered per frame
  36367. * @returns the total number of vertices rendered per frame
  36368. */
  36369. getTotalVertices(): number;
  36370. /**
  36371. * Gets the performance counter for total vertices
  36372. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36373. */
  36374. get totalVerticesPerfCounter(): PerfCounter;
  36375. /**
  36376. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36377. * @returns the total number of active indices rendered per frame
  36378. */
  36379. getActiveIndices(): number;
  36380. /**
  36381. * Gets the performance counter for active indices
  36382. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36383. */
  36384. get totalActiveIndicesPerfCounter(): PerfCounter;
  36385. /**
  36386. * Gets the total number of active particles rendered per frame
  36387. * @returns the total number of active particles rendered per frame
  36388. */
  36389. getActiveParticles(): number;
  36390. /**
  36391. * Gets the performance counter for active particles
  36392. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36393. */
  36394. get activeParticlesPerfCounter(): PerfCounter;
  36395. /**
  36396. * Gets the total number of active bones rendered per frame
  36397. * @returns the total number of active bones rendered per frame
  36398. */
  36399. getActiveBones(): number;
  36400. /**
  36401. * Gets the performance counter for active bones
  36402. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36403. */
  36404. get activeBonesPerfCounter(): PerfCounter;
  36405. /**
  36406. * Gets the array of active meshes
  36407. * @returns an array of AbstractMesh
  36408. */
  36409. getActiveMeshes(): SmartArray<AbstractMesh>;
  36410. /**
  36411. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36412. * @returns a number
  36413. */
  36414. getAnimationRatio(): number;
  36415. /**
  36416. * Gets an unique Id for the current render phase
  36417. * @returns a number
  36418. */
  36419. getRenderId(): number;
  36420. /**
  36421. * Gets an unique Id for the current frame
  36422. * @returns a number
  36423. */
  36424. getFrameId(): number;
  36425. /** Call this function if you want to manually increment the render Id*/
  36426. incrementRenderId(): void;
  36427. private _createUbo;
  36428. /**
  36429. * Use this method to simulate a pointer move on a mesh
  36430. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36431. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36432. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36433. * @returns the current scene
  36434. */
  36435. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36436. /**
  36437. * Use this method to simulate a pointer down on a mesh
  36438. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36439. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36440. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36441. * @returns the current scene
  36442. */
  36443. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36444. /**
  36445. * Use this method to simulate a pointer up on a mesh
  36446. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36447. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36448. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36449. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36450. * @returns the current scene
  36451. */
  36452. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36453. /**
  36454. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36455. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36456. * @returns true if the pointer was captured
  36457. */
  36458. isPointerCaptured(pointerId?: number): boolean;
  36459. /**
  36460. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36461. * @param attachUp defines if you want to attach events to pointerup
  36462. * @param attachDown defines if you want to attach events to pointerdown
  36463. * @param attachMove defines if you want to attach events to pointermove
  36464. */
  36465. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36466. /** Detaches all event handlers*/
  36467. detachControl(): void;
  36468. /**
  36469. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36470. * Delay loaded resources are not taking in account
  36471. * @return true if all required resources are ready
  36472. */
  36473. isReady(): boolean;
  36474. /** Resets all cached information relative to material (including effect and visibility) */
  36475. resetCachedMaterial(): void;
  36476. /**
  36477. * Registers a function to be called before every frame render
  36478. * @param func defines the function to register
  36479. */
  36480. registerBeforeRender(func: () => void): void;
  36481. /**
  36482. * Unregisters a function called before every frame render
  36483. * @param func defines the function to unregister
  36484. */
  36485. unregisterBeforeRender(func: () => void): void;
  36486. /**
  36487. * Registers a function to be called after every frame render
  36488. * @param func defines the function to register
  36489. */
  36490. registerAfterRender(func: () => void): void;
  36491. /**
  36492. * Unregisters a function called after every frame render
  36493. * @param func defines the function to unregister
  36494. */
  36495. unregisterAfterRender(func: () => void): void;
  36496. private _executeOnceBeforeRender;
  36497. /**
  36498. * The provided function will run before render once and will be disposed afterwards.
  36499. * A timeout delay can be provided so that the function will be executed in N ms.
  36500. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36501. * @param func The function to be executed.
  36502. * @param timeout optional delay in ms
  36503. */
  36504. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36505. /** @hidden */
  36506. _addPendingData(data: any): void;
  36507. /** @hidden */
  36508. _removePendingData(data: any): void;
  36509. /**
  36510. * Returns the number of items waiting to be loaded
  36511. * @returns the number of items waiting to be loaded
  36512. */
  36513. getWaitingItemsCount(): number;
  36514. /**
  36515. * Returns a boolean indicating if the scene is still loading data
  36516. */
  36517. get isLoading(): boolean;
  36518. /**
  36519. * Registers a function to be executed when the scene is ready
  36520. * @param {Function} func - the function to be executed
  36521. */
  36522. executeWhenReady(func: () => void): void;
  36523. /**
  36524. * Returns a promise that resolves when the scene is ready
  36525. * @returns A promise that resolves when the scene is ready
  36526. */
  36527. whenReadyAsync(): Promise<void>;
  36528. /** @hidden */
  36529. _checkIsReady(): void;
  36530. /**
  36531. * Gets all animatable attached to the scene
  36532. */
  36533. get animatables(): Animatable[];
  36534. /**
  36535. * Resets the last animation time frame.
  36536. * Useful to override when animations start running when loading a scene for the first time.
  36537. */
  36538. resetLastAnimationTimeFrame(): void;
  36539. /**
  36540. * Gets the current view matrix
  36541. * @returns a Matrix
  36542. */
  36543. getViewMatrix(): Matrix;
  36544. /**
  36545. * Gets the current projection matrix
  36546. * @returns a Matrix
  36547. */
  36548. getProjectionMatrix(): Matrix;
  36549. /**
  36550. * Gets the current transform matrix
  36551. * @returns a Matrix made of View * Projection
  36552. */
  36553. getTransformMatrix(): Matrix;
  36554. /**
  36555. * Sets the current transform matrix
  36556. * @param viewL defines the View matrix to use
  36557. * @param projectionL defines the Projection matrix to use
  36558. * @param viewR defines the right View matrix to use (if provided)
  36559. * @param projectionR defines the right Projection matrix to use (if provided)
  36560. */
  36561. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36562. /**
  36563. * Gets the uniform buffer used to store scene data
  36564. * @returns a UniformBuffer
  36565. */
  36566. getSceneUniformBuffer(): UniformBuffer;
  36567. /**
  36568. * Gets an unique (relatively to the current scene) Id
  36569. * @returns an unique number for the scene
  36570. */
  36571. getUniqueId(): number;
  36572. /**
  36573. * Add a mesh to the list of scene's meshes
  36574. * @param newMesh defines the mesh to add
  36575. * @param recursive if all child meshes should also be added to the scene
  36576. */
  36577. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36578. /**
  36579. * Remove a mesh for the list of scene's meshes
  36580. * @param toRemove defines the mesh to remove
  36581. * @param recursive if all child meshes should also be removed from the scene
  36582. * @returns the index where the mesh was in the mesh list
  36583. */
  36584. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36585. /**
  36586. * Add a transform node to the list of scene's transform nodes
  36587. * @param newTransformNode defines the transform node to add
  36588. */
  36589. addTransformNode(newTransformNode: TransformNode): void;
  36590. /**
  36591. * Remove a transform node for the list of scene's transform nodes
  36592. * @param toRemove defines the transform node to remove
  36593. * @returns the index where the transform node was in the transform node list
  36594. */
  36595. removeTransformNode(toRemove: TransformNode): number;
  36596. /**
  36597. * Remove a skeleton for the list of scene's skeletons
  36598. * @param toRemove defines the skeleton to remove
  36599. * @returns the index where the skeleton was in the skeleton list
  36600. */
  36601. removeSkeleton(toRemove: Skeleton): number;
  36602. /**
  36603. * Remove a morph target for the list of scene's morph targets
  36604. * @param toRemove defines the morph target to remove
  36605. * @returns the index where the morph target was in the morph target list
  36606. */
  36607. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36608. /**
  36609. * Remove a light for the list of scene's lights
  36610. * @param toRemove defines the light to remove
  36611. * @returns the index where the light was in the light list
  36612. */
  36613. removeLight(toRemove: Light): number;
  36614. /**
  36615. * Remove a camera for the list of scene's cameras
  36616. * @param toRemove defines the camera to remove
  36617. * @returns the index where the camera was in the camera list
  36618. */
  36619. removeCamera(toRemove: Camera): number;
  36620. /**
  36621. * Remove a particle system for the list of scene's particle systems
  36622. * @param toRemove defines the particle system to remove
  36623. * @returns the index where the particle system was in the particle system list
  36624. */
  36625. removeParticleSystem(toRemove: IParticleSystem): number;
  36626. /**
  36627. * Remove a animation for the list of scene's animations
  36628. * @param toRemove defines the animation to remove
  36629. * @returns the index where the animation was in the animation list
  36630. */
  36631. removeAnimation(toRemove: Animation): number;
  36632. /**
  36633. * Will stop the animation of the given target
  36634. * @param target - the target
  36635. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36636. * @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)
  36637. */
  36638. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36639. /**
  36640. * Removes the given animation group from this scene.
  36641. * @param toRemove The animation group to remove
  36642. * @returns The index of the removed animation group
  36643. */
  36644. removeAnimationGroup(toRemove: AnimationGroup): number;
  36645. /**
  36646. * Removes the given multi-material from this scene.
  36647. * @param toRemove The multi-material to remove
  36648. * @returns The index of the removed multi-material
  36649. */
  36650. removeMultiMaterial(toRemove: MultiMaterial): number;
  36651. /**
  36652. * Removes the given material from this scene.
  36653. * @param toRemove The material to remove
  36654. * @returns The index of the removed material
  36655. */
  36656. removeMaterial(toRemove: Material): number;
  36657. /**
  36658. * Removes the given action manager from this scene.
  36659. * @param toRemove The action manager to remove
  36660. * @returns The index of the removed action manager
  36661. */
  36662. removeActionManager(toRemove: AbstractActionManager): number;
  36663. /**
  36664. * Removes the given texture from this scene.
  36665. * @param toRemove The texture to remove
  36666. * @returns The index of the removed texture
  36667. */
  36668. removeTexture(toRemove: BaseTexture): number;
  36669. /**
  36670. * Adds the given light to this scene
  36671. * @param newLight The light to add
  36672. */
  36673. addLight(newLight: Light): void;
  36674. /**
  36675. * Sorts the list list based on light priorities
  36676. */
  36677. sortLightsByPriority(): void;
  36678. /**
  36679. * Adds the given camera to this scene
  36680. * @param newCamera The camera to add
  36681. */
  36682. addCamera(newCamera: Camera): void;
  36683. /**
  36684. * Adds the given skeleton to this scene
  36685. * @param newSkeleton The skeleton to add
  36686. */
  36687. addSkeleton(newSkeleton: Skeleton): void;
  36688. /**
  36689. * Adds the given particle system to this scene
  36690. * @param newParticleSystem The particle system to add
  36691. */
  36692. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36693. /**
  36694. * Adds the given animation to this scene
  36695. * @param newAnimation The animation to add
  36696. */
  36697. addAnimation(newAnimation: Animation): void;
  36698. /**
  36699. * Adds the given animation group to this scene.
  36700. * @param newAnimationGroup The animation group to add
  36701. */
  36702. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36703. /**
  36704. * Adds the given multi-material to this scene
  36705. * @param newMultiMaterial The multi-material to add
  36706. */
  36707. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36708. /**
  36709. * Adds the given material to this scene
  36710. * @param newMaterial The material to add
  36711. */
  36712. addMaterial(newMaterial: Material): void;
  36713. /**
  36714. * Adds the given morph target to this scene
  36715. * @param newMorphTargetManager The morph target to add
  36716. */
  36717. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36718. /**
  36719. * Adds the given geometry to this scene
  36720. * @param newGeometry The geometry to add
  36721. */
  36722. addGeometry(newGeometry: Geometry): void;
  36723. /**
  36724. * Adds the given action manager to this scene
  36725. * @param newActionManager The action manager to add
  36726. */
  36727. addActionManager(newActionManager: AbstractActionManager): void;
  36728. /**
  36729. * Adds the given texture to this scene.
  36730. * @param newTexture The texture to add
  36731. */
  36732. addTexture(newTexture: BaseTexture): void;
  36733. /**
  36734. * Switch active camera
  36735. * @param newCamera defines the new active camera
  36736. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36737. */
  36738. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36739. /**
  36740. * sets the active camera of the scene using its ID
  36741. * @param id defines the camera's ID
  36742. * @return the new active camera or null if none found.
  36743. */
  36744. setActiveCameraByID(id: string): Nullable<Camera>;
  36745. /**
  36746. * sets the active camera of the scene using its name
  36747. * @param name defines the camera's name
  36748. * @returns the new active camera or null if none found.
  36749. */
  36750. setActiveCameraByName(name: string): Nullable<Camera>;
  36751. /**
  36752. * get an animation group using its name
  36753. * @param name defines the material's name
  36754. * @return the animation group or null if none found.
  36755. */
  36756. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36757. /**
  36758. * Get a material using its unique id
  36759. * @param uniqueId defines the material's unique id
  36760. * @return the material or null if none found.
  36761. */
  36762. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36763. /**
  36764. * get a material using its id
  36765. * @param id defines the material's ID
  36766. * @return the material or null if none found.
  36767. */
  36768. getMaterialByID(id: string): Nullable<Material>;
  36769. /**
  36770. * Gets a the last added material using a given id
  36771. * @param id defines the material's ID
  36772. * @return the last material with the given id or null if none found.
  36773. */
  36774. getLastMaterialByID(id: string): Nullable<Material>;
  36775. /**
  36776. * Gets a material using its name
  36777. * @param name defines the material's name
  36778. * @return the material or null if none found.
  36779. */
  36780. getMaterialByName(name: string): Nullable<Material>;
  36781. /**
  36782. * Get a texture using its unique id
  36783. * @param uniqueId defines the texture's unique id
  36784. * @return the texture or null if none found.
  36785. */
  36786. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36787. /**
  36788. * Gets a camera using its id
  36789. * @param id defines the id to look for
  36790. * @returns the camera or null if not found
  36791. */
  36792. getCameraByID(id: string): Nullable<Camera>;
  36793. /**
  36794. * Gets a camera using its unique id
  36795. * @param uniqueId defines the unique id to look for
  36796. * @returns the camera or null if not found
  36797. */
  36798. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36799. /**
  36800. * Gets a camera using its name
  36801. * @param name defines the camera's name
  36802. * @return the camera or null if none found.
  36803. */
  36804. getCameraByName(name: string): Nullable<Camera>;
  36805. /**
  36806. * Gets a bone using its id
  36807. * @param id defines the bone's id
  36808. * @return the bone or null if not found
  36809. */
  36810. getBoneByID(id: string): Nullable<Bone>;
  36811. /**
  36812. * Gets a bone using its id
  36813. * @param name defines the bone's name
  36814. * @return the bone or null if not found
  36815. */
  36816. getBoneByName(name: string): Nullable<Bone>;
  36817. /**
  36818. * Gets a light node using its name
  36819. * @param name defines the the light's name
  36820. * @return the light or null if none found.
  36821. */
  36822. getLightByName(name: string): Nullable<Light>;
  36823. /**
  36824. * Gets a light node using its id
  36825. * @param id defines the light's id
  36826. * @return the light or null if none found.
  36827. */
  36828. getLightByID(id: string): Nullable<Light>;
  36829. /**
  36830. * Gets a light node using its scene-generated unique ID
  36831. * @param uniqueId defines the light's unique id
  36832. * @return the light or null if none found.
  36833. */
  36834. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36835. /**
  36836. * Gets a particle system by id
  36837. * @param id defines the particle system id
  36838. * @return the corresponding system or null if none found
  36839. */
  36840. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36841. /**
  36842. * Gets a geometry using its ID
  36843. * @param id defines the geometry's id
  36844. * @return the geometry or null if none found.
  36845. */
  36846. getGeometryByID(id: string): Nullable<Geometry>;
  36847. private _getGeometryByUniqueID;
  36848. /**
  36849. * Add a new geometry to this scene
  36850. * @param geometry defines the geometry to be added to the scene.
  36851. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36852. * @return a boolean defining if the geometry was added or not
  36853. */
  36854. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36855. /**
  36856. * Removes an existing geometry
  36857. * @param geometry defines the geometry to be removed from the scene
  36858. * @return a boolean defining if the geometry was removed or not
  36859. */
  36860. removeGeometry(geometry: Geometry): boolean;
  36861. /**
  36862. * Gets the list of geometries attached to the scene
  36863. * @returns an array of Geometry
  36864. */
  36865. getGeometries(): Geometry[];
  36866. /**
  36867. * Gets the first added mesh found of a given ID
  36868. * @param id defines the id to search for
  36869. * @return the mesh found or null if not found at all
  36870. */
  36871. getMeshByID(id: string): Nullable<AbstractMesh>;
  36872. /**
  36873. * Gets a list of meshes using their id
  36874. * @param id defines the id to search for
  36875. * @returns a list of meshes
  36876. */
  36877. getMeshesByID(id: string): Array<AbstractMesh>;
  36878. /**
  36879. * Gets the first added transform node found of a given ID
  36880. * @param id defines the id to search for
  36881. * @return the found transform node or null if not found at all.
  36882. */
  36883. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36884. /**
  36885. * Gets a transform node with its auto-generated unique id
  36886. * @param uniqueId efines the unique id to search for
  36887. * @return the found transform node or null if not found at all.
  36888. */
  36889. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36890. /**
  36891. * Gets a list of transform nodes using their id
  36892. * @param id defines the id to search for
  36893. * @returns a list of transform nodes
  36894. */
  36895. getTransformNodesByID(id: string): Array<TransformNode>;
  36896. /**
  36897. * Gets a mesh with its auto-generated unique id
  36898. * @param uniqueId defines the unique id to search for
  36899. * @return the found mesh or null if not found at all.
  36900. */
  36901. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36902. /**
  36903. * Gets a the last added mesh using a given id
  36904. * @param id defines the id to search for
  36905. * @return the found mesh or null if not found at all.
  36906. */
  36907. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36908. /**
  36909. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36910. * @param id defines the id to search for
  36911. * @return the found node or null if not found at all
  36912. */
  36913. getLastEntryByID(id: string): Nullable<Node>;
  36914. /**
  36915. * Gets a node (Mesh, Camera, Light) using a given id
  36916. * @param id defines the id to search for
  36917. * @return the found node or null if not found at all
  36918. */
  36919. getNodeByID(id: string): Nullable<Node>;
  36920. /**
  36921. * Gets a node (Mesh, Camera, Light) using a given name
  36922. * @param name defines the name to search for
  36923. * @return the found node or null if not found at all.
  36924. */
  36925. getNodeByName(name: string): Nullable<Node>;
  36926. /**
  36927. * Gets a mesh using a given name
  36928. * @param name defines the name to search for
  36929. * @return the found mesh or null if not found at all.
  36930. */
  36931. getMeshByName(name: string): Nullable<AbstractMesh>;
  36932. /**
  36933. * Gets a transform node using a given name
  36934. * @param name defines the name to search for
  36935. * @return the found transform node or null if not found at all.
  36936. */
  36937. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36938. /**
  36939. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36940. * @param id defines the id to search for
  36941. * @return the found skeleton or null if not found at all.
  36942. */
  36943. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36944. /**
  36945. * Gets a skeleton using a given auto generated unique id
  36946. * @param uniqueId defines the unique id to search for
  36947. * @return the found skeleton or null if not found at all.
  36948. */
  36949. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36950. /**
  36951. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36952. * @param id defines the id to search for
  36953. * @return the found skeleton or null if not found at all.
  36954. */
  36955. getSkeletonById(id: string): Nullable<Skeleton>;
  36956. /**
  36957. * Gets a skeleton using a given name
  36958. * @param name defines the name to search for
  36959. * @return the found skeleton or null if not found at all.
  36960. */
  36961. getSkeletonByName(name: string): Nullable<Skeleton>;
  36962. /**
  36963. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36964. * @param id defines the id to search for
  36965. * @return the found morph target manager or null if not found at all.
  36966. */
  36967. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36968. /**
  36969. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36970. * @param id defines the id to search for
  36971. * @return the found morph target or null if not found at all.
  36972. */
  36973. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36974. /**
  36975. * Gets a boolean indicating if the given mesh is active
  36976. * @param mesh defines the mesh to look for
  36977. * @returns true if the mesh is in the active list
  36978. */
  36979. isActiveMesh(mesh: AbstractMesh): boolean;
  36980. /**
  36981. * Return a unique id as a string which can serve as an identifier for the scene
  36982. */
  36983. get uid(): string;
  36984. /**
  36985. * Add an externaly attached data from its key.
  36986. * This method call will fail and return false, if such key already exists.
  36987. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36988. * @param key the unique key that identifies the data
  36989. * @param data the data object to associate to the key for this Engine instance
  36990. * @return true if no such key were already present and the data was added successfully, false otherwise
  36991. */
  36992. addExternalData<T>(key: string, data: T): boolean;
  36993. /**
  36994. * Get an externaly attached data from its key
  36995. * @param key the unique key that identifies the data
  36996. * @return the associated data, if present (can be null), or undefined if not present
  36997. */
  36998. getExternalData<T>(key: string): Nullable<T>;
  36999. /**
  37000. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37001. * @param key the unique key that identifies the data
  37002. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37003. * @return the associated data, can be null if the factory returned null.
  37004. */
  37005. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37006. /**
  37007. * Remove an externaly attached data from the Engine instance
  37008. * @param key the unique key that identifies the data
  37009. * @return true if the data was successfully removed, false if it doesn't exist
  37010. */
  37011. removeExternalData(key: string): boolean;
  37012. private _evaluateSubMesh;
  37013. /**
  37014. * Clear the processed materials smart array preventing retention point in material dispose.
  37015. */
  37016. freeProcessedMaterials(): void;
  37017. private _preventFreeActiveMeshesAndRenderingGroups;
  37018. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37019. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37020. * when disposing several meshes in a row or a hierarchy of meshes.
  37021. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37022. */
  37023. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37024. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37025. /**
  37026. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37027. */
  37028. freeActiveMeshes(): void;
  37029. /**
  37030. * Clear the info related to rendering groups preventing retention points during dispose.
  37031. */
  37032. freeRenderingGroups(): void;
  37033. /** @hidden */
  37034. _isInIntermediateRendering(): boolean;
  37035. /**
  37036. * Lambda returning the list of potentially active meshes.
  37037. */
  37038. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37039. /**
  37040. * Lambda returning the list of potentially active sub meshes.
  37041. */
  37042. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37043. /**
  37044. * Lambda returning the list of potentially intersecting sub meshes.
  37045. */
  37046. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37047. /**
  37048. * Lambda returning the list of potentially colliding sub meshes.
  37049. */
  37050. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37051. private _activeMeshesFrozen;
  37052. private _skipEvaluateActiveMeshesCompletely;
  37053. /**
  37054. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37055. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37056. * @returns the current scene
  37057. */
  37058. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37059. /**
  37060. * Use this function to restart evaluating active meshes on every frame
  37061. * @returns the current scene
  37062. */
  37063. unfreezeActiveMeshes(): Scene;
  37064. private _evaluateActiveMeshes;
  37065. private _activeMesh;
  37066. /**
  37067. * Update the transform matrix to update from the current active camera
  37068. * @param force defines a boolean used to force the update even if cache is up to date
  37069. */
  37070. updateTransformMatrix(force?: boolean): void;
  37071. private _bindFrameBuffer;
  37072. /** @hidden */
  37073. _allowPostProcessClearColor: boolean;
  37074. /** @hidden */
  37075. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37076. private _processSubCameras;
  37077. private _checkIntersections;
  37078. /** @hidden */
  37079. _advancePhysicsEngineStep(step: number): void;
  37080. /**
  37081. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37082. */
  37083. getDeterministicFrameTime: () => number;
  37084. /** @hidden */
  37085. _animate(): void;
  37086. /** Execute all animations (for a frame) */
  37087. animate(): void;
  37088. /**
  37089. * Render the scene
  37090. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37091. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37092. */
  37093. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37094. /**
  37095. * Freeze all materials
  37096. * A frozen material will not be updatable but should be faster to render
  37097. */
  37098. freezeMaterials(): void;
  37099. /**
  37100. * Unfreeze all materials
  37101. * A frozen material will not be updatable but should be faster to render
  37102. */
  37103. unfreezeMaterials(): void;
  37104. /**
  37105. * Releases all held ressources
  37106. */
  37107. dispose(): void;
  37108. /**
  37109. * Gets if the scene is already disposed
  37110. */
  37111. get isDisposed(): boolean;
  37112. /**
  37113. * Call this function to reduce memory footprint of the scene.
  37114. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37115. */
  37116. clearCachedVertexData(): void;
  37117. /**
  37118. * This function will remove the local cached buffer data from texture.
  37119. * It will save memory but will prevent the texture from being rebuilt
  37120. */
  37121. cleanCachedTextureBuffer(): void;
  37122. /**
  37123. * Get the world extend vectors with an optional filter
  37124. *
  37125. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37126. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37127. */
  37128. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37129. min: Vector3;
  37130. max: Vector3;
  37131. };
  37132. /**
  37133. * Creates a ray that can be used to pick in the scene
  37134. * @param x defines the x coordinate of the origin (on-screen)
  37135. * @param y defines the y coordinate of the origin (on-screen)
  37136. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37137. * @param camera defines the camera to use for the picking
  37138. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37139. * @returns a Ray
  37140. */
  37141. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37142. /**
  37143. * Creates a ray that can be used to pick in the scene
  37144. * @param x defines the x coordinate of the origin (on-screen)
  37145. * @param y defines the y coordinate of the origin (on-screen)
  37146. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37147. * @param result defines the ray where to store the picking ray
  37148. * @param camera defines the camera to use for the picking
  37149. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37150. * @returns the current scene
  37151. */
  37152. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37153. /**
  37154. * Creates a ray that can be used to pick in the scene
  37155. * @param x defines the x coordinate of the origin (on-screen)
  37156. * @param y defines the y coordinate of the origin (on-screen)
  37157. * @param camera defines the camera to use for the picking
  37158. * @returns a Ray
  37159. */
  37160. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37161. /**
  37162. * Creates a ray that can be used to pick in the scene
  37163. * @param x defines the x coordinate of the origin (on-screen)
  37164. * @param y defines the y coordinate of the origin (on-screen)
  37165. * @param result defines the ray where to store the picking ray
  37166. * @param camera defines the camera to use for the picking
  37167. * @returns the current scene
  37168. */
  37169. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37170. /** Launch a ray to try to pick a mesh in the scene
  37171. * @param x position on screen
  37172. * @param y position on screen
  37173. * @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
  37174. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37175. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37176. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37177. * @returns a PickingInfo
  37178. */
  37179. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37180. /** Use the given ray to pick a mesh in the scene
  37181. * @param ray The ray to use to pick meshes
  37182. * @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
  37183. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37184. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37185. * @returns a PickingInfo
  37186. */
  37187. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37188. /**
  37189. * Launch a ray to try to pick a mesh in the scene
  37190. * @param x X position on screen
  37191. * @param y Y position on screen
  37192. * @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
  37193. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37194. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37195. * @returns an array of PickingInfo
  37196. */
  37197. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37198. /**
  37199. * Launch a ray to try to pick a mesh in the scene
  37200. * @param ray Ray to use
  37201. * @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
  37202. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37203. * @returns an array of PickingInfo
  37204. */
  37205. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37206. /**
  37207. * Force the value of meshUnderPointer
  37208. * @param mesh defines the mesh to use
  37209. */
  37210. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37211. /**
  37212. * Gets the mesh under the pointer
  37213. * @returns a Mesh or null if no mesh is under the pointer
  37214. */
  37215. getPointerOverMesh(): Nullable<AbstractMesh>;
  37216. /** @hidden */
  37217. _rebuildGeometries(): void;
  37218. /** @hidden */
  37219. _rebuildTextures(): void;
  37220. private _getByTags;
  37221. /**
  37222. * Get a list of meshes by tags
  37223. * @param tagsQuery defines the tags query to use
  37224. * @param forEach defines a predicate used to filter results
  37225. * @returns an array of Mesh
  37226. */
  37227. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37228. /**
  37229. * Get a list of cameras by tags
  37230. * @param tagsQuery defines the tags query to use
  37231. * @param forEach defines a predicate used to filter results
  37232. * @returns an array of Camera
  37233. */
  37234. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37235. /**
  37236. * Get a list of lights by tags
  37237. * @param tagsQuery defines the tags query to use
  37238. * @param forEach defines a predicate used to filter results
  37239. * @returns an array of Light
  37240. */
  37241. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37242. /**
  37243. * Get a list of materials by tags
  37244. * @param tagsQuery defines the tags query to use
  37245. * @param forEach defines a predicate used to filter results
  37246. * @returns an array of Material
  37247. */
  37248. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37249. /**
  37250. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37251. * This allowed control for front to back rendering or reversly depending of the special needs.
  37252. *
  37253. * @param renderingGroupId The rendering group id corresponding to its index
  37254. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37255. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37256. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37257. */
  37258. 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;
  37259. /**
  37260. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37261. *
  37262. * @param renderingGroupId The rendering group id corresponding to its index
  37263. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37264. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37265. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37266. */
  37267. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37268. /**
  37269. * Gets the current auto clear configuration for one rendering group of the rendering
  37270. * manager.
  37271. * @param index the rendering group index to get the information for
  37272. * @returns The auto clear setup for the requested rendering group
  37273. */
  37274. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37275. private _blockMaterialDirtyMechanism;
  37276. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37277. get blockMaterialDirtyMechanism(): boolean;
  37278. set blockMaterialDirtyMechanism(value: boolean);
  37279. /**
  37280. * Will flag all materials as dirty to trigger new shader compilation
  37281. * @param flag defines the flag used to specify which material part must be marked as dirty
  37282. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37283. */
  37284. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37285. /** @hidden */
  37286. _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;
  37287. /** @hidden */
  37288. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37289. /** @hidden */
  37290. _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;
  37291. /** @hidden */
  37292. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37293. /** @hidden */
  37294. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37295. /** @hidden */
  37296. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37297. }
  37298. }
  37299. declare module BABYLON {
  37300. /**
  37301. * Set of assets to keep when moving a scene into an asset container.
  37302. */
  37303. export class KeepAssets extends AbstractScene {
  37304. }
  37305. /**
  37306. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37307. */
  37308. export class InstantiatedEntries {
  37309. /**
  37310. * List of new root nodes (eg. nodes with no parent)
  37311. */
  37312. rootNodes: TransformNode[];
  37313. /**
  37314. * List of new skeletons
  37315. */
  37316. skeletons: Skeleton[];
  37317. /**
  37318. * List of new animation groups
  37319. */
  37320. animationGroups: AnimationGroup[];
  37321. }
  37322. /**
  37323. * Container with a set of assets that can be added or removed from a scene.
  37324. */
  37325. export class AssetContainer extends AbstractScene {
  37326. private _wasAddedToScene;
  37327. /**
  37328. * The scene the AssetContainer belongs to.
  37329. */
  37330. scene: Scene;
  37331. /**
  37332. * Instantiates an AssetContainer.
  37333. * @param scene The scene the AssetContainer belongs to.
  37334. */
  37335. constructor(scene: Scene);
  37336. /**
  37337. * Instantiate or clone all meshes and add the new ones to the scene.
  37338. * Skeletons and animation groups will all be cloned
  37339. * @param nameFunction defines an optional function used to get new names for clones
  37340. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37341. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37342. */
  37343. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37344. /**
  37345. * Adds all the assets from the container to the scene.
  37346. */
  37347. addAllToScene(): void;
  37348. /**
  37349. * Removes all the assets in the container from the scene
  37350. */
  37351. removeAllFromScene(): void;
  37352. /**
  37353. * Disposes all the assets in the container
  37354. */
  37355. dispose(): void;
  37356. private _moveAssets;
  37357. /**
  37358. * Removes all the assets contained in the scene and adds them to the container.
  37359. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37360. */
  37361. moveAllFromScene(keepAssets?: KeepAssets): void;
  37362. /**
  37363. * 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.
  37364. * @returns the root mesh
  37365. */
  37366. createRootMesh(): Mesh;
  37367. /**
  37368. * Merge animations from this asset container into a scene
  37369. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37370. * @param animatables set of animatables to retarget to a node from the scene
  37371. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37372. */
  37373. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37374. }
  37375. }
  37376. declare module BABYLON {
  37377. /**
  37378. * Defines how the parser contract is defined.
  37379. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37380. */
  37381. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37382. /**
  37383. * Defines how the individual parser contract is defined.
  37384. * These parser can parse an individual asset
  37385. */
  37386. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37387. /**
  37388. * Base class of the scene acting as a container for the different elements composing a scene.
  37389. * This class is dynamically extended by the different components of the scene increasing
  37390. * flexibility and reducing coupling
  37391. */
  37392. export abstract class AbstractScene {
  37393. /**
  37394. * Stores the list of available parsers in the application.
  37395. */
  37396. private static _BabylonFileParsers;
  37397. /**
  37398. * Stores the list of available individual parsers in the application.
  37399. */
  37400. private static _IndividualBabylonFileParsers;
  37401. /**
  37402. * Adds a parser in the list of available ones
  37403. * @param name Defines the name of the parser
  37404. * @param parser Defines the parser to add
  37405. */
  37406. static AddParser(name: string, parser: BabylonFileParser): void;
  37407. /**
  37408. * Gets a general parser from the list of avaialble ones
  37409. * @param name Defines the name of the parser
  37410. * @returns the requested parser or null
  37411. */
  37412. static GetParser(name: string): Nullable<BabylonFileParser>;
  37413. /**
  37414. * Adds n individual parser in the list of available ones
  37415. * @param name Defines the name of the parser
  37416. * @param parser Defines the parser to add
  37417. */
  37418. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37419. /**
  37420. * Gets an individual parser from the list of avaialble ones
  37421. * @param name Defines the name of the parser
  37422. * @returns the requested parser or null
  37423. */
  37424. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37425. /**
  37426. * Parser json data and populate both a scene and its associated container object
  37427. * @param jsonData Defines the data to parse
  37428. * @param scene Defines the scene to parse the data for
  37429. * @param container Defines the container attached to the parsing sequence
  37430. * @param rootUrl Defines the root url of the data
  37431. */
  37432. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37433. /**
  37434. * Gets the list of root nodes (ie. nodes with no parent)
  37435. */
  37436. rootNodes: Node[];
  37437. /** All of the cameras added to this scene
  37438. * @see http://doc.babylonjs.com/babylon101/cameras
  37439. */
  37440. cameras: Camera[];
  37441. /**
  37442. * All of the lights added to this scene
  37443. * @see http://doc.babylonjs.com/babylon101/lights
  37444. */
  37445. lights: Light[];
  37446. /**
  37447. * All of the (abstract) meshes added to this scene
  37448. */
  37449. meshes: AbstractMesh[];
  37450. /**
  37451. * The list of skeletons added to the scene
  37452. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37453. */
  37454. skeletons: Skeleton[];
  37455. /**
  37456. * All of the particle systems added to this scene
  37457. * @see http://doc.babylonjs.com/babylon101/particles
  37458. */
  37459. particleSystems: IParticleSystem[];
  37460. /**
  37461. * Gets a list of Animations associated with the scene
  37462. */
  37463. animations: Animation[];
  37464. /**
  37465. * All of the animation groups added to this scene
  37466. * @see http://doc.babylonjs.com/how_to/group
  37467. */
  37468. animationGroups: AnimationGroup[];
  37469. /**
  37470. * All of the multi-materials added to this scene
  37471. * @see http://doc.babylonjs.com/how_to/multi_materials
  37472. */
  37473. multiMaterials: MultiMaterial[];
  37474. /**
  37475. * All of the materials added to this scene
  37476. * In the context of a Scene, it is not supposed to be modified manually.
  37477. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37478. * Note also that the order of the Material within the array is not significant and might change.
  37479. * @see http://doc.babylonjs.com/babylon101/materials
  37480. */
  37481. materials: Material[];
  37482. /**
  37483. * The list of morph target managers added to the scene
  37484. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37485. */
  37486. morphTargetManagers: MorphTargetManager[];
  37487. /**
  37488. * The list of geometries used in the scene.
  37489. */
  37490. geometries: Geometry[];
  37491. /**
  37492. * All of the tranform nodes added to this scene
  37493. * In the context of a Scene, it is not supposed to be modified manually.
  37494. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37495. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37496. * @see http://doc.babylonjs.com/how_to/transformnode
  37497. */
  37498. transformNodes: TransformNode[];
  37499. /**
  37500. * ActionManagers available on the scene.
  37501. */
  37502. actionManagers: AbstractActionManager[];
  37503. /**
  37504. * Textures to keep.
  37505. */
  37506. textures: BaseTexture[];
  37507. /**
  37508. * Environment texture for the scene
  37509. */
  37510. environmentTexture: Nullable<BaseTexture>;
  37511. /**
  37512. * @returns all meshes, lights, cameras, transformNodes and bones
  37513. */
  37514. getNodes(): Array<Node>;
  37515. }
  37516. }
  37517. declare module BABYLON {
  37518. /**
  37519. * Interface used to define options for Sound class
  37520. */
  37521. export interface ISoundOptions {
  37522. /**
  37523. * Does the sound autoplay once loaded.
  37524. */
  37525. autoplay?: boolean;
  37526. /**
  37527. * Does the sound loop after it finishes playing once.
  37528. */
  37529. loop?: boolean;
  37530. /**
  37531. * Sound's volume
  37532. */
  37533. volume?: number;
  37534. /**
  37535. * Is it a spatial sound?
  37536. */
  37537. spatialSound?: boolean;
  37538. /**
  37539. * Maximum distance to hear that sound
  37540. */
  37541. maxDistance?: number;
  37542. /**
  37543. * Uses user defined attenuation function
  37544. */
  37545. useCustomAttenuation?: boolean;
  37546. /**
  37547. * Define the roll off factor of spatial sounds.
  37548. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37549. */
  37550. rolloffFactor?: number;
  37551. /**
  37552. * Define the reference distance the sound should be heard perfectly.
  37553. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37554. */
  37555. refDistance?: number;
  37556. /**
  37557. * Define the distance attenuation model the sound will follow.
  37558. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37559. */
  37560. distanceModel?: string;
  37561. /**
  37562. * Defines the playback speed (1 by default)
  37563. */
  37564. playbackRate?: number;
  37565. /**
  37566. * Defines if the sound is from a streaming source
  37567. */
  37568. streaming?: boolean;
  37569. /**
  37570. * Defines an optional length (in seconds) inside the sound file
  37571. */
  37572. length?: number;
  37573. /**
  37574. * Defines an optional offset (in seconds) inside the sound file
  37575. */
  37576. offset?: number;
  37577. /**
  37578. * If true, URLs will not be required to state the audio file codec to use.
  37579. */
  37580. skipCodecCheck?: boolean;
  37581. }
  37582. /**
  37583. * Defines a sound that can be played in the application.
  37584. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37585. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37586. */
  37587. export class Sound {
  37588. /**
  37589. * The name of the sound in the scene.
  37590. */
  37591. name: string;
  37592. /**
  37593. * Does the sound autoplay once loaded.
  37594. */
  37595. autoplay: boolean;
  37596. /**
  37597. * Does the sound loop after it finishes playing once.
  37598. */
  37599. loop: boolean;
  37600. /**
  37601. * Does the sound use a custom attenuation curve to simulate the falloff
  37602. * happening when the source gets further away from the camera.
  37603. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37604. */
  37605. useCustomAttenuation: boolean;
  37606. /**
  37607. * The sound track id this sound belongs to.
  37608. */
  37609. soundTrackId: number;
  37610. /**
  37611. * Is this sound currently played.
  37612. */
  37613. isPlaying: boolean;
  37614. /**
  37615. * Is this sound currently paused.
  37616. */
  37617. isPaused: boolean;
  37618. /**
  37619. * Does this sound enables spatial sound.
  37620. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37621. */
  37622. spatialSound: boolean;
  37623. /**
  37624. * Define the reference distance the sound should be heard perfectly.
  37625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37626. */
  37627. refDistance: number;
  37628. /**
  37629. * Define the roll off factor of spatial sounds.
  37630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37631. */
  37632. rolloffFactor: number;
  37633. /**
  37634. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37635. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37636. */
  37637. maxDistance: number;
  37638. /**
  37639. * Define the distance attenuation model the sound will follow.
  37640. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37641. */
  37642. distanceModel: string;
  37643. /**
  37644. * @hidden
  37645. * Back Compat
  37646. **/
  37647. onended: () => any;
  37648. /**
  37649. * Observable event when the current playing sound finishes.
  37650. */
  37651. onEndedObservable: Observable<Sound>;
  37652. private _panningModel;
  37653. private _playbackRate;
  37654. private _streaming;
  37655. private _startTime;
  37656. private _startOffset;
  37657. private _position;
  37658. /** @hidden */
  37659. _positionInEmitterSpace: boolean;
  37660. private _localDirection;
  37661. private _volume;
  37662. private _isReadyToPlay;
  37663. private _isDirectional;
  37664. private _readyToPlayCallback;
  37665. private _audioBuffer;
  37666. private _soundSource;
  37667. private _streamingSource;
  37668. private _soundPanner;
  37669. private _soundGain;
  37670. private _inputAudioNode;
  37671. private _outputAudioNode;
  37672. private _coneInnerAngle;
  37673. private _coneOuterAngle;
  37674. private _coneOuterGain;
  37675. private _scene;
  37676. private _connectedTransformNode;
  37677. private _customAttenuationFunction;
  37678. private _registerFunc;
  37679. private _isOutputConnected;
  37680. private _htmlAudioElement;
  37681. private _urlType;
  37682. private _length?;
  37683. private _offset?;
  37684. /** @hidden */
  37685. static _SceneComponentInitialization: (scene: Scene) => void;
  37686. /**
  37687. * Create a sound and attach it to a scene
  37688. * @param name Name of your sound
  37689. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37690. * @param scene defines the scene the sound belongs to
  37691. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37692. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37693. */
  37694. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37695. /**
  37696. * Release the sound and its associated resources
  37697. */
  37698. dispose(): void;
  37699. /**
  37700. * Gets if the sounds is ready to be played or not.
  37701. * @returns true if ready, otherwise false
  37702. */
  37703. isReady(): boolean;
  37704. private _soundLoaded;
  37705. /**
  37706. * Sets the data of the sound from an audiobuffer
  37707. * @param audioBuffer The audioBuffer containing the data
  37708. */
  37709. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37710. /**
  37711. * Updates the current sounds options such as maxdistance, loop...
  37712. * @param options A JSON object containing values named as the object properties
  37713. */
  37714. updateOptions(options: ISoundOptions): void;
  37715. private _createSpatialParameters;
  37716. private _updateSpatialParameters;
  37717. /**
  37718. * Switch the panning model to HRTF:
  37719. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37720. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37721. */
  37722. switchPanningModelToHRTF(): void;
  37723. /**
  37724. * Switch the panning model to Equal Power:
  37725. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37726. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37727. */
  37728. switchPanningModelToEqualPower(): void;
  37729. private _switchPanningModel;
  37730. /**
  37731. * Connect this sound to a sound track audio node like gain...
  37732. * @param soundTrackAudioNode the sound track audio node to connect to
  37733. */
  37734. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37735. /**
  37736. * Transform this sound into a directional source
  37737. * @param coneInnerAngle Size of the inner cone in degree
  37738. * @param coneOuterAngle Size of the outer cone in degree
  37739. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37740. */
  37741. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37742. /**
  37743. * Gets or sets the inner angle for the directional cone.
  37744. */
  37745. get directionalConeInnerAngle(): number;
  37746. /**
  37747. * Gets or sets the inner angle for the directional cone.
  37748. */
  37749. set directionalConeInnerAngle(value: number);
  37750. /**
  37751. * Gets or sets the outer angle for the directional cone.
  37752. */
  37753. get directionalConeOuterAngle(): number;
  37754. /**
  37755. * Gets or sets the outer angle for the directional cone.
  37756. */
  37757. set directionalConeOuterAngle(value: number);
  37758. /**
  37759. * Sets the position of the emitter if spatial sound is enabled
  37760. * @param newPosition Defines the new posisiton
  37761. */
  37762. setPosition(newPosition: Vector3): void;
  37763. /**
  37764. * Sets the local direction of the emitter if spatial sound is enabled
  37765. * @param newLocalDirection Defines the new local direction
  37766. */
  37767. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37768. private _updateDirection;
  37769. /** @hidden */
  37770. updateDistanceFromListener(): void;
  37771. /**
  37772. * Sets a new custom attenuation function for the sound.
  37773. * @param callback Defines the function used for the attenuation
  37774. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37775. */
  37776. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37777. /**
  37778. * Play the sound
  37779. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37780. * @param offset (optional) Start the sound at a specific time in seconds
  37781. * @param length (optional) Sound duration (in seconds)
  37782. */
  37783. play(time?: number, offset?: number, length?: number): void;
  37784. private _onended;
  37785. /**
  37786. * Stop the sound
  37787. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37788. */
  37789. stop(time?: number): void;
  37790. /**
  37791. * Put the sound in pause
  37792. */
  37793. pause(): void;
  37794. /**
  37795. * Sets a dedicated volume for this sounds
  37796. * @param newVolume Define the new volume of the sound
  37797. * @param time Define time for gradual change to new volume
  37798. */
  37799. setVolume(newVolume: number, time?: number): void;
  37800. /**
  37801. * Set the sound play back rate
  37802. * @param newPlaybackRate Define the playback rate the sound should be played at
  37803. */
  37804. setPlaybackRate(newPlaybackRate: number): void;
  37805. /**
  37806. * Gets the volume of the sound.
  37807. * @returns the volume of the sound
  37808. */
  37809. getVolume(): number;
  37810. /**
  37811. * Attach the sound to a dedicated mesh
  37812. * @param transformNode The transform node to connect the sound with
  37813. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37814. */
  37815. attachToMesh(transformNode: TransformNode): void;
  37816. /**
  37817. * Detach the sound from the previously attached mesh
  37818. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37819. */
  37820. detachFromMesh(): void;
  37821. private _onRegisterAfterWorldMatrixUpdate;
  37822. /**
  37823. * Clone the current sound in the scene.
  37824. * @returns the new sound clone
  37825. */
  37826. clone(): Nullable<Sound>;
  37827. /**
  37828. * Gets the current underlying audio buffer containing the data
  37829. * @returns the audio buffer
  37830. */
  37831. getAudioBuffer(): Nullable<AudioBuffer>;
  37832. /**
  37833. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  37834. * @returns the source node
  37835. */
  37836. getSoundSource(): Nullable<AudioBufferSourceNode>;
  37837. /**
  37838. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  37839. * @returns the gain node
  37840. */
  37841. getSoundGain(): Nullable<GainNode>;
  37842. /**
  37843. * Serializes the Sound in a JSON representation
  37844. * @returns the JSON representation of the sound
  37845. */
  37846. serialize(): any;
  37847. /**
  37848. * Parse a JSON representation of a sound to innstantiate in a given scene
  37849. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37850. * @param scene Define the scene the new parsed sound should be created in
  37851. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37852. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37853. * @returns the newly parsed sound
  37854. */
  37855. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37856. }
  37857. }
  37858. declare module BABYLON {
  37859. /**
  37860. * This defines an action helpful to play a defined sound on a triggered action.
  37861. */
  37862. export class PlaySoundAction extends Action {
  37863. private _sound;
  37864. /**
  37865. * Instantiate the action
  37866. * @param triggerOptions defines the trigger options
  37867. * @param sound defines the sound to play
  37868. * @param condition defines the trigger related conditions
  37869. */
  37870. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37871. /** @hidden */
  37872. _prepare(): void;
  37873. /**
  37874. * Execute the action and play the sound.
  37875. */
  37876. execute(): void;
  37877. /**
  37878. * Serializes the actions and its related information.
  37879. * @param parent defines the object to serialize in
  37880. * @returns the serialized object
  37881. */
  37882. serialize(parent: any): any;
  37883. }
  37884. /**
  37885. * This defines an action helpful to stop a defined sound on a triggered action.
  37886. */
  37887. export class StopSoundAction extends Action {
  37888. private _sound;
  37889. /**
  37890. * Instantiate the action
  37891. * @param triggerOptions defines the trigger options
  37892. * @param sound defines the sound to stop
  37893. * @param condition defines the trigger related conditions
  37894. */
  37895. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37896. /** @hidden */
  37897. _prepare(): void;
  37898. /**
  37899. * Execute the action and stop the sound.
  37900. */
  37901. execute(): void;
  37902. /**
  37903. * Serializes the actions and its related information.
  37904. * @param parent defines the object to serialize in
  37905. * @returns the serialized object
  37906. */
  37907. serialize(parent: any): any;
  37908. }
  37909. }
  37910. declare module BABYLON {
  37911. /**
  37912. * This defines an action responsible to change the value of a property
  37913. * by interpolating between its current value and the newly set one once triggered.
  37914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37915. */
  37916. export class InterpolateValueAction extends Action {
  37917. /**
  37918. * Defines the path of the property where the value should be interpolated
  37919. */
  37920. propertyPath: string;
  37921. /**
  37922. * Defines the target value at the end of the interpolation.
  37923. */
  37924. value: any;
  37925. /**
  37926. * Defines the time it will take for the property to interpolate to the value.
  37927. */
  37928. duration: number;
  37929. /**
  37930. * Defines if the other scene animations should be stopped when the action has been triggered
  37931. */
  37932. stopOtherAnimations?: boolean;
  37933. /**
  37934. * Defines a callback raised once the interpolation animation has been done.
  37935. */
  37936. onInterpolationDone?: () => void;
  37937. /**
  37938. * Observable triggered once the interpolation animation has been done.
  37939. */
  37940. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37941. private _target;
  37942. private _effectiveTarget;
  37943. private _property;
  37944. /**
  37945. * Instantiate the action
  37946. * @param triggerOptions defines the trigger options
  37947. * @param target defines the object containing the value to interpolate
  37948. * @param propertyPath defines the path to the property in the target object
  37949. * @param value defines the target value at the end of the interpolation
  37950. * @param duration deines the time it will take for the property to interpolate to the value.
  37951. * @param condition defines the trigger related conditions
  37952. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37953. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37954. */
  37955. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37956. /** @hidden */
  37957. _prepare(): void;
  37958. /**
  37959. * Execute the action starts the value interpolation.
  37960. */
  37961. execute(): void;
  37962. /**
  37963. * Serializes the actions and its related information.
  37964. * @param parent defines the object to serialize in
  37965. * @returns the serialized object
  37966. */
  37967. serialize(parent: any): any;
  37968. }
  37969. }
  37970. declare module BABYLON {
  37971. /**
  37972. * Options allowed during the creation of a sound track.
  37973. */
  37974. export interface ISoundTrackOptions {
  37975. /**
  37976. * The volume the sound track should take during creation
  37977. */
  37978. volume?: number;
  37979. /**
  37980. * Define if the sound track is the main sound track of the scene
  37981. */
  37982. mainTrack?: boolean;
  37983. }
  37984. /**
  37985. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37986. * It will be also used in a future release to apply effects on a specific track.
  37987. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37988. */
  37989. export class SoundTrack {
  37990. /**
  37991. * The unique identifier of the sound track in the scene.
  37992. */
  37993. id: number;
  37994. /**
  37995. * The list of sounds included in the sound track.
  37996. */
  37997. soundCollection: Array<Sound>;
  37998. private _outputAudioNode;
  37999. private _scene;
  38000. private _connectedAnalyser;
  38001. private _options;
  38002. private _isInitialized;
  38003. /**
  38004. * Creates a new sound track.
  38005. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38006. * @param scene Define the scene the sound track belongs to
  38007. * @param options
  38008. */
  38009. constructor(scene: Scene, options?: ISoundTrackOptions);
  38010. private _initializeSoundTrackAudioGraph;
  38011. /**
  38012. * Release the sound track and its associated resources
  38013. */
  38014. dispose(): void;
  38015. /**
  38016. * Adds a sound to this sound track
  38017. * @param sound define the cound to add
  38018. * @ignoreNaming
  38019. */
  38020. AddSound(sound: Sound): void;
  38021. /**
  38022. * Removes a sound to this sound track
  38023. * @param sound define the cound to remove
  38024. * @ignoreNaming
  38025. */
  38026. RemoveSound(sound: Sound): void;
  38027. /**
  38028. * Set a global volume for the full sound track.
  38029. * @param newVolume Define the new volume of the sound track
  38030. */
  38031. setVolume(newVolume: number): void;
  38032. /**
  38033. * Switch the panning model to HRTF:
  38034. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38035. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38036. */
  38037. switchPanningModelToHRTF(): void;
  38038. /**
  38039. * Switch the panning model to Equal Power:
  38040. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38042. */
  38043. switchPanningModelToEqualPower(): void;
  38044. /**
  38045. * Connect the sound track to an audio analyser allowing some amazing
  38046. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38047. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38048. * @param analyser The analyser to connect to the engine
  38049. */
  38050. connectToAnalyser(analyser: Analyser): void;
  38051. }
  38052. }
  38053. declare module BABYLON {
  38054. interface AbstractScene {
  38055. /**
  38056. * The list of sounds used in the scene.
  38057. */
  38058. sounds: Nullable<Array<Sound>>;
  38059. }
  38060. interface Scene {
  38061. /**
  38062. * @hidden
  38063. * Backing field
  38064. */
  38065. _mainSoundTrack: SoundTrack;
  38066. /**
  38067. * The main sound track played by the scene.
  38068. * It cotains your primary collection of sounds.
  38069. */
  38070. mainSoundTrack: SoundTrack;
  38071. /**
  38072. * The list of sound tracks added to the scene
  38073. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38074. */
  38075. soundTracks: Nullable<Array<SoundTrack>>;
  38076. /**
  38077. * Gets a sound using a given name
  38078. * @param name defines the name to search for
  38079. * @return the found sound or null if not found at all.
  38080. */
  38081. getSoundByName(name: string): Nullable<Sound>;
  38082. /**
  38083. * Gets or sets if audio support is enabled
  38084. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38085. */
  38086. audioEnabled: boolean;
  38087. /**
  38088. * Gets or sets if audio will be output to headphones
  38089. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38090. */
  38091. headphone: boolean;
  38092. /**
  38093. * Gets or sets custom audio listener position provider
  38094. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38095. */
  38096. audioListenerPositionProvider: Nullable<() => Vector3>;
  38097. /**
  38098. * Gets or sets a refresh rate when using 3D audio positioning
  38099. */
  38100. audioPositioningRefreshRate: number;
  38101. }
  38102. /**
  38103. * Defines the sound scene component responsible to manage any sounds
  38104. * in a given scene.
  38105. */
  38106. export class AudioSceneComponent implements ISceneSerializableComponent {
  38107. /**
  38108. * The component name helpfull to identify the component in the list of scene components.
  38109. */
  38110. readonly name: string;
  38111. /**
  38112. * The scene the component belongs to.
  38113. */
  38114. scene: Scene;
  38115. private _audioEnabled;
  38116. /**
  38117. * Gets whether audio is enabled or not.
  38118. * Please use related enable/disable method to switch state.
  38119. */
  38120. get audioEnabled(): boolean;
  38121. private _headphone;
  38122. /**
  38123. * Gets whether audio is outputing to headphone or not.
  38124. * Please use the according Switch methods to change output.
  38125. */
  38126. get headphone(): boolean;
  38127. /**
  38128. * Gets or sets a refresh rate when using 3D audio positioning
  38129. */
  38130. audioPositioningRefreshRate: number;
  38131. private _audioListenerPositionProvider;
  38132. /**
  38133. * Gets the current audio listener position provider
  38134. */
  38135. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38136. /**
  38137. * Sets a custom listener position for all sounds in the scene
  38138. * By default, this is the position of the first active camera
  38139. */
  38140. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38141. /**
  38142. * Creates a new instance of the component for the given scene
  38143. * @param scene Defines the scene to register the component in
  38144. */
  38145. constructor(scene: Scene);
  38146. /**
  38147. * Registers the component in a given scene
  38148. */
  38149. register(): void;
  38150. /**
  38151. * Rebuilds the elements related to this component in case of
  38152. * context lost for instance.
  38153. */
  38154. rebuild(): void;
  38155. /**
  38156. * Serializes the component data to the specified json object
  38157. * @param serializationObject The object to serialize to
  38158. */
  38159. serialize(serializationObject: any): void;
  38160. /**
  38161. * Adds all the elements from the container to the scene
  38162. * @param container the container holding the elements
  38163. */
  38164. addFromContainer(container: AbstractScene): void;
  38165. /**
  38166. * Removes all the elements in the container from the scene
  38167. * @param container contains the elements to remove
  38168. * @param dispose if the removed element should be disposed (default: false)
  38169. */
  38170. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38171. /**
  38172. * Disposes the component and the associated ressources.
  38173. */
  38174. dispose(): void;
  38175. /**
  38176. * Disables audio in the associated scene.
  38177. */
  38178. disableAudio(): void;
  38179. /**
  38180. * Enables audio in the associated scene.
  38181. */
  38182. enableAudio(): void;
  38183. /**
  38184. * Switch audio to headphone output.
  38185. */
  38186. switchAudioModeForHeadphones(): void;
  38187. /**
  38188. * Switch audio to normal speakers.
  38189. */
  38190. switchAudioModeForNormalSpeakers(): void;
  38191. private _cachedCameraDirection;
  38192. private _cachedCameraPosition;
  38193. private _lastCheck;
  38194. private _afterRender;
  38195. }
  38196. }
  38197. declare module BABYLON {
  38198. /**
  38199. * Wraps one or more Sound objects and selects one with random weight for playback.
  38200. */
  38201. export class WeightedSound {
  38202. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38203. loop: boolean;
  38204. private _coneInnerAngle;
  38205. private _coneOuterAngle;
  38206. private _volume;
  38207. /** A Sound is currently playing. */
  38208. isPlaying: boolean;
  38209. /** A Sound is currently paused. */
  38210. isPaused: boolean;
  38211. private _sounds;
  38212. private _weights;
  38213. private _currentIndex?;
  38214. /**
  38215. * Creates a new WeightedSound from the list of sounds given.
  38216. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38217. * @param sounds Array of Sounds that will be selected from.
  38218. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38219. */
  38220. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38221. /**
  38222. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38223. */
  38224. get directionalConeInnerAngle(): number;
  38225. /**
  38226. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38227. */
  38228. set directionalConeInnerAngle(value: number);
  38229. /**
  38230. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38231. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38232. */
  38233. get directionalConeOuterAngle(): number;
  38234. /**
  38235. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38236. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38237. */
  38238. set directionalConeOuterAngle(value: number);
  38239. /**
  38240. * Playback volume.
  38241. */
  38242. get volume(): number;
  38243. /**
  38244. * Playback volume.
  38245. */
  38246. set volume(value: number);
  38247. private _onended;
  38248. /**
  38249. * Suspend playback
  38250. */
  38251. pause(): void;
  38252. /**
  38253. * Stop playback
  38254. */
  38255. stop(): void;
  38256. /**
  38257. * Start playback.
  38258. * @param startOffset Position the clip head at a specific time in seconds.
  38259. */
  38260. play(startOffset?: number): void;
  38261. }
  38262. }
  38263. declare module BABYLON {
  38264. /**
  38265. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38266. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38267. */
  38268. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38269. /**
  38270. * Gets the name of the behavior.
  38271. */
  38272. get name(): string;
  38273. /**
  38274. * The easing function used by animations
  38275. */
  38276. static EasingFunction: BackEase;
  38277. /**
  38278. * The easing mode used by animations
  38279. */
  38280. static EasingMode: number;
  38281. /**
  38282. * The duration of the animation, in milliseconds
  38283. */
  38284. transitionDuration: number;
  38285. /**
  38286. * Length of the distance animated by the transition when lower radius is reached
  38287. */
  38288. lowerRadiusTransitionRange: number;
  38289. /**
  38290. * Length of the distance animated by the transition when upper radius is reached
  38291. */
  38292. upperRadiusTransitionRange: number;
  38293. private _autoTransitionRange;
  38294. /**
  38295. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38296. */
  38297. get autoTransitionRange(): boolean;
  38298. /**
  38299. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38300. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38301. */
  38302. set autoTransitionRange(value: boolean);
  38303. private _attachedCamera;
  38304. private _onAfterCheckInputsObserver;
  38305. private _onMeshTargetChangedObserver;
  38306. /**
  38307. * Initializes the behavior.
  38308. */
  38309. init(): void;
  38310. /**
  38311. * Attaches the behavior to its arc rotate camera.
  38312. * @param camera Defines the camera to attach the behavior to
  38313. */
  38314. attach(camera: ArcRotateCamera): void;
  38315. /**
  38316. * Detaches the behavior from its current arc rotate camera.
  38317. */
  38318. detach(): void;
  38319. private _radiusIsAnimating;
  38320. private _radiusBounceTransition;
  38321. private _animatables;
  38322. private _cachedWheelPrecision;
  38323. /**
  38324. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38325. * @param radiusLimit The limit to check against.
  38326. * @return Bool to indicate if at limit.
  38327. */
  38328. private _isRadiusAtLimit;
  38329. /**
  38330. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38331. * @param radiusDelta The delta by which to animate to. Can be negative.
  38332. */
  38333. private _applyBoundRadiusAnimation;
  38334. /**
  38335. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38336. */
  38337. protected _clearAnimationLocks(): void;
  38338. /**
  38339. * Stops and removes all animations that have been applied to the camera
  38340. */
  38341. stopAllAnimations(): void;
  38342. }
  38343. }
  38344. declare module BABYLON {
  38345. /**
  38346. * 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.
  38347. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38348. */
  38349. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38350. /**
  38351. * Gets the name of the behavior.
  38352. */
  38353. get name(): string;
  38354. private _mode;
  38355. private _radiusScale;
  38356. private _positionScale;
  38357. private _defaultElevation;
  38358. private _elevationReturnTime;
  38359. private _elevationReturnWaitTime;
  38360. private _zoomStopsAnimation;
  38361. private _framingTime;
  38362. /**
  38363. * The easing function used by animations
  38364. */
  38365. static EasingFunction: ExponentialEase;
  38366. /**
  38367. * The easing mode used by animations
  38368. */
  38369. static EasingMode: number;
  38370. /**
  38371. * Sets the current mode used by the behavior
  38372. */
  38373. set mode(mode: number);
  38374. /**
  38375. * Gets current mode used by the behavior.
  38376. */
  38377. get mode(): number;
  38378. /**
  38379. * Sets the scale applied to the radius (1 by default)
  38380. */
  38381. set radiusScale(radius: number);
  38382. /**
  38383. * Gets the scale applied to the radius
  38384. */
  38385. get radiusScale(): number;
  38386. /**
  38387. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38388. */
  38389. set positionScale(scale: number);
  38390. /**
  38391. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38392. */
  38393. get positionScale(): number;
  38394. /**
  38395. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38396. * behaviour is triggered, in radians.
  38397. */
  38398. set defaultElevation(elevation: number);
  38399. /**
  38400. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38401. * behaviour is triggered, in radians.
  38402. */
  38403. get defaultElevation(): number;
  38404. /**
  38405. * Sets the time (in milliseconds) taken to return to the default beta position.
  38406. * Negative value indicates camera should not return to default.
  38407. */
  38408. set elevationReturnTime(speed: number);
  38409. /**
  38410. * Gets the time (in milliseconds) taken to return to the default beta position.
  38411. * Negative value indicates camera should not return to default.
  38412. */
  38413. get elevationReturnTime(): number;
  38414. /**
  38415. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38416. */
  38417. set elevationReturnWaitTime(time: number);
  38418. /**
  38419. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38420. */
  38421. get elevationReturnWaitTime(): number;
  38422. /**
  38423. * Sets the flag that indicates if user zooming should stop animation.
  38424. */
  38425. set zoomStopsAnimation(flag: boolean);
  38426. /**
  38427. * Gets the flag that indicates if user zooming should stop animation.
  38428. */
  38429. get zoomStopsAnimation(): boolean;
  38430. /**
  38431. * Sets the transition time when framing the mesh, in milliseconds
  38432. */
  38433. set framingTime(time: number);
  38434. /**
  38435. * Gets the transition time when framing the mesh, in milliseconds
  38436. */
  38437. get framingTime(): number;
  38438. /**
  38439. * Define if the behavior should automatically change the configured
  38440. * camera limits and sensibilities.
  38441. */
  38442. autoCorrectCameraLimitsAndSensibility: boolean;
  38443. private _onPrePointerObservableObserver;
  38444. private _onAfterCheckInputsObserver;
  38445. private _onMeshTargetChangedObserver;
  38446. private _attachedCamera;
  38447. private _isPointerDown;
  38448. private _lastInteractionTime;
  38449. /**
  38450. * Initializes the behavior.
  38451. */
  38452. init(): void;
  38453. /**
  38454. * Attaches the behavior to its arc rotate camera.
  38455. * @param camera Defines the camera to attach the behavior to
  38456. */
  38457. attach(camera: ArcRotateCamera): void;
  38458. /**
  38459. * Detaches the behavior from its current arc rotate camera.
  38460. */
  38461. detach(): void;
  38462. private _animatables;
  38463. private _betaIsAnimating;
  38464. private _betaTransition;
  38465. private _radiusTransition;
  38466. private _vectorTransition;
  38467. /**
  38468. * Targets the given mesh and updates zoom level accordingly.
  38469. * @param mesh The mesh to target.
  38470. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38471. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38472. */
  38473. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38474. /**
  38475. * Targets the given mesh with its children and updates zoom level accordingly.
  38476. * @param mesh The mesh to target.
  38477. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38478. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38479. */
  38480. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38481. /**
  38482. * Targets the given meshes with their children and updates zoom level accordingly.
  38483. * @param meshes The mesh to target.
  38484. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38485. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38486. */
  38487. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38488. /**
  38489. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38490. * @param minimumWorld Determines the smaller position of the bounding box extend
  38491. * @param maximumWorld Determines the bigger position of the bounding box extend
  38492. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38493. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38494. */
  38495. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38496. /**
  38497. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38498. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38499. * frustum width.
  38500. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38501. * to fully enclose the mesh in the viewing frustum.
  38502. */
  38503. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38504. /**
  38505. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38506. * is automatically returned to its default position (expected to be above ground plane).
  38507. */
  38508. private _maintainCameraAboveGround;
  38509. /**
  38510. * Returns the frustum slope based on the canvas ratio and camera FOV
  38511. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38512. */
  38513. private _getFrustumSlope;
  38514. /**
  38515. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38516. */
  38517. private _clearAnimationLocks;
  38518. /**
  38519. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38520. */
  38521. private _applyUserInteraction;
  38522. /**
  38523. * Stops and removes all animations that have been applied to the camera
  38524. */
  38525. stopAllAnimations(): void;
  38526. /**
  38527. * Gets a value indicating if the user is moving the camera
  38528. */
  38529. get isUserIsMoving(): boolean;
  38530. /**
  38531. * The camera can move all the way towards the mesh.
  38532. */
  38533. static IgnoreBoundsSizeMode: number;
  38534. /**
  38535. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38536. */
  38537. static FitFrustumSidesMode: number;
  38538. }
  38539. }
  38540. declare module BABYLON {
  38541. /**
  38542. * Base class for Camera Pointer Inputs.
  38543. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38544. * for example usage.
  38545. */
  38546. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38547. /**
  38548. * Defines the camera the input is attached to.
  38549. */
  38550. abstract camera: Camera;
  38551. /**
  38552. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38553. */
  38554. protected _altKey: boolean;
  38555. protected _ctrlKey: boolean;
  38556. protected _metaKey: boolean;
  38557. protected _shiftKey: boolean;
  38558. /**
  38559. * Which mouse buttons were pressed at time of last mouse event.
  38560. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38561. */
  38562. protected _buttonsPressed: number;
  38563. /**
  38564. * Defines the buttons associated with the input to handle camera move.
  38565. */
  38566. buttons: number[];
  38567. /**
  38568. * Attach the input controls to a specific dom element to get the input from.
  38569. * @param element Defines the element the controls should be listened from
  38570. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38571. */
  38572. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38573. /**
  38574. * Detach the current controls from the specified dom element.
  38575. * @param element Defines the element to stop listening the inputs from
  38576. */
  38577. detachControl(element: Nullable<HTMLElement>): void;
  38578. /**
  38579. * Gets the class name of the current input.
  38580. * @returns the class name
  38581. */
  38582. getClassName(): string;
  38583. /**
  38584. * Get the friendly name associated with the input class.
  38585. * @returns the input friendly name
  38586. */
  38587. getSimpleName(): string;
  38588. /**
  38589. * Called on pointer POINTERDOUBLETAP event.
  38590. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38591. */
  38592. protected onDoubleTap(type: string): void;
  38593. /**
  38594. * Called on pointer POINTERMOVE event if only a single touch is active.
  38595. * Override this method to provide functionality.
  38596. */
  38597. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38598. /**
  38599. * Called on pointer POINTERMOVE event if multiple touches are active.
  38600. * Override this method to provide functionality.
  38601. */
  38602. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38603. /**
  38604. * Called on JS contextmenu event.
  38605. * Override this method to provide functionality.
  38606. */
  38607. protected onContextMenu(evt: PointerEvent): void;
  38608. /**
  38609. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38610. * press.
  38611. * Override this method to provide functionality.
  38612. */
  38613. protected onButtonDown(evt: PointerEvent): void;
  38614. /**
  38615. * Called each time a new POINTERUP event occurs. Ie, for each button
  38616. * release.
  38617. * Override this method to provide functionality.
  38618. */
  38619. protected onButtonUp(evt: PointerEvent): void;
  38620. /**
  38621. * Called when window becomes inactive.
  38622. * Override this method to provide functionality.
  38623. */
  38624. protected onLostFocus(): void;
  38625. private _pointerInput;
  38626. private _observer;
  38627. private _onLostFocus;
  38628. private pointA;
  38629. private pointB;
  38630. }
  38631. }
  38632. declare module BABYLON {
  38633. /**
  38634. * Manage the pointers inputs to control an arc rotate camera.
  38635. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38636. */
  38637. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38638. /**
  38639. * Defines the camera the input is attached to.
  38640. */
  38641. camera: ArcRotateCamera;
  38642. /**
  38643. * Gets the class name of the current input.
  38644. * @returns the class name
  38645. */
  38646. getClassName(): string;
  38647. /**
  38648. * Defines the buttons associated with the input to handle camera move.
  38649. */
  38650. buttons: number[];
  38651. /**
  38652. * Defines the pointer angular sensibility along the X axis or how fast is
  38653. * the camera rotating.
  38654. */
  38655. angularSensibilityX: number;
  38656. /**
  38657. * Defines the pointer angular sensibility along the Y axis or how fast is
  38658. * the camera rotating.
  38659. */
  38660. angularSensibilityY: number;
  38661. /**
  38662. * Defines the pointer pinch precision or how fast is the camera zooming.
  38663. */
  38664. pinchPrecision: number;
  38665. /**
  38666. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38667. * from 0.
  38668. * It defines the percentage of current camera.radius to use as delta when
  38669. * pinch zoom is used.
  38670. */
  38671. pinchDeltaPercentage: number;
  38672. /**
  38673. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38674. * that any object in the plane at the camera's target point will scale
  38675. * perfectly with finger motion.
  38676. * Overrides pinchDeltaPercentage and pinchPrecision.
  38677. */
  38678. useNaturalPinchZoom: boolean;
  38679. /**
  38680. * Defines the pointer panning sensibility or how fast is the camera moving.
  38681. */
  38682. panningSensibility: number;
  38683. /**
  38684. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38685. */
  38686. multiTouchPanning: boolean;
  38687. /**
  38688. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38689. * zoom (pinch) through multitouch.
  38690. */
  38691. multiTouchPanAndZoom: boolean;
  38692. /**
  38693. * Revers pinch action direction.
  38694. */
  38695. pinchInwards: boolean;
  38696. private _isPanClick;
  38697. private _twoFingerActivityCount;
  38698. private _isPinching;
  38699. /**
  38700. * Called on pointer POINTERMOVE event if only a single touch is active.
  38701. */
  38702. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38703. /**
  38704. * Called on pointer POINTERDOUBLETAP event.
  38705. */
  38706. protected onDoubleTap(type: string): void;
  38707. /**
  38708. * Called on pointer POINTERMOVE event if multiple touches are active.
  38709. */
  38710. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38711. /**
  38712. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38713. * press.
  38714. */
  38715. protected onButtonDown(evt: PointerEvent): void;
  38716. /**
  38717. * Called each time a new POINTERUP event occurs. Ie, for each button
  38718. * release.
  38719. */
  38720. protected onButtonUp(evt: PointerEvent): void;
  38721. /**
  38722. * Called when window becomes inactive.
  38723. */
  38724. protected onLostFocus(): void;
  38725. }
  38726. }
  38727. declare module BABYLON {
  38728. /**
  38729. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38730. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38731. */
  38732. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38733. /**
  38734. * Defines the camera the input is attached to.
  38735. */
  38736. camera: ArcRotateCamera;
  38737. /**
  38738. * Defines the list of key codes associated with the up action (increase alpha)
  38739. */
  38740. keysUp: number[];
  38741. /**
  38742. * Defines the list of key codes associated with the down action (decrease alpha)
  38743. */
  38744. keysDown: number[];
  38745. /**
  38746. * Defines the list of key codes associated with the left action (increase beta)
  38747. */
  38748. keysLeft: number[];
  38749. /**
  38750. * Defines the list of key codes associated with the right action (decrease beta)
  38751. */
  38752. keysRight: number[];
  38753. /**
  38754. * Defines the list of key codes associated with the reset action.
  38755. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38756. */
  38757. keysReset: number[];
  38758. /**
  38759. * Defines the panning sensibility of the inputs.
  38760. * (How fast is the camera panning)
  38761. */
  38762. panningSensibility: number;
  38763. /**
  38764. * Defines the zooming sensibility of the inputs.
  38765. * (How fast is the camera zooming)
  38766. */
  38767. zoomingSensibility: number;
  38768. /**
  38769. * Defines whether maintaining the alt key down switch the movement mode from
  38770. * orientation to zoom.
  38771. */
  38772. useAltToZoom: boolean;
  38773. /**
  38774. * Rotation speed of the camera
  38775. */
  38776. angularSpeed: number;
  38777. private _keys;
  38778. private _ctrlPressed;
  38779. private _altPressed;
  38780. private _onCanvasBlurObserver;
  38781. private _onKeyboardObserver;
  38782. private _engine;
  38783. private _scene;
  38784. /**
  38785. * Attach the input controls to a specific dom element to get the input from.
  38786. * @param element Defines the element the controls should be listened from
  38787. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38788. */
  38789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38790. /**
  38791. * Detach the current controls from the specified dom element.
  38792. * @param element Defines the element to stop listening the inputs from
  38793. */
  38794. detachControl(element: Nullable<HTMLElement>): void;
  38795. /**
  38796. * Update the current camera state depending on the inputs that have been used this frame.
  38797. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38798. */
  38799. checkInputs(): void;
  38800. /**
  38801. * Gets the class name of the current intput.
  38802. * @returns the class name
  38803. */
  38804. getClassName(): string;
  38805. /**
  38806. * Get the friendly name associated with the input class.
  38807. * @returns the input friendly name
  38808. */
  38809. getSimpleName(): string;
  38810. }
  38811. }
  38812. declare module BABYLON {
  38813. /**
  38814. * Manage the mouse wheel inputs to control an arc rotate camera.
  38815. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38816. */
  38817. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38818. /**
  38819. * Defines the camera the input is attached to.
  38820. */
  38821. camera: ArcRotateCamera;
  38822. /**
  38823. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38824. */
  38825. wheelPrecision: number;
  38826. /**
  38827. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38828. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38829. */
  38830. wheelDeltaPercentage: number;
  38831. private _wheel;
  38832. private _observer;
  38833. private computeDeltaFromMouseWheelLegacyEvent;
  38834. /**
  38835. * Attach the input controls to a specific dom element to get the input from.
  38836. * @param element Defines the element the controls should be listened from
  38837. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38838. */
  38839. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38840. /**
  38841. * Detach the current controls from the specified dom element.
  38842. * @param element Defines the element to stop listening the inputs from
  38843. */
  38844. detachControl(element: Nullable<HTMLElement>): void;
  38845. /**
  38846. * Gets the class name of the current intput.
  38847. * @returns the class name
  38848. */
  38849. getClassName(): string;
  38850. /**
  38851. * Get the friendly name associated with the input class.
  38852. * @returns the input friendly name
  38853. */
  38854. getSimpleName(): string;
  38855. }
  38856. }
  38857. declare module BABYLON {
  38858. /**
  38859. * Default Inputs manager for the ArcRotateCamera.
  38860. * It groups all the default supported inputs for ease of use.
  38861. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38862. */
  38863. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38864. /**
  38865. * Instantiates a new ArcRotateCameraInputsManager.
  38866. * @param camera Defines the camera the inputs belong to
  38867. */
  38868. constructor(camera: ArcRotateCamera);
  38869. /**
  38870. * Add mouse wheel input support to the input manager.
  38871. * @returns the current input manager
  38872. */
  38873. addMouseWheel(): ArcRotateCameraInputsManager;
  38874. /**
  38875. * Add pointers input support to the input manager.
  38876. * @returns the current input manager
  38877. */
  38878. addPointers(): ArcRotateCameraInputsManager;
  38879. /**
  38880. * Add keyboard input support to the input manager.
  38881. * @returns the current input manager
  38882. */
  38883. addKeyboard(): ArcRotateCameraInputsManager;
  38884. }
  38885. }
  38886. declare module BABYLON {
  38887. /**
  38888. * This represents an orbital type of camera.
  38889. *
  38890. * 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.
  38891. * 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.
  38892. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38893. */
  38894. export class ArcRotateCamera extends TargetCamera {
  38895. /**
  38896. * Defines the rotation angle of the camera along the longitudinal axis.
  38897. */
  38898. alpha: number;
  38899. /**
  38900. * Defines the rotation angle of the camera along the latitudinal axis.
  38901. */
  38902. beta: number;
  38903. /**
  38904. * Defines the radius of the camera from it s target point.
  38905. */
  38906. radius: number;
  38907. protected _target: Vector3;
  38908. protected _targetHost: Nullable<AbstractMesh>;
  38909. /**
  38910. * Defines the target point of the camera.
  38911. * The camera looks towards it form the radius distance.
  38912. */
  38913. get target(): Vector3;
  38914. set target(value: Vector3);
  38915. /**
  38916. * Define the current local position of the camera in the scene
  38917. */
  38918. get position(): Vector3;
  38919. set position(newPosition: Vector3);
  38920. protected _upVector: Vector3;
  38921. protected _upToYMatrix: Matrix;
  38922. protected _YToUpMatrix: Matrix;
  38923. /**
  38924. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38925. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38926. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38927. */
  38928. set upVector(vec: Vector3);
  38929. get upVector(): Vector3;
  38930. /**
  38931. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38932. */
  38933. setMatUp(): void;
  38934. /**
  38935. * Current inertia value on the longitudinal axis.
  38936. * The bigger this number the longer it will take for the camera to stop.
  38937. */
  38938. inertialAlphaOffset: number;
  38939. /**
  38940. * Current inertia value on the latitudinal axis.
  38941. * The bigger this number the longer it will take for the camera to stop.
  38942. */
  38943. inertialBetaOffset: number;
  38944. /**
  38945. * Current inertia value on the radius axis.
  38946. * The bigger this number the longer it will take for the camera to stop.
  38947. */
  38948. inertialRadiusOffset: number;
  38949. /**
  38950. * Minimum allowed angle on the longitudinal axis.
  38951. * This can help limiting how the Camera is able to move in the scene.
  38952. */
  38953. lowerAlphaLimit: Nullable<number>;
  38954. /**
  38955. * Maximum allowed angle on the longitudinal axis.
  38956. * This can help limiting how the Camera is able to move in the scene.
  38957. */
  38958. upperAlphaLimit: Nullable<number>;
  38959. /**
  38960. * Minimum allowed angle on the latitudinal axis.
  38961. * This can help limiting how the Camera is able to move in the scene.
  38962. */
  38963. lowerBetaLimit: number;
  38964. /**
  38965. * Maximum allowed angle on the latitudinal axis.
  38966. * This can help limiting how the Camera is able to move in the scene.
  38967. */
  38968. upperBetaLimit: number;
  38969. /**
  38970. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38971. * This can help limiting how the Camera is able to move in the scene.
  38972. */
  38973. lowerRadiusLimit: Nullable<number>;
  38974. /**
  38975. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38976. * This can help limiting how the Camera is able to move in the scene.
  38977. */
  38978. upperRadiusLimit: Nullable<number>;
  38979. /**
  38980. * Defines the current inertia value used during panning of the camera along the X axis.
  38981. */
  38982. inertialPanningX: number;
  38983. /**
  38984. * Defines the current inertia value used during panning of the camera along the Y axis.
  38985. */
  38986. inertialPanningY: number;
  38987. /**
  38988. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38989. * Basically if your fingers moves away from more than this distance you will be considered
  38990. * in pinch mode.
  38991. */
  38992. pinchToPanMaxDistance: number;
  38993. /**
  38994. * Defines the maximum distance the camera can pan.
  38995. * This could help keeping the cammera always in your scene.
  38996. */
  38997. panningDistanceLimit: Nullable<number>;
  38998. /**
  38999. * Defines the target of the camera before paning.
  39000. */
  39001. panningOriginTarget: Vector3;
  39002. /**
  39003. * Defines the value of the inertia used during panning.
  39004. * 0 would mean stop inertia and one would mean no decelleration at all.
  39005. */
  39006. panningInertia: number;
  39007. /**
  39008. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39009. */
  39010. get angularSensibilityX(): number;
  39011. set angularSensibilityX(value: number);
  39012. /**
  39013. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39014. */
  39015. get angularSensibilityY(): number;
  39016. set angularSensibilityY(value: number);
  39017. /**
  39018. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39019. */
  39020. get pinchPrecision(): number;
  39021. set pinchPrecision(value: number);
  39022. /**
  39023. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39024. * It will be used instead of pinchDeltaPrecision if different from 0.
  39025. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39026. */
  39027. get pinchDeltaPercentage(): number;
  39028. set pinchDeltaPercentage(value: number);
  39029. /**
  39030. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39031. * and pinch delta percentage.
  39032. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39033. * that any object in the plane at the camera's target point will scale
  39034. * perfectly with finger motion.
  39035. */
  39036. get useNaturalPinchZoom(): boolean;
  39037. set useNaturalPinchZoom(value: boolean);
  39038. /**
  39039. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39040. */
  39041. get panningSensibility(): number;
  39042. set panningSensibility(value: number);
  39043. /**
  39044. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39045. */
  39046. get keysUp(): number[];
  39047. set keysUp(value: number[]);
  39048. /**
  39049. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39050. */
  39051. get keysDown(): number[];
  39052. set keysDown(value: number[]);
  39053. /**
  39054. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39055. */
  39056. get keysLeft(): number[];
  39057. set keysLeft(value: number[]);
  39058. /**
  39059. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39060. */
  39061. get keysRight(): number[];
  39062. set keysRight(value: number[]);
  39063. /**
  39064. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39065. */
  39066. get wheelPrecision(): number;
  39067. set wheelPrecision(value: number);
  39068. /**
  39069. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39070. * It will be used instead of pinchDeltaPrecision if different from 0.
  39071. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39072. */
  39073. get wheelDeltaPercentage(): number;
  39074. set wheelDeltaPercentage(value: number);
  39075. /**
  39076. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39077. */
  39078. zoomOnFactor: number;
  39079. /**
  39080. * Defines a screen offset for the camera position.
  39081. */
  39082. targetScreenOffset: Vector2;
  39083. /**
  39084. * Allows the camera to be completely reversed.
  39085. * If false the camera can not arrive upside down.
  39086. */
  39087. allowUpsideDown: boolean;
  39088. /**
  39089. * Define if double tap/click is used to restore the previously saved state of the camera.
  39090. */
  39091. useInputToRestoreState: boolean;
  39092. /** @hidden */
  39093. _viewMatrix: Matrix;
  39094. /** @hidden */
  39095. _useCtrlForPanning: boolean;
  39096. /** @hidden */
  39097. _panningMouseButton: number;
  39098. /**
  39099. * Defines the input associated to the camera.
  39100. */
  39101. inputs: ArcRotateCameraInputsManager;
  39102. /** @hidden */
  39103. _reset: () => void;
  39104. /**
  39105. * Defines the allowed panning axis.
  39106. */
  39107. panningAxis: Vector3;
  39108. protected _localDirection: Vector3;
  39109. protected _transformedDirection: Vector3;
  39110. private _bouncingBehavior;
  39111. /**
  39112. * Gets the bouncing behavior of the camera if it has been enabled.
  39113. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39114. */
  39115. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39116. /**
  39117. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39118. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39119. */
  39120. get useBouncingBehavior(): boolean;
  39121. set useBouncingBehavior(value: boolean);
  39122. private _framingBehavior;
  39123. /**
  39124. * Gets the framing behavior of the camera if it has been enabled.
  39125. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39126. */
  39127. get framingBehavior(): Nullable<FramingBehavior>;
  39128. /**
  39129. * Defines if the framing behavior of the camera is enabled on the camera.
  39130. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39131. */
  39132. get useFramingBehavior(): boolean;
  39133. set useFramingBehavior(value: boolean);
  39134. private _autoRotationBehavior;
  39135. /**
  39136. * Gets the auto rotation behavior of the camera if it has been enabled.
  39137. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39138. */
  39139. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39140. /**
  39141. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39142. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39143. */
  39144. get useAutoRotationBehavior(): boolean;
  39145. set useAutoRotationBehavior(value: boolean);
  39146. /**
  39147. * Observable triggered when the mesh target has been changed on the camera.
  39148. */
  39149. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39150. /**
  39151. * Event raised when the camera is colliding with a mesh.
  39152. */
  39153. onCollide: (collidedMesh: AbstractMesh) => void;
  39154. /**
  39155. * Defines whether the camera should check collision with the objects oh the scene.
  39156. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39157. */
  39158. checkCollisions: boolean;
  39159. /**
  39160. * Defines the collision radius of the camera.
  39161. * This simulates a sphere around the camera.
  39162. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39163. */
  39164. collisionRadius: Vector3;
  39165. protected _collider: Collider;
  39166. protected _previousPosition: Vector3;
  39167. protected _collisionVelocity: Vector3;
  39168. protected _newPosition: Vector3;
  39169. protected _previousAlpha: number;
  39170. protected _previousBeta: number;
  39171. protected _previousRadius: number;
  39172. protected _collisionTriggered: boolean;
  39173. protected _targetBoundingCenter: Nullable<Vector3>;
  39174. private _computationVector;
  39175. /**
  39176. * Instantiates a new ArcRotateCamera in a given scene
  39177. * @param name Defines the name of the camera
  39178. * @param alpha Defines the camera rotation along the logitudinal axis
  39179. * @param beta Defines the camera rotation along the latitudinal axis
  39180. * @param radius Defines the camera distance from its target
  39181. * @param target Defines the camera target
  39182. * @param scene Defines the scene the camera belongs to
  39183. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39184. */
  39185. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39186. /** @hidden */
  39187. _initCache(): void;
  39188. /** @hidden */
  39189. _updateCache(ignoreParentClass?: boolean): void;
  39190. protected _getTargetPosition(): Vector3;
  39191. private _storedAlpha;
  39192. private _storedBeta;
  39193. private _storedRadius;
  39194. private _storedTarget;
  39195. private _storedTargetScreenOffset;
  39196. /**
  39197. * Stores the current state of the camera (alpha, beta, radius and target)
  39198. * @returns the camera itself
  39199. */
  39200. storeState(): Camera;
  39201. /**
  39202. * @hidden
  39203. * Restored camera state. You must call storeState() first
  39204. */
  39205. _restoreStateValues(): boolean;
  39206. /** @hidden */
  39207. _isSynchronizedViewMatrix(): boolean;
  39208. /**
  39209. * Attached controls to the current camera.
  39210. * @param element Defines the element the controls should be listened from
  39211. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39212. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39213. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39214. */
  39215. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39216. /**
  39217. * Detach the current controls from the camera.
  39218. * The camera will stop reacting to inputs.
  39219. * @param element Defines the element to stop listening the inputs from
  39220. */
  39221. detachControl(element: HTMLElement): void;
  39222. /** @hidden */
  39223. _checkInputs(): void;
  39224. protected _checkLimits(): void;
  39225. /**
  39226. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39227. */
  39228. rebuildAnglesAndRadius(): void;
  39229. /**
  39230. * Use a position to define the current camera related information like alpha, beta and radius
  39231. * @param position Defines the position to set the camera at
  39232. */
  39233. setPosition(position: Vector3): void;
  39234. /**
  39235. * Defines the target the camera should look at.
  39236. * This will automatically adapt alpha beta and radius to fit within the new target.
  39237. * @param target Defines the new target as a Vector or a mesh
  39238. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39239. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39240. */
  39241. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39242. /** @hidden */
  39243. _getViewMatrix(): Matrix;
  39244. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39245. /**
  39246. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39247. * @param meshes Defines the mesh to zoom on
  39248. * @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)
  39249. */
  39250. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39251. /**
  39252. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39253. * The target will be changed but the radius
  39254. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39255. * @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)
  39256. */
  39257. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39258. min: Vector3;
  39259. max: Vector3;
  39260. distance: number;
  39261. }, doNotUpdateMaxZ?: boolean): void;
  39262. /**
  39263. * @override
  39264. * Override Camera.createRigCamera
  39265. */
  39266. createRigCamera(name: string, cameraIndex: number): Camera;
  39267. /**
  39268. * @hidden
  39269. * @override
  39270. * Override Camera._updateRigCameras
  39271. */
  39272. _updateRigCameras(): void;
  39273. /**
  39274. * Destroy the camera and release the current resources hold by it.
  39275. */
  39276. dispose(): void;
  39277. /**
  39278. * Gets the current object class name.
  39279. * @return the class name
  39280. */
  39281. getClassName(): string;
  39282. }
  39283. }
  39284. declare module BABYLON {
  39285. /**
  39286. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39287. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39288. */
  39289. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39290. /**
  39291. * Gets the name of the behavior.
  39292. */
  39293. get name(): string;
  39294. private _zoomStopsAnimation;
  39295. private _idleRotationSpeed;
  39296. private _idleRotationWaitTime;
  39297. private _idleRotationSpinupTime;
  39298. /**
  39299. * Sets the flag that indicates if user zooming should stop animation.
  39300. */
  39301. set zoomStopsAnimation(flag: boolean);
  39302. /**
  39303. * Gets the flag that indicates if user zooming should stop animation.
  39304. */
  39305. get zoomStopsAnimation(): boolean;
  39306. /**
  39307. * Sets the default speed at which the camera rotates around the model.
  39308. */
  39309. set idleRotationSpeed(speed: number);
  39310. /**
  39311. * Gets the default speed at which the camera rotates around the model.
  39312. */
  39313. get idleRotationSpeed(): number;
  39314. /**
  39315. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39316. */
  39317. set idleRotationWaitTime(time: number);
  39318. /**
  39319. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39320. */
  39321. get idleRotationWaitTime(): number;
  39322. /**
  39323. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39324. */
  39325. set idleRotationSpinupTime(time: number);
  39326. /**
  39327. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39328. */
  39329. get idleRotationSpinupTime(): number;
  39330. /**
  39331. * Gets a value indicating if the camera is currently rotating because of this behavior
  39332. */
  39333. get rotationInProgress(): boolean;
  39334. private _onPrePointerObservableObserver;
  39335. private _onAfterCheckInputsObserver;
  39336. private _attachedCamera;
  39337. private _isPointerDown;
  39338. private _lastFrameTime;
  39339. private _lastInteractionTime;
  39340. private _cameraRotationSpeed;
  39341. /**
  39342. * Initializes the behavior.
  39343. */
  39344. init(): void;
  39345. /**
  39346. * Attaches the behavior to its arc rotate camera.
  39347. * @param camera Defines the camera to attach the behavior to
  39348. */
  39349. attach(camera: ArcRotateCamera): void;
  39350. /**
  39351. * Detaches the behavior from its current arc rotate camera.
  39352. */
  39353. detach(): void;
  39354. /**
  39355. * Returns true if user is scrolling.
  39356. * @return true if user is scrolling.
  39357. */
  39358. private _userIsZooming;
  39359. private _lastFrameRadius;
  39360. private _shouldAnimationStopForInteraction;
  39361. /**
  39362. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39363. */
  39364. private _applyUserInteraction;
  39365. private _userIsMoving;
  39366. }
  39367. }
  39368. declare module BABYLON {
  39369. /**
  39370. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39371. */
  39372. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39373. private ui;
  39374. /**
  39375. * The name of the behavior
  39376. */
  39377. name: string;
  39378. /**
  39379. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39380. */
  39381. distanceAwayFromFace: number;
  39382. /**
  39383. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39384. */
  39385. distanceAwayFromBottomOfFace: number;
  39386. private _faceVectors;
  39387. private _target;
  39388. private _scene;
  39389. private _onRenderObserver;
  39390. private _tmpMatrix;
  39391. private _tmpVector;
  39392. /**
  39393. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39394. * @param ui The transform node that should be attched to the mesh
  39395. */
  39396. constructor(ui: TransformNode);
  39397. /**
  39398. * Initializes the behavior
  39399. */
  39400. init(): void;
  39401. private _closestFace;
  39402. private _zeroVector;
  39403. private _lookAtTmpMatrix;
  39404. private _lookAtToRef;
  39405. /**
  39406. * Attaches the AttachToBoxBehavior to the passed in mesh
  39407. * @param target The mesh that the specified node will be attached to
  39408. */
  39409. attach(target: Mesh): void;
  39410. /**
  39411. * Detaches the behavior from the mesh
  39412. */
  39413. detach(): void;
  39414. }
  39415. }
  39416. declare module BABYLON {
  39417. /**
  39418. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39419. */
  39420. export class FadeInOutBehavior implements Behavior<Mesh> {
  39421. /**
  39422. * Time in milliseconds to delay before fading in (Default: 0)
  39423. */
  39424. delay: number;
  39425. /**
  39426. * Time in milliseconds for the mesh to fade in (Default: 300)
  39427. */
  39428. fadeInTime: number;
  39429. private _millisecondsPerFrame;
  39430. private _hovered;
  39431. private _hoverValue;
  39432. private _ownerNode;
  39433. /**
  39434. * Instatiates the FadeInOutBehavior
  39435. */
  39436. constructor();
  39437. /**
  39438. * The name of the behavior
  39439. */
  39440. get name(): string;
  39441. /**
  39442. * Initializes the behavior
  39443. */
  39444. init(): void;
  39445. /**
  39446. * Attaches the fade behavior on the passed in mesh
  39447. * @param ownerNode The mesh that will be faded in/out once attached
  39448. */
  39449. attach(ownerNode: Mesh): void;
  39450. /**
  39451. * Detaches the behavior from the mesh
  39452. */
  39453. detach(): void;
  39454. /**
  39455. * Triggers the mesh to begin fading in or out
  39456. * @param value if the object should fade in or out (true to fade in)
  39457. */
  39458. fadeIn(value: boolean): void;
  39459. private _update;
  39460. private _setAllVisibility;
  39461. }
  39462. }
  39463. declare module BABYLON {
  39464. /**
  39465. * Class containing a set of static utilities functions for managing Pivots
  39466. * @hidden
  39467. */
  39468. export class PivotTools {
  39469. private static _PivotCached;
  39470. private static _OldPivotPoint;
  39471. private static _PivotTranslation;
  39472. private static _PivotTmpVector;
  39473. /** @hidden */
  39474. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39475. /** @hidden */
  39476. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39477. }
  39478. }
  39479. declare module BABYLON {
  39480. /**
  39481. * Class containing static functions to help procedurally build meshes
  39482. */
  39483. export class PlaneBuilder {
  39484. /**
  39485. * Creates a plane mesh
  39486. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39487. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39488. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39489. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39490. * * 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
  39491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39492. * @param name defines the name of the mesh
  39493. * @param options defines the options used to create the mesh
  39494. * @param scene defines the hosting scene
  39495. * @returns the plane mesh
  39496. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39497. */
  39498. static CreatePlane(name: string, options: {
  39499. size?: number;
  39500. width?: number;
  39501. height?: number;
  39502. sideOrientation?: number;
  39503. frontUVs?: Vector4;
  39504. backUVs?: Vector4;
  39505. updatable?: boolean;
  39506. sourcePlane?: Plane;
  39507. }, scene?: Nullable<Scene>): Mesh;
  39508. }
  39509. }
  39510. declare module BABYLON {
  39511. /**
  39512. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39513. */
  39514. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39515. private static _AnyMouseID;
  39516. /**
  39517. * Abstract mesh the behavior is set on
  39518. */
  39519. attachedNode: AbstractMesh;
  39520. private _dragPlane;
  39521. private _scene;
  39522. private _pointerObserver;
  39523. private _beforeRenderObserver;
  39524. private static _planeScene;
  39525. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39526. /**
  39527. * 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)
  39528. */
  39529. maxDragAngle: number;
  39530. /**
  39531. * @hidden
  39532. */
  39533. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39534. /**
  39535. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39536. */
  39537. currentDraggingPointerID: number;
  39538. /**
  39539. * The last position where the pointer hit the drag plane in world space
  39540. */
  39541. lastDragPosition: Vector3;
  39542. /**
  39543. * If the behavior is currently in a dragging state
  39544. */
  39545. dragging: boolean;
  39546. /**
  39547. * 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)
  39548. */
  39549. dragDeltaRatio: number;
  39550. /**
  39551. * If the drag plane orientation should be updated during the dragging (Default: true)
  39552. */
  39553. updateDragPlane: boolean;
  39554. private _debugMode;
  39555. private _moving;
  39556. /**
  39557. * Fires each time the attached mesh is dragged with the pointer
  39558. * * delta between last drag position and current drag position in world space
  39559. * * dragDistance along the drag axis
  39560. * * dragPlaneNormal normal of the current drag plane used during the drag
  39561. * * dragPlanePoint in world space where the drag intersects the drag plane
  39562. */
  39563. onDragObservable: Observable<{
  39564. delta: Vector3;
  39565. dragPlanePoint: Vector3;
  39566. dragPlaneNormal: Vector3;
  39567. dragDistance: number;
  39568. pointerId: number;
  39569. }>;
  39570. /**
  39571. * Fires each time a drag begins (eg. mouse down on mesh)
  39572. */
  39573. onDragStartObservable: Observable<{
  39574. dragPlanePoint: Vector3;
  39575. pointerId: number;
  39576. }>;
  39577. /**
  39578. * Fires each time a drag ends (eg. mouse release after drag)
  39579. */
  39580. onDragEndObservable: Observable<{
  39581. dragPlanePoint: Vector3;
  39582. pointerId: number;
  39583. }>;
  39584. /**
  39585. * If the attached mesh should be moved when dragged
  39586. */
  39587. moveAttached: boolean;
  39588. /**
  39589. * If the drag behavior will react to drag events (Default: true)
  39590. */
  39591. enabled: boolean;
  39592. /**
  39593. * If pointer events should start and release the drag (Default: true)
  39594. */
  39595. startAndReleaseDragOnPointerEvents: boolean;
  39596. /**
  39597. * If camera controls should be detached during the drag
  39598. */
  39599. detachCameraControls: boolean;
  39600. /**
  39601. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39602. */
  39603. useObjectOrientationForDragging: boolean;
  39604. private _options;
  39605. /**
  39606. * Gets the options used by the behavior
  39607. */
  39608. get options(): {
  39609. dragAxis?: Vector3;
  39610. dragPlaneNormal?: Vector3;
  39611. };
  39612. /**
  39613. * Sets the options used by the behavior
  39614. */
  39615. set options(options: {
  39616. dragAxis?: Vector3;
  39617. dragPlaneNormal?: Vector3;
  39618. });
  39619. /**
  39620. * Creates a pointer drag behavior that can be attached to a mesh
  39621. * @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)
  39622. */
  39623. constructor(options?: {
  39624. dragAxis?: Vector3;
  39625. dragPlaneNormal?: Vector3;
  39626. });
  39627. /**
  39628. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39629. */
  39630. validateDrag: (targetPosition: Vector3) => boolean;
  39631. /**
  39632. * The name of the behavior
  39633. */
  39634. get name(): string;
  39635. /**
  39636. * Initializes the behavior
  39637. */
  39638. init(): void;
  39639. private _tmpVector;
  39640. private _alternatePickedPoint;
  39641. private _worldDragAxis;
  39642. private _targetPosition;
  39643. private _attachedElement;
  39644. /**
  39645. * Attaches the drag behavior the passed in mesh
  39646. * @param ownerNode The mesh that will be dragged around once attached
  39647. * @param predicate Predicate to use for pick filtering
  39648. */
  39649. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39650. /**
  39651. * Force relase the drag action by code.
  39652. */
  39653. releaseDrag(): void;
  39654. private _startDragRay;
  39655. private _lastPointerRay;
  39656. /**
  39657. * Simulates the start of a pointer drag event on the behavior
  39658. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39659. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39660. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39661. */
  39662. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39663. private _startDrag;
  39664. private _dragDelta;
  39665. private _moveDrag;
  39666. private _pickWithRayOnDragPlane;
  39667. private _pointA;
  39668. private _pointB;
  39669. private _pointC;
  39670. private _lineA;
  39671. private _lineB;
  39672. private _localAxis;
  39673. private _lookAt;
  39674. private _updateDragPlanePosition;
  39675. /**
  39676. * Detaches the behavior from the mesh
  39677. */
  39678. detach(): void;
  39679. }
  39680. }
  39681. declare module BABYLON {
  39682. /**
  39683. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39684. */
  39685. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39686. private _dragBehaviorA;
  39687. private _dragBehaviorB;
  39688. private _startDistance;
  39689. private _initialScale;
  39690. private _targetScale;
  39691. private _ownerNode;
  39692. private _sceneRenderObserver;
  39693. /**
  39694. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39695. */
  39696. constructor();
  39697. /**
  39698. * The name of the behavior
  39699. */
  39700. get name(): string;
  39701. /**
  39702. * Initializes the behavior
  39703. */
  39704. init(): void;
  39705. private _getCurrentDistance;
  39706. /**
  39707. * Attaches the scale behavior the passed in mesh
  39708. * @param ownerNode The mesh that will be scaled around once attached
  39709. */
  39710. attach(ownerNode: Mesh): void;
  39711. /**
  39712. * Detaches the behavior from the mesh
  39713. */
  39714. detach(): void;
  39715. }
  39716. }
  39717. declare module BABYLON {
  39718. /**
  39719. * 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
  39720. */
  39721. export class SixDofDragBehavior implements Behavior<Mesh> {
  39722. private static _virtualScene;
  39723. private _ownerNode;
  39724. private _sceneRenderObserver;
  39725. private _scene;
  39726. private _targetPosition;
  39727. private _virtualOriginMesh;
  39728. private _virtualDragMesh;
  39729. private _pointerObserver;
  39730. private _moving;
  39731. private _startingOrientation;
  39732. private _attachedElement;
  39733. /**
  39734. * 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)
  39735. */
  39736. private zDragFactor;
  39737. /**
  39738. * If the object should rotate to face the drag origin
  39739. */
  39740. rotateDraggedObject: boolean;
  39741. /**
  39742. * If the behavior is currently in a dragging state
  39743. */
  39744. dragging: boolean;
  39745. /**
  39746. * 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)
  39747. */
  39748. dragDeltaRatio: number;
  39749. /**
  39750. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39751. */
  39752. currentDraggingPointerID: number;
  39753. /**
  39754. * If camera controls should be detached during the drag
  39755. */
  39756. detachCameraControls: boolean;
  39757. /**
  39758. * Fires each time a drag starts
  39759. */
  39760. onDragStartObservable: Observable<{}>;
  39761. /**
  39762. * Fires each time a drag ends (eg. mouse release after drag)
  39763. */
  39764. onDragEndObservable: Observable<{}>;
  39765. /**
  39766. * 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
  39767. */
  39768. constructor();
  39769. /**
  39770. * The name of the behavior
  39771. */
  39772. get name(): string;
  39773. /**
  39774. * Initializes the behavior
  39775. */
  39776. init(): void;
  39777. /**
  39778. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39779. */
  39780. private get _pointerCamera();
  39781. /**
  39782. * Attaches the scale behavior the passed in mesh
  39783. * @param ownerNode The mesh that will be scaled around once attached
  39784. */
  39785. attach(ownerNode: Mesh): void;
  39786. /**
  39787. * Detaches the behavior from the mesh
  39788. */
  39789. detach(): void;
  39790. }
  39791. }
  39792. declare module BABYLON {
  39793. /**
  39794. * Class used to apply inverse kinematics to bones
  39795. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39796. */
  39797. export class BoneIKController {
  39798. private static _tmpVecs;
  39799. private static _tmpQuat;
  39800. private static _tmpMats;
  39801. /**
  39802. * Gets or sets the target mesh
  39803. */
  39804. targetMesh: AbstractMesh;
  39805. /** Gets or sets the mesh used as pole */
  39806. poleTargetMesh: AbstractMesh;
  39807. /**
  39808. * Gets or sets the bone used as pole
  39809. */
  39810. poleTargetBone: Nullable<Bone>;
  39811. /**
  39812. * Gets or sets the target position
  39813. */
  39814. targetPosition: Vector3;
  39815. /**
  39816. * Gets or sets the pole target position
  39817. */
  39818. poleTargetPosition: Vector3;
  39819. /**
  39820. * Gets or sets the pole target local offset
  39821. */
  39822. poleTargetLocalOffset: Vector3;
  39823. /**
  39824. * Gets or sets the pole angle
  39825. */
  39826. poleAngle: number;
  39827. /**
  39828. * Gets or sets the mesh associated with the controller
  39829. */
  39830. mesh: AbstractMesh;
  39831. /**
  39832. * 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)
  39833. */
  39834. slerpAmount: number;
  39835. private _bone1Quat;
  39836. private _bone1Mat;
  39837. private _bone2Ang;
  39838. private _bone1;
  39839. private _bone2;
  39840. private _bone1Length;
  39841. private _bone2Length;
  39842. private _maxAngle;
  39843. private _maxReach;
  39844. private _rightHandedSystem;
  39845. private _bendAxis;
  39846. private _slerping;
  39847. private _adjustRoll;
  39848. /**
  39849. * Gets or sets maximum allowed angle
  39850. */
  39851. get maxAngle(): number;
  39852. set maxAngle(value: number);
  39853. /**
  39854. * Creates a new BoneIKController
  39855. * @param mesh defines the mesh to control
  39856. * @param bone defines the bone to control
  39857. * @param options defines options to set up the controller
  39858. */
  39859. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39860. targetMesh?: AbstractMesh;
  39861. poleTargetMesh?: AbstractMesh;
  39862. poleTargetBone?: Bone;
  39863. poleTargetLocalOffset?: Vector3;
  39864. poleAngle?: number;
  39865. bendAxis?: Vector3;
  39866. maxAngle?: number;
  39867. slerpAmount?: number;
  39868. });
  39869. private _setMaxAngle;
  39870. /**
  39871. * Force the controller to update the bones
  39872. */
  39873. update(): void;
  39874. }
  39875. }
  39876. declare module BABYLON {
  39877. /**
  39878. * Class used to make a bone look toward a point in space
  39879. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39880. */
  39881. export class BoneLookController {
  39882. private static _tmpVecs;
  39883. private static _tmpQuat;
  39884. private static _tmpMats;
  39885. /**
  39886. * The target Vector3 that the bone will look at
  39887. */
  39888. target: Vector3;
  39889. /**
  39890. * The mesh that the bone is attached to
  39891. */
  39892. mesh: AbstractMesh;
  39893. /**
  39894. * The bone that will be looking to the target
  39895. */
  39896. bone: Bone;
  39897. /**
  39898. * The up axis of the coordinate system that is used when the bone is rotated
  39899. */
  39900. upAxis: Vector3;
  39901. /**
  39902. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39903. */
  39904. upAxisSpace: Space;
  39905. /**
  39906. * Used to make an adjustment to the yaw of the bone
  39907. */
  39908. adjustYaw: number;
  39909. /**
  39910. * Used to make an adjustment to the pitch of the bone
  39911. */
  39912. adjustPitch: number;
  39913. /**
  39914. * Used to make an adjustment to the roll of the bone
  39915. */
  39916. adjustRoll: number;
  39917. /**
  39918. * 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)
  39919. */
  39920. slerpAmount: number;
  39921. private _minYaw;
  39922. private _maxYaw;
  39923. private _minPitch;
  39924. private _maxPitch;
  39925. private _minYawSin;
  39926. private _minYawCos;
  39927. private _maxYawSin;
  39928. private _maxYawCos;
  39929. private _midYawConstraint;
  39930. private _minPitchTan;
  39931. private _maxPitchTan;
  39932. private _boneQuat;
  39933. private _slerping;
  39934. private _transformYawPitch;
  39935. private _transformYawPitchInv;
  39936. private _firstFrameSkipped;
  39937. private _yawRange;
  39938. private _fowardAxis;
  39939. /**
  39940. * Gets or sets the minimum yaw angle that the bone can look to
  39941. */
  39942. get minYaw(): number;
  39943. set minYaw(value: number);
  39944. /**
  39945. * Gets or sets the maximum yaw angle that the bone can look to
  39946. */
  39947. get maxYaw(): number;
  39948. set maxYaw(value: number);
  39949. /**
  39950. * Gets or sets the minimum pitch angle that the bone can look to
  39951. */
  39952. get minPitch(): number;
  39953. set minPitch(value: number);
  39954. /**
  39955. * Gets or sets the maximum pitch angle that the bone can look to
  39956. */
  39957. get maxPitch(): number;
  39958. set maxPitch(value: number);
  39959. /**
  39960. * Create a BoneLookController
  39961. * @param mesh the mesh that the bone belongs to
  39962. * @param bone the bone that will be looking to the target
  39963. * @param target the target Vector3 to look at
  39964. * @param options optional settings:
  39965. * * maxYaw: the maximum angle the bone will yaw to
  39966. * * minYaw: the minimum angle the bone will yaw to
  39967. * * maxPitch: the maximum angle the bone will pitch to
  39968. * * minPitch: the minimum angle the bone will yaw to
  39969. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39970. * * upAxis: the up axis of the coordinate system
  39971. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39972. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39973. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39974. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39975. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39976. * * adjustRoll: used to make an adjustment to the roll of the bone
  39977. **/
  39978. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39979. maxYaw?: number;
  39980. minYaw?: number;
  39981. maxPitch?: number;
  39982. minPitch?: number;
  39983. slerpAmount?: number;
  39984. upAxis?: Vector3;
  39985. upAxisSpace?: Space;
  39986. yawAxis?: Vector3;
  39987. pitchAxis?: Vector3;
  39988. adjustYaw?: number;
  39989. adjustPitch?: number;
  39990. adjustRoll?: number;
  39991. });
  39992. /**
  39993. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39994. */
  39995. update(): void;
  39996. private _getAngleDiff;
  39997. private _getAngleBetween;
  39998. private _isAngleBetween;
  39999. }
  40000. }
  40001. declare module BABYLON {
  40002. /**
  40003. * Manage the gamepad inputs to control an arc rotate camera.
  40004. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40005. */
  40006. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40007. /**
  40008. * Defines the camera the input is attached to.
  40009. */
  40010. camera: ArcRotateCamera;
  40011. /**
  40012. * Defines the gamepad the input is gathering event from.
  40013. */
  40014. gamepad: Nullable<Gamepad>;
  40015. /**
  40016. * Defines the gamepad rotation sensiblity.
  40017. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40018. */
  40019. gamepadRotationSensibility: number;
  40020. /**
  40021. * Defines the gamepad move sensiblity.
  40022. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40023. */
  40024. gamepadMoveSensibility: number;
  40025. private _yAxisScale;
  40026. /**
  40027. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40028. */
  40029. get invertYAxis(): boolean;
  40030. set invertYAxis(value: boolean);
  40031. private _onGamepadConnectedObserver;
  40032. private _onGamepadDisconnectedObserver;
  40033. /**
  40034. * Attach the input controls to a specific dom element to get the input from.
  40035. * @param element Defines the element the controls should be listened from
  40036. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40037. */
  40038. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40039. /**
  40040. * Detach the current controls from the specified dom element.
  40041. * @param element Defines the element to stop listening the inputs from
  40042. */
  40043. detachControl(element: Nullable<HTMLElement>): void;
  40044. /**
  40045. * Update the current camera state depending on the inputs that have been used this frame.
  40046. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40047. */
  40048. checkInputs(): void;
  40049. /**
  40050. * Gets the class name of the current intput.
  40051. * @returns the class name
  40052. */
  40053. getClassName(): string;
  40054. /**
  40055. * Get the friendly name associated with the input class.
  40056. * @returns the input friendly name
  40057. */
  40058. getSimpleName(): string;
  40059. }
  40060. }
  40061. declare module BABYLON {
  40062. interface ArcRotateCameraInputsManager {
  40063. /**
  40064. * Add orientation input support to the input manager.
  40065. * @returns the current input manager
  40066. */
  40067. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40068. }
  40069. /**
  40070. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40071. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40072. */
  40073. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40074. /**
  40075. * Defines the camera the input is attached to.
  40076. */
  40077. camera: ArcRotateCamera;
  40078. /**
  40079. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40080. */
  40081. alphaCorrection: number;
  40082. /**
  40083. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40084. */
  40085. gammaCorrection: number;
  40086. private _alpha;
  40087. private _gamma;
  40088. private _dirty;
  40089. private _deviceOrientationHandler;
  40090. /**
  40091. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40092. */
  40093. constructor();
  40094. /**
  40095. * Attach the input controls to a specific dom element to get the input from.
  40096. * @param element Defines the element the controls should be listened from
  40097. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40098. */
  40099. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40100. /** @hidden */
  40101. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40102. /**
  40103. * Update the current camera state depending on the inputs that have been used this frame.
  40104. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40105. */
  40106. checkInputs(): void;
  40107. /**
  40108. * Detach the current controls from the specified dom element.
  40109. * @param element Defines the element to stop listening the inputs from
  40110. */
  40111. detachControl(element: Nullable<HTMLElement>): void;
  40112. /**
  40113. * Gets the class name of the current intput.
  40114. * @returns the class name
  40115. */
  40116. getClassName(): string;
  40117. /**
  40118. * Get the friendly name associated with the input class.
  40119. * @returns the input friendly name
  40120. */
  40121. getSimpleName(): string;
  40122. }
  40123. }
  40124. declare module BABYLON {
  40125. /**
  40126. * Listen to mouse events to control the camera.
  40127. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40128. */
  40129. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40130. /**
  40131. * Defines the camera the input is attached to.
  40132. */
  40133. camera: FlyCamera;
  40134. /**
  40135. * Defines if touch is enabled. (Default is true.)
  40136. */
  40137. touchEnabled: boolean;
  40138. /**
  40139. * Defines the buttons associated with the input to handle camera rotation.
  40140. */
  40141. buttons: number[];
  40142. /**
  40143. * Assign buttons for Yaw control.
  40144. */
  40145. buttonsYaw: number[];
  40146. /**
  40147. * Assign buttons for Pitch control.
  40148. */
  40149. buttonsPitch: number[];
  40150. /**
  40151. * Assign buttons for Roll control.
  40152. */
  40153. buttonsRoll: number[];
  40154. /**
  40155. * Detect if any button is being pressed while mouse is moved.
  40156. * -1 = Mouse locked.
  40157. * 0 = Left button.
  40158. * 1 = Middle Button.
  40159. * 2 = Right Button.
  40160. */
  40161. activeButton: number;
  40162. /**
  40163. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40164. * Higher values reduce its sensitivity.
  40165. */
  40166. angularSensibility: number;
  40167. private _mousemoveCallback;
  40168. private _observer;
  40169. private _rollObserver;
  40170. private previousPosition;
  40171. private noPreventDefault;
  40172. private element;
  40173. /**
  40174. * Listen to mouse events to control the camera.
  40175. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40176. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40177. */
  40178. constructor(touchEnabled?: boolean);
  40179. /**
  40180. * Attach the mouse control to the HTML DOM element.
  40181. * @param element Defines the element that listens to the input events.
  40182. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40183. */
  40184. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40185. /**
  40186. * Detach the current controls from the specified dom element.
  40187. * @param element Defines the element to stop listening the inputs from
  40188. */
  40189. detachControl(element: Nullable<HTMLElement>): void;
  40190. /**
  40191. * Gets the class name of the current input.
  40192. * @returns the class name.
  40193. */
  40194. getClassName(): string;
  40195. /**
  40196. * Get the friendly name associated with the input class.
  40197. * @returns the input's friendly name.
  40198. */
  40199. getSimpleName(): string;
  40200. private _pointerInput;
  40201. private _onMouseMove;
  40202. /**
  40203. * Rotate camera by mouse offset.
  40204. */
  40205. private rotateCamera;
  40206. }
  40207. }
  40208. declare module BABYLON {
  40209. /**
  40210. * Default Inputs manager for the FlyCamera.
  40211. * It groups all the default supported inputs for ease of use.
  40212. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40213. */
  40214. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40215. /**
  40216. * Instantiates a new FlyCameraInputsManager.
  40217. * @param camera Defines the camera the inputs belong to.
  40218. */
  40219. constructor(camera: FlyCamera);
  40220. /**
  40221. * Add keyboard input support to the input manager.
  40222. * @returns the new FlyCameraKeyboardMoveInput().
  40223. */
  40224. addKeyboard(): FlyCameraInputsManager;
  40225. /**
  40226. * Add mouse input support to the input manager.
  40227. * @param touchEnabled Enable touch screen support.
  40228. * @returns the new FlyCameraMouseInput().
  40229. */
  40230. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40231. }
  40232. }
  40233. declare module BABYLON {
  40234. /**
  40235. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40236. * such as in a 3D Space Shooter or a Flight Simulator.
  40237. */
  40238. export class FlyCamera extends TargetCamera {
  40239. /**
  40240. * Define the collision ellipsoid of the camera.
  40241. * This is helpful for simulating a camera body, like a player's body.
  40242. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40243. */
  40244. ellipsoid: Vector3;
  40245. /**
  40246. * Define an offset for the position of the ellipsoid around the camera.
  40247. * This can be helpful if the camera is attached away from the player's body center,
  40248. * such as at its head.
  40249. */
  40250. ellipsoidOffset: Vector3;
  40251. /**
  40252. * Enable or disable collisions of the camera with the rest of the scene objects.
  40253. */
  40254. checkCollisions: boolean;
  40255. /**
  40256. * Enable or disable gravity on the camera.
  40257. */
  40258. applyGravity: boolean;
  40259. /**
  40260. * Define the current direction the camera is moving to.
  40261. */
  40262. cameraDirection: Vector3;
  40263. /**
  40264. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40265. * This overrides and empties cameraRotation.
  40266. */
  40267. rotationQuaternion: Quaternion;
  40268. /**
  40269. * Track Roll to maintain the wanted Rolling when looking around.
  40270. */
  40271. _trackRoll: number;
  40272. /**
  40273. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40274. */
  40275. rollCorrect: number;
  40276. /**
  40277. * Mimic a banked turn, Rolling the camera when Yawing.
  40278. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40279. */
  40280. bankedTurn: boolean;
  40281. /**
  40282. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40283. */
  40284. bankedTurnLimit: number;
  40285. /**
  40286. * Value of 0 disables the banked Roll.
  40287. * Value of 1 is equal to the Yaw angle in radians.
  40288. */
  40289. bankedTurnMultiplier: number;
  40290. /**
  40291. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40292. */
  40293. inputs: FlyCameraInputsManager;
  40294. /**
  40295. * Gets the input sensibility for mouse input.
  40296. * Higher values reduce sensitivity.
  40297. */
  40298. get angularSensibility(): number;
  40299. /**
  40300. * Sets the input sensibility for a mouse input.
  40301. * Higher values reduce sensitivity.
  40302. */
  40303. set angularSensibility(value: number);
  40304. /**
  40305. * Get the keys for camera movement forward.
  40306. */
  40307. get keysForward(): number[];
  40308. /**
  40309. * Set the keys for camera movement forward.
  40310. */
  40311. set keysForward(value: number[]);
  40312. /**
  40313. * Get the keys for camera movement backward.
  40314. */
  40315. get keysBackward(): number[];
  40316. set keysBackward(value: number[]);
  40317. /**
  40318. * Get the keys for camera movement up.
  40319. */
  40320. get keysUp(): number[];
  40321. /**
  40322. * Set the keys for camera movement up.
  40323. */
  40324. set keysUp(value: number[]);
  40325. /**
  40326. * Get the keys for camera movement down.
  40327. */
  40328. get keysDown(): number[];
  40329. /**
  40330. * Set the keys for camera movement down.
  40331. */
  40332. set keysDown(value: number[]);
  40333. /**
  40334. * Get the keys for camera movement left.
  40335. */
  40336. get keysLeft(): number[];
  40337. /**
  40338. * Set the keys for camera movement left.
  40339. */
  40340. set keysLeft(value: number[]);
  40341. /**
  40342. * Set the keys for camera movement right.
  40343. */
  40344. get keysRight(): number[];
  40345. /**
  40346. * Set the keys for camera movement right.
  40347. */
  40348. set keysRight(value: number[]);
  40349. /**
  40350. * Event raised when the camera collides with a mesh in the scene.
  40351. */
  40352. onCollide: (collidedMesh: AbstractMesh) => void;
  40353. private _collider;
  40354. private _needMoveForGravity;
  40355. private _oldPosition;
  40356. private _diffPosition;
  40357. private _newPosition;
  40358. /** @hidden */
  40359. _localDirection: Vector3;
  40360. /** @hidden */
  40361. _transformedDirection: Vector3;
  40362. /**
  40363. * Instantiates a FlyCamera.
  40364. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40365. * such as in a 3D Space Shooter or a Flight Simulator.
  40366. * @param name Define the name of the camera in the scene.
  40367. * @param position Define the starting position of the camera in the scene.
  40368. * @param scene Define the scene the camera belongs to.
  40369. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40370. */
  40371. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40372. /**
  40373. * Attach a control to the HTML DOM element.
  40374. * @param element Defines the element that listens to the input events.
  40375. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40376. */
  40377. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40378. /**
  40379. * Detach a control from the HTML DOM element.
  40380. * The camera will stop reacting to that input.
  40381. * @param element Defines the element that listens to the input events.
  40382. */
  40383. detachControl(element: HTMLElement): void;
  40384. private _collisionMask;
  40385. /**
  40386. * Get the mask that the camera ignores in collision events.
  40387. */
  40388. get collisionMask(): number;
  40389. /**
  40390. * Set the mask that the camera ignores in collision events.
  40391. */
  40392. set collisionMask(mask: number);
  40393. /** @hidden */
  40394. _collideWithWorld(displacement: Vector3): void;
  40395. /** @hidden */
  40396. private _onCollisionPositionChange;
  40397. /** @hidden */
  40398. _checkInputs(): void;
  40399. /** @hidden */
  40400. _decideIfNeedsToMove(): boolean;
  40401. /** @hidden */
  40402. _updatePosition(): void;
  40403. /**
  40404. * Restore the Roll to its target value at the rate specified.
  40405. * @param rate - Higher means slower restoring.
  40406. * @hidden
  40407. */
  40408. restoreRoll(rate: number): void;
  40409. /**
  40410. * Destroy the camera and release the current resources held by it.
  40411. */
  40412. dispose(): void;
  40413. /**
  40414. * Get the current object class name.
  40415. * @returns the class name.
  40416. */
  40417. getClassName(): string;
  40418. }
  40419. }
  40420. declare module BABYLON {
  40421. /**
  40422. * Listen to keyboard events to control the camera.
  40423. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40424. */
  40425. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40426. /**
  40427. * Defines the camera the input is attached to.
  40428. */
  40429. camera: FlyCamera;
  40430. /**
  40431. * The list of keyboard keys used to control the forward move of the camera.
  40432. */
  40433. keysForward: number[];
  40434. /**
  40435. * The list of keyboard keys used to control the backward move of the camera.
  40436. */
  40437. keysBackward: number[];
  40438. /**
  40439. * The list of keyboard keys used to control the forward move of the camera.
  40440. */
  40441. keysUp: number[];
  40442. /**
  40443. * The list of keyboard keys used to control the backward move of the camera.
  40444. */
  40445. keysDown: number[];
  40446. /**
  40447. * The list of keyboard keys used to control the right strafe move of the camera.
  40448. */
  40449. keysRight: number[];
  40450. /**
  40451. * The list of keyboard keys used to control the left strafe move of the camera.
  40452. */
  40453. keysLeft: number[];
  40454. private _keys;
  40455. private _onCanvasBlurObserver;
  40456. private _onKeyboardObserver;
  40457. private _engine;
  40458. private _scene;
  40459. /**
  40460. * Attach the input controls to a specific dom element to get the input from.
  40461. * @param element Defines the element the controls should be listened from
  40462. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40463. */
  40464. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40465. /**
  40466. * Detach the current controls from the specified dom element.
  40467. * @param element Defines the element to stop listening the inputs from
  40468. */
  40469. detachControl(element: Nullable<HTMLElement>): void;
  40470. /**
  40471. * Gets the class name of the current intput.
  40472. * @returns the class name
  40473. */
  40474. getClassName(): string;
  40475. /** @hidden */
  40476. _onLostFocus(e: FocusEvent): void;
  40477. /**
  40478. * Get the friendly name associated with the input class.
  40479. * @returns the input friendly name
  40480. */
  40481. getSimpleName(): string;
  40482. /**
  40483. * Update the current camera state depending on the inputs that have been used this frame.
  40484. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40485. */
  40486. checkInputs(): void;
  40487. }
  40488. }
  40489. declare module BABYLON {
  40490. /**
  40491. * Manage the mouse wheel inputs to control a follow camera.
  40492. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40493. */
  40494. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40495. /**
  40496. * Defines the camera the input is attached to.
  40497. */
  40498. camera: FollowCamera;
  40499. /**
  40500. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40501. */
  40502. axisControlRadius: boolean;
  40503. /**
  40504. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40505. */
  40506. axisControlHeight: boolean;
  40507. /**
  40508. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40509. */
  40510. axisControlRotation: boolean;
  40511. /**
  40512. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40513. * relation to mouseWheel events.
  40514. */
  40515. wheelPrecision: number;
  40516. /**
  40517. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40518. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40519. */
  40520. wheelDeltaPercentage: number;
  40521. private _wheel;
  40522. private _observer;
  40523. /**
  40524. * Attach the input controls to a specific dom element to get the input from.
  40525. * @param element Defines the element the controls should be listened from
  40526. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40527. */
  40528. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40529. /**
  40530. * Detach the current controls from the specified dom element.
  40531. * @param element Defines the element to stop listening the inputs from
  40532. */
  40533. detachControl(element: Nullable<HTMLElement>): void;
  40534. /**
  40535. * Gets the class name of the current intput.
  40536. * @returns the class name
  40537. */
  40538. getClassName(): string;
  40539. /**
  40540. * Get the friendly name associated with the input class.
  40541. * @returns the input friendly name
  40542. */
  40543. getSimpleName(): string;
  40544. }
  40545. }
  40546. declare module BABYLON {
  40547. /**
  40548. * Manage the pointers inputs to control an follow camera.
  40549. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40550. */
  40551. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40552. /**
  40553. * Defines the camera the input is attached to.
  40554. */
  40555. camera: FollowCamera;
  40556. /**
  40557. * Gets the class name of the current input.
  40558. * @returns the class name
  40559. */
  40560. getClassName(): string;
  40561. /**
  40562. * Defines the pointer angular sensibility along the X axis or how fast is
  40563. * the camera rotating.
  40564. * A negative number will reverse the axis direction.
  40565. */
  40566. angularSensibilityX: number;
  40567. /**
  40568. * Defines the pointer angular sensibility along the Y axis or how fast is
  40569. * the camera rotating.
  40570. * A negative number will reverse the axis direction.
  40571. */
  40572. angularSensibilityY: number;
  40573. /**
  40574. * Defines the pointer pinch precision or how fast is the camera zooming.
  40575. * A negative number will reverse the axis direction.
  40576. */
  40577. pinchPrecision: number;
  40578. /**
  40579. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40580. * from 0.
  40581. * It defines the percentage of current camera.radius to use as delta when
  40582. * pinch zoom is used.
  40583. */
  40584. pinchDeltaPercentage: number;
  40585. /**
  40586. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40587. */
  40588. axisXControlRadius: boolean;
  40589. /**
  40590. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40591. */
  40592. axisXControlHeight: boolean;
  40593. /**
  40594. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40595. */
  40596. axisXControlRotation: boolean;
  40597. /**
  40598. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40599. */
  40600. axisYControlRadius: boolean;
  40601. /**
  40602. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40603. */
  40604. axisYControlHeight: boolean;
  40605. /**
  40606. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40607. */
  40608. axisYControlRotation: boolean;
  40609. /**
  40610. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40611. */
  40612. axisPinchControlRadius: boolean;
  40613. /**
  40614. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40615. */
  40616. axisPinchControlHeight: boolean;
  40617. /**
  40618. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40619. */
  40620. axisPinchControlRotation: boolean;
  40621. /**
  40622. * Log error messages if basic misconfiguration has occurred.
  40623. */
  40624. warningEnable: boolean;
  40625. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40626. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40627. private _warningCounter;
  40628. private _warning;
  40629. }
  40630. }
  40631. declare module BABYLON {
  40632. /**
  40633. * Default Inputs manager for the FollowCamera.
  40634. * It groups all the default supported inputs for ease of use.
  40635. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40636. */
  40637. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40638. /**
  40639. * Instantiates a new FollowCameraInputsManager.
  40640. * @param camera Defines the camera the inputs belong to
  40641. */
  40642. constructor(camera: FollowCamera);
  40643. /**
  40644. * Add keyboard input support to the input manager.
  40645. * @returns the current input manager
  40646. */
  40647. addKeyboard(): FollowCameraInputsManager;
  40648. /**
  40649. * Add mouse wheel input support to the input manager.
  40650. * @returns the current input manager
  40651. */
  40652. addMouseWheel(): FollowCameraInputsManager;
  40653. /**
  40654. * Add pointers input support to the input manager.
  40655. * @returns the current input manager
  40656. */
  40657. addPointers(): FollowCameraInputsManager;
  40658. /**
  40659. * Add orientation input support to the input manager.
  40660. * @returns the current input manager
  40661. */
  40662. addVRDeviceOrientation(): FollowCameraInputsManager;
  40663. }
  40664. }
  40665. declare module BABYLON {
  40666. /**
  40667. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40668. * an arc rotate version arcFollowCamera are available.
  40669. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40670. */
  40671. export class FollowCamera extends TargetCamera {
  40672. /**
  40673. * Distance the follow camera should follow an object at
  40674. */
  40675. radius: number;
  40676. /**
  40677. * Minimum allowed distance of the camera to the axis of rotation
  40678. * (The camera can not get closer).
  40679. * This can help limiting how the Camera is able to move in the scene.
  40680. */
  40681. lowerRadiusLimit: Nullable<number>;
  40682. /**
  40683. * Maximum allowed distance of the camera to the axis of rotation
  40684. * (The camera can not get further).
  40685. * This can help limiting how the Camera is able to move in the scene.
  40686. */
  40687. upperRadiusLimit: Nullable<number>;
  40688. /**
  40689. * Define a rotation offset between the camera and the object it follows
  40690. */
  40691. rotationOffset: number;
  40692. /**
  40693. * Minimum allowed angle to camera position relative to target object.
  40694. * This can help limiting how the Camera is able to move in the scene.
  40695. */
  40696. lowerRotationOffsetLimit: Nullable<number>;
  40697. /**
  40698. * Maximum allowed angle to camera position relative to target object.
  40699. * This can help limiting how the Camera is able to move in the scene.
  40700. */
  40701. upperRotationOffsetLimit: Nullable<number>;
  40702. /**
  40703. * Define a height offset between the camera and the object it follows.
  40704. * It can help following an object from the top (like a car chaing a plane)
  40705. */
  40706. heightOffset: number;
  40707. /**
  40708. * Minimum allowed height of camera position relative to target object.
  40709. * This can help limiting how the Camera is able to move in the scene.
  40710. */
  40711. lowerHeightOffsetLimit: Nullable<number>;
  40712. /**
  40713. * Maximum allowed height of camera position relative to target object.
  40714. * This can help limiting how the Camera is able to move in the scene.
  40715. */
  40716. upperHeightOffsetLimit: Nullable<number>;
  40717. /**
  40718. * Define how fast the camera can accelerate to follow it s target.
  40719. */
  40720. cameraAcceleration: number;
  40721. /**
  40722. * Define the speed limit of the camera following an object.
  40723. */
  40724. maxCameraSpeed: number;
  40725. /**
  40726. * Define the target of the camera.
  40727. */
  40728. lockedTarget: Nullable<AbstractMesh>;
  40729. /**
  40730. * Defines the input associated with the camera.
  40731. */
  40732. inputs: FollowCameraInputsManager;
  40733. /**
  40734. * Instantiates the follow camera.
  40735. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40736. * @param name Define the name of the camera in the scene
  40737. * @param position Define the position of the camera
  40738. * @param scene Define the scene the camera belong to
  40739. * @param lockedTarget Define the target of the camera
  40740. */
  40741. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40742. private _follow;
  40743. /**
  40744. * Attached controls to the current camera.
  40745. * @param element Defines the element the controls should be listened from
  40746. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40747. */
  40748. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40749. /**
  40750. * Detach the current controls from the camera.
  40751. * The camera will stop reacting to inputs.
  40752. * @param element Defines the element to stop listening the inputs from
  40753. */
  40754. detachControl(element: HTMLElement): void;
  40755. /** @hidden */
  40756. _checkInputs(): void;
  40757. private _checkLimits;
  40758. /**
  40759. * Gets the camera class name.
  40760. * @returns the class name
  40761. */
  40762. getClassName(): string;
  40763. }
  40764. /**
  40765. * Arc Rotate version of the follow camera.
  40766. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40767. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40768. */
  40769. export class ArcFollowCamera extends TargetCamera {
  40770. /** The longitudinal angle of the camera */
  40771. alpha: number;
  40772. /** The latitudinal angle of the camera */
  40773. beta: number;
  40774. /** The radius of the camera from its target */
  40775. radius: number;
  40776. /** Define the camera target (the messh it should follow) */
  40777. target: Nullable<AbstractMesh>;
  40778. private _cartesianCoordinates;
  40779. /**
  40780. * Instantiates a new ArcFollowCamera
  40781. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40782. * @param name Define the name of the camera
  40783. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40784. * @param beta Define the rotation angle of the camera around the elevation axis
  40785. * @param radius Define the radius of the camera from its target point
  40786. * @param target Define the target of the camera
  40787. * @param scene Define the scene the camera belongs to
  40788. */
  40789. constructor(name: string,
  40790. /** The longitudinal angle of the camera */
  40791. alpha: number,
  40792. /** The latitudinal angle of the camera */
  40793. beta: number,
  40794. /** The radius of the camera from its target */
  40795. radius: number,
  40796. /** Define the camera target (the messh it should follow) */
  40797. target: Nullable<AbstractMesh>, scene: Scene);
  40798. private _follow;
  40799. /** @hidden */
  40800. _checkInputs(): void;
  40801. /**
  40802. * Returns the class name of the object.
  40803. * It is mostly used internally for serialization purposes.
  40804. */
  40805. getClassName(): string;
  40806. }
  40807. }
  40808. declare module BABYLON {
  40809. /**
  40810. * Manage the keyboard inputs to control the movement of a follow camera.
  40811. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40812. */
  40813. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40814. /**
  40815. * Defines the camera the input is attached to.
  40816. */
  40817. camera: FollowCamera;
  40818. /**
  40819. * Defines the list of key codes associated with the up action (increase heightOffset)
  40820. */
  40821. keysHeightOffsetIncr: number[];
  40822. /**
  40823. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40824. */
  40825. keysHeightOffsetDecr: number[];
  40826. /**
  40827. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40828. */
  40829. keysHeightOffsetModifierAlt: boolean;
  40830. /**
  40831. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40832. */
  40833. keysHeightOffsetModifierCtrl: boolean;
  40834. /**
  40835. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40836. */
  40837. keysHeightOffsetModifierShift: boolean;
  40838. /**
  40839. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40840. */
  40841. keysRotationOffsetIncr: number[];
  40842. /**
  40843. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40844. */
  40845. keysRotationOffsetDecr: number[];
  40846. /**
  40847. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40848. */
  40849. keysRotationOffsetModifierAlt: boolean;
  40850. /**
  40851. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40852. */
  40853. keysRotationOffsetModifierCtrl: boolean;
  40854. /**
  40855. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40856. */
  40857. keysRotationOffsetModifierShift: boolean;
  40858. /**
  40859. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40860. */
  40861. keysRadiusIncr: number[];
  40862. /**
  40863. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40864. */
  40865. keysRadiusDecr: number[];
  40866. /**
  40867. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40868. */
  40869. keysRadiusModifierAlt: boolean;
  40870. /**
  40871. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40872. */
  40873. keysRadiusModifierCtrl: boolean;
  40874. /**
  40875. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40876. */
  40877. keysRadiusModifierShift: boolean;
  40878. /**
  40879. * Defines the rate of change of heightOffset.
  40880. */
  40881. heightSensibility: number;
  40882. /**
  40883. * Defines the rate of change of rotationOffset.
  40884. */
  40885. rotationSensibility: number;
  40886. /**
  40887. * Defines the rate of change of radius.
  40888. */
  40889. radiusSensibility: number;
  40890. private _keys;
  40891. private _ctrlPressed;
  40892. private _altPressed;
  40893. private _shiftPressed;
  40894. private _onCanvasBlurObserver;
  40895. private _onKeyboardObserver;
  40896. private _engine;
  40897. private _scene;
  40898. /**
  40899. * Attach the input controls to a specific dom element to get the input from.
  40900. * @param element Defines the element the controls should be listened from
  40901. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40902. */
  40903. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40904. /**
  40905. * Detach the current controls from the specified dom element.
  40906. * @param element Defines the element to stop listening the inputs from
  40907. */
  40908. detachControl(element: Nullable<HTMLElement>): void;
  40909. /**
  40910. * Update the current camera state depending on the inputs that have been used this frame.
  40911. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40912. */
  40913. checkInputs(): void;
  40914. /**
  40915. * Gets the class name of the current input.
  40916. * @returns the class name
  40917. */
  40918. getClassName(): string;
  40919. /**
  40920. * Get the friendly name associated with the input class.
  40921. * @returns the input friendly name
  40922. */
  40923. getSimpleName(): string;
  40924. /**
  40925. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40926. * allow modification of the heightOffset value.
  40927. */
  40928. private _modifierHeightOffset;
  40929. /**
  40930. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40931. * allow modification of the rotationOffset value.
  40932. */
  40933. private _modifierRotationOffset;
  40934. /**
  40935. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40936. * allow modification of the radius value.
  40937. */
  40938. private _modifierRadius;
  40939. }
  40940. }
  40941. declare module BABYLON {
  40942. interface FreeCameraInputsManager {
  40943. /**
  40944. * @hidden
  40945. */
  40946. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40947. /**
  40948. * Add orientation input support to the input manager.
  40949. * @returns the current input manager
  40950. */
  40951. addDeviceOrientation(): FreeCameraInputsManager;
  40952. }
  40953. /**
  40954. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40955. * Screen rotation is taken into account.
  40956. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40957. */
  40958. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40959. private _camera;
  40960. private _screenOrientationAngle;
  40961. private _constantTranform;
  40962. private _screenQuaternion;
  40963. private _alpha;
  40964. private _beta;
  40965. private _gamma;
  40966. /**
  40967. * Can be used to detect if a device orientation sensor is available on a device
  40968. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40969. * @returns a promise that will resolve on orientation change
  40970. */
  40971. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40972. /**
  40973. * @hidden
  40974. */
  40975. _onDeviceOrientationChangedObservable: Observable<void>;
  40976. /**
  40977. * Instantiates a new input
  40978. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40979. */
  40980. constructor();
  40981. /**
  40982. * Define the camera controlled by the input.
  40983. */
  40984. get camera(): FreeCamera;
  40985. set camera(camera: FreeCamera);
  40986. /**
  40987. * Attach the input controls to a specific dom element to get the input from.
  40988. * @param element Defines the element the controls should be listened from
  40989. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40990. */
  40991. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40992. private _orientationChanged;
  40993. private _deviceOrientation;
  40994. /**
  40995. * Detach the current controls from the specified dom element.
  40996. * @param element Defines the element to stop listening the inputs from
  40997. */
  40998. detachControl(element: Nullable<HTMLElement>): void;
  40999. /**
  41000. * Update the current camera state depending on the inputs that have been used this frame.
  41001. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41002. */
  41003. checkInputs(): void;
  41004. /**
  41005. * Gets the class name of the current intput.
  41006. * @returns the class name
  41007. */
  41008. getClassName(): string;
  41009. /**
  41010. * Get the friendly name associated with the input class.
  41011. * @returns the input friendly name
  41012. */
  41013. getSimpleName(): string;
  41014. }
  41015. }
  41016. declare module BABYLON {
  41017. /**
  41018. * Manage the gamepad inputs to control a free camera.
  41019. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41020. */
  41021. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41022. /**
  41023. * Define the camera the input is attached to.
  41024. */
  41025. camera: FreeCamera;
  41026. /**
  41027. * Define the Gamepad controlling the input
  41028. */
  41029. gamepad: Nullable<Gamepad>;
  41030. /**
  41031. * Defines the gamepad rotation sensiblity.
  41032. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41033. */
  41034. gamepadAngularSensibility: number;
  41035. /**
  41036. * Defines the gamepad move sensiblity.
  41037. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41038. */
  41039. gamepadMoveSensibility: number;
  41040. private _yAxisScale;
  41041. /**
  41042. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41043. */
  41044. get invertYAxis(): boolean;
  41045. set invertYAxis(value: boolean);
  41046. private _onGamepadConnectedObserver;
  41047. private _onGamepadDisconnectedObserver;
  41048. private _cameraTransform;
  41049. private _deltaTransform;
  41050. private _vector3;
  41051. private _vector2;
  41052. /**
  41053. * Attach the input controls to a specific dom element to get the input from.
  41054. * @param element Defines the element the controls should be listened from
  41055. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41056. */
  41057. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41058. /**
  41059. * Detach the current controls from the specified dom element.
  41060. * @param element Defines the element to stop listening the inputs from
  41061. */
  41062. detachControl(element: Nullable<HTMLElement>): void;
  41063. /**
  41064. * Update the current camera state depending on the inputs that have been used this frame.
  41065. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41066. */
  41067. checkInputs(): void;
  41068. /**
  41069. * Gets the class name of the current intput.
  41070. * @returns the class name
  41071. */
  41072. getClassName(): string;
  41073. /**
  41074. * Get the friendly name associated with the input class.
  41075. * @returns the input friendly name
  41076. */
  41077. getSimpleName(): string;
  41078. }
  41079. }
  41080. declare module BABYLON {
  41081. /**
  41082. * Defines the potential axis of a Joystick
  41083. */
  41084. export enum JoystickAxis {
  41085. /** X axis */
  41086. X = 0,
  41087. /** Y axis */
  41088. Y = 1,
  41089. /** Z axis */
  41090. Z = 2
  41091. }
  41092. /**
  41093. * Class used to define virtual joystick (used in touch mode)
  41094. */
  41095. export class VirtualJoystick {
  41096. /**
  41097. * Gets or sets a boolean indicating that left and right values must be inverted
  41098. */
  41099. reverseLeftRight: boolean;
  41100. /**
  41101. * Gets or sets a boolean indicating that up and down values must be inverted
  41102. */
  41103. reverseUpDown: boolean;
  41104. /**
  41105. * Gets the offset value for the position (ie. the change of the position value)
  41106. */
  41107. deltaPosition: Vector3;
  41108. /**
  41109. * Gets a boolean indicating if the virtual joystick was pressed
  41110. */
  41111. pressed: boolean;
  41112. /**
  41113. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41114. */
  41115. static Canvas: Nullable<HTMLCanvasElement>;
  41116. private static _globalJoystickIndex;
  41117. private static vjCanvasContext;
  41118. private static vjCanvasWidth;
  41119. private static vjCanvasHeight;
  41120. private static halfWidth;
  41121. private _action;
  41122. private _axisTargetedByLeftAndRight;
  41123. private _axisTargetedByUpAndDown;
  41124. private _joystickSensibility;
  41125. private _inversedSensibility;
  41126. private _joystickPointerID;
  41127. private _joystickColor;
  41128. private _joystickPointerPos;
  41129. private _joystickPreviousPointerPos;
  41130. private _joystickPointerStartPos;
  41131. private _deltaJoystickVector;
  41132. private _leftJoystick;
  41133. private _touches;
  41134. private _onPointerDownHandlerRef;
  41135. private _onPointerMoveHandlerRef;
  41136. private _onPointerUpHandlerRef;
  41137. private _onResize;
  41138. /**
  41139. * Creates a new virtual joystick
  41140. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41141. */
  41142. constructor(leftJoystick?: boolean);
  41143. /**
  41144. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41145. * @param newJoystickSensibility defines the new sensibility
  41146. */
  41147. setJoystickSensibility(newJoystickSensibility: number): void;
  41148. private _onPointerDown;
  41149. private _onPointerMove;
  41150. private _onPointerUp;
  41151. /**
  41152. * Change the color of the virtual joystick
  41153. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41154. */
  41155. setJoystickColor(newColor: string): void;
  41156. /**
  41157. * Defines a callback to call when the joystick is touched
  41158. * @param action defines the callback
  41159. */
  41160. setActionOnTouch(action: () => any): void;
  41161. /**
  41162. * Defines which axis you'd like to control for left & right
  41163. * @param axis defines the axis to use
  41164. */
  41165. setAxisForLeftRight(axis: JoystickAxis): void;
  41166. /**
  41167. * Defines which axis you'd like to control for up & down
  41168. * @param axis defines the axis to use
  41169. */
  41170. setAxisForUpDown(axis: JoystickAxis): void;
  41171. private _drawVirtualJoystick;
  41172. /**
  41173. * Release internal HTML canvas
  41174. */
  41175. releaseCanvas(): void;
  41176. }
  41177. }
  41178. declare module BABYLON {
  41179. interface FreeCameraInputsManager {
  41180. /**
  41181. * Add virtual joystick input support to the input manager.
  41182. * @returns the current input manager
  41183. */
  41184. addVirtualJoystick(): FreeCameraInputsManager;
  41185. }
  41186. /**
  41187. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41188. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41189. */
  41190. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41191. /**
  41192. * Defines the camera the input is attached to.
  41193. */
  41194. camera: FreeCamera;
  41195. private _leftjoystick;
  41196. private _rightjoystick;
  41197. /**
  41198. * Gets the left stick of the virtual joystick.
  41199. * @returns The virtual Joystick
  41200. */
  41201. getLeftJoystick(): VirtualJoystick;
  41202. /**
  41203. * Gets the right stick of the virtual joystick.
  41204. * @returns The virtual Joystick
  41205. */
  41206. getRightJoystick(): VirtualJoystick;
  41207. /**
  41208. * Update the current camera state depending on the inputs that have been used this frame.
  41209. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41210. */
  41211. checkInputs(): void;
  41212. /**
  41213. * Attach the input controls to a specific dom element to get the input from.
  41214. * @param element Defines the element the controls should be listened from
  41215. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41216. */
  41217. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41218. /**
  41219. * Detach the current controls from the specified dom element.
  41220. * @param element Defines the element to stop listening the inputs from
  41221. */
  41222. detachControl(element: Nullable<HTMLElement>): void;
  41223. /**
  41224. * Gets the class name of the current intput.
  41225. * @returns the class name
  41226. */
  41227. getClassName(): string;
  41228. /**
  41229. * Get the friendly name associated with the input class.
  41230. * @returns the input friendly name
  41231. */
  41232. getSimpleName(): string;
  41233. }
  41234. }
  41235. declare module BABYLON {
  41236. /**
  41237. * This represents a FPS type of camera controlled by touch.
  41238. * This is like a universal camera minus the Gamepad controls.
  41239. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41240. */
  41241. export class TouchCamera extends FreeCamera {
  41242. /**
  41243. * Defines the touch sensibility for rotation.
  41244. * The higher the faster.
  41245. */
  41246. get touchAngularSensibility(): number;
  41247. set touchAngularSensibility(value: number);
  41248. /**
  41249. * Defines the touch sensibility for move.
  41250. * The higher the faster.
  41251. */
  41252. get touchMoveSensibility(): number;
  41253. set touchMoveSensibility(value: number);
  41254. /**
  41255. * Instantiates a new touch camera.
  41256. * This represents a FPS type of camera controlled by touch.
  41257. * This is like a universal camera minus the Gamepad controls.
  41258. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41259. * @param name Define the name of the camera in the scene
  41260. * @param position Define the start position of the camera in the scene
  41261. * @param scene Define the scene the camera belongs to
  41262. */
  41263. constructor(name: string, position: Vector3, scene: Scene);
  41264. /**
  41265. * Gets the current object class name.
  41266. * @return the class name
  41267. */
  41268. getClassName(): string;
  41269. /** @hidden */
  41270. _setupInputs(): void;
  41271. }
  41272. }
  41273. declare module BABYLON {
  41274. /**
  41275. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41276. * being tilted forward or back and left or right.
  41277. */
  41278. export class DeviceOrientationCamera extends FreeCamera {
  41279. private _initialQuaternion;
  41280. private _quaternionCache;
  41281. private _tmpDragQuaternion;
  41282. private _disablePointerInputWhenUsingDeviceOrientation;
  41283. /**
  41284. * Creates a new device orientation camera
  41285. * @param name The name of the camera
  41286. * @param position The start position camera
  41287. * @param scene The scene the camera belongs to
  41288. */
  41289. constructor(name: string, position: Vector3, scene: Scene);
  41290. /**
  41291. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41292. */
  41293. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41294. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41295. private _dragFactor;
  41296. /**
  41297. * Enabled turning on the y axis when the orientation sensor is active
  41298. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41299. */
  41300. enableHorizontalDragging(dragFactor?: number): void;
  41301. /**
  41302. * Gets the current instance class name ("DeviceOrientationCamera").
  41303. * This helps avoiding instanceof at run time.
  41304. * @returns the class name
  41305. */
  41306. getClassName(): string;
  41307. /**
  41308. * @hidden
  41309. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41310. */
  41311. _checkInputs(): void;
  41312. /**
  41313. * Reset the camera to its default orientation on the specified axis only.
  41314. * @param axis The axis to reset
  41315. */
  41316. resetToCurrentRotation(axis?: Axis): void;
  41317. }
  41318. }
  41319. declare module BABYLON {
  41320. /**
  41321. * Defines supported buttons for XBox360 compatible gamepads
  41322. */
  41323. export enum Xbox360Button {
  41324. /** A */
  41325. A = 0,
  41326. /** B */
  41327. B = 1,
  41328. /** X */
  41329. X = 2,
  41330. /** Y */
  41331. Y = 3,
  41332. /** Left button */
  41333. LB = 4,
  41334. /** Right button */
  41335. RB = 5,
  41336. /** Back */
  41337. Back = 8,
  41338. /** Start */
  41339. Start = 9,
  41340. /** Left stick */
  41341. LeftStick = 10,
  41342. /** Right stick */
  41343. RightStick = 11
  41344. }
  41345. /** Defines values for XBox360 DPad */
  41346. export enum Xbox360Dpad {
  41347. /** Up */
  41348. Up = 12,
  41349. /** Down */
  41350. Down = 13,
  41351. /** Left */
  41352. Left = 14,
  41353. /** Right */
  41354. Right = 15
  41355. }
  41356. /**
  41357. * Defines a XBox360 gamepad
  41358. */
  41359. export class Xbox360Pad extends Gamepad {
  41360. private _leftTrigger;
  41361. private _rightTrigger;
  41362. private _onlefttriggerchanged;
  41363. private _onrighttriggerchanged;
  41364. private _onbuttondown;
  41365. private _onbuttonup;
  41366. private _ondpaddown;
  41367. private _ondpadup;
  41368. /** Observable raised when a button is pressed */
  41369. onButtonDownObservable: Observable<Xbox360Button>;
  41370. /** Observable raised when a button is released */
  41371. onButtonUpObservable: Observable<Xbox360Button>;
  41372. /** Observable raised when a pad is pressed */
  41373. onPadDownObservable: Observable<Xbox360Dpad>;
  41374. /** Observable raised when a pad is released */
  41375. onPadUpObservable: Observable<Xbox360Dpad>;
  41376. private _buttonA;
  41377. private _buttonB;
  41378. private _buttonX;
  41379. private _buttonY;
  41380. private _buttonBack;
  41381. private _buttonStart;
  41382. private _buttonLB;
  41383. private _buttonRB;
  41384. private _buttonLeftStick;
  41385. private _buttonRightStick;
  41386. private _dPadUp;
  41387. private _dPadDown;
  41388. private _dPadLeft;
  41389. private _dPadRight;
  41390. private _isXboxOnePad;
  41391. /**
  41392. * Creates a new XBox360 gamepad object
  41393. * @param id defines the id of this gamepad
  41394. * @param index defines its index
  41395. * @param gamepad defines the internal HTML gamepad object
  41396. * @param xboxOne defines if it is a XBox One gamepad
  41397. */
  41398. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41399. /**
  41400. * Defines the callback to call when left trigger is pressed
  41401. * @param callback defines the callback to use
  41402. */
  41403. onlefttriggerchanged(callback: (value: number) => void): void;
  41404. /**
  41405. * Defines the callback to call when right trigger is pressed
  41406. * @param callback defines the callback to use
  41407. */
  41408. onrighttriggerchanged(callback: (value: number) => void): void;
  41409. /**
  41410. * Gets the left trigger value
  41411. */
  41412. get leftTrigger(): number;
  41413. /**
  41414. * Sets the left trigger value
  41415. */
  41416. set leftTrigger(newValue: number);
  41417. /**
  41418. * Gets the right trigger value
  41419. */
  41420. get rightTrigger(): number;
  41421. /**
  41422. * Sets the right trigger value
  41423. */
  41424. set rightTrigger(newValue: number);
  41425. /**
  41426. * Defines the callback to call when a button is pressed
  41427. * @param callback defines the callback to use
  41428. */
  41429. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41430. /**
  41431. * Defines the callback to call when a button is released
  41432. * @param callback defines the callback to use
  41433. */
  41434. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41435. /**
  41436. * Defines the callback to call when a pad is pressed
  41437. * @param callback defines the callback to use
  41438. */
  41439. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41440. /**
  41441. * Defines the callback to call when a pad is released
  41442. * @param callback defines the callback to use
  41443. */
  41444. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41445. private _setButtonValue;
  41446. private _setDPadValue;
  41447. /**
  41448. * Gets the value of the `A` button
  41449. */
  41450. get buttonA(): number;
  41451. /**
  41452. * Sets the value of the `A` button
  41453. */
  41454. set buttonA(value: number);
  41455. /**
  41456. * Gets the value of the `B` button
  41457. */
  41458. get buttonB(): number;
  41459. /**
  41460. * Sets the value of the `B` button
  41461. */
  41462. set buttonB(value: number);
  41463. /**
  41464. * Gets the value of the `X` button
  41465. */
  41466. get buttonX(): number;
  41467. /**
  41468. * Sets the value of the `X` button
  41469. */
  41470. set buttonX(value: number);
  41471. /**
  41472. * Gets the value of the `Y` button
  41473. */
  41474. get buttonY(): number;
  41475. /**
  41476. * Sets the value of the `Y` button
  41477. */
  41478. set buttonY(value: number);
  41479. /**
  41480. * Gets the value of the `Start` button
  41481. */
  41482. get buttonStart(): number;
  41483. /**
  41484. * Sets the value of the `Start` button
  41485. */
  41486. set buttonStart(value: number);
  41487. /**
  41488. * Gets the value of the `Back` button
  41489. */
  41490. get buttonBack(): number;
  41491. /**
  41492. * Sets the value of the `Back` button
  41493. */
  41494. set buttonBack(value: number);
  41495. /**
  41496. * Gets the value of the `Left` button
  41497. */
  41498. get buttonLB(): number;
  41499. /**
  41500. * Sets the value of the `Left` button
  41501. */
  41502. set buttonLB(value: number);
  41503. /**
  41504. * Gets the value of the `Right` button
  41505. */
  41506. get buttonRB(): number;
  41507. /**
  41508. * Sets the value of the `Right` button
  41509. */
  41510. set buttonRB(value: number);
  41511. /**
  41512. * Gets the value of the Left joystick
  41513. */
  41514. get buttonLeftStick(): number;
  41515. /**
  41516. * Sets the value of the Left joystick
  41517. */
  41518. set buttonLeftStick(value: number);
  41519. /**
  41520. * Gets the value of the Right joystick
  41521. */
  41522. get buttonRightStick(): number;
  41523. /**
  41524. * Sets the value of the Right joystick
  41525. */
  41526. set buttonRightStick(value: number);
  41527. /**
  41528. * Gets the value of D-pad up
  41529. */
  41530. get dPadUp(): number;
  41531. /**
  41532. * Sets the value of D-pad up
  41533. */
  41534. set dPadUp(value: number);
  41535. /**
  41536. * Gets the value of D-pad down
  41537. */
  41538. get dPadDown(): number;
  41539. /**
  41540. * Sets the value of D-pad down
  41541. */
  41542. set dPadDown(value: number);
  41543. /**
  41544. * Gets the value of D-pad left
  41545. */
  41546. get dPadLeft(): number;
  41547. /**
  41548. * Sets the value of D-pad left
  41549. */
  41550. set dPadLeft(value: number);
  41551. /**
  41552. * Gets the value of D-pad right
  41553. */
  41554. get dPadRight(): number;
  41555. /**
  41556. * Sets the value of D-pad right
  41557. */
  41558. set dPadRight(value: number);
  41559. /**
  41560. * Force the gamepad to synchronize with device values
  41561. */
  41562. update(): void;
  41563. /**
  41564. * Disposes the gamepad
  41565. */
  41566. dispose(): void;
  41567. }
  41568. }
  41569. declare module BABYLON {
  41570. /**
  41571. * Defines supported buttons for DualShock compatible gamepads
  41572. */
  41573. export enum DualShockButton {
  41574. /** Cross */
  41575. Cross = 0,
  41576. /** Circle */
  41577. Circle = 1,
  41578. /** Square */
  41579. Square = 2,
  41580. /** Triangle */
  41581. Triangle = 3,
  41582. /** L1 */
  41583. L1 = 4,
  41584. /** R1 */
  41585. R1 = 5,
  41586. /** Share */
  41587. Share = 8,
  41588. /** Options */
  41589. Options = 9,
  41590. /** Left stick */
  41591. LeftStick = 10,
  41592. /** Right stick */
  41593. RightStick = 11
  41594. }
  41595. /** Defines values for DualShock DPad */
  41596. export enum DualShockDpad {
  41597. /** Up */
  41598. Up = 12,
  41599. /** Down */
  41600. Down = 13,
  41601. /** Left */
  41602. Left = 14,
  41603. /** Right */
  41604. Right = 15
  41605. }
  41606. /**
  41607. * Defines a DualShock gamepad
  41608. */
  41609. export class DualShockPad extends Gamepad {
  41610. private _leftTrigger;
  41611. private _rightTrigger;
  41612. private _onlefttriggerchanged;
  41613. private _onrighttriggerchanged;
  41614. private _onbuttondown;
  41615. private _onbuttonup;
  41616. private _ondpaddown;
  41617. private _ondpadup;
  41618. /** Observable raised when a button is pressed */
  41619. onButtonDownObservable: Observable<DualShockButton>;
  41620. /** Observable raised when a button is released */
  41621. onButtonUpObservable: Observable<DualShockButton>;
  41622. /** Observable raised when a pad is pressed */
  41623. onPadDownObservable: Observable<DualShockDpad>;
  41624. /** Observable raised when a pad is released */
  41625. onPadUpObservable: Observable<DualShockDpad>;
  41626. private _buttonCross;
  41627. private _buttonCircle;
  41628. private _buttonSquare;
  41629. private _buttonTriangle;
  41630. private _buttonShare;
  41631. private _buttonOptions;
  41632. private _buttonL1;
  41633. private _buttonR1;
  41634. private _buttonLeftStick;
  41635. private _buttonRightStick;
  41636. private _dPadUp;
  41637. private _dPadDown;
  41638. private _dPadLeft;
  41639. private _dPadRight;
  41640. /**
  41641. * Creates a new DualShock gamepad object
  41642. * @param id defines the id of this gamepad
  41643. * @param index defines its index
  41644. * @param gamepad defines the internal HTML gamepad object
  41645. */
  41646. constructor(id: string, index: number, gamepad: any);
  41647. /**
  41648. * Defines the callback to call when left trigger is pressed
  41649. * @param callback defines the callback to use
  41650. */
  41651. onlefttriggerchanged(callback: (value: number) => void): void;
  41652. /**
  41653. * Defines the callback to call when right trigger is pressed
  41654. * @param callback defines the callback to use
  41655. */
  41656. onrighttriggerchanged(callback: (value: number) => void): void;
  41657. /**
  41658. * Gets the left trigger value
  41659. */
  41660. get leftTrigger(): number;
  41661. /**
  41662. * Sets the left trigger value
  41663. */
  41664. set leftTrigger(newValue: number);
  41665. /**
  41666. * Gets the right trigger value
  41667. */
  41668. get rightTrigger(): number;
  41669. /**
  41670. * Sets the right trigger value
  41671. */
  41672. set rightTrigger(newValue: number);
  41673. /**
  41674. * Defines the callback to call when a button is pressed
  41675. * @param callback defines the callback to use
  41676. */
  41677. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41678. /**
  41679. * Defines the callback to call when a button is released
  41680. * @param callback defines the callback to use
  41681. */
  41682. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41683. /**
  41684. * Defines the callback to call when a pad is pressed
  41685. * @param callback defines the callback to use
  41686. */
  41687. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41688. /**
  41689. * Defines the callback to call when a pad is released
  41690. * @param callback defines the callback to use
  41691. */
  41692. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41693. private _setButtonValue;
  41694. private _setDPadValue;
  41695. /**
  41696. * Gets the value of the `Cross` button
  41697. */
  41698. get buttonCross(): number;
  41699. /**
  41700. * Sets the value of the `Cross` button
  41701. */
  41702. set buttonCross(value: number);
  41703. /**
  41704. * Gets the value of the `Circle` button
  41705. */
  41706. get buttonCircle(): number;
  41707. /**
  41708. * Sets the value of the `Circle` button
  41709. */
  41710. set buttonCircle(value: number);
  41711. /**
  41712. * Gets the value of the `Square` button
  41713. */
  41714. get buttonSquare(): number;
  41715. /**
  41716. * Sets the value of the `Square` button
  41717. */
  41718. set buttonSquare(value: number);
  41719. /**
  41720. * Gets the value of the `Triangle` button
  41721. */
  41722. get buttonTriangle(): number;
  41723. /**
  41724. * Sets the value of the `Triangle` button
  41725. */
  41726. set buttonTriangle(value: number);
  41727. /**
  41728. * Gets the value of the `Options` button
  41729. */
  41730. get buttonOptions(): number;
  41731. /**
  41732. * Sets the value of the `Options` button
  41733. */
  41734. set buttonOptions(value: number);
  41735. /**
  41736. * Gets the value of the `Share` button
  41737. */
  41738. get buttonShare(): number;
  41739. /**
  41740. * Sets the value of the `Share` button
  41741. */
  41742. set buttonShare(value: number);
  41743. /**
  41744. * Gets the value of the `L1` button
  41745. */
  41746. get buttonL1(): number;
  41747. /**
  41748. * Sets the value of the `L1` button
  41749. */
  41750. set buttonL1(value: number);
  41751. /**
  41752. * Gets the value of the `R1` button
  41753. */
  41754. get buttonR1(): number;
  41755. /**
  41756. * Sets the value of the `R1` button
  41757. */
  41758. set buttonR1(value: number);
  41759. /**
  41760. * Gets the value of the Left joystick
  41761. */
  41762. get buttonLeftStick(): number;
  41763. /**
  41764. * Sets the value of the Left joystick
  41765. */
  41766. set buttonLeftStick(value: number);
  41767. /**
  41768. * Gets the value of the Right joystick
  41769. */
  41770. get buttonRightStick(): number;
  41771. /**
  41772. * Sets the value of the Right joystick
  41773. */
  41774. set buttonRightStick(value: number);
  41775. /**
  41776. * Gets the value of D-pad up
  41777. */
  41778. get dPadUp(): number;
  41779. /**
  41780. * Sets the value of D-pad up
  41781. */
  41782. set dPadUp(value: number);
  41783. /**
  41784. * Gets the value of D-pad down
  41785. */
  41786. get dPadDown(): number;
  41787. /**
  41788. * Sets the value of D-pad down
  41789. */
  41790. set dPadDown(value: number);
  41791. /**
  41792. * Gets the value of D-pad left
  41793. */
  41794. get dPadLeft(): number;
  41795. /**
  41796. * Sets the value of D-pad left
  41797. */
  41798. set dPadLeft(value: number);
  41799. /**
  41800. * Gets the value of D-pad right
  41801. */
  41802. get dPadRight(): number;
  41803. /**
  41804. * Sets the value of D-pad right
  41805. */
  41806. set dPadRight(value: number);
  41807. /**
  41808. * Force the gamepad to synchronize with device values
  41809. */
  41810. update(): void;
  41811. /**
  41812. * Disposes the gamepad
  41813. */
  41814. dispose(): void;
  41815. }
  41816. }
  41817. declare module BABYLON {
  41818. /**
  41819. * Manager for handling gamepads
  41820. */
  41821. export class GamepadManager {
  41822. private _scene?;
  41823. private _babylonGamepads;
  41824. private _oneGamepadConnected;
  41825. /** @hidden */
  41826. _isMonitoring: boolean;
  41827. private _gamepadEventSupported;
  41828. private _gamepadSupport?;
  41829. /**
  41830. * observable to be triggered when the gamepad controller has been connected
  41831. */
  41832. onGamepadConnectedObservable: Observable<Gamepad>;
  41833. /**
  41834. * observable to be triggered when the gamepad controller has been disconnected
  41835. */
  41836. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41837. private _onGamepadConnectedEvent;
  41838. private _onGamepadDisconnectedEvent;
  41839. /**
  41840. * Initializes the gamepad manager
  41841. * @param _scene BabylonJS scene
  41842. */
  41843. constructor(_scene?: Scene | undefined);
  41844. /**
  41845. * The gamepads in the game pad manager
  41846. */
  41847. get gamepads(): Gamepad[];
  41848. /**
  41849. * Get the gamepad controllers based on type
  41850. * @param type The type of gamepad controller
  41851. * @returns Nullable gamepad
  41852. */
  41853. getGamepadByType(type?: number): Nullable<Gamepad>;
  41854. /**
  41855. * Disposes the gamepad manager
  41856. */
  41857. dispose(): void;
  41858. private _addNewGamepad;
  41859. private _startMonitoringGamepads;
  41860. private _stopMonitoringGamepads;
  41861. /** @hidden */
  41862. _checkGamepadsStatus(): void;
  41863. private _updateGamepadObjects;
  41864. }
  41865. }
  41866. declare module BABYLON {
  41867. interface Scene {
  41868. /** @hidden */
  41869. _gamepadManager: Nullable<GamepadManager>;
  41870. /**
  41871. * Gets the gamepad manager associated with the scene
  41872. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41873. */
  41874. gamepadManager: GamepadManager;
  41875. }
  41876. /**
  41877. * Interface representing a free camera inputs manager
  41878. */
  41879. interface FreeCameraInputsManager {
  41880. /**
  41881. * Adds gamepad input support to the FreeCameraInputsManager.
  41882. * @returns the FreeCameraInputsManager
  41883. */
  41884. addGamepad(): FreeCameraInputsManager;
  41885. }
  41886. /**
  41887. * Interface representing an arc rotate camera inputs manager
  41888. */
  41889. interface ArcRotateCameraInputsManager {
  41890. /**
  41891. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41892. * @returns the camera inputs manager
  41893. */
  41894. addGamepad(): ArcRotateCameraInputsManager;
  41895. }
  41896. /**
  41897. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41898. */
  41899. export class GamepadSystemSceneComponent implements ISceneComponent {
  41900. /**
  41901. * The component name helpfull to identify the component in the list of scene components.
  41902. */
  41903. readonly name: string;
  41904. /**
  41905. * The scene the component belongs to.
  41906. */
  41907. scene: Scene;
  41908. /**
  41909. * Creates a new instance of the component for the given scene
  41910. * @param scene Defines the scene to register the component in
  41911. */
  41912. constructor(scene: Scene);
  41913. /**
  41914. * Registers the component in a given scene
  41915. */
  41916. register(): void;
  41917. /**
  41918. * Rebuilds the elements related to this component in case of
  41919. * context lost for instance.
  41920. */
  41921. rebuild(): void;
  41922. /**
  41923. * Disposes the component and the associated ressources
  41924. */
  41925. dispose(): void;
  41926. private _beforeCameraUpdate;
  41927. }
  41928. }
  41929. declare module BABYLON {
  41930. /**
  41931. * 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,
  41932. * which still works and will still be found in many Playgrounds.
  41933. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41934. */
  41935. export class UniversalCamera extends TouchCamera {
  41936. /**
  41937. * Defines the gamepad rotation sensiblity.
  41938. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41939. */
  41940. get gamepadAngularSensibility(): number;
  41941. set gamepadAngularSensibility(value: number);
  41942. /**
  41943. * Defines the gamepad move sensiblity.
  41944. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41945. */
  41946. get gamepadMoveSensibility(): number;
  41947. set gamepadMoveSensibility(value: number);
  41948. /**
  41949. * 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,
  41950. * which still works and will still be found in many Playgrounds.
  41951. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41952. * @param name Define the name of the camera in the scene
  41953. * @param position Define the start position of the camera in the scene
  41954. * @param scene Define the scene the camera belongs to
  41955. */
  41956. constructor(name: string, position: Vector3, scene: Scene);
  41957. /**
  41958. * Gets the current object class name.
  41959. * @return the class name
  41960. */
  41961. getClassName(): string;
  41962. }
  41963. }
  41964. declare module BABYLON {
  41965. /**
  41966. * This represents a FPS type of camera. This is only here for back compat purpose.
  41967. * Please use the UniversalCamera instead as both are identical.
  41968. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41969. */
  41970. export class GamepadCamera extends UniversalCamera {
  41971. /**
  41972. * Instantiates a new Gamepad Camera
  41973. * This represents a FPS type of camera. This is only here for back compat purpose.
  41974. * Please use the UniversalCamera instead as both are identical.
  41975. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41976. * @param name Define the name of the camera in the scene
  41977. * @param position Define the start position of the camera in the scene
  41978. * @param scene Define the scene the camera belongs to
  41979. */
  41980. constructor(name: string, position: Vector3, scene: Scene);
  41981. /**
  41982. * Gets the current object class name.
  41983. * @return the class name
  41984. */
  41985. getClassName(): string;
  41986. }
  41987. }
  41988. declare module BABYLON {
  41989. /** @hidden */
  41990. export var passPixelShader: {
  41991. name: string;
  41992. shader: string;
  41993. };
  41994. }
  41995. declare module BABYLON {
  41996. /** @hidden */
  41997. export var passCubePixelShader: {
  41998. name: string;
  41999. shader: string;
  42000. };
  42001. }
  42002. declare module BABYLON {
  42003. /**
  42004. * PassPostProcess which produces an output the same as it's input
  42005. */
  42006. export class PassPostProcess extends PostProcess {
  42007. /**
  42008. * Creates the PassPostProcess
  42009. * @param name The name of the effect.
  42010. * @param options The required width/height ratio to downsize to before computing the render pass.
  42011. * @param camera The camera to apply the render pass to.
  42012. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42013. * @param engine The engine which the post process will be applied. (default: current engine)
  42014. * @param reusable If the post process can be reused on the same frame. (default: false)
  42015. * @param textureType The type of texture to be used when performing the post processing.
  42016. * @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)
  42017. */
  42018. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42019. }
  42020. /**
  42021. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42022. */
  42023. export class PassCubePostProcess extends PostProcess {
  42024. private _face;
  42025. /**
  42026. * Gets or sets the cube face to display.
  42027. * * 0 is +X
  42028. * * 1 is -X
  42029. * * 2 is +Y
  42030. * * 3 is -Y
  42031. * * 4 is +Z
  42032. * * 5 is -Z
  42033. */
  42034. get face(): number;
  42035. set face(value: number);
  42036. /**
  42037. * Creates the PassCubePostProcess
  42038. * @param name The name of the effect.
  42039. * @param options The required width/height ratio to downsize to before computing the render pass.
  42040. * @param camera The camera to apply the render pass to.
  42041. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42042. * @param engine The engine which the post process will be applied. (default: current engine)
  42043. * @param reusable If the post process can be reused on the same frame. (default: false)
  42044. * @param textureType The type of texture to be used when performing the post processing.
  42045. * @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)
  42046. */
  42047. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42048. }
  42049. }
  42050. declare module BABYLON {
  42051. /** @hidden */
  42052. export var anaglyphPixelShader: {
  42053. name: string;
  42054. shader: string;
  42055. };
  42056. }
  42057. declare module BABYLON {
  42058. /**
  42059. * Postprocess used to generate anaglyphic rendering
  42060. */
  42061. export class AnaglyphPostProcess extends PostProcess {
  42062. private _passedProcess;
  42063. /**
  42064. * Creates a new AnaglyphPostProcess
  42065. * @param name defines postprocess name
  42066. * @param options defines creation options or target ratio scale
  42067. * @param rigCameras defines cameras using this postprocess
  42068. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42069. * @param engine defines hosting engine
  42070. * @param reusable defines if the postprocess will be reused multiple times per frame
  42071. */
  42072. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42073. }
  42074. }
  42075. declare module BABYLON {
  42076. /**
  42077. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42078. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42079. */
  42080. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42081. /**
  42082. * Creates a new AnaglyphArcRotateCamera
  42083. * @param name defines camera name
  42084. * @param alpha defines alpha angle (in radians)
  42085. * @param beta defines beta angle (in radians)
  42086. * @param radius defines radius
  42087. * @param target defines camera target
  42088. * @param interaxialDistance defines distance between each color axis
  42089. * @param scene defines the hosting scene
  42090. */
  42091. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42092. /**
  42093. * Gets camera class name
  42094. * @returns AnaglyphArcRotateCamera
  42095. */
  42096. getClassName(): string;
  42097. }
  42098. }
  42099. declare module BABYLON {
  42100. /**
  42101. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42102. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42103. */
  42104. export class AnaglyphFreeCamera extends FreeCamera {
  42105. /**
  42106. * Creates a new AnaglyphFreeCamera
  42107. * @param name defines camera name
  42108. * @param position defines initial position
  42109. * @param interaxialDistance defines distance between each color axis
  42110. * @param scene defines the hosting scene
  42111. */
  42112. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42113. /**
  42114. * Gets camera class name
  42115. * @returns AnaglyphFreeCamera
  42116. */
  42117. getClassName(): string;
  42118. }
  42119. }
  42120. declare module BABYLON {
  42121. /**
  42122. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42123. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42124. */
  42125. export class AnaglyphGamepadCamera extends GamepadCamera {
  42126. /**
  42127. * Creates a new AnaglyphGamepadCamera
  42128. * @param name defines camera name
  42129. * @param position defines initial position
  42130. * @param interaxialDistance defines distance between each color axis
  42131. * @param scene defines the hosting scene
  42132. */
  42133. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42134. /**
  42135. * Gets camera class name
  42136. * @returns AnaglyphGamepadCamera
  42137. */
  42138. getClassName(): string;
  42139. }
  42140. }
  42141. declare module BABYLON {
  42142. /**
  42143. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42144. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42145. */
  42146. export class AnaglyphUniversalCamera extends UniversalCamera {
  42147. /**
  42148. * Creates a new AnaglyphUniversalCamera
  42149. * @param name defines camera name
  42150. * @param position defines initial position
  42151. * @param interaxialDistance defines distance between each color axis
  42152. * @param scene defines the hosting scene
  42153. */
  42154. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42155. /**
  42156. * Gets camera class name
  42157. * @returns AnaglyphUniversalCamera
  42158. */
  42159. getClassName(): string;
  42160. }
  42161. }
  42162. declare module BABYLON {
  42163. /** @hidden */
  42164. export var stereoscopicInterlacePixelShader: {
  42165. name: string;
  42166. shader: string;
  42167. };
  42168. }
  42169. declare module BABYLON {
  42170. /**
  42171. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  42172. */
  42173. export class StereoscopicInterlacePostProcessI extends PostProcess {
  42174. private _stepSize;
  42175. private _passedProcess;
  42176. /**
  42177. * Initializes a StereoscopicInterlacePostProcessI
  42178. * @param name The name of the effect.
  42179. * @param rigCameras The rig cameras to be appled to the post process
  42180. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  42181. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  42182. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42183. * @param engine The engine which the post process will be applied. (default: current engine)
  42184. * @param reusable If the post process can be reused on the same frame. (default: false)
  42185. */
  42186. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42187. }
  42188. /**
  42189. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42190. */
  42191. export class StereoscopicInterlacePostProcess extends PostProcess {
  42192. private _stepSize;
  42193. private _passedProcess;
  42194. /**
  42195. * Initializes a StereoscopicInterlacePostProcess
  42196. * @param name The name of the effect.
  42197. * @param rigCameras The rig cameras to be appled to the post process
  42198. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42199. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42200. * @param engine The engine which the post process will be applied. (default: current engine)
  42201. * @param reusable If the post process can be reused on the same frame. (default: false)
  42202. */
  42203. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42204. }
  42205. }
  42206. declare module BABYLON {
  42207. /**
  42208. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42209. * @see http://doc.babylonjs.com/features/cameras
  42210. */
  42211. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42212. /**
  42213. * Creates a new StereoscopicArcRotateCamera
  42214. * @param name defines camera name
  42215. * @param alpha defines alpha angle (in radians)
  42216. * @param beta defines beta angle (in radians)
  42217. * @param radius defines radius
  42218. * @param target defines camera target
  42219. * @param interaxialDistance defines distance between each color axis
  42220. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42221. * @param scene defines the hosting scene
  42222. */
  42223. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42224. /**
  42225. * Gets camera class name
  42226. * @returns StereoscopicArcRotateCamera
  42227. */
  42228. getClassName(): string;
  42229. }
  42230. }
  42231. declare module BABYLON {
  42232. /**
  42233. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42234. * @see http://doc.babylonjs.com/features/cameras
  42235. */
  42236. export class StereoscopicFreeCamera extends FreeCamera {
  42237. /**
  42238. * Creates a new StereoscopicFreeCamera
  42239. * @param name defines camera name
  42240. * @param position defines initial position
  42241. * @param interaxialDistance defines distance between each color axis
  42242. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42243. * @param scene defines the hosting scene
  42244. */
  42245. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42246. /**
  42247. * Gets camera class name
  42248. * @returns StereoscopicFreeCamera
  42249. */
  42250. getClassName(): string;
  42251. }
  42252. }
  42253. declare module BABYLON {
  42254. /**
  42255. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42256. * @see http://doc.babylonjs.com/features/cameras
  42257. */
  42258. export class StereoscopicGamepadCamera extends GamepadCamera {
  42259. /**
  42260. * Creates a new StereoscopicGamepadCamera
  42261. * @param name defines camera name
  42262. * @param position defines initial position
  42263. * @param interaxialDistance defines distance between each color axis
  42264. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42265. * @param scene defines the hosting scene
  42266. */
  42267. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42268. /**
  42269. * Gets camera class name
  42270. * @returns StereoscopicGamepadCamera
  42271. */
  42272. getClassName(): string;
  42273. }
  42274. }
  42275. declare module BABYLON {
  42276. /**
  42277. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42278. * @see http://doc.babylonjs.com/features/cameras
  42279. */
  42280. export class StereoscopicUniversalCamera extends UniversalCamera {
  42281. /**
  42282. * Creates a new StereoscopicUniversalCamera
  42283. * @param name defines camera name
  42284. * @param position defines initial position
  42285. * @param interaxialDistance defines distance between each color axis
  42286. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42287. * @param scene defines the hosting scene
  42288. */
  42289. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42290. /**
  42291. * Gets camera class name
  42292. * @returns StereoscopicUniversalCamera
  42293. */
  42294. getClassName(): string;
  42295. }
  42296. }
  42297. declare module BABYLON {
  42298. /**
  42299. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42300. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42301. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42302. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42303. */
  42304. export class VirtualJoysticksCamera extends FreeCamera {
  42305. /**
  42306. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42307. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42308. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42309. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42310. * @param name Define the name of the camera in the scene
  42311. * @param position Define the start position of the camera in the scene
  42312. * @param scene Define the scene the camera belongs to
  42313. */
  42314. constructor(name: string, position: Vector3, scene: Scene);
  42315. /**
  42316. * Gets the current object class name.
  42317. * @return the class name
  42318. */
  42319. getClassName(): string;
  42320. }
  42321. }
  42322. declare module BABYLON {
  42323. /**
  42324. * This represents all the required metrics to create a VR camera.
  42325. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42326. */
  42327. export class VRCameraMetrics {
  42328. /**
  42329. * Define the horizontal resolution off the screen.
  42330. */
  42331. hResolution: number;
  42332. /**
  42333. * Define the vertical resolution off the screen.
  42334. */
  42335. vResolution: number;
  42336. /**
  42337. * Define the horizontal screen size.
  42338. */
  42339. hScreenSize: number;
  42340. /**
  42341. * Define the vertical screen size.
  42342. */
  42343. vScreenSize: number;
  42344. /**
  42345. * Define the vertical screen center position.
  42346. */
  42347. vScreenCenter: number;
  42348. /**
  42349. * Define the distance of the eyes to the screen.
  42350. */
  42351. eyeToScreenDistance: number;
  42352. /**
  42353. * Define the distance between both lenses
  42354. */
  42355. lensSeparationDistance: number;
  42356. /**
  42357. * Define the distance between both viewer's eyes.
  42358. */
  42359. interpupillaryDistance: number;
  42360. /**
  42361. * Define the distortion factor of the VR postprocess.
  42362. * Please, touch with care.
  42363. */
  42364. distortionK: number[];
  42365. /**
  42366. * Define the chromatic aberration correction factors for the VR post process.
  42367. */
  42368. chromaAbCorrection: number[];
  42369. /**
  42370. * Define the scale factor of the post process.
  42371. * The smaller the better but the slower.
  42372. */
  42373. postProcessScaleFactor: number;
  42374. /**
  42375. * Define an offset for the lens center.
  42376. */
  42377. lensCenterOffset: number;
  42378. /**
  42379. * Define if the current vr camera should compensate the distortion of the lense or not.
  42380. */
  42381. compensateDistortion: boolean;
  42382. /**
  42383. * Defines if multiview should be enabled when rendering (Default: false)
  42384. */
  42385. multiviewEnabled: boolean;
  42386. /**
  42387. * Gets the rendering aspect ratio based on the provided resolutions.
  42388. */
  42389. get aspectRatio(): number;
  42390. /**
  42391. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42392. */
  42393. get aspectRatioFov(): number;
  42394. /**
  42395. * @hidden
  42396. */
  42397. get leftHMatrix(): Matrix;
  42398. /**
  42399. * @hidden
  42400. */
  42401. get rightHMatrix(): Matrix;
  42402. /**
  42403. * @hidden
  42404. */
  42405. get leftPreViewMatrix(): Matrix;
  42406. /**
  42407. * @hidden
  42408. */
  42409. get rightPreViewMatrix(): Matrix;
  42410. /**
  42411. * Get the default VRMetrics based on the most generic setup.
  42412. * @returns the default vr metrics
  42413. */
  42414. static GetDefault(): VRCameraMetrics;
  42415. }
  42416. }
  42417. declare module BABYLON {
  42418. /** @hidden */
  42419. export var vrDistortionCorrectionPixelShader: {
  42420. name: string;
  42421. shader: string;
  42422. };
  42423. }
  42424. declare module BABYLON {
  42425. /**
  42426. * VRDistortionCorrectionPostProcess used for mobile VR
  42427. */
  42428. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42429. private _isRightEye;
  42430. private _distortionFactors;
  42431. private _postProcessScaleFactor;
  42432. private _lensCenterOffset;
  42433. private _scaleIn;
  42434. private _scaleFactor;
  42435. private _lensCenter;
  42436. /**
  42437. * Initializes the VRDistortionCorrectionPostProcess
  42438. * @param name The name of the effect.
  42439. * @param camera The camera to apply the render pass to.
  42440. * @param isRightEye If this is for the right eye distortion
  42441. * @param vrMetrics All the required metrics for the VR camera
  42442. */
  42443. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42444. }
  42445. }
  42446. declare module BABYLON {
  42447. /**
  42448. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42449. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42450. */
  42451. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42452. /**
  42453. * Creates a new VRDeviceOrientationArcRotateCamera
  42454. * @param name defines camera name
  42455. * @param alpha defines the camera rotation along the logitudinal axis
  42456. * @param beta defines the camera rotation along the latitudinal axis
  42457. * @param radius defines the camera distance from its target
  42458. * @param target defines the camera target
  42459. * @param scene defines the scene the camera belongs to
  42460. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42461. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42462. */
  42463. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42464. /**
  42465. * Gets camera class name
  42466. * @returns VRDeviceOrientationArcRotateCamera
  42467. */
  42468. getClassName(): string;
  42469. }
  42470. }
  42471. declare module BABYLON {
  42472. /**
  42473. * Camera used to simulate VR rendering (based on FreeCamera)
  42474. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42475. */
  42476. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42477. /**
  42478. * Creates a new VRDeviceOrientationFreeCamera
  42479. * @param name defines camera name
  42480. * @param position defines the start position of the camera
  42481. * @param scene defines the scene the camera belongs to
  42482. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42483. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42484. */
  42485. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42486. /**
  42487. * Gets camera class name
  42488. * @returns VRDeviceOrientationFreeCamera
  42489. */
  42490. getClassName(): string;
  42491. }
  42492. }
  42493. declare module BABYLON {
  42494. /**
  42495. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42496. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42497. */
  42498. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42499. /**
  42500. * Creates a new VRDeviceOrientationGamepadCamera
  42501. * @param name defines camera name
  42502. * @param position defines the start position of the camera
  42503. * @param scene defines the scene the camera belongs to
  42504. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42505. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42506. */
  42507. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42508. /**
  42509. * Gets camera class name
  42510. * @returns VRDeviceOrientationGamepadCamera
  42511. */
  42512. getClassName(): string;
  42513. }
  42514. }
  42515. declare module BABYLON {
  42516. /** @hidden */
  42517. export var imageProcessingPixelShader: {
  42518. name: string;
  42519. shader: string;
  42520. };
  42521. }
  42522. declare module BABYLON {
  42523. /**
  42524. * ImageProcessingPostProcess
  42525. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42526. */
  42527. export class ImageProcessingPostProcess extends PostProcess {
  42528. /**
  42529. * Default configuration related to image processing available in the PBR Material.
  42530. */
  42531. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42532. /**
  42533. * Gets the image processing configuration used either in this material.
  42534. */
  42535. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42536. /**
  42537. * Sets the Default image processing configuration used either in the this material.
  42538. *
  42539. * If sets to null, the scene one is in use.
  42540. */
  42541. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42542. /**
  42543. * Keep track of the image processing observer to allow dispose and replace.
  42544. */
  42545. private _imageProcessingObserver;
  42546. /**
  42547. * Attaches a new image processing configuration to the PBR Material.
  42548. * @param configuration
  42549. */
  42550. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42551. /**
  42552. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42553. */
  42554. get colorCurves(): Nullable<ColorCurves>;
  42555. /**
  42556. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42557. */
  42558. set colorCurves(value: Nullable<ColorCurves>);
  42559. /**
  42560. * Gets wether the color curves effect is enabled.
  42561. */
  42562. get colorCurvesEnabled(): boolean;
  42563. /**
  42564. * Sets wether the color curves effect is enabled.
  42565. */
  42566. set colorCurvesEnabled(value: boolean);
  42567. /**
  42568. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42569. */
  42570. get colorGradingTexture(): Nullable<BaseTexture>;
  42571. /**
  42572. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42573. */
  42574. set colorGradingTexture(value: Nullable<BaseTexture>);
  42575. /**
  42576. * Gets wether the color grading effect is enabled.
  42577. */
  42578. get colorGradingEnabled(): boolean;
  42579. /**
  42580. * Gets wether the color grading effect is enabled.
  42581. */
  42582. set colorGradingEnabled(value: boolean);
  42583. /**
  42584. * Gets exposure used in the effect.
  42585. */
  42586. get exposure(): number;
  42587. /**
  42588. * Sets exposure used in the effect.
  42589. */
  42590. set exposure(value: number);
  42591. /**
  42592. * Gets wether tonemapping is enabled or not.
  42593. */
  42594. get toneMappingEnabled(): boolean;
  42595. /**
  42596. * Sets wether tonemapping is enabled or not
  42597. */
  42598. set toneMappingEnabled(value: boolean);
  42599. /**
  42600. * Gets the type of tone mapping effect.
  42601. */
  42602. get toneMappingType(): number;
  42603. /**
  42604. * Sets the type of tone mapping effect.
  42605. */
  42606. set toneMappingType(value: number);
  42607. /**
  42608. * Gets contrast used in the effect.
  42609. */
  42610. get contrast(): number;
  42611. /**
  42612. * Sets contrast used in the effect.
  42613. */
  42614. set contrast(value: number);
  42615. /**
  42616. * Gets Vignette stretch size.
  42617. */
  42618. get vignetteStretch(): number;
  42619. /**
  42620. * Sets Vignette stretch size.
  42621. */
  42622. set vignetteStretch(value: number);
  42623. /**
  42624. * Gets Vignette centre X Offset.
  42625. */
  42626. get vignetteCentreX(): number;
  42627. /**
  42628. * Sets Vignette centre X Offset.
  42629. */
  42630. set vignetteCentreX(value: number);
  42631. /**
  42632. * Gets Vignette centre Y Offset.
  42633. */
  42634. get vignetteCentreY(): number;
  42635. /**
  42636. * Sets Vignette centre Y Offset.
  42637. */
  42638. set vignetteCentreY(value: number);
  42639. /**
  42640. * Gets Vignette weight or intensity of the vignette effect.
  42641. */
  42642. get vignetteWeight(): number;
  42643. /**
  42644. * Sets Vignette weight or intensity of the vignette effect.
  42645. */
  42646. set vignetteWeight(value: number);
  42647. /**
  42648. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42649. * if vignetteEnabled is set to true.
  42650. */
  42651. get vignetteColor(): Color4;
  42652. /**
  42653. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42654. * if vignetteEnabled is set to true.
  42655. */
  42656. set vignetteColor(value: Color4);
  42657. /**
  42658. * Gets Camera field of view used by the Vignette effect.
  42659. */
  42660. get vignetteCameraFov(): number;
  42661. /**
  42662. * Sets Camera field of view used by the Vignette effect.
  42663. */
  42664. set vignetteCameraFov(value: number);
  42665. /**
  42666. * Gets the vignette blend mode allowing different kind of effect.
  42667. */
  42668. get vignetteBlendMode(): number;
  42669. /**
  42670. * Sets the vignette blend mode allowing different kind of effect.
  42671. */
  42672. set vignetteBlendMode(value: number);
  42673. /**
  42674. * Gets wether the vignette effect is enabled.
  42675. */
  42676. get vignetteEnabled(): boolean;
  42677. /**
  42678. * Sets wether the vignette effect is enabled.
  42679. */
  42680. set vignetteEnabled(value: boolean);
  42681. private _fromLinearSpace;
  42682. /**
  42683. * Gets wether the input of the processing is in Gamma or Linear Space.
  42684. */
  42685. get fromLinearSpace(): boolean;
  42686. /**
  42687. * Sets wether the input of the processing is in Gamma or Linear Space.
  42688. */
  42689. set fromLinearSpace(value: boolean);
  42690. /**
  42691. * Defines cache preventing GC.
  42692. */
  42693. private _defines;
  42694. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42695. /**
  42696. * "ImageProcessingPostProcess"
  42697. * @returns "ImageProcessingPostProcess"
  42698. */
  42699. getClassName(): string;
  42700. protected _updateParameters(): void;
  42701. dispose(camera?: Camera): void;
  42702. }
  42703. }
  42704. declare module BABYLON {
  42705. /**
  42706. * Class containing static functions to help procedurally build meshes
  42707. */
  42708. export class GroundBuilder {
  42709. /**
  42710. * Creates a ground mesh
  42711. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42712. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42714. * @param name defines the name of the mesh
  42715. * @param options defines the options used to create the mesh
  42716. * @param scene defines the hosting scene
  42717. * @returns the ground mesh
  42718. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42719. */
  42720. static CreateGround(name: string, options: {
  42721. width?: number;
  42722. height?: number;
  42723. subdivisions?: number;
  42724. subdivisionsX?: number;
  42725. subdivisionsY?: number;
  42726. updatable?: boolean;
  42727. }, scene: any): Mesh;
  42728. /**
  42729. * Creates a tiled ground mesh
  42730. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42731. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42732. * * 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
  42733. * * 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
  42734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42735. * @param name defines the name of the mesh
  42736. * @param options defines the options used to create the mesh
  42737. * @param scene defines the hosting scene
  42738. * @returns the tiled ground mesh
  42739. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42740. */
  42741. static CreateTiledGround(name: string, options: {
  42742. xmin: number;
  42743. zmin: number;
  42744. xmax: number;
  42745. zmax: number;
  42746. subdivisions?: {
  42747. w: number;
  42748. h: number;
  42749. };
  42750. precision?: {
  42751. w: number;
  42752. h: number;
  42753. };
  42754. updatable?: boolean;
  42755. }, scene?: Nullable<Scene>): Mesh;
  42756. /**
  42757. * Creates a ground mesh from a height map
  42758. * * The parameter `url` sets the URL of the height map image resource.
  42759. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42760. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42761. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42762. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42763. * * 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.
  42764. * * 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).
  42765. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42767. * @param name defines the name of the mesh
  42768. * @param url defines the url to the height map
  42769. * @param options defines the options used to create the mesh
  42770. * @param scene defines the hosting scene
  42771. * @returns the ground mesh
  42772. * @see https://doc.babylonjs.com/babylon101/height_map
  42773. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42774. */
  42775. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42776. width?: number;
  42777. height?: number;
  42778. subdivisions?: number;
  42779. minHeight?: number;
  42780. maxHeight?: number;
  42781. colorFilter?: Color3;
  42782. alphaFilter?: number;
  42783. updatable?: boolean;
  42784. onReady?: (mesh: GroundMesh) => void;
  42785. }, scene?: Nullable<Scene>): GroundMesh;
  42786. }
  42787. }
  42788. declare module BABYLON {
  42789. /**
  42790. * Class containing static functions to help procedurally build meshes
  42791. */
  42792. export class TorusBuilder {
  42793. /**
  42794. * Creates a torus mesh
  42795. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42796. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42797. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42798. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42799. * * 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
  42800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42801. * @param name defines the name of the mesh
  42802. * @param options defines the options used to create the mesh
  42803. * @param scene defines the hosting scene
  42804. * @returns the torus mesh
  42805. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42806. */
  42807. static CreateTorus(name: string, options: {
  42808. diameter?: number;
  42809. thickness?: number;
  42810. tessellation?: number;
  42811. updatable?: boolean;
  42812. sideOrientation?: number;
  42813. frontUVs?: Vector4;
  42814. backUVs?: Vector4;
  42815. }, scene: any): Mesh;
  42816. }
  42817. }
  42818. declare module BABYLON {
  42819. /**
  42820. * Class containing static functions to help procedurally build meshes
  42821. */
  42822. export class CylinderBuilder {
  42823. /**
  42824. * Creates a cylinder or a cone mesh
  42825. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42826. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42827. * * 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.
  42828. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42829. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42830. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42831. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42832. * * 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).
  42833. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42834. * * 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).
  42835. * * 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
  42836. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42837. * * 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
  42838. * * 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.
  42839. * * If `enclose` is false, a ring surface is one element.
  42840. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42841. * * 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
  42842. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42843. * * 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
  42844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42845. * @param name defines the name of the mesh
  42846. * @param options defines the options used to create the mesh
  42847. * @param scene defines the hosting scene
  42848. * @returns the cylinder mesh
  42849. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42850. */
  42851. static CreateCylinder(name: string, options: {
  42852. height?: number;
  42853. diameterTop?: number;
  42854. diameterBottom?: number;
  42855. diameter?: number;
  42856. tessellation?: number;
  42857. subdivisions?: number;
  42858. arc?: number;
  42859. faceColors?: Color4[];
  42860. faceUV?: Vector4[];
  42861. updatable?: boolean;
  42862. hasRings?: boolean;
  42863. enclose?: boolean;
  42864. cap?: number;
  42865. sideOrientation?: number;
  42866. frontUVs?: Vector4;
  42867. backUVs?: Vector4;
  42868. }, scene: any): Mesh;
  42869. }
  42870. }
  42871. declare module BABYLON {
  42872. /**
  42873. * States of the webXR experience
  42874. */
  42875. export enum WebXRState {
  42876. /**
  42877. * Transitioning to being in XR mode
  42878. */
  42879. ENTERING_XR = 0,
  42880. /**
  42881. * Transitioning to non XR mode
  42882. */
  42883. EXITING_XR = 1,
  42884. /**
  42885. * In XR mode and presenting
  42886. */
  42887. IN_XR = 2,
  42888. /**
  42889. * Not entered XR mode
  42890. */
  42891. NOT_IN_XR = 3
  42892. }
  42893. /**
  42894. * Abstraction of the XR render target
  42895. */
  42896. export interface WebXRRenderTarget extends IDisposable {
  42897. /**
  42898. * xrpresent context of the canvas which can be used to display/mirror xr content
  42899. */
  42900. canvasContext: WebGLRenderingContext;
  42901. /**
  42902. * xr layer for the canvas
  42903. */
  42904. xrLayer: Nullable<XRWebGLLayer>;
  42905. /**
  42906. * Initializes the xr layer for the session
  42907. * @param xrSession xr session
  42908. * @returns a promise that will resolve once the XR Layer has been created
  42909. */
  42910. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42911. }
  42912. }
  42913. declare module BABYLON {
  42914. /**
  42915. * COnfiguration object for WebXR output canvas
  42916. */
  42917. export class WebXRManagedOutputCanvasOptions {
  42918. /**
  42919. * An optional canvas in case you wish to create it yourself and provide it here.
  42920. * If not provided, a new canvas will be created
  42921. */
  42922. canvasElement?: HTMLCanvasElement;
  42923. /**
  42924. * Options for this XR Layer output
  42925. */
  42926. canvasOptions?: XRWebGLLayerOptions;
  42927. /**
  42928. * CSS styling for a newly created canvas (if not provided)
  42929. */
  42930. newCanvasCssStyle?: string;
  42931. /**
  42932. * Get the default values of the configuration object
  42933. * @returns default values of this configuration object
  42934. */
  42935. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42936. }
  42937. /**
  42938. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42939. */
  42940. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42941. private _options;
  42942. private _canvas;
  42943. private _engine;
  42944. /**
  42945. * Rendering context of the canvas which can be used to display/mirror xr content
  42946. */
  42947. canvasContext: WebGLRenderingContext;
  42948. /**
  42949. * xr layer for the canvas
  42950. */
  42951. xrLayer: Nullable<XRWebGLLayer>;
  42952. /**
  42953. * Initializes the canvas to be added/removed upon entering/exiting xr
  42954. * @param _xrSessionManager The XR Session manager
  42955. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42956. */
  42957. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42958. /**
  42959. * Disposes of the object
  42960. */
  42961. dispose(): void;
  42962. /**
  42963. * Initializes the xr layer for the session
  42964. * @param xrSession xr session
  42965. * @returns a promise that will resolve once the XR Layer has been created
  42966. */
  42967. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42968. private _addCanvas;
  42969. private _removeCanvas;
  42970. private _setManagedOutputCanvas;
  42971. }
  42972. }
  42973. declare module BABYLON {
  42974. /**
  42975. * Manages an XRSession to work with Babylon's engine
  42976. * @see https://doc.babylonjs.com/how_to/webxr
  42977. */
  42978. export class WebXRSessionManager implements IDisposable {
  42979. /** The scene which the session should be created for */
  42980. scene: Scene;
  42981. private _referenceSpace;
  42982. private _rttProvider;
  42983. private _sessionEnded;
  42984. private _xrNavigator;
  42985. private baseLayer;
  42986. /**
  42987. * The base reference space from which the session started. good if you want to reset your
  42988. * reference space
  42989. */
  42990. baseReferenceSpace: XRReferenceSpace;
  42991. /**
  42992. * Current XR frame
  42993. */
  42994. currentFrame: Nullable<XRFrame>;
  42995. /** WebXR timestamp updated every frame */
  42996. currentTimestamp: number;
  42997. /**
  42998. * Used just in case of a failure to initialize an immersive session.
  42999. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43000. */
  43001. defaultHeightCompensation: number;
  43002. /**
  43003. * Fires every time a new xrFrame arrives which can be used to update the camera
  43004. */
  43005. onXRFrameObservable: Observable<XRFrame>;
  43006. /**
  43007. * Fires when the reference space changed
  43008. */
  43009. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  43010. /**
  43011. * Fires when the xr session is ended either by the device or manually done
  43012. */
  43013. onXRSessionEnded: Observable<any>;
  43014. /**
  43015. * Fires when the xr session is ended either by the device or manually done
  43016. */
  43017. onXRSessionInit: Observable<XRSession>;
  43018. /**
  43019. * Underlying xr session
  43020. */
  43021. session: XRSession;
  43022. /**
  43023. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43024. * or get the offset the player is currently at.
  43025. */
  43026. viewerReferenceSpace: XRReferenceSpace;
  43027. /**
  43028. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43029. * @param scene The scene which the session should be created for
  43030. */
  43031. constructor(
  43032. /** The scene which the session should be created for */
  43033. scene: Scene);
  43034. /**
  43035. * The current reference space used in this session. This reference space can constantly change!
  43036. * It is mainly used to offset the camera's position.
  43037. */
  43038. get referenceSpace(): XRReferenceSpace;
  43039. /**
  43040. * Set a new reference space and triggers the observable
  43041. */
  43042. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43043. /**
  43044. * Disposes of the session manager
  43045. */
  43046. dispose(): void;
  43047. /**
  43048. * Stops the xrSession and restores the render loop
  43049. * @returns Promise which resolves after it exits XR
  43050. */
  43051. exitXRAsync(): Promise<void>;
  43052. /**
  43053. * Gets the correct render target texture to be rendered this frame for this eye
  43054. * @param eye the eye for which to get the render target
  43055. * @returns the render target for the specified eye
  43056. */
  43057. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43058. /**
  43059. * Creates a WebXRRenderTarget object for the XR session
  43060. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43061. * @param options optional options to provide when creating a new render target
  43062. * @returns a WebXR render target to which the session can render
  43063. */
  43064. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43065. /**
  43066. * Initializes the manager
  43067. * After initialization enterXR can be called to start an XR session
  43068. * @returns Promise which resolves after it is initialized
  43069. */
  43070. initializeAsync(): Promise<void>;
  43071. /**
  43072. * Initializes an xr session
  43073. * @param xrSessionMode mode to initialize
  43074. * @param xrSessionInit defines optional and required values to pass to the session builder
  43075. * @returns a promise which will resolve once the session has been initialized
  43076. */
  43077. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  43078. /**
  43079. * Checks if a session would be supported for the creation options specified
  43080. * @param sessionMode session mode to check if supported eg. immersive-vr
  43081. * @returns A Promise that resolves to true if supported and false if not
  43082. */
  43083. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43084. /**
  43085. * Resets the reference space to the one started the session
  43086. */
  43087. resetReferenceSpace(): void;
  43088. /**
  43089. * Starts rendering to the xr layer
  43090. */
  43091. runXRRenderLoop(): void;
  43092. /**
  43093. * Sets the reference space on the xr session
  43094. * @param referenceSpaceType space to set
  43095. * @returns a promise that will resolve once the reference space has been set
  43096. */
  43097. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  43098. /**
  43099. * Updates the render state of the session
  43100. * @param state state to set
  43101. * @returns a promise that resolves once the render state has been updated
  43102. */
  43103. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43104. /**
  43105. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  43106. * @param sessionMode defines the session to test
  43107. * @returns a promise with boolean as final value
  43108. */
  43109. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43110. private _createRenderTargetTexture;
  43111. }
  43112. }
  43113. declare module BABYLON {
  43114. /**
  43115. * WebXR Camera which holds the views for the xrSession
  43116. * @see https://doc.babylonjs.com/how_to/webxr_camera
  43117. */
  43118. export class WebXRCamera extends FreeCamera {
  43119. private _xrSessionManager;
  43120. private _firstFrame;
  43121. private _referenceQuaternion;
  43122. private _referencedPosition;
  43123. private _xrInvPositionCache;
  43124. private _xrInvQuaternionCache;
  43125. /**
  43126. * Should position compensation execute on first frame.
  43127. * This is used when copying the position from a native (non XR) camera
  43128. */
  43129. compensateOnFirstFrame: boolean;
  43130. /**
  43131. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43132. * @param name the name of the camera
  43133. * @param scene the scene to add the camera to
  43134. * @param _xrSessionManager a constructed xr session manager
  43135. */
  43136. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43137. /**
  43138. * Return the user's height, unrelated to the current ground.
  43139. * This will be the y position of this camera, when ground level is 0.
  43140. */
  43141. get realWorldHeight(): number;
  43142. /** @hidden */
  43143. _updateForDualEyeDebugging(): void;
  43144. /**
  43145. * Sets this camera's transformation based on a non-vr camera
  43146. * @param otherCamera the non-vr camera to copy the transformation from
  43147. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  43148. */
  43149. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  43150. /**
  43151. * Gets the current instance class name ("WebXRCamera").
  43152. * @returns the class name
  43153. */
  43154. getClassName(): string;
  43155. private _updateFromXRSession;
  43156. private _updateNumberOfRigCameras;
  43157. private _updateReferenceSpace;
  43158. private _updateReferenceSpaceOffset;
  43159. }
  43160. }
  43161. declare module BABYLON {
  43162. /**
  43163. * Defining the interface required for a (webxr) feature
  43164. */
  43165. export interface IWebXRFeature extends IDisposable {
  43166. /**
  43167. * Is this feature attached
  43168. */
  43169. attached: boolean;
  43170. /**
  43171. * Should auto-attach be disabled?
  43172. */
  43173. disableAutoAttach: boolean;
  43174. /**
  43175. * Attach the feature to the session
  43176. * Will usually be called by the features manager
  43177. *
  43178. * @param force should attachment be forced (even when already attached)
  43179. * @returns true if successful.
  43180. */
  43181. attach(force?: boolean): boolean;
  43182. /**
  43183. * Detach the feature from the session
  43184. * Will usually be called by the features manager
  43185. *
  43186. * @returns true if successful.
  43187. */
  43188. detach(): boolean;
  43189. }
  43190. /**
  43191. * A list of the currently available features without referencing them
  43192. */
  43193. export class WebXRFeatureName {
  43194. /**
  43195. * The name of the anchor system feature
  43196. */
  43197. static ANCHOR_SYSTEM: string;
  43198. /**
  43199. * The name of the background remover feature
  43200. */
  43201. static BACKGROUND_REMOVER: string;
  43202. /**
  43203. * The name of the hit test feature
  43204. */
  43205. static HIT_TEST: string;
  43206. /**
  43207. * physics impostors for xr controllers feature
  43208. */
  43209. static PHYSICS_CONTROLLERS: string;
  43210. /**
  43211. * The name of the plane detection feature
  43212. */
  43213. static PLANE_DETECTION: string;
  43214. /**
  43215. * The name of the pointer selection feature
  43216. */
  43217. static POINTER_SELECTION: string;
  43218. /**
  43219. * The name of the teleportation feature
  43220. */
  43221. static TELEPORTATION: string;
  43222. }
  43223. /**
  43224. * Defining the constructor of a feature. Used to register the modules.
  43225. */
  43226. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43227. /**
  43228. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43229. * It is mainly used in AR sessions.
  43230. *
  43231. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43232. */
  43233. export class WebXRFeaturesManager implements IDisposable {
  43234. private _xrSessionManager;
  43235. private static readonly _AvailableFeatures;
  43236. private _features;
  43237. /**
  43238. * constructs a new features manages.
  43239. *
  43240. * @param _xrSessionManager an instance of WebXRSessionManager
  43241. */
  43242. constructor(_xrSessionManager: WebXRSessionManager);
  43243. /**
  43244. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43245. * Mainly used internally.
  43246. *
  43247. * @param featureName the name of the feature to register
  43248. * @param constructorFunction the function used to construct the module
  43249. * @param version the (babylon) version of the module
  43250. * @param stable is that a stable version of this module
  43251. */
  43252. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43253. /**
  43254. * Returns a constructor of a specific feature.
  43255. *
  43256. * @param featureName the name of the feature to construct
  43257. * @param version the version of the feature to load
  43258. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43259. * @param options optional options provided to the module.
  43260. * @returns a function that, when called, will return a new instance of this feature
  43261. */
  43262. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43263. /**
  43264. * Can be used to return the list of features currently registered
  43265. *
  43266. * @returns an Array of available features
  43267. */
  43268. static GetAvailableFeatures(): string[];
  43269. /**
  43270. * Gets the versions available for a specific feature
  43271. * @param featureName the name of the feature
  43272. * @returns an array with the available versions
  43273. */
  43274. static GetAvailableVersions(featureName: string): string[];
  43275. /**
  43276. * Return the latest unstable version of this feature
  43277. * @param featureName the name of the feature to search
  43278. * @returns the version number. if not found will return -1
  43279. */
  43280. static GetLatestVersionOfFeature(featureName: string): number;
  43281. /**
  43282. * Return the latest stable version of this feature
  43283. * @param featureName the name of the feature to search
  43284. * @returns the version number. if not found will return -1
  43285. */
  43286. static GetStableVersionOfFeature(featureName: string): number;
  43287. /**
  43288. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43289. * Can be used during a session to start a feature
  43290. * @param featureName the name of feature to attach
  43291. */
  43292. attachFeature(featureName: string): void;
  43293. /**
  43294. * Can be used inside a session or when the session ends to detach a specific feature
  43295. * @param featureName the name of the feature to detach
  43296. */
  43297. detachFeature(featureName: string): void;
  43298. /**
  43299. * Used to disable an already-enabled feature
  43300. * The feature will be disposed and will be recreated once enabled.
  43301. * @param featureName the feature to disable
  43302. * @returns true if disable was successful
  43303. */
  43304. disableFeature(featureName: string | {
  43305. Name: string;
  43306. }): boolean;
  43307. /**
  43308. * dispose this features manager
  43309. */
  43310. dispose(): void;
  43311. /**
  43312. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  43313. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  43314. *
  43315. * @param featureName the name of the feature to load or the class of the feature
  43316. * @param version optional version to load. if not provided the latest version will be enabled
  43317. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43318. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43319. * @returns a new constructed feature or throws an error if feature not found.
  43320. */
  43321. enableFeature(featureName: string | {
  43322. Name: string;
  43323. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43324. /**
  43325. * get the implementation of an enabled feature.
  43326. * @param featureName the name of the feature to load
  43327. * @returns the feature class, if found
  43328. */
  43329. getEnabledFeature(featureName: string): IWebXRFeature;
  43330. /**
  43331. * Get the list of enabled features
  43332. * @returns an array of enabled features
  43333. */
  43334. getEnabledFeatures(): string[];
  43335. }
  43336. }
  43337. declare module BABYLON {
  43338. /**
  43339. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43340. * @see https://doc.babylonjs.com/how_to/webxr
  43341. */
  43342. export class WebXRExperienceHelper implements IDisposable {
  43343. private scene;
  43344. private _nonVRCamera;
  43345. private _originalSceneAutoClear;
  43346. private _supported;
  43347. /**
  43348. * Camera used to render xr content
  43349. */
  43350. camera: WebXRCamera;
  43351. /** A features manager for this xr session */
  43352. featuresManager: WebXRFeaturesManager;
  43353. /**
  43354. * Observers registered here will be triggered after the camera's initial transformation is set
  43355. * This can be used to set a different ground level or an extra rotation.
  43356. *
  43357. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43358. * to the position set after this observable is done executing.
  43359. */
  43360. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43361. /**
  43362. * Fires when the state of the experience helper has changed
  43363. */
  43364. onStateChangedObservable: Observable<WebXRState>;
  43365. /** Session manager used to keep track of xr session */
  43366. sessionManager: WebXRSessionManager;
  43367. /**
  43368. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43369. */
  43370. state: WebXRState;
  43371. /**
  43372. * Creates a WebXRExperienceHelper
  43373. * @param scene The scene the helper should be created in
  43374. */
  43375. private constructor();
  43376. /**
  43377. * Creates the experience helper
  43378. * @param scene the scene to attach the experience helper to
  43379. * @returns a promise for the experience helper
  43380. */
  43381. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43382. /**
  43383. * Disposes of the experience helper
  43384. */
  43385. dispose(): void;
  43386. /**
  43387. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43388. * @param sessionMode options for the XR session
  43389. * @param referenceSpaceType frame of reference of the XR session
  43390. * @param renderTarget the output canvas that will be used to enter XR mode
  43391. * @returns promise that resolves after xr mode has entered
  43392. */
  43393. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43394. /**
  43395. * Exits XR mode and returns the scene to its original state
  43396. * @returns promise that resolves after xr mode has exited
  43397. */
  43398. exitXRAsync(): Promise<void>;
  43399. private _nonXRToXRCamera;
  43400. private _setState;
  43401. }
  43402. }
  43403. declare module BABYLON {
  43404. /**
  43405. * X-Y values for axes in WebXR
  43406. */
  43407. export interface IWebXRMotionControllerAxesValue {
  43408. /**
  43409. * The value of the x axis
  43410. */
  43411. x: number;
  43412. /**
  43413. * The value of the y-axis
  43414. */
  43415. y: number;
  43416. }
  43417. /**
  43418. * changed / previous values for the values of this component
  43419. */
  43420. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43421. /**
  43422. * current (this frame) value
  43423. */
  43424. current: T;
  43425. /**
  43426. * previous (last change) value
  43427. */
  43428. previous: T;
  43429. }
  43430. /**
  43431. * Represents changes in the component between current frame and last values recorded
  43432. */
  43433. export interface IWebXRMotionControllerComponentChanges {
  43434. /**
  43435. * will be populated with previous and current values if axes changed
  43436. */
  43437. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43438. /**
  43439. * will be populated with previous and current values if pressed changed
  43440. */
  43441. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43442. /**
  43443. * will be populated with previous and current values if touched changed
  43444. */
  43445. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43446. /**
  43447. * will be populated with previous and current values if value changed
  43448. */
  43449. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43450. }
  43451. /**
  43452. * This class represents a single component (for example button or thumbstick) of a motion controller
  43453. */
  43454. export class WebXRControllerComponent implements IDisposable {
  43455. /**
  43456. * the id of this component
  43457. */
  43458. id: string;
  43459. /**
  43460. * the type of the component
  43461. */
  43462. type: MotionControllerComponentType;
  43463. private _buttonIndex;
  43464. private _axesIndices;
  43465. private _axes;
  43466. private _changes;
  43467. private _currentValue;
  43468. private _hasChanges;
  43469. private _pressed;
  43470. private _touched;
  43471. /**
  43472. * button component type
  43473. */
  43474. static BUTTON_TYPE: MotionControllerComponentType;
  43475. /**
  43476. * squeeze component type
  43477. */
  43478. static SQUEEZE_TYPE: MotionControllerComponentType;
  43479. /**
  43480. * Thumbstick component type
  43481. */
  43482. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43483. /**
  43484. * Touchpad component type
  43485. */
  43486. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43487. /**
  43488. * trigger component type
  43489. */
  43490. static TRIGGER_TYPE: MotionControllerComponentType;
  43491. /**
  43492. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43493. * the axes data changes
  43494. */
  43495. onAxisValueChangedObservable: Observable<{
  43496. x: number;
  43497. y: number;
  43498. }>;
  43499. /**
  43500. * Observers registered here will be triggered when the state of a button changes
  43501. * State change is either pressed / touched / value
  43502. */
  43503. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43504. /**
  43505. * Creates a new component for a motion controller.
  43506. * It is created by the motion controller itself
  43507. *
  43508. * @param id the id of this component
  43509. * @param type the type of the component
  43510. * @param _buttonIndex index in the buttons array of the gamepad
  43511. * @param _axesIndices indices of the values in the axes array of the gamepad
  43512. */
  43513. constructor(
  43514. /**
  43515. * the id of this component
  43516. */
  43517. id: string,
  43518. /**
  43519. * the type of the component
  43520. */
  43521. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43522. /**
  43523. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43524. */
  43525. get axes(): IWebXRMotionControllerAxesValue;
  43526. /**
  43527. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43528. */
  43529. get changes(): IWebXRMotionControllerComponentChanges;
  43530. /**
  43531. * Return whether or not the component changed the last frame
  43532. */
  43533. get hasChanges(): boolean;
  43534. /**
  43535. * is the button currently pressed
  43536. */
  43537. get pressed(): boolean;
  43538. /**
  43539. * is the button currently touched
  43540. */
  43541. get touched(): boolean;
  43542. /**
  43543. * Get the current value of this component
  43544. */
  43545. get value(): number;
  43546. /**
  43547. * Dispose this component
  43548. */
  43549. dispose(): void;
  43550. /**
  43551. * Are there axes correlating to this component
  43552. * @return true is axes data is available
  43553. */
  43554. isAxes(): boolean;
  43555. /**
  43556. * Is this component a button (hence - pressable)
  43557. * @returns true if can be pressed
  43558. */
  43559. isButton(): boolean;
  43560. /**
  43561. * update this component using the gamepad object it is in. Called on every frame
  43562. * @param nativeController the native gamepad controller object
  43563. */
  43564. update(nativeController: IMinimalMotionControllerObject): void;
  43565. }
  43566. }
  43567. declare module BABYLON {
  43568. /**
  43569. * Class used to represent data loading progression
  43570. */
  43571. export class SceneLoaderProgressEvent {
  43572. /** defines if data length to load can be evaluated */
  43573. readonly lengthComputable: boolean;
  43574. /** defines the loaded data length */
  43575. readonly loaded: number;
  43576. /** defines the data length to load */
  43577. readonly total: number;
  43578. /**
  43579. * Create a new progress event
  43580. * @param lengthComputable defines if data length to load can be evaluated
  43581. * @param loaded defines the loaded data length
  43582. * @param total defines the data length to load
  43583. */
  43584. constructor(
  43585. /** defines if data length to load can be evaluated */
  43586. lengthComputable: boolean,
  43587. /** defines the loaded data length */
  43588. loaded: number,
  43589. /** defines the data length to load */
  43590. total: number);
  43591. /**
  43592. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43593. * @param event defines the source event
  43594. * @returns a new SceneLoaderProgressEvent
  43595. */
  43596. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43597. }
  43598. /**
  43599. * Interface used by SceneLoader plugins to define supported file extensions
  43600. */
  43601. export interface ISceneLoaderPluginExtensions {
  43602. /**
  43603. * Defines the list of supported extensions
  43604. */
  43605. [extension: string]: {
  43606. isBinary: boolean;
  43607. };
  43608. }
  43609. /**
  43610. * Interface used by SceneLoader plugin factory
  43611. */
  43612. export interface ISceneLoaderPluginFactory {
  43613. /**
  43614. * Defines the name of the factory
  43615. */
  43616. name: string;
  43617. /**
  43618. * Function called to create a new plugin
  43619. * @return the new plugin
  43620. */
  43621. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43622. /**
  43623. * The callback that returns true if the data can be directly loaded.
  43624. * @param data string containing the file data
  43625. * @returns if the data can be loaded directly
  43626. */
  43627. canDirectLoad?(data: string): boolean;
  43628. }
  43629. /**
  43630. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43631. */
  43632. export interface ISceneLoaderPluginBase {
  43633. /**
  43634. * The friendly name of this plugin.
  43635. */
  43636. name: string;
  43637. /**
  43638. * The file extensions supported by this plugin.
  43639. */
  43640. extensions: string | ISceneLoaderPluginExtensions;
  43641. /**
  43642. * The callback called when loading from a url.
  43643. * @param scene scene loading this url
  43644. * @param url url to load
  43645. * @param onSuccess callback called when the file successfully loads
  43646. * @param onProgress callback called while file is loading (if the server supports this mode)
  43647. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43648. * @param onError callback called when the file fails to load
  43649. * @returns a file request object
  43650. */
  43651. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43652. /**
  43653. * The callback called when loading from a file object.
  43654. * @param scene scene loading this file
  43655. * @param file defines the file to load
  43656. * @param onSuccess defines the callback to call when data is loaded
  43657. * @param onProgress defines the callback to call during loading process
  43658. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43659. * @param onError defines the callback to call when an error occurs
  43660. * @returns a file request object
  43661. */
  43662. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43663. /**
  43664. * The callback that returns true if the data can be directly loaded.
  43665. * @param data string containing the file data
  43666. * @returns if the data can be loaded directly
  43667. */
  43668. canDirectLoad?(data: string): boolean;
  43669. /**
  43670. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43671. * @param scene scene loading this data
  43672. * @param data string containing the data
  43673. * @returns data to pass to the plugin
  43674. */
  43675. directLoad?(scene: Scene, data: string): any;
  43676. /**
  43677. * The callback that allows custom handling of the root url based on the response url.
  43678. * @param rootUrl the original root url
  43679. * @param responseURL the response url if available
  43680. * @returns the new root url
  43681. */
  43682. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43683. }
  43684. /**
  43685. * Interface used to define a SceneLoader plugin
  43686. */
  43687. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43688. /**
  43689. * Import meshes into a scene.
  43690. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43691. * @param scene The scene to import into
  43692. * @param data The data to import
  43693. * @param rootUrl The root url for scene and resources
  43694. * @param meshes The meshes array to import into
  43695. * @param particleSystems The particle systems array to import into
  43696. * @param skeletons The skeletons array to import into
  43697. * @param onError The callback when import fails
  43698. * @returns True if successful or false otherwise
  43699. */
  43700. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43701. /**
  43702. * Load into a scene.
  43703. * @param scene The scene to load into
  43704. * @param data The data to import
  43705. * @param rootUrl The root url for scene and resources
  43706. * @param onError The callback when import fails
  43707. * @returns True if successful or false otherwise
  43708. */
  43709. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43710. /**
  43711. * Load into an asset container.
  43712. * @param scene The scene to load into
  43713. * @param data The data to import
  43714. * @param rootUrl The root url for scene and resources
  43715. * @param onError The callback when import fails
  43716. * @returns The loaded asset container
  43717. */
  43718. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43719. }
  43720. /**
  43721. * Interface used to define an async SceneLoader plugin
  43722. */
  43723. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43724. /**
  43725. * Import meshes into a scene.
  43726. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43727. * @param scene The scene to import into
  43728. * @param data The data to import
  43729. * @param rootUrl The root url for scene and resources
  43730. * @param onProgress The callback when the load progresses
  43731. * @param fileName Defines the name of the file to load
  43732. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43733. */
  43734. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43735. meshes: AbstractMesh[];
  43736. particleSystems: IParticleSystem[];
  43737. skeletons: Skeleton[];
  43738. animationGroups: AnimationGroup[];
  43739. }>;
  43740. /**
  43741. * Load into a scene.
  43742. * @param scene The scene to load into
  43743. * @param data The data to import
  43744. * @param rootUrl The root url for scene and resources
  43745. * @param onProgress The callback when the load progresses
  43746. * @param fileName Defines the name of the file to load
  43747. * @returns Nothing
  43748. */
  43749. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43750. /**
  43751. * Load into an asset container.
  43752. * @param scene The scene to load into
  43753. * @param data The data to import
  43754. * @param rootUrl The root url for scene and resources
  43755. * @param onProgress The callback when the load progresses
  43756. * @param fileName Defines the name of the file to load
  43757. * @returns The loaded asset container
  43758. */
  43759. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43760. }
  43761. /**
  43762. * Mode that determines how to handle old animation groups before loading new ones.
  43763. */
  43764. export enum SceneLoaderAnimationGroupLoadingMode {
  43765. /**
  43766. * Reset all old animations to initial state then dispose them.
  43767. */
  43768. Clean = 0,
  43769. /**
  43770. * Stop all old animations.
  43771. */
  43772. Stop = 1,
  43773. /**
  43774. * Restart old animations from first frame.
  43775. */
  43776. Sync = 2,
  43777. /**
  43778. * Old animations remains untouched.
  43779. */
  43780. NoSync = 3
  43781. }
  43782. /**
  43783. * Class used to load scene from various file formats using registered plugins
  43784. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43785. */
  43786. export class SceneLoader {
  43787. /**
  43788. * No logging while loading
  43789. */
  43790. static readonly NO_LOGGING: number;
  43791. /**
  43792. * Minimal logging while loading
  43793. */
  43794. static readonly MINIMAL_LOGGING: number;
  43795. /**
  43796. * Summary logging while loading
  43797. */
  43798. static readonly SUMMARY_LOGGING: number;
  43799. /**
  43800. * Detailled logging while loading
  43801. */
  43802. static readonly DETAILED_LOGGING: number;
  43803. /**
  43804. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43805. */
  43806. static get ForceFullSceneLoadingForIncremental(): boolean;
  43807. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43808. /**
  43809. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43810. */
  43811. static get ShowLoadingScreen(): boolean;
  43812. static set ShowLoadingScreen(value: boolean);
  43813. /**
  43814. * Defines the current logging level (while loading the scene)
  43815. * @ignorenaming
  43816. */
  43817. static get loggingLevel(): number;
  43818. static set loggingLevel(value: number);
  43819. /**
  43820. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43821. */
  43822. static get CleanBoneMatrixWeights(): boolean;
  43823. static set CleanBoneMatrixWeights(value: boolean);
  43824. /**
  43825. * Event raised when a plugin is used to load a scene
  43826. */
  43827. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43828. private static _registeredPlugins;
  43829. private static _getDefaultPlugin;
  43830. private static _getPluginForExtension;
  43831. private static _getPluginForDirectLoad;
  43832. private static _getPluginForFilename;
  43833. private static _getDirectLoad;
  43834. private static _loadData;
  43835. private static _getFileInfo;
  43836. /**
  43837. * Gets a plugin that can load the given extension
  43838. * @param extension defines the extension to load
  43839. * @returns a plugin or null if none works
  43840. */
  43841. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43842. /**
  43843. * Gets a boolean indicating that the given extension can be loaded
  43844. * @param extension defines the extension to load
  43845. * @returns true if the extension is supported
  43846. */
  43847. static IsPluginForExtensionAvailable(extension: string): boolean;
  43848. /**
  43849. * Adds a new plugin to the list of registered plugins
  43850. * @param plugin defines the plugin to add
  43851. */
  43852. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43853. /**
  43854. * Import meshes into a scene
  43855. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43856. * @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)
  43857. * @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)
  43858. * @param scene the instance of BABYLON.Scene to append to
  43859. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43860. * @param onProgress a callback with a progress event for each file being loaded
  43861. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43862. * @param pluginExtension the extension used to determine the plugin
  43863. * @returns The loaded plugin
  43864. */
  43865. 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>;
  43866. /**
  43867. * Import meshes into a scene
  43868. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43869. * @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)
  43870. * @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)
  43871. * @param scene the instance of BABYLON.Scene to append to
  43872. * @param onProgress a callback with a progress event for each file being loaded
  43873. * @param pluginExtension the extension used to determine the plugin
  43874. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43875. */
  43876. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43877. meshes: AbstractMesh[];
  43878. particleSystems: IParticleSystem[];
  43879. skeletons: Skeleton[];
  43880. animationGroups: AnimationGroup[];
  43881. }>;
  43882. /**
  43883. * Load a scene
  43884. * @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)
  43885. * @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)
  43886. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43887. * @param onSuccess a callback with the scene when import succeeds
  43888. * @param onProgress a callback with a progress event for each file being loaded
  43889. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43890. * @param pluginExtension the extension used to determine the plugin
  43891. * @returns The loaded plugin
  43892. */
  43893. 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>;
  43894. /**
  43895. * Load a scene
  43896. * @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)
  43897. * @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)
  43898. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43899. * @param onProgress a callback with a progress event for each file being loaded
  43900. * @param pluginExtension the extension used to determine the plugin
  43901. * @returns The loaded scene
  43902. */
  43903. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43904. /**
  43905. * Append a scene
  43906. * @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)
  43907. * @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)
  43908. * @param scene is the instance of BABYLON.Scene to append to
  43909. * @param onSuccess a callback with the scene when import succeeds
  43910. * @param onProgress a callback with a progress event for each file being loaded
  43911. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43912. * @param pluginExtension the extension used to determine the plugin
  43913. * @returns The loaded plugin
  43914. */
  43915. 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>;
  43916. /**
  43917. * Append a scene
  43918. * @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)
  43919. * @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)
  43920. * @param scene is the instance of BABYLON.Scene to append to
  43921. * @param onProgress a callback with a progress event for each file being loaded
  43922. * @param pluginExtension the extension used to determine the plugin
  43923. * @returns The given scene
  43924. */
  43925. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43926. /**
  43927. * Load a scene into an asset container
  43928. * @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)
  43929. * @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)
  43930. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43931. * @param onSuccess a callback with the scene when import succeeds
  43932. * @param onProgress a callback with a progress event for each file being loaded
  43933. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43934. * @param pluginExtension the extension used to determine the plugin
  43935. * @returns The loaded plugin
  43936. */
  43937. 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>;
  43938. /**
  43939. * Load a scene into an asset container
  43940. * @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)
  43941. * @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)
  43942. * @param scene is the instance of Scene to append to
  43943. * @param onProgress a callback with a progress event for each file being loaded
  43944. * @param pluginExtension the extension used to determine the plugin
  43945. * @returns The loaded asset container
  43946. */
  43947. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43948. /**
  43949. * Import animations from a file into a scene
  43950. * @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)
  43951. * @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)
  43952. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43953. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43954. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43955. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43956. * @param onSuccess a callback with the scene when import succeeds
  43957. * @param onProgress a callback with a progress event for each file being loaded
  43958. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43959. */
  43960. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  43961. /**
  43962. * Import animations from a file into a scene
  43963. * @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)
  43964. * @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)
  43965. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43966. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43967. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43968. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43969. * @param onSuccess a callback with the scene when import succeeds
  43970. * @param onProgress a callback with a progress event for each file being loaded
  43971. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43972. * @returns the updated scene with imported animations
  43973. */
  43974. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  43975. }
  43976. }
  43977. declare module BABYLON {
  43978. /**
  43979. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43980. */
  43981. export type MotionControllerHandness = "none" | "left" | "right";
  43982. /**
  43983. * The type of components available in motion controllers.
  43984. * This is not the name of the component.
  43985. */
  43986. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43987. /**
  43988. * The state of a controller component
  43989. */
  43990. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  43991. /**
  43992. * The schema of motion controller layout.
  43993. * No object will be initialized using this interface
  43994. * This is used just to define the profile.
  43995. */
  43996. export interface IMotionControllerLayout {
  43997. /**
  43998. * Path to load the assets. Usually relative to the base path
  43999. */
  44000. assetPath: string;
  44001. /**
  44002. * Available components (unsorted)
  44003. */
  44004. components: {
  44005. /**
  44006. * A map of component Ids
  44007. */
  44008. [componentId: string]: {
  44009. /**
  44010. * The type of input the component outputs
  44011. */
  44012. type: MotionControllerComponentType;
  44013. /**
  44014. * The indices of this component in the gamepad object
  44015. */
  44016. gamepadIndices: {
  44017. /**
  44018. * Index of button
  44019. */
  44020. button?: number;
  44021. /**
  44022. * If available, index of x-axis
  44023. */
  44024. xAxis?: number;
  44025. /**
  44026. * If available, index of y-axis
  44027. */
  44028. yAxis?: number;
  44029. };
  44030. /**
  44031. * The mesh's root node name
  44032. */
  44033. rootNodeName: string;
  44034. /**
  44035. * Animation definitions for this model
  44036. */
  44037. visualResponses: {
  44038. [stateKey: string]: {
  44039. /**
  44040. * What property will be animated
  44041. */
  44042. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  44043. /**
  44044. * What states influence this visual response
  44045. */
  44046. states: MotionControllerComponentStateType[];
  44047. /**
  44048. * Type of animation - movement or visibility
  44049. */
  44050. valueNodeProperty: "transform" | "visibility";
  44051. /**
  44052. * Base node name to move. Its position will be calculated according to the min and max nodes
  44053. */
  44054. valueNodeName?: string;
  44055. /**
  44056. * Minimum movement node
  44057. */
  44058. minNodeName?: string;
  44059. /**
  44060. * Max movement node
  44061. */
  44062. maxNodeName?: string;
  44063. };
  44064. };
  44065. /**
  44066. * If touch enabled, what is the name of node to display user feedback
  44067. */
  44068. touchPointNodeName?: string;
  44069. };
  44070. };
  44071. /**
  44072. * Is it xr standard mapping or not
  44073. */
  44074. gamepadMapping: "" | "xr-standard";
  44075. /**
  44076. * Base root node of this entire model
  44077. */
  44078. rootNodeName: string;
  44079. /**
  44080. * Defines the main button component id
  44081. */
  44082. selectComponentId: string;
  44083. }
  44084. /**
  44085. * A definition for the layout map in the input profile
  44086. */
  44087. export interface IMotionControllerLayoutMap {
  44088. /**
  44089. * Layouts with handness type as a key
  44090. */
  44091. [handness: string]: IMotionControllerLayout;
  44092. }
  44093. /**
  44094. * The XR Input profile schema
  44095. * Profiles can be found here:
  44096. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44097. */
  44098. export interface IMotionControllerProfile {
  44099. /**
  44100. * fallback profiles for this profileId
  44101. */
  44102. fallbackProfileIds: string[];
  44103. /**
  44104. * The layout map, with handness as key
  44105. */
  44106. layouts: IMotionControllerLayoutMap;
  44107. /**
  44108. * The id of this profile
  44109. * correlates to the profile(s) in the xrInput.profiles array
  44110. */
  44111. profileId: string;
  44112. }
  44113. /**
  44114. * A helper-interface for the 3 meshes needed for controller button animation
  44115. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44116. */
  44117. export interface IMotionControllerButtonMeshMap {
  44118. /**
  44119. * the mesh that defines the pressed value mesh position.
  44120. * This is used to find the max-position of this button
  44121. */
  44122. pressedMesh: AbstractMesh;
  44123. /**
  44124. * the mesh that defines the unpressed value mesh position.
  44125. * This is used to find the min (or initial) position of this button
  44126. */
  44127. unpressedMesh: AbstractMesh;
  44128. /**
  44129. * The mesh that will be changed when value changes
  44130. */
  44131. valueMesh: AbstractMesh;
  44132. }
  44133. /**
  44134. * A helper-interface for the 3 meshes needed for controller axis animation.
  44135. * This will be expanded when touchpad animations are fully supported
  44136. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44137. */
  44138. export interface IMotionControllerMeshMap {
  44139. /**
  44140. * the mesh that defines the maximum value mesh position.
  44141. */
  44142. maxMesh?: AbstractMesh;
  44143. /**
  44144. * the mesh that defines the minimum value mesh position.
  44145. */
  44146. minMesh?: AbstractMesh;
  44147. /**
  44148. * The mesh that will be changed when axis value changes
  44149. */
  44150. valueMesh: AbstractMesh;
  44151. }
  44152. /**
  44153. * The elements needed for change-detection of the gamepad objects in motion controllers
  44154. */
  44155. export interface IMinimalMotionControllerObject {
  44156. /**
  44157. * Available axes of this controller
  44158. */
  44159. axes: number[];
  44160. /**
  44161. * An array of available buttons
  44162. */
  44163. buttons: Array<{
  44164. /**
  44165. * Value of the button/trigger
  44166. */
  44167. value: number;
  44168. /**
  44169. * If the button/trigger is currently touched
  44170. */
  44171. touched: boolean;
  44172. /**
  44173. * If the button/trigger is currently pressed
  44174. */
  44175. pressed: boolean;
  44176. }>;
  44177. }
  44178. /**
  44179. * An Abstract Motion controller
  44180. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44181. * Each component has an observable to check for changes in value and state
  44182. */
  44183. export abstract class WebXRAbstractMotionController implements IDisposable {
  44184. protected scene: Scene;
  44185. protected layout: IMotionControllerLayout;
  44186. /**
  44187. * The gamepad object correlating to this controller
  44188. */
  44189. gamepadObject: IMinimalMotionControllerObject;
  44190. /**
  44191. * handness (left/right/none) of this controller
  44192. */
  44193. handness: MotionControllerHandness;
  44194. private _initComponent;
  44195. private _modelReady;
  44196. /**
  44197. * A map of components (WebXRControllerComponent) in this motion controller
  44198. * Components have a ComponentType and can also have both button and axis definitions
  44199. */
  44200. readonly components: {
  44201. [id: string]: WebXRControllerComponent;
  44202. };
  44203. /**
  44204. * Disable the model's animation. Can be set at any time.
  44205. */
  44206. disableAnimation: boolean;
  44207. /**
  44208. * Observers registered here will be triggered when the model of this controller is done loading
  44209. */
  44210. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44211. /**
  44212. * The profile id of this motion controller
  44213. */
  44214. abstract profileId: string;
  44215. /**
  44216. * The root mesh of the model. It is null if the model was not yet initialized
  44217. */
  44218. rootMesh: Nullable<AbstractMesh>;
  44219. /**
  44220. * constructs a new abstract motion controller
  44221. * @param scene the scene to which the model of the controller will be added
  44222. * @param layout The profile layout to load
  44223. * @param gamepadObject The gamepad object correlating to this controller
  44224. * @param handness handness (left/right/none) of this controller
  44225. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44226. */
  44227. constructor(scene: Scene, layout: IMotionControllerLayout,
  44228. /**
  44229. * The gamepad object correlating to this controller
  44230. */
  44231. gamepadObject: IMinimalMotionControllerObject,
  44232. /**
  44233. * handness (left/right/none) of this controller
  44234. */
  44235. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  44236. /**
  44237. * Dispose this controller, the model mesh and all its components
  44238. */
  44239. dispose(): void;
  44240. /**
  44241. * Returns all components of specific type
  44242. * @param type the type to search for
  44243. * @return an array of components with this type
  44244. */
  44245. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44246. /**
  44247. * get a component based an its component id as defined in layout.components
  44248. * @param id the id of the component
  44249. * @returns the component correlates to the id or undefined if not found
  44250. */
  44251. getComponent(id: string): WebXRControllerComponent;
  44252. /**
  44253. * Get the list of components available in this motion controller
  44254. * @returns an array of strings correlating to available components
  44255. */
  44256. getComponentIds(): string[];
  44257. /**
  44258. * Get the first component of specific type
  44259. * @param type type of component to find
  44260. * @return a controller component or null if not found
  44261. */
  44262. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44263. /**
  44264. * Get the main (Select) component of this controller as defined in the layout
  44265. * @returns the main component of this controller
  44266. */
  44267. getMainComponent(): WebXRControllerComponent;
  44268. /**
  44269. * Loads the model correlating to this controller
  44270. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44271. * @returns A promise fulfilled with the result of the model loading
  44272. */
  44273. loadModel(): Promise<boolean>;
  44274. /**
  44275. * Update this model using the current XRFrame
  44276. * @param xrFrame the current xr frame to use and update the model
  44277. */
  44278. updateFromXRFrame(xrFrame: XRFrame): void;
  44279. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44280. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44281. /**
  44282. * Moves the axis on the controller mesh based on its current state
  44283. * @param axis the index of the axis
  44284. * @param axisValue the value of the axis which determines the meshes new position
  44285. * @hidden
  44286. */
  44287. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44288. /**
  44289. * Update the model itself with the current frame data
  44290. * @param xrFrame the frame to use for updating the model mesh
  44291. */
  44292. protected updateModel(xrFrame: XRFrame): void;
  44293. /**
  44294. * Get the filename and path for this controller's model
  44295. * @returns a map of filename and path
  44296. */
  44297. protected abstract _getFilenameAndPath(): {
  44298. filename: string;
  44299. path: string;
  44300. };
  44301. /**
  44302. * This function is called before the mesh is loaded. It checks for loading constraints.
  44303. * For example, this function can check if the GLB loader is available
  44304. * If this function returns false, the generic controller will be loaded instead
  44305. * @returns Is the client ready to load the mesh
  44306. */
  44307. protected abstract _getModelLoadingConstraints(): boolean;
  44308. /**
  44309. * This function will be called after the model was successfully loaded and can be used
  44310. * for mesh transformations before it is available for the user
  44311. * @param meshes the loaded meshes
  44312. */
  44313. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44314. /**
  44315. * Set the root mesh for this controller. Important for the WebXR controller class
  44316. * @param meshes the loaded meshes
  44317. */
  44318. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44319. /**
  44320. * A function executed each frame that updates the mesh (if needed)
  44321. * @param xrFrame the current xrFrame
  44322. */
  44323. protected abstract _updateModel(xrFrame: XRFrame): void;
  44324. private _getGenericFilenameAndPath;
  44325. private _getGenericParentMesh;
  44326. }
  44327. }
  44328. declare module BABYLON {
  44329. /**
  44330. * A generic trigger-only motion controller for WebXR
  44331. */
  44332. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44333. /**
  44334. * Static version of the profile id of this controller
  44335. */
  44336. static ProfileId: string;
  44337. profileId: string;
  44338. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  44339. protected _getFilenameAndPath(): {
  44340. filename: string;
  44341. path: string;
  44342. };
  44343. protected _getModelLoadingConstraints(): boolean;
  44344. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44345. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44346. protected _updateModel(): void;
  44347. }
  44348. }
  44349. declare module BABYLON {
  44350. /**
  44351. * Class containing static functions to help procedurally build meshes
  44352. */
  44353. export class SphereBuilder {
  44354. /**
  44355. * Creates a sphere mesh
  44356. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44357. * * 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`)
  44358. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44359. * * 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
  44360. * * 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)
  44361. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44362. * * 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
  44363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44364. * @param name defines the name of the mesh
  44365. * @param options defines the options used to create the mesh
  44366. * @param scene defines the hosting scene
  44367. * @returns the sphere mesh
  44368. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44369. */
  44370. static CreateSphere(name: string, options: {
  44371. segments?: number;
  44372. diameter?: number;
  44373. diameterX?: number;
  44374. diameterY?: number;
  44375. diameterZ?: number;
  44376. arc?: number;
  44377. slice?: number;
  44378. sideOrientation?: number;
  44379. frontUVs?: Vector4;
  44380. backUVs?: Vector4;
  44381. updatable?: boolean;
  44382. }, scene?: Nullable<Scene>): Mesh;
  44383. }
  44384. }
  44385. declare module BABYLON {
  44386. /**
  44387. * A profiled motion controller has its profile loaded from an online repository.
  44388. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44389. */
  44390. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44391. private _repositoryUrl;
  44392. private _buttonMeshMapping;
  44393. private _touchDots;
  44394. /**
  44395. * The profile ID of this controller. Will be populated when the controller initializes.
  44396. */
  44397. profileId: string;
  44398. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44399. dispose(): void;
  44400. protected _getFilenameAndPath(): {
  44401. filename: string;
  44402. path: string;
  44403. };
  44404. protected _getModelLoadingConstraints(): boolean;
  44405. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44406. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44407. protected _updateModel(_xrFrame: XRFrame): void;
  44408. }
  44409. }
  44410. declare module BABYLON {
  44411. /**
  44412. * A construction function type to create a new controller based on an xrInput object
  44413. */
  44414. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44415. /**
  44416. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44417. *
  44418. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44419. * it should be replaced with auto-loaded controllers.
  44420. *
  44421. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44422. */
  44423. export class WebXRMotionControllerManager {
  44424. private static _AvailableControllers;
  44425. private static _Fallbacks;
  44426. private static _ProfileLoadingPromises;
  44427. private static _ProfilesList;
  44428. /**
  44429. * The base URL of the online controller repository. Can be changed at any time.
  44430. */
  44431. static BaseRepositoryUrl: string;
  44432. /**
  44433. * Which repository gets priority - local or online
  44434. */
  44435. static PrioritizeOnlineRepository: boolean;
  44436. /**
  44437. * Use the online repository, or use only locally-defined controllers
  44438. */
  44439. static UseOnlineRepository: boolean;
  44440. /**
  44441. * Clear the cache used for profile loading and reload when requested again
  44442. */
  44443. static ClearProfilesCache(): void;
  44444. /**
  44445. * Register the default fallbacks.
  44446. * This function is called automatically when this file is imported.
  44447. */
  44448. static DefaultFallbacks(): void;
  44449. /**
  44450. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44451. * @param profileId the profile to which a fallback needs to be found
  44452. * @return an array with corresponding fallback profiles
  44453. */
  44454. static FindFallbackWithProfileId(profileId: string): string[];
  44455. /**
  44456. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44457. * The order of search:
  44458. *
  44459. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44460. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44461. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44462. * 4) return the generic trigger controller if none were found
  44463. *
  44464. * @param xrInput the xrInput to which a new controller is initialized
  44465. * @param scene the scene to which the model will be added
  44466. * @param forceProfile force a certain profile for this controller
  44467. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44468. */
  44469. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44470. /**
  44471. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44472. *
  44473. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44474. *
  44475. * @param type the profile type to register
  44476. * @param constructFunction the function to be called when loading this profile
  44477. */
  44478. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44479. /**
  44480. * Register a fallback to a specific profile.
  44481. * @param profileId the profileId that will receive the fallbacks
  44482. * @param fallbacks A list of fallback profiles
  44483. */
  44484. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44485. /**
  44486. * Will update the list of profiles available in the repository
  44487. * @return a promise that resolves to a map of profiles available online
  44488. */
  44489. static UpdateProfilesList(): Promise<{
  44490. [profile: string]: string;
  44491. }>;
  44492. private static _LoadProfileFromRepository;
  44493. private static _LoadProfilesFromAvailableControllers;
  44494. }
  44495. }
  44496. declare module BABYLON {
  44497. /**
  44498. * Configuration options for the WebXR controller creation
  44499. */
  44500. export interface IWebXRControllerOptions {
  44501. /**
  44502. * Should the controller mesh be animated when a user interacts with it
  44503. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44504. */
  44505. disableMotionControllerAnimation?: boolean;
  44506. /**
  44507. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44508. */
  44509. doNotLoadControllerMesh?: boolean;
  44510. /**
  44511. * Force a specific controller type for this controller.
  44512. * This can be used when creating your own profile or when testing different controllers
  44513. */
  44514. forceControllerProfile?: string;
  44515. }
  44516. /**
  44517. * Represents an XR controller
  44518. */
  44519. export class WebXRInputSource {
  44520. private _scene;
  44521. /** The underlying input source for the controller */
  44522. inputSource: XRInputSource;
  44523. private _options;
  44524. private _tmpQuaternion;
  44525. private _tmpVector;
  44526. private _uniqueId;
  44527. /**
  44528. * 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
  44529. */
  44530. grip?: AbstractMesh;
  44531. /**
  44532. * If available, this is the gamepad object related to this controller.
  44533. * Using this object it is possible to get click events and trackpad changes of the
  44534. * webxr controller that is currently being used.
  44535. */
  44536. motionController?: WebXRAbstractMotionController;
  44537. /**
  44538. * Event that fires when the controller is removed/disposed.
  44539. * The object provided as event data is this controller, after associated assets were disposed.
  44540. * uniqueId is still available.
  44541. */
  44542. onDisposeObservable: Observable<WebXRInputSource>;
  44543. /**
  44544. * Will be triggered when the mesh associated with the motion controller is done loading.
  44545. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44546. * A shortened version of controller -> motion controller -> on mesh loaded.
  44547. */
  44548. onMeshLoadedObservable: Observable<AbstractMesh>;
  44549. /**
  44550. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44551. */
  44552. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44553. /**
  44554. * Pointer which can be used to select objects or attach a visible laser to
  44555. */
  44556. pointer: AbstractMesh;
  44557. /**
  44558. * Creates the controller
  44559. * @see https://doc.babylonjs.com/how_to/webxr
  44560. * @param _scene the scene which the controller should be associated to
  44561. * @param inputSource the underlying input source for the controller
  44562. * @param _options options for this controller creation
  44563. */
  44564. constructor(_scene: Scene,
  44565. /** The underlying input source for the controller */
  44566. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44567. /**
  44568. * Get this controllers unique id
  44569. */
  44570. get uniqueId(): string;
  44571. /**
  44572. * Disposes of the object
  44573. */
  44574. dispose(): void;
  44575. /**
  44576. * Gets a world space ray coming from the pointer or grip
  44577. * @param result the resulting ray
  44578. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44579. */
  44580. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44581. /**
  44582. * Updates the controller pose based on the given XRFrame
  44583. * @param xrFrame xr frame to update the pose with
  44584. * @param referenceSpace reference space to use
  44585. */
  44586. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44587. }
  44588. }
  44589. declare module BABYLON {
  44590. /**
  44591. * The schema for initialization options of the XR Input class
  44592. */
  44593. export interface IWebXRInputOptions {
  44594. /**
  44595. * If set to true no model will be automatically loaded
  44596. */
  44597. doNotLoadControllerMeshes?: boolean;
  44598. /**
  44599. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44600. * If not found, the xr input profile data will be used.
  44601. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44602. */
  44603. forceInputProfile?: string;
  44604. /**
  44605. * Do not send a request to the controller repository to load the profile.
  44606. *
  44607. * Instead, use the controllers available in babylon itself.
  44608. */
  44609. disableOnlineControllerRepository?: boolean;
  44610. /**
  44611. * A custom URL for the controllers repository
  44612. */
  44613. customControllersRepositoryURL?: string;
  44614. /**
  44615. * Should the controller model's components not move according to the user input
  44616. */
  44617. disableControllerAnimation?: boolean;
  44618. }
  44619. /**
  44620. * XR input used to track XR inputs such as controllers/rays
  44621. */
  44622. export class WebXRInput implements IDisposable {
  44623. /**
  44624. * the xr session manager for this session
  44625. */
  44626. xrSessionManager: WebXRSessionManager;
  44627. /**
  44628. * the WebXR camera for this session. Mainly used for teleportation
  44629. */
  44630. xrCamera: WebXRCamera;
  44631. private readonly options;
  44632. /**
  44633. * XR controllers being tracked
  44634. */
  44635. controllers: Array<WebXRInputSource>;
  44636. private _frameObserver;
  44637. private _sessionEndedObserver;
  44638. private _sessionInitObserver;
  44639. /**
  44640. * Event when a controller has been connected/added
  44641. */
  44642. onControllerAddedObservable: Observable<WebXRInputSource>;
  44643. /**
  44644. * Event when a controller has been removed/disconnected
  44645. */
  44646. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44647. /**
  44648. * Initializes the WebXRInput
  44649. * @param xrSessionManager the xr session manager for this session
  44650. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44651. * @param options = initialization options for this xr input
  44652. */
  44653. constructor(
  44654. /**
  44655. * the xr session manager for this session
  44656. */
  44657. xrSessionManager: WebXRSessionManager,
  44658. /**
  44659. * the WebXR camera for this session. Mainly used for teleportation
  44660. */
  44661. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44662. private _onInputSourcesChange;
  44663. private _addAndRemoveControllers;
  44664. /**
  44665. * Disposes of the object
  44666. */
  44667. dispose(): void;
  44668. }
  44669. }
  44670. declare module BABYLON {
  44671. /**
  44672. * This is the base class for all WebXR features.
  44673. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44674. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44675. */
  44676. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44677. protected _xrSessionManager: WebXRSessionManager;
  44678. private _attached;
  44679. private _removeOnDetach;
  44680. /**
  44681. * Should auto-attach be disabled?
  44682. */
  44683. disableAutoAttach: boolean;
  44684. /**
  44685. * Construct a new (abstract) WebXR feature
  44686. * @param _xrSessionManager the xr session manager for this feature
  44687. */
  44688. constructor(_xrSessionManager: WebXRSessionManager);
  44689. /**
  44690. * Is this feature attached
  44691. */
  44692. get attached(): boolean;
  44693. /**
  44694. * attach this feature
  44695. *
  44696. * @param force should attachment be forced (even when already attached)
  44697. * @returns true if successful, false is failed or already attached
  44698. */
  44699. attach(force?: boolean): boolean;
  44700. /**
  44701. * detach this feature.
  44702. *
  44703. * @returns true if successful, false if failed or already detached
  44704. */
  44705. detach(): boolean;
  44706. /**
  44707. * Dispose this feature and all of the resources attached
  44708. */
  44709. dispose(): void;
  44710. /**
  44711. * This is used to register callbacks that will automatically be removed when detach is called.
  44712. * @param observable the observable to which the observer will be attached
  44713. * @param callback the callback to register
  44714. */
  44715. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44716. /**
  44717. * Code in this function will be executed on each xrFrame received from the browser.
  44718. * This function will not execute after the feature is detached.
  44719. * @param _xrFrame the current frame
  44720. */
  44721. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44722. }
  44723. }
  44724. declare module BABYLON {
  44725. /**
  44726. * Renders a layer on top of an existing scene
  44727. */
  44728. export class UtilityLayerRenderer implements IDisposable {
  44729. /** the original scene that will be rendered on top of */
  44730. originalScene: Scene;
  44731. private _pointerCaptures;
  44732. private _lastPointerEvents;
  44733. private static _DefaultUtilityLayer;
  44734. private static _DefaultKeepDepthUtilityLayer;
  44735. private _sharedGizmoLight;
  44736. private _renderCamera;
  44737. /**
  44738. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44739. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44740. * @returns the camera that is used when rendering the utility layer
  44741. */
  44742. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44743. /**
  44744. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44745. * @param cam the camera that should be used when rendering the utility layer
  44746. */
  44747. setRenderCamera(cam: Nullable<Camera>): void;
  44748. /**
  44749. * @hidden
  44750. * Light which used by gizmos to get light shading
  44751. */
  44752. _getSharedGizmoLight(): HemisphericLight;
  44753. /**
  44754. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44755. */
  44756. pickUtilitySceneFirst: boolean;
  44757. /**
  44758. * 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)
  44759. */
  44760. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44761. /**
  44762. * 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)
  44763. */
  44764. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44765. /**
  44766. * The scene that is rendered on top of the original scene
  44767. */
  44768. utilityLayerScene: Scene;
  44769. /**
  44770. * If the utility layer should automatically be rendered on top of existing scene
  44771. */
  44772. shouldRender: boolean;
  44773. /**
  44774. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44775. */
  44776. onlyCheckPointerDownEvents: boolean;
  44777. /**
  44778. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44779. */
  44780. processAllEvents: boolean;
  44781. /**
  44782. * Observable raised when the pointer move from the utility layer scene to the main scene
  44783. */
  44784. onPointerOutObservable: Observable<number>;
  44785. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44786. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44787. private _afterRenderObserver;
  44788. private _sceneDisposeObserver;
  44789. private _originalPointerObserver;
  44790. /**
  44791. * Instantiates a UtilityLayerRenderer
  44792. * @param originalScene the original scene that will be rendered on top of
  44793. * @param handleEvents boolean indicating if the utility layer should handle events
  44794. */
  44795. constructor(
  44796. /** the original scene that will be rendered on top of */
  44797. originalScene: Scene, handleEvents?: boolean);
  44798. private _notifyObservers;
  44799. /**
  44800. * Renders the utility layers scene on top of the original scene
  44801. */
  44802. render(): void;
  44803. /**
  44804. * Disposes of the renderer
  44805. */
  44806. dispose(): void;
  44807. private _updateCamera;
  44808. }
  44809. }
  44810. declare module BABYLON {
  44811. /**
  44812. * Options interface for the pointer selection module
  44813. */
  44814. export interface IWebXRControllerPointerSelectionOptions {
  44815. /**
  44816. * if provided, this scene will be used to render meshes.
  44817. */
  44818. customUtilityLayerScene?: Scene;
  44819. /**
  44820. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  44821. * If not disabled, the last picked point will be used to execute a pointer up event
  44822. * If disabled, pointer up event will be triggered right after the pointer down event.
  44823. * Used in screen and gaze target ray mode only
  44824. */
  44825. disablePointerUpOnTouchOut: boolean;
  44826. /**
  44827. * For gaze mode (time to select instead of press)
  44828. */
  44829. forceGazeMode: boolean;
  44830. /**
  44831. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  44832. * to start a new countdown to the pointer down event.
  44833. * Defaults to 1.
  44834. */
  44835. gazeModePointerMovedFactor?: number;
  44836. /**
  44837. * Different button type to use instead of the main component
  44838. */
  44839. overrideButtonId?: string;
  44840. /**
  44841. * use this rendering group id for the meshes (optional)
  44842. */
  44843. renderingGroupId?: number;
  44844. /**
  44845. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44846. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44847. * 3000 means 3 seconds between pointing at something and selecting it
  44848. */
  44849. timeToSelect?: number;
  44850. /**
  44851. * Should meshes created here be added to a utility layer or the main scene
  44852. */
  44853. useUtilityLayer?: boolean;
  44854. /**
  44855. * the xr input to use with this pointer selection
  44856. */
  44857. xrInput: WebXRInput;
  44858. }
  44859. /**
  44860. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44861. */
  44862. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44863. private readonly _options;
  44864. private static _idCounter;
  44865. private _attachController;
  44866. private _controllers;
  44867. private _scene;
  44868. private _tmpVectorForPickCompare;
  44869. /**
  44870. * The module's name
  44871. */
  44872. static readonly Name: string;
  44873. /**
  44874. * The (Babylon) version of this module.
  44875. * This is an integer representing the implementation version.
  44876. * This number does not correspond to the WebXR specs version
  44877. */
  44878. static readonly Version: number;
  44879. /**
  44880. * Disable lighting on the laser pointer (so it will always be visible)
  44881. */
  44882. disablePointerLighting: boolean;
  44883. /**
  44884. * Disable lighting on the selection mesh (so it will always be visible)
  44885. */
  44886. disableSelectionMeshLighting: boolean;
  44887. /**
  44888. * Should the laser pointer be displayed
  44889. */
  44890. displayLaserPointer: boolean;
  44891. /**
  44892. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44893. */
  44894. displaySelectionMesh: boolean;
  44895. /**
  44896. * This color will be set to the laser pointer when selection is triggered
  44897. */
  44898. laserPointerPickedColor: Color3;
  44899. /**
  44900. * Default color of the laser pointer
  44901. */
  44902. lasterPointerDefaultColor: Color3;
  44903. /**
  44904. * default color of the selection ring
  44905. */
  44906. selectionMeshDefaultColor: Color3;
  44907. /**
  44908. * This color will be applied to the selection ring when selection is triggered
  44909. */
  44910. selectionMeshPickedColor: Color3;
  44911. /**
  44912. * Optional filter to be used for ray selection. This predicate shares behavior with
  44913. * scene.pointerMovePredicate which takes priority if it is also assigned.
  44914. */
  44915. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44916. /**
  44917. * constructs a new background remover module
  44918. * @param _xrSessionManager the session manager for this module
  44919. * @param _options read-only options to be used in this module
  44920. */
  44921. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44922. /**
  44923. * attach this feature
  44924. * Will usually be called by the features manager
  44925. *
  44926. * @returns true if successful.
  44927. */
  44928. attach(): boolean;
  44929. /**
  44930. * detach this feature.
  44931. * Will usually be called by the features manager
  44932. *
  44933. * @returns true if successful.
  44934. */
  44935. detach(): boolean;
  44936. /**
  44937. * Will get the mesh under a specific pointer.
  44938. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  44939. * @param controllerId the controllerId to check
  44940. * @returns The mesh under pointer or null if no mesh is under the pointer
  44941. */
  44942. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  44943. /**
  44944. * Get the xr controller that correlates to the pointer id in the pointer event
  44945. *
  44946. * @param id the pointer id to search for
  44947. * @returns the controller that correlates to this id or null if not found
  44948. */
  44949. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  44950. protected _onXRFrame(_xrFrame: XRFrame): void;
  44951. private _attachGazeMode;
  44952. private _attachScreenRayMode;
  44953. private _attachTrackedPointerRayMode;
  44954. private _convertNormalToDirectionOfRay;
  44955. private _detachController;
  44956. private _generateNewMeshPair;
  44957. private _pickingMoved;
  44958. private _updatePointerDistance;
  44959. }
  44960. }
  44961. declare module BABYLON {
  44962. /**
  44963. * Button which can be used to enter a different mode of XR
  44964. */
  44965. export class WebXREnterExitUIButton {
  44966. /** button element */
  44967. element: HTMLElement;
  44968. /** XR initialization options for the button */
  44969. sessionMode: XRSessionMode;
  44970. /** Reference space type */
  44971. referenceSpaceType: XRReferenceSpaceType;
  44972. /**
  44973. * Creates a WebXREnterExitUIButton
  44974. * @param element button element
  44975. * @param sessionMode XR initialization session mode
  44976. * @param referenceSpaceType the type of reference space to be used
  44977. */
  44978. constructor(
  44979. /** button element */
  44980. element: HTMLElement,
  44981. /** XR initialization options for the button */
  44982. sessionMode: XRSessionMode,
  44983. /** Reference space type */
  44984. referenceSpaceType: XRReferenceSpaceType);
  44985. /**
  44986. * Extendable function which can be used to update the button's visuals when the state changes
  44987. * @param activeButton the current active button in the UI
  44988. */
  44989. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44990. }
  44991. /**
  44992. * Options to create the webXR UI
  44993. */
  44994. export class WebXREnterExitUIOptions {
  44995. /**
  44996. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44997. */
  44998. customButtons?: Array<WebXREnterExitUIButton>;
  44999. /**
  45000. * A reference space type to use when creating the default button.
  45001. * Default is local-floor
  45002. */
  45003. referenceSpaceType?: XRReferenceSpaceType;
  45004. /**
  45005. * Context to enter xr with
  45006. */
  45007. renderTarget?: Nullable<WebXRRenderTarget>;
  45008. /**
  45009. * A session mode to use when creating the default button.
  45010. * Default is immersive-vr
  45011. */
  45012. sessionMode?: XRSessionMode;
  45013. }
  45014. /**
  45015. * UI to allow the user to enter/exit XR mode
  45016. */
  45017. export class WebXREnterExitUI implements IDisposable {
  45018. private scene;
  45019. /** version of the options passed to this UI */
  45020. options: WebXREnterExitUIOptions;
  45021. private _activeButton;
  45022. private _buttons;
  45023. private _overlay;
  45024. /**
  45025. * Fired every time the active button is changed.
  45026. *
  45027. * When xr is entered via a button that launches xr that button will be the callback parameter
  45028. *
  45029. * When exiting xr the callback parameter will be null)
  45030. */
  45031. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45032. /**
  45033. *
  45034. * @param scene babylon scene object to use
  45035. * @param options (read-only) version of the options passed to this UI
  45036. */
  45037. private constructor();
  45038. /**
  45039. * Creates UI to allow the user to enter/exit XR mode
  45040. * @param scene the scene to add the ui to
  45041. * @param helper the xr experience helper to enter/exit xr with
  45042. * @param options options to configure the UI
  45043. * @returns the created ui
  45044. */
  45045. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45046. /**
  45047. * Disposes of the XR UI component
  45048. */
  45049. dispose(): void;
  45050. private _updateButtons;
  45051. }
  45052. }
  45053. declare module BABYLON {
  45054. /**
  45055. * Class containing static functions to help procedurally build meshes
  45056. */
  45057. export class LinesBuilder {
  45058. /**
  45059. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45060. * * 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
  45061. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45062. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45063. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45064. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45065. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45066. * * 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
  45067. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45069. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45070. * @param name defines the name of the new line system
  45071. * @param options defines the options used to create the line system
  45072. * @param scene defines the hosting scene
  45073. * @returns a new line system mesh
  45074. */
  45075. static CreateLineSystem(name: string, options: {
  45076. lines: Vector3[][];
  45077. updatable?: boolean;
  45078. instance?: Nullable<LinesMesh>;
  45079. colors?: Nullable<Color4[][]>;
  45080. useVertexAlpha?: boolean;
  45081. }, scene: Nullable<Scene>): LinesMesh;
  45082. /**
  45083. * Creates a line mesh
  45084. * 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
  45085. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45086. * * The parameter `points` is an array successive Vector3
  45087. * * 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
  45088. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45089. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45090. * * When updating an instance, remember that only point positions can change, not the number of points
  45091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45092. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45093. * @param name defines the name of the new line system
  45094. * @param options defines the options used to create the line system
  45095. * @param scene defines the hosting scene
  45096. * @returns a new line mesh
  45097. */
  45098. static CreateLines(name: string, options: {
  45099. points: Vector3[];
  45100. updatable?: boolean;
  45101. instance?: Nullable<LinesMesh>;
  45102. colors?: Color4[];
  45103. useVertexAlpha?: boolean;
  45104. }, scene?: Nullable<Scene>): LinesMesh;
  45105. /**
  45106. * Creates a dashed line mesh
  45107. * * 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
  45108. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45109. * * The parameter `points` is an array successive Vector3
  45110. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45111. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45112. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45113. * * 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
  45114. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45115. * * When updating an instance, remember that only point positions can change, not the number of points
  45116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45117. * @param name defines the name of the mesh
  45118. * @param options defines the options used to create the mesh
  45119. * @param scene defines the hosting scene
  45120. * @returns the dashed line mesh
  45121. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45122. */
  45123. static CreateDashedLines(name: string, options: {
  45124. points: Vector3[];
  45125. dashSize?: number;
  45126. gapSize?: number;
  45127. dashNb?: number;
  45128. updatable?: boolean;
  45129. instance?: LinesMesh;
  45130. useVertexAlpha?: boolean;
  45131. }, scene?: Nullable<Scene>): LinesMesh;
  45132. }
  45133. }
  45134. declare module BABYLON {
  45135. /**
  45136. * The options container for the teleportation module
  45137. */
  45138. export interface IWebXRTeleportationOptions {
  45139. /**
  45140. * if provided, this scene will be used to render meshes.
  45141. */
  45142. customUtilityLayerScene?: Scene;
  45143. /**
  45144. * Values to configure the default target mesh
  45145. */
  45146. defaultTargetMeshOptions?: {
  45147. /**
  45148. * Fill color of the teleportation area
  45149. */
  45150. teleportationFillColor?: string;
  45151. /**
  45152. * Border color for the teleportation area
  45153. */
  45154. teleportationBorderColor?: string;
  45155. /**
  45156. * Disable the mesh's animation sequence
  45157. */
  45158. disableAnimation?: boolean;
  45159. /**
  45160. * Disable lighting on the material or the ring and arrow
  45161. */
  45162. disableLighting?: boolean;
  45163. /**
  45164. * Override the default material of the torus and arrow
  45165. */
  45166. torusArrowMaterial?: Material;
  45167. };
  45168. /**
  45169. * A list of meshes to use as floor meshes.
  45170. * Meshes can be added and removed after initializing the feature using the
  45171. * addFloorMesh and removeFloorMesh functions
  45172. * If empty, rotation will still work
  45173. */
  45174. floorMeshes?: AbstractMesh[];
  45175. /**
  45176. * use this rendering group id for the meshes (optional)
  45177. */
  45178. renderingGroupId?: number;
  45179. /**
  45180. * Should teleportation move only to snap points
  45181. */
  45182. snapPointsOnly?: boolean;
  45183. /**
  45184. * An array of points to which the teleportation will snap to.
  45185. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  45186. */
  45187. snapPositions?: Vector3[];
  45188. /**
  45189. * How close should the teleportation ray be in order to snap to position.
  45190. * Default to 0.8 units (meters)
  45191. */
  45192. snapToPositionRadius?: number;
  45193. /**
  45194. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45195. * If you want to support rotation, make sure your mesh has a direction indicator.
  45196. *
  45197. * When left untouched, the default mesh will be initialized.
  45198. */
  45199. teleportationTargetMesh?: AbstractMesh;
  45200. /**
  45201. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  45202. */
  45203. timeToTeleport?: number;
  45204. /**
  45205. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  45206. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  45207. */
  45208. useMainComponentOnly?: boolean;
  45209. /**
  45210. * Should meshes created here be added to a utility layer or the main scene
  45211. */
  45212. useUtilityLayer?: boolean;
  45213. /**
  45214. * Babylon XR Input class for controller
  45215. */
  45216. xrInput: WebXRInput;
  45217. }
  45218. /**
  45219. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  45220. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  45221. * the input of the attached controllers.
  45222. */
  45223. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45224. private _options;
  45225. private _controllers;
  45226. private _currentTeleportationControllerId;
  45227. private _floorMeshes;
  45228. private _quadraticBezierCurve;
  45229. private _selectionFeature;
  45230. private _snapToPositions;
  45231. private _snappedToPoint;
  45232. private _teleportationRingMaterial?;
  45233. private _tmpRay;
  45234. private _tmpVector;
  45235. /**
  45236. * The module's name
  45237. */
  45238. static readonly Name: string;
  45239. /**
  45240. * The (Babylon) version of this module.
  45241. * This is an integer representing the implementation version.
  45242. * This number does not correspond to the webxr specs version
  45243. */
  45244. static readonly Version: number;
  45245. /**
  45246. * Is movement backwards enabled
  45247. */
  45248. backwardsMovementEnabled: boolean;
  45249. /**
  45250. * Distance to travel when moving backwards
  45251. */
  45252. backwardsTeleportationDistance: number;
  45253. /**
  45254. * The distance from the user to the inspection point in the direction of the controller
  45255. * A higher number will allow the user to move further
  45256. * defaults to 5 (meters, in xr units)
  45257. */
  45258. parabolicCheckRadius: number;
  45259. /**
  45260. * Should the module support parabolic ray on top of direct ray
  45261. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45262. * Very helpful when moving between floors / different heights
  45263. */
  45264. parabolicRayEnabled: boolean;
  45265. /**
  45266. * How much rotation should be applied when rotating right and left
  45267. */
  45268. rotationAngle: number;
  45269. /**
  45270. * Is rotation enabled when moving forward?
  45271. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45272. */
  45273. rotationEnabled: boolean;
  45274. /**
  45275. * constructs a new anchor system
  45276. * @param _xrSessionManager an instance of WebXRSessionManager
  45277. * @param _options configuration object for this feature
  45278. */
  45279. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45280. /**
  45281. * Get the snapPointsOnly flag
  45282. */
  45283. get snapPointsOnly(): boolean;
  45284. /**
  45285. * Sets the snapPointsOnly flag
  45286. * @param snapToPoints should teleportation be exclusively to snap points
  45287. */
  45288. set snapPointsOnly(snapToPoints: boolean);
  45289. /**
  45290. * Add a new mesh to the floor meshes array
  45291. * @param mesh the mesh to use as floor mesh
  45292. */
  45293. addFloorMesh(mesh: AbstractMesh): void;
  45294. /**
  45295. * Add a new snap-to point to fix teleportation to this position
  45296. * @param newSnapPoint The new Snap-To point
  45297. */
  45298. addSnapPoint(newSnapPoint: Vector3): void;
  45299. attach(): boolean;
  45300. detach(): boolean;
  45301. dispose(): void;
  45302. /**
  45303. * Remove a mesh from the floor meshes array
  45304. * @param mesh the mesh to remove
  45305. */
  45306. removeFloorMesh(mesh: AbstractMesh): void;
  45307. /**
  45308. * Remove a mesh from the floor meshes array using its name
  45309. * @param name the mesh name to remove
  45310. */
  45311. removeFloorMeshByName(name: string): void;
  45312. /**
  45313. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  45314. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45315. * @returns was the point found and removed or not
  45316. */
  45317. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45318. /**
  45319. * This function sets a selection feature that will be disabled when
  45320. * the forward ray is shown and will be reattached when hidden.
  45321. * This is used to remove the selection rays when moving.
  45322. * @param selectionFeature the feature to disable when forward movement is enabled
  45323. */
  45324. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45325. protected _onXRFrame(_xrFrame: XRFrame): void;
  45326. private _attachController;
  45327. private _createDefaultTargetMesh;
  45328. private _detachController;
  45329. private _findClosestSnapPointWithRadius;
  45330. private _setTargetMeshPosition;
  45331. private _setTargetMeshVisibility;
  45332. private _showParabolicPath;
  45333. private _teleportForward;
  45334. }
  45335. }
  45336. declare module BABYLON {
  45337. /**
  45338. * Options for the default xr helper
  45339. */
  45340. export class WebXRDefaultExperienceOptions {
  45341. /**
  45342. * Enable or disable default UI to enter XR
  45343. */
  45344. disableDefaultUI?: boolean;
  45345. /**
  45346. * Should teleportation not initialize. defaults to false.
  45347. */
  45348. disableTeleportation?: boolean;
  45349. /**
  45350. * Floor meshes that will be used for teleport
  45351. */
  45352. floorMeshes?: Array<AbstractMesh>;
  45353. /**
  45354. * If set to true, the first frame will not be used to reset position
  45355. * The first frame is mainly used when copying transformation from the old camera
  45356. * Mainly used in AR
  45357. */
  45358. ignoreNativeCameraTransformation?: boolean;
  45359. /**
  45360. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45361. */
  45362. inputOptions?: IWebXRInputOptions;
  45363. /**
  45364. * optional configuration for the output canvas
  45365. */
  45366. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45367. /**
  45368. * optional UI options. This can be used among other to change session mode and reference space type
  45369. */
  45370. uiOptions?: WebXREnterExitUIOptions;
  45371. /**
  45372. * When loading teleportation and pointer select, use stable versions instead of latest.
  45373. */
  45374. useStablePlugins?: boolean;
  45375. }
  45376. /**
  45377. * Default experience which provides a similar setup to the previous webVRExperience
  45378. */
  45379. export class WebXRDefaultExperience {
  45380. /**
  45381. * Base experience
  45382. */
  45383. baseExperience: WebXRExperienceHelper;
  45384. /**
  45385. * Enables ui for entering/exiting xr
  45386. */
  45387. enterExitUI: WebXREnterExitUI;
  45388. /**
  45389. * Input experience extension
  45390. */
  45391. input: WebXRInput;
  45392. /**
  45393. * Enables laser pointer and selection
  45394. */
  45395. pointerSelection: WebXRControllerPointerSelection;
  45396. /**
  45397. * Default target xr should render to
  45398. */
  45399. renderTarget: WebXRRenderTarget;
  45400. /**
  45401. * Enables teleportation
  45402. */
  45403. teleportation: WebXRMotionControllerTeleportation;
  45404. private constructor();
  45405. /**
  45406. * Creates the default xr experience
  45407. * @param scene scene
  45408. * @param options options for basic configuration
  45409. * @returns resulting WebXRDefaultExperience
  45410. */
  45411. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45412. /**
  45413. * DIsposes of the experience helper
  45414. */
  45415. dispose(): void;
  45416. }
  45417. }
  45418. declare module BABYLON {
  45419. /**
  45420. * Options to modify the vr teleportation behavior.
  45421. */
  45422. export interface VRTeleportationOptions {
  45423. /**
  45424. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45425. */
  45426. floorMeshName?: string;
  45427. /**
  45428. * A list of meshes to be used as the teleportation floor. (default: empty)
  45429. */
  45430. floorMeshes?: Mesh[];
  45431. /**
  45432. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45433. */
  45434. teleportationMode?: number;
  45435. /**
  45436. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45437. */
  45438. teleportationTime?: number;
  45439. /**
  45440. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45441. */
  45442. teleportationSpeed?: number;
  45443. /**
  45444. * The easing function used in the animation or null for Linear. (default CircleEase)
  45445. */
  45446. easingFunction?: EasingFunction;
  45447. }
  45448. /**
  45449. * Options to modify the vr experience helper's behavior.
  45450. */
  45451. export interface VRExperienceHelperOptions extends WebVROptions {
  45452. /**
  45453. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45454. */
  45455. createDeviceOrientationCamera?: boolean;
  45456. /**
  45457. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45458. */
  45459. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45460. /**
  45461. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45462. */
  45463. laserToggle?: boolean;
  45464. /**
  45465. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45466. */
  45467. floorMeshes?: Mesh[];
  45468. /**
  45469. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45470. */
  45471. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45472. /**
  45473. * Defines if WebXR should be used instead of WebVR (if available)
  45474. */
  45475. useXR?: boolean;
  45476. }
  45477. /**
  45478. * Event containing information after VR has been entered
  45479. */
  45480. export class OnAfterEnteringVRObservableEvent {
  45481. /**
  45482. * If entering vr was successful
  45483. */
  45484. success: boolean;
  45485. }
  45486. /**
  45487. * Helps to quickly add VR support to an existing scene.
  45488. * See http://doc.babylonjs.com/how_to/webvr_helper
  45489. */
  45490. export class VRExperienceHelper {
  45491. /** Options to modify the vr experience helper's behavior. */
  45492. webVROptions: VRExperienceHelperOptions;
  45493. private _scene;
  45494. private _position;
  45495. private _btnVR;
  45496. private _btnVRDisplayed;
  45497. private _webVRsupported;
  45498. private _webVRready;
  45499. private _webVRrequesting;
  45500. private _webVRpresenting;
  45501. private _hasEnteredVR;
  45502. private _fullscreenVRpresenting;
  45503. private _inputElement;
  45504. private _webVRCamera;
  45505. private _vrDeviceOrientationCamera;
  45506. private _deviceOrientationCamera;
  45507. private _existingCamera;
  45508. private _onKeyDown;
  45509. private _onVrDisplayPresentChange;
  45510. private _onVRDisplayChanged;
  45511. private _onVRRequestPresentStart;
  45512. private _onVRRequestPresentComplete;
  45513. /**
  45514. * 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)
  45515. */
  45516. enableGazeEvenWhenNoPointerLock: boolean;
  45517. /**
  45518. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45519. */
  45520. exitVROnDoubleTap: boolean;
  45521. /**
  45522. * Observable raised right before entering VR.
  45523. */
  45524. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45525. /**
  45526. * Observable raised when entering VR has completed.
  45527. */
  45528. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45529. /**
  45530. * Observable raised when exiting VR.
  45531. */
  45532. onExitingVRObservable: Observable<VRExperienceHelper>;
  45533. /**
  45534. * Observable raised when controller mesh is loaded.
  45535. */
  45536. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45537. /** Return this.onEnteringVRObservable
  45538. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45539. */
  45540. get onEnteringVR(): Observable<VRExperienceHelper>;
  45541. /** Return this.onExitingVRObservable
  45542. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45543. */
  45544. get onExitingVR(): Observable<VRExperienceHelper>;
  45545. /** Return this.onControllerMeshLoadedObservable
  45546. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45547. */
  45548. get onControllerMeshLoaded(): Observable<WebVRController>;
  45549. private _rayLength;
  45550. private _useCustomVRButton;
  45551. private _teleportationRequested;
  45552. private _teleportActive;
  45553. private _floorMeshName;
  45554. private _floorMeshesCollection;
  45555. private _teleportationMode;
  45556. private _teleportationTime;
  45557. private _teleportationSpeed;
  45558. private _teleportationEasing;
  45559. private _rotationAllowed;
  45560. private _teleportBackwardsVector;
  45561. private _teleportationTarget;
  45562. private _isDefaultTeleportationTarget;
  45563. private _postProcessMove;
  45564. private _teleportationFillColor;
  45565. private _teleportationBorderColor;
  45566. private _rotationAngle;
  45567. private _haloCenter;
  45568. private _cameraGazer;
  45569. private _padSensibilityUp;
  45570. private _padSensibilityDown;
  45571. private _leftController;
  45572. private _rightController;
  45573. private _gazeColor;
  45574. private _laserColor;
  45575. private _pickedLaserColor;
  45576. private _pickedGazeColor;
  45577. /**
  45578. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45579. */
  45580. onNewMeshSelected: Observable<AbstractMesh>;
  45581. /**
  45582. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45583. * This observable will provide the mesh and the controller used to select the mesh
  45584. */
  45585. onMeshSelectedWithController: Observable<{
  45586. mesh: AbstractMesh;
  45587. controller: WebVRController;
  45588. }>;
  45589. /**
  45590. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45591. */
  45592. onNewMeshPicked: Observable<PickingInfo>;
  45593. private _circleEase;
  45594. /**
  45595. * Observable raised before camera teleportation
  45596. */
  45597. onBeforeCameraTeleport: Observable<Vector3>;
  45598. /**
  45599. * Observable raised after camera teleportation
  45600. */
  45601. onAfterCameraTeleport: Observable<Vector3>;
  45602. /**
  45603. * Observable raised when current selected mesh gets unselected
  45604. */
  45605. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45606. private _raySelectionPredicate;
  45607. /**
  45608. * To be optionaly changed by user to define custom ray selection
  45609. */
  45610. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45611. /**
  45612. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45613. */
  45614. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45615. /**
  45616. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45617. */
  45618. teleportationEnabled: boolean;
  45619. private _defaultHeight;
  45620. private _teleportationInitialized;
  45621. private _interactionsEnabled;
  45622. private _interactionsRequested;
  45623. private _displayGaze;
  45624. private _displayLaserPointer;
  45625. /**
  45626. * The mesh used to display where the user is going to teleport.
  45627. */
  45628. get teleportationTarget(): Mesh;
  45629. /**
  45630. * Sets the mesh to be used to display where the user is going to teleport.
  45631. */
  45632. set teleportationTarget(value: Mesh);
  45633. /**
  45634. * 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
  45635. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45636. * See http://doc.babylonjs.com/resources/baking_transformations
  45637. */
  45638. get gazeTrackerMesh(): Mesh;
  45639. set gazeTrackerMesh(value: Mesh);
  45640. /**
  45641. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45642. */
  45643. updateGazeTrackerScale: boolean;
  45644. /**
  45645. * If the gaze trackers color should be updated when selecting meshes
  45646. */
  45647. updateGazeTrackerColor: boolean;
  45648. /**
  45649. * If the controller laser color should be updated when selecting meshes
  45650. */
  45651. updateControllerLaserColor: boolean;
  45652. /**
  45653. * The gaze tracking mesh corresponding to the left controller
  45654. */
  45655. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45656. /**
  45657. * The gaze tracking mesh corresponding to the right controller
  45658. */
  45659. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45660. /**
  45661. * If the ray of the gaze should be displayed.
  45662. */
  45663. get displayGaze(): boolean;
  45664. /**
  45665. * Sets if the ray of the gaze should be displayed.
  45666. */
  45667. set displayGaze(value: boolean);
  45668. /**
  45669. * If the ray of the LaserPointer should be displayed.
  45670. */
  45671. get displayLaserPointer(): boolean;
  45672. /**
  45673. * Sets if the ray of the LaserPointer should be displayed.
  45674. */
  45675. set displayLaserPointer(value: boolean);
  45676. /**
  45677. * The deviceOrientationCamera used as the camera when not in VR.
  45678. */
  45679. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45680. /**
  45681. * Based on the current WebVR support, returns the current VR camera used.
  45682. */
  45683. get currentVRCamera(): Nullable<Camera>;
  45684. /**
  45685. * The webVRCamera which is used when in VR.
  45686. */
  45687. get webVRCamera(): WebVRFreeCamera;
  45688. /**
  45689. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45690. */
  45691. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45692. /**
  45693. * The html button that is used to trigger entering into VR.
  45694. */
  45695. get vrButton(): Nullable<HTMLButtonElement>;
  45696. private get _teleportationRequestInitiated();
  45697. /**
  45698. * Defines whether or not Pointer lock should be requested when switching to
  45699. * full screen.
  45700. */
  45701. requestPointerLockOnFullScreen: boolean;
  45702. /**
  45703. * If asking to force XR, this will be populated with the default xr experience
  45704. */
  45705. xr: WebXRDefaultExperience;
  45706. /**
  45707. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45708. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45709. */
  45710. xrTestDone: boolean;
  45711. /**
  45712. * Instantiates a VRExperienceHelper.
  45713. * Helps to quickly add VR support to an existing scene.
  45714. * @param scene The scene the VRExperienceHelper belongs to.
  45715. * @param webVROptions Options to modify the vr experience helper's behavior.
  45716. */
  45717. constructor(scene: Scene,
  45718. /** Options to modify the vr experience helper's behavior. */
  45719. webVROptions?: VRExperienceHelperOptions);
  45720. private completeVRInit;
  45721. private _onDefaultMeshLoaded;
  45722. private _onResize;
  45723. private _onFullscreenChange;
  45724. /**
  45725. * Gets a value indicating if we are currently in VR mode.
  45726. */
  45727. get isInVRMode(): boolean;
  45728. private onVrDisplayPresentChange;
  45729. private onVRDisplayChanged;
  45730. private moveButtonToBottomRight;
  45731. private displayVRButton;
  45732. private updateButtonVisibility;
  45733. private _cachedAngularSensibility;
  45734. /**
  45735. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45736. * Otherwise, will use the fullscreen API.
  45737. */
  45738. enterVR(): void;
  45739. /**
  45740. * Attempt to exit VR, or fullscreen.
  45741. */
  45742. exitVR(): void;
  45743. /**
  45744. * The position of the vr experience helper.
  45745. */
  45746. get position(): Vector3;
  45747. /**
  45748. * Sets the position of the vr experience helper.
  45749. */
  45750. set position(value: Vector3);
  45751. /**
  45752. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45753. */
  45754. enableInteractions(): void;
  45755. private get _noControllerIsActive();
  45756. private beforeRender;
  45757. private _isTeleportationFloor;
  45758. /**
  45759. * Adds a floor mesh to be used for teleportation.
  45760. * @param floorMesh the mesh to be used for teleportation.
  45761. */
  45762. addFloorMesh(floorMesh: Mesh): void;
  45763. /**
  45764. * Removes a floor mesh from being used for teleportation.
  45765. * @param floorMesh the mesh to be removed.
  45766. */
  45767. removeFloorMesh(floorMesh: Mesh): void;
  45768. /**
  45769. * Enables interactions and teleportation using the VR controllers and gaze.
  45770. * @param vrTeleportationOptions options to modify teleportation behavior.
  45771. */
  45772. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45773. private _onNewGamepadConnected;
  45774. private _tryEnableInteractionOnController;
  45775. private _onNewGamepadDisconnected;
  45776. private _enableInteractionOnController;
  45777. private _checkTeleportWithRay;
  45778. private _checkRotate;
  45779. private _checkTeleportBackwards;
  45780. private _enableTeleportationOnController;
  45781. private _createTeleportationCircles;
  45782. private _displayTeleportationTarget;
  45783. private _hideTeleportationTarget;
  45784. private _rotateCamera;
  45785. private _moveTeleportationSelectorTo;
  45786. private _workingVector;
  45787. private _workingQuaternion;
  45788. private _workingMatrix;
  45789. /**
  45790. * Time Constant Teleportation Mode
  45791. */
  45792. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45793. /**
  45794. * Speed Constant Teleportation Mode
  45795. */
  45796. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45797. /**
  45798. * Teleports the users feet to the desired location
  45799. * @param location The location where the user's feet should be placed
  45800. */
  45801. teleportCamera(location: Vector3): void;
  45802. private _convertNormalToDirectionOfRay;
  45803. private _castRayAndSelectObject;
  45804. private _notifySelectedMeshUnselected;
  45805. /**
  45806. * Permanently set new colors for the laser pointer
  45807. * @param color the new laser color
  45808. * @param pickedColor the new laser color when picked mesh detected
  45809. */
  45810. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45811. /**
  45812. * Set lighting enabled / disabled on the laser pointer of both controllers
  45813. * @param enabled should the lighting be enabled on the laser pointer
  45814. */
  45815. setLaserLightingState(enabled?: boolean): void;
  45816. /**
  45817. * Permanently set new colors for the gaze pointer
  45818. * @param color the new gaze color
  45819. * @param pickedColor the new gaze color when picked mesh detected
  45820. */
  45821. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45822. /**
  45823. * Sets the color of the laser ray from the vr controllers.
  45824. * @param color new color for the ray.
  45825. */
  45826. changeLaserColor(color: Color3): void;
  45827. /**
  45828. * Sets the color of the ray from the vr headsets gaze.
  45829. * @param color new color for the ray.
  45830. */
  45831. changeGazeColor(color: Color3): void;
  45832. /**
  45833. * Exits VR and disposes of the vr experience helper
  45834. */
  45835. dispose(): void;
  45836. /**
  45837. * Gets the name of the VRExperienceHelper class
  45838. * @returns "VRExperienceHelper"
  45839. */
  45840. getClassName(): string;
  45841. }
  45842. }
  45843. declare module BABYLON {
  45844. /**
  45845. * Contains an array of blocks representing the octree
  45846. */
  45847. export interface IOctreeContainer<T> {
  45848. /**
  45849. * Blocks within the octree
  45850. */
  45851. blocks: Array<OctreeBlock<T>>;
  45852. }
  45853. /**
  45854. * Class used to store a cell in an octree
  45855. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45856. */
  45857. export class OctreeBlock<T> {
  45858. /**
  45859. * Gets the content of the current block
  45860. */
  45861. entries: T[];
  45862. /**
  45863. * Gets the list of block children
  45864. */
  45865. blocks: Array<OctreeBlock<T>>;
  45866. private _depth;
  45867. private _maxDepth;
  45868. private _capacity;
  45869. private _minPoint;
  45870. private _maxPoint;
  45871. private _boundingVectors;
  45872. private _creationFunc;
  45873. /**
  45874. * Creates a new block
  45875. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45876. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45877. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45878. * @param depth defines the current depth of this block in the octree
  45879. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45880. * @param creationFunc defines a callback to call when an element is added to the block
  45881. */
  45882. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45883. /**
  45884. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45885. */
  45886. get capacity(): number;
  45887. /**
  45888. * Gets the minimum vector (in world space) of the block's bounding box
  45889. */
  45890. get minPoint(): Vector3;
  45891. /**
  45892. * Gets the maximum vector (in world space) of the block's bounding box
  45893. */
  45894. get maxPoint(): Vector3;
  45895. /**
  45896. * Add a new element to this block
  45897. * @param entry defines the element to add
  45898. */
  45899. addEntry(entry: T): void;
  45900. /**
  45901. * Remove an element from this block
  45902. * @param entry defines the element to remove
  45903. */
  45904. removeEntry(entry: T): void;
  45905. /**
  45906. * Add an array of elements to this block
  45907. * @param entries defines the array of elements to add
  45908. */
  45909. addEntries(entries: T[]): void;
  45910. /**
  45911. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45912. * @param frustumPlanes defines the frustum planes to test
  45913. * @param selection defines the array to store current content if selection is positive
  45914. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45915. */
  45916. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45917. /**
  45918. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45919. * @param sphereCenter defines the bounding sphere center
  45920. * @param sphereRadius defines the bounding sphere radius
  45921. * @param selection defines the array to store current content if selection is positive
  45922. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45923. */
  45924. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45925. /**
  45926. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45927. * @param ray defines the ray to test with
  45928. * @param selection defines the array to store current content if selection is positive
  45929. */
  45930. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45931. /**
  45932. * Subdivide the content into child blocks (this block will then be empty)
  45933. */
  45934. createInnerBlocks(): void;
  45935. /**
  45936. * @hidden
  45937. */
  45938. 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;
  45939. }
  45940. }
  45941. declare module BABYLON {
  45942. /**
  45943. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45944. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45945. */
  45946. export class Octree<T> {
  45947. /** 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.) */
  45948. maxDepth: number;
  45949. /**
  45950. * Blocks within the octree containing objects
  45951. */
  45952. blocks: Array<OctreeBlock<T>>;
  45953. /**
  45954. * Content stored in the octree
  45955. */
  45956. dynamicContent: T[];
  45957. private _maxBlockCapacity;
  45958. private _selectionContent;
  45959. private _creationFunc;
  45960. /**
  45961. * Creates a octree
  45962. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45963. * @param creationFunc function to be used to instatiate the octree
  45964. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45965. * @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.)
  45966. */
  45967. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45968. /** 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.) */
  45969. maxDepth?: number);
  45970. /**
  45971. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45972. * @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);
  45973. * @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);
  45974. * @param entries meshes to be added to the octree blocks
  45975. */
  45976. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45977. /**
  45978. * Adds a mesh to the octree
  45979. * @param entry Mesh to add to the octree
  45980. */
  45981. addMesh(entry: T): void;
  45982. /**
  45983. * Remove an element from the octree
  45984. * @param entry defines the element to remove
  45985. */
  45986. removeMesh(entry: T): void;
  45987. /**
  45988. * Selects an array of meshes within the frustum
  45989. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45990. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45991. * @returns array of meshes within the frustum
  45992. */
  45993. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45994. /**
  45995. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45996. * @param sphereCenter defines the bounding sphere center
  45997. * @param sphereRadius defines the bounding sphere radius
  45998. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45999. * @returns an array of objects that intersect the sphere
  46000. */
  46001. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46002. /**
  46003. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46004. * @param ray defines the ray to test with
  46005. * @returns array of intersected objects
  46006. */
  46007. intersectsRay(ray: Ray): SmartArray<T>;
  46008. /**
  46009. * Adds a mesh into the octree block if it intersects the block
  46010. */
  46011. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46012. /**
  46013. * Adds a submesh into the octree block if it intersects the block
  46014. */
  46015. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46016. }
  46017. }
  46018. declare module BABYLON {
  46019. interface Scene {
  46020. /**
  46021. * @hidden
  46022. * Backing Filed
  46023. */
  46024. _selectionOctree: Octree<AbstractMesh>;
  46025. /**
  46026. * Gets the octree used to boost mesh selection (picking)
  46027. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46028. */
  46029. selectionOctree: Octree<AbstractMesh>;
  46030. /**
  46031. * Creates or updates the octree used to boost selection (picking)
  46032. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46033. * @param maxCapacity defines the maximum capacity per leaf
  46034. * @param maxDepth defines the maximum depth of the octree
  46035. * @returns an octree of AbstractMesh
  46036. */
  46037. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46038. }
  46039. interface AbstractMesh {
  46040. /**
  46041. * @hidden
  46042. * Backing Field
  46043. */
  46044. _submeshesOctree: Octree<SubMesh>;
  46045. /**
  46046. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46047. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46048. * @param maxCapacity defines the maximum size of each block (64 by default)
  46049. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46050. * @returns the new octree
  46051. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46052. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46053. */
  46054. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46055. }
  46056. /**
  46057. * Defines the octree scene component responsible to manage any octrees
  46058. * in a given scene.
  46059. */
  46060. export class OctreeSceneComponent {
  46061. /**
  46062. * The component name help to identify the component in the list of scene components.
  46063. */
  46064. readonly name: string;
  46065. /**
  46066. * The scene the component belongs to.
  46067. */
  46068. scene: Scene;
  46069. /**
  46070. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46071. */
  46072. readonly checksIsEnabled: boolean;
  46073. /**
  46074. * Creates a new instance of the component for the given scene
  46075. * @param scene Defines the scene to register the component in
  46076. */
  46077. constructor(scene: Scene);
  46078. /**
  46079. * Registers the component in a given scene
  46080. */
  46081. register(): void;
  46082. /**
  46083. * Return the list of active meshes
  46084. * @returns the list of active meshes
  46085. */
  46086. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46087. /**
  46088. * Return the list of active sub meshes
  46089. * @param mesh The mesh to get the candidates sub meshes from
  46090. * @returns the list of active sub meshes
  46091. */
  46092. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46093. private _tempRay;
  46094. /**
  46095. * Return the list of sub meshes intersecting with a given local ray
  46096. * @param mesh defines the mesh to find the submesh for
  46097. * @param localRay defines the ray in local space
  46098. * @returns the list of intersecting sub meshes
  46099. */
  46100. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46101. /**
  46102. * Return the list of sub meshes colliding with a collider
  46103. * @param mesh defines the mesh to find the submesh for
  46104. * @param collider defines the collider to evaluate the collision against
  46105. * @returns the list of colliding sub meshes
  46106. */
  46107. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46108. /**
  46109. * Rebuilds the elements related to this component in case of
  46110. * context lost for instance.
  46111. */
  46112. rebuild(): void;
  46113. /**
  46114. * Disposes the component and the associated ressources.
  46115. */
  46116. dispose(): void;
  46117. }
  46118. }
  46119. declare module BABYLON {
  46120. /**
  46121. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46122. */
  46123. export class Gizmo implements IDisposable {
  46124. /** The utility layer the gizmo will be added to */
  46125. gizmoLayer: UtilityLayerRenderer;
  46126. /**
  46127. * The root mesh of the gizmo
  46128. */
  46129. _rootMesh: Mesh;
  46130. private _attachedMesh;
  46131. /**
  46132. * Ratio for the scale of the gizmo (Default: 1)
  46133. */
  46134. scaleRatio: number;
  46135. /**
  46136. * If a custom mesh has been set (Default: false)
  46137. */
  46138. protected _customMeshSet: boolean;
  46139. /**
  46140. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46141. * * When set, interactions will be enabled
  46142. */
  46143. get attachedMesh(): Nullable<AbstractMesh>;
  46144. set attachedMesh(value: Nullable<AbstractMesh>);
  46145. /**
  46146. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46147. * @param mesh The mesh to replace the default mesh of the gizmo
  46148. */
  46149. setCustomMesh(mesh: Mesh): void;
  46150. /**
  46151. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46152. */
  46153. updateGizmoRotationToMatchAttachedMesh: boolean;
  46154. /**
  46155. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46156. */
  46157. updateGizmoPositionToMatchAttachedMesh: boolean;
  46158. /**
  46159. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46160. */
  46161. updateScale: boolean;
  46162. protected _interactionsEnabled: boolean;
  46163. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46164. private _beforeRenderObserver;
  46165. private _tempVector;
  46166. /**
  46167. * Creates a gizmo
  46168. * @param gizmoLayer The utility layer the gizmo will be added to
  46169. */
  46170. constructor(
  46171. /** The utility layer the gizmo will be added to */
  46172. gizmoLayer?: UtilityLayerRenderer);
  46173. /**
  46174. * Updates the gizmo to match the attached mesh's position/rotation
  46175. */
  46176. protected _update(): void;
  46177. /**
  46178. * Disposes of the gizmo
  46179. */
  46180. dispose(): void;
  46181. }
  46182. }
  46183. declare module BABYLON {
  46184. /**
  46185. * Single plane drag gizmo
  46186. */
  46187. export class PlaneDragGizmo extends Gizmo {
  46188. /**
  46189. * Drag behavior responsible for the gizmos dragging interactions
  46190. */
  46191. dragBehavior: PointerDragBehavior;
  46192. private _pointerObserver;
  46193. /**
  46194. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46195. */
  46196. snapDistance: number;
  46197. /**
  46198. * Event that fires each time the gizmo snaps to a new location.
  46199. * * snapDistance is the the change in distance
  46200. */
  46201. onSnapObservable: Observable<{
  46202. snapDistance: number;
  46203. }>;
  46204. private _plane;
  46205. private _coloredMaterial;
  46206. private _hoverMaterial;
  46207. private _isEnabled;
  46208. private _parent;
  46209. /** @hidden */
  46210. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46211. /** @hidden */
  46212. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46213. /**
  46214. * Creates a PlaneDragGizmo
  46215. * @param gizmoLayer The utility layer the gizmo will be added to
  46216. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46217. * @param color The color of the gizmo
  46218. */
  46219. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46220. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46221. /**
  46222. * If the gizmo is enabled
  46223. */
  46224. set isEnabled(value: boolean);
  46225. get isEnabled(): boolean;
  46226. /**
  46227. * Disposes of the gizmo
  46228. */
  46229. dispose(): void;
  46230. }
  46231. }
  46232. declare module BABYLON {
  46233. /**
  46234. * Gizmo that enables dragging a mesh along 3 axis
  46235. */
  46236. export class PositionGizmo extends Gizmo {
  46237. /**
  46238. * Internal gizmo used for interactions on the x axis
  46239. */
  46240. xGizmo: AxisDragGizmo;
  46241. /**
  46242. * Internal gizmo used for interactions on the y axis
  46243. */
  46244. yGizmo: AxisDragGizmo;
  46245. /**
  46246. * Internal gizmo used for interactions on the z axis
  46247. */
  46248. zGizmo: AxisDragGizmo;
  46249. /**
  46250. * Internal gizmo used for interactions on the yz plane
  46251. */
  46252. xPlaneGizmo: PlaneDragGizmo;
  46253. /**
  46254. * Internal gizmo used for interactions on the xz plane
  46255. */
  46256. yPlaneGizmo: PlaneDragGizmo;
  46257. /**
  46258. * Internal gizmo used for interactions on the xy plane
  46259. */
  46260. zPlaneGizmo: PlaneDragGizmo;
  46261. /**
  46262. * private variables
  46263. */
  46264. private _meshAttached;
  46265. private _updateGizmoRotationToMatchAttachedMesh;
  46266. private _snapDistance;
  46267. private _scaleRatio;
  46268. /** Fires an event when any of it's sub gizmos are dragged */
  46269. onDragStartObservable: Observable<unknown>;
  46270. /** Fires an event when any of it's sub gizmos are released from dragging */
  46271. onDragEndObservable: Observable<unknown>;
  46272. /**
  46273. * If set to true, planar drag is enabled
  46274. */
  46275. private _planarGizmoEnabled;
  46276. get attachedMesh(): Nullable<AbstractMesh>;
  46277. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46278. /**
  46279. * Creates a PositionGizmo
  46280. * @param gizmoLayer The utility layer the gizmo will be added to
  46281. */
  46282. constructor(gizmoLayer?: UtilityLayerRenderer);
  46283. /**
  46284. * If the planar drag gizmo is enabled
  46285. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46286. */
  46287. set planarGizmoEnabled(value: boolean);
  46288. get planarGizmoEnabled(): boolean;
  46289. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46290. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46291. /**
  46292. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46293. */
  46294. set snapDistance(value: number);
  46295. get snapDistance(): number;
  46296. /**
  46297. * Ratio for the scale of the gizmo (Default: 1)
  46298. */
  46299. set scaleRatio(value: number);
  46300. get scaleRatio(): number;
  46301. /**
  46302. * Disposes of the gizmo
  46303. */
  46304. dispose(): void;
  46305. /**
  46306. * CustomMeshes are not supported by this gizmo
  46307. * @param mesh The mesh to replace the default mesh of the gizmo
  46308. */
  46309. setCustomMesh(mesh: Mesh): void;
  46310. }
  46311. }
  46312. declare module BABYLON {
  46313. /**
  46314. * Single axis drag gizmo
  46315. */
  46316. export class AxisDragGizmo extends Gizmo {
  46317. /**
  46318. * Drag behavior responsible for the gizmos dragging interactions
  46319. */
  46320. dragBehavior: PointerDragBehavior;
  46321. private _pointerObserver;
  46322. /**
  46323. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46324. */
  46325. snapDistance: number;
  46326. /**
  46327. * Event that fires each time the gizmo snaps to a new location.
  46328. * * snapDistance is the the change in distance
  46329. */
  46330. onSnapObservable: Observable<{
  46331. snapDistance: number;
  46332. }>;
  46333. private _isEnabled;
  46334. private _parent;
  46335. private _arrow;
  46336. private _coloredMaterial;
  46337. private _hoverMaterial;
  46338. /** @hidden */
  46339. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46340. /** @hidden */
  46341. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46342. /**
  46343. * Creates an AxisDragGizmo
  46344. * @param gizmoLayer The utility layer the gizmo will be added to
  46345. * @param dragAxis The axis which the gizmo will be able to drag on
  46346. * @param color The color of the gizmo
  46347. */
  46348. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46349. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46350. /**
  46351. * If the gizmo is enabled
  46352. */
  46353. set isEnabled(value: boolean);
  46354. get isEnabled(): boolean;
  46355. /**
  46356. * Disposes of the gizmo
  46357. */
  46358. dispose(): void;
  46359. }
  46360. }
  46361. declare module BABYLON.Debug {
  46362. /**
  46363. * The Axes viewer will show 3 axes in a specific point in space
  46364. */
  46365. export class AxesViewer {
  46366. private _xAxis;
  46367. private _yAxis;
  46368. private _zAxis;
  46369. private _scaleLinesFactor;
  46370. private _instanced;
  46371. /**
  46372. * Gets the hosting scene
  46373. */
  46374. scene: Scene;
  46375. /**
  46376. * Gets or sets a number used to scale line length
  46377. */
  46378. scaleLines: number;
  46379. /** Gets the node hierarchy used to render x-axis */
  46380. get xAxis(): TransformNode;
  46381. /** Gets the node hierarchy used to render y-axis */
  46382. get yAxis(): TransformNode;
  46383. /** Gets the node hierarchy used to render z-axis */
  46384. get zAxis(): TransformNode;
  46385. /**
  46386. * Creates a new AxesViewer
  46387. * @param scene defines the hosting scene
  46388. * @param scaleLines defines a number used to scale line length (1 by default)
  46389. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46390. * @param xAxis defines the node hierarchy used to render the x-axis
  46391. * @param yAxis defines the node hierarchy used to render the y-axis
  46392. * @param zAxis defines the node hierarchy used to render the z-axis
  46393. */
  46394. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46395. /**
  46396. * Force the viewer to update
  46397. * @param position defines the position of the viewer
  46398. * @param xaxis defines the x axis of the viewer
  46399. * @param yaxis defines the y axis of the viewer
  46400. * @param zaxis defines the z axis of the viewer
  46401. */
  46402. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46403. /**
  46404. * Creates an instance of this axes viewer.
  46405. * @returns a new axes viewer with instanced meshes
  46406. */
  46407. createInstance(): AxesViewer;
  46408. /** Releases resources */
  46409. dispose(): void;
  46410. private static _SetRenderingGroupId;
  46411. }
  46412. }
  46413. declare module BABYLON.Debug {
  46414. /**
  46415. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46416. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46417. */
  46418. export class BoneAxesViewer extends AxesViewer {
  46419. /**
  46420. * Gets or sets the target mesh where to display the axes viewer
  46421. */
  46422. mesh: Nullable<Mesh>;
  46423. /**
  46424. * Gets or sets the target bone where to display the axes viewer
  46425. */
  46426. bone: Nullable<Bone>;
  46427. /** Gets current position */
  46428. pos: Vector3;
  46429. /** Gets direction of X axis */
  46430. xaxis: Vector3;
  46431. /** Gets direction of Y axis */
  46432. yaxis: Vector3;
  46433. /** Gets direction of Z axis */
  46434. zaxis: Vector3;
  46435. /**
  46436. * Creates a new BoneAxesViewer
  46437. * @param scene defines the hosting scene
  46438. * @param bone defines the target bone
  46439. * @param mesh defines the target mesh
  46440. * @param scaleLines defines a scaling factor for line length (1 by default)
  46441. */
  46442. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46443. /**
  46444. * Force the viewer to update
  46445. */
  46446. update(): void;
  46447. /** Releases resources */
  46448. dispose(): void;
  46449. }
  46450. }
  46451. declare module BABYLON {
  46452. /**
  46453. * Interface used to define scene explorer extensibility option
  46454. */
  46455. export interface IExplorerExtensibilityOption {
  46456. /**
  46457. * Define the option label
  46458. */
  46459. label: string;
  46460. /**
  46461. * Defines the action to execute on click
  46462. */
  46463. action: (entity: any) => void;
  46464. }
  46465. /**
  46466. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46467. */
  46468. export interface IExplorerExtensibilityGroup {
  46469. /**
  46470. * Defines a predicate to test if a given type mut be extended
  46471. */
  46472. predicate: (entity: any) => boolean;
  46473. /**
  46474. * Gets the list of options added to a type
  46475. */
  46476. entries: IExplorerExtensibilityOption[];
  46477. }
  46478. /**
  46479. * Interface used to define the options to use to create the Inspector
  46480. */
  46481. export interface IInspectorOptions {
  46482. /**
  46483. * Display in overlay mode (default: false)
  46484. */
  46485. overlay?: boolean;
  46486. /**
  46487. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46488. */
  46489. globalRoot?: HTMLElement;
  46490. /**
  46491. * Display the Scene explorer
  46492. */
  46493. showExplorer?: boolean;
  46494. /**
  46495. * Display the property inspector
  46496. */
  46497. showInspector?: boolean;
  46498. /**
  46499. * Display in embed mode (both panes on the right)
  46500. */
  46501. embedMode?: boolean;
  46502. /**
  46503. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46504. */
  46505. handleResize?: boolean;
  46506. /**
  46507. * Allow the panes to popup (default: true)
  46508. */
  46509. enablePopup?: boolean;
  46510. /**
  46511. * Allow the panes to be closed by users (default: true)
  46512. */
  46513. enableClose?: boolean;
  46514. /**
  46515. * Optional list of extensibility entries
  46516. */
  46517. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46518. /**
  46519. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46520. */
  46521. inspectorURL?: string;
  46522. /**
  46523. * Optional initial tab (default to DebugLayerTab.Properties)
  46524. */
  46525. initialTab?: DebugLayerTab;
  46526. }
  46527. interface Scene {
  46528. /**
  46529. * @hidden
  46530. * Backing field
  46531. */
  46532. _debugLayer: DebugLayer;
  46533. /**
  46534. * Gets the debug layer (aka Inspector) associated with the scene
  46535. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46536. */
  46537. debugLayer: DebugLayer;
  46538. }
  46539. /**
  46540. * Enum of inspector action tab
  46541. */
  46542. export enum DebugLayerTab {
  46543. /**
  46544. * Properties tag (default)
  46545. */
  46546. Properties = 0,
  46547. /**
  46548. * Debug tab
  46549. */
  46550. Debug = 1,
  46551. /**
  46552. * Statistics tab
  46553. */
  46554. Statistics = 2,
  46555. /**
  46556. * Tools tab
  46557. */
  46558. Tools = 3,
  46559. /**
  46560. * Settings tab
  46561. */
  46562. Settings = 4
  46563. }
  46564. /**
  46565. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46566. * what is happening in your scene
  46567. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46568. */
  46569. export class DebugLayer {
  46570. /**
  46571. * Define the url to get the inspector script from.
  46572. * By default it uses the babylonjs CDN.
  46573. * @ignoreNaming
  46574. */
  46575. static InspectorURL: string;
  46576. private _scene;
  46577. private BJSINSPECTOR;
  46578. private _onPropertyChangedObservable?;
  46579. /**
  46580. * Observable triggered when a property is changed through the inspector.
  46581. */
  46582. get onPropertyChangedObservable(): any;
  46583. /**
  46584. * Instantiates a new debug layer.
  46585. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46586. * what is happening in your scene
  46587. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46588. * @param scene Defines the scene to inspect
  46589. */
  46590. constructor(scene: Scene);
  46591. /** Creates the inspector window. */
  46592. private _createInspector;
  46593. /**
  46594. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46595. * @param entity defines the entity to select
  46596. * @param lineContainerTitle defines the specific block to highlight
  46597. */
  46598. select(entity: any, lineContainerTitle?: string): void;
  46599. /** Get the inspector from bundle or global */
  46600. private _getGlobalInspector;
  46601. /**
  46602. * Get if the inspector is visible or not.
  46603. * @returns true if visible otherwise, false
  46604. */
  46605. isVisible(): boolean;
  46606. /**
  46607. * Hide the inspector and close its window.
  46608. */
  46609. hide(): void;
  46610. /**
  46611. * Launch the debugLayer.
  46612. * @param config Define the configuration of the inspector
  46613. * @return a promise fulfilled when the debug layer is visible
  46614. */
  46615. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46616. }
  46617. }
  46618. declare module BABYLON {
  46619. /**
  46620. * Class containing static functions to help procedurally build meshes
  46621. */
  46622. export class BoxBuilder {
  46623. /**
  46624. * Creates a box mesh
  46625. * * The parameter `size` sets the size (float) of each box side (default 1)
  46626. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46627. * * 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)
  46628. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46630. * * 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
  46631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46632. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46633. * @param name defines the name of the mesh
  46634. * @param options defines the options used to create the mesh
  46635. * @param scene defines the hosting scene
  46636. * @returns the box mesh
  46637. */
  46638. static CreateBox(name: string, options: {
  46639. size?: number;
  46640. width?: number;
  46641. height?: number;
  46642. depth?: number;
  46643. faceUV?: Vector4[];
  46644. faceColors?: Color4[];
  46645. sideOrientation?: number;
  46646. frontUVs?: Vector4;
  46647. backUVs?: Vector4;
  46648. wrap?: boolean;
  46649. topBaseAt?: number;
  46650. bottomBaseAt?: number;
  46651. updatable?: boolean;
  46652. }, scene?: Nullable<Scene>): Mesh;
  46653. }
  46654. }
  46655. declare module BABYLON.Debug {
  46656. /**
  46657. * Used to show the physics impostor around the specific mesh
  46658. */
  46659. export class PhysicsViewer {
  46660. /** @hidden */
  46661. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46662. /** @hidden */
  46663. protected _meshes: Array<Nullable<AbstractMesh>>;
  46664. /** @hidden */
  46665. protected _scene: Nullable<Scene>;
  46666. /** @hidden */
  46667. protected _numMeshes: number;
  46668. /** @hidden */
  46669. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46670. private _renderFunction;
  46671. private _utilityLayer;
  46672. private _debugBoxMesh;
  46673. private _debugSphereMesh;
  46674. private _debugCylinderMesh;
  46675. private _debugMaterial;
  46676. private _debugMeshMeshes;
  46677. /**
  46678. * Creates a new PhysicsViewer
  46679. * @param scene defines the hosting scene
  46680. */
  46681. constructor(scene: Scene);
  46682. /** @hidden */
  46683. protected _updateDebugMeshes(): void;
  46684. /**
  46685. * Renders a specified physic impostor
  46686. * @param impostor defines the impostor to render
  46687. * @param targetMesh defines the mesh represented by the impostor
  46688. * @returns the new debug mesh used to render the impostor
  46689. */
  46690. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46691. /**
  46692. * Hides a specified physic impostor
  46693. * @param impostor defines the impostor to hide
  46694. */
  46695. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46696. private _getDebugMaterial;
  46697. private _getDebugBoxMesh;
  46698. private _getDebugSphereMesh;
  46699. private _getDebugCylinderMesh;
  46700. private _getDebugMeshMesh;
  46701. private _getDebugMesh;
  46702. /** Releases all resources */
  46703. dispose(): void;
  46704. }
  46705. }
  46706. declare module BABYLON {
  46707. /**
  46708. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46709. * in order to better appreciate the issue one might have.
  46710. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46711. */
  46712. export class RayHelper {
  46713. /**
  46714. * Defines the ray we are currently tryin to visualize.
  46715. */
  46716. ray: Nullable<Ray>;
  46717. private _renderPoints;
  46718. private _renderLine;
  46719. private _renderFunction;
  46720. private _scene;
  46721. private _updateToMeshFunction;
  46722. private _attachedToMesh;
  46723. private _meshSpaceDirection;
  46724. private _meshSpaceOrigin;
  46725. /**
  46726. * Helper function to create a colored helper in a scene in one line.
  46727. * @param ray Defines the ray we are currently tryin to visualize
  46728. * @param scene Defines the scene the ray is used in
  46729. * @param color Defines the color we want to see the ray in
  46730. * @returns The newly created ray helper.
  46731. */
  46732. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46733. /**
  46734. * Instantiate a new ray helper.
  46735. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46736. * in order to better appreciate the issue one might have.
  46737. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46738. * @param ray Defines the ray we are currently tryin to visualize
  46739. */
  46740. constructor(ray: Ray);
  46741. /**
  46742. * Shows the ray we are willing to debug.
  46743. * @param scene Defines the scene the ray needs to be rendered in
  46744. * @param color Defines the color the ray needs to be rendered in
  46745. */
  46746. show(scene: Scene, color?: Color3): void;
  46747. /**
  46748. * Hides the ray we are debugging.
  46749. */
  46750. hide(): void;
  46751. private _render;
  46752. /**
  46753. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46754. * @param mesh Defines the mesh we want the helper attached to
  46755. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46756. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46757. * @param length Defines the length of the ray
  46758. */
  46759. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46760. /**
  46761. * Detach the ray helper from the mesh it has previously been attached to.
  46762. */
  46763. detachFromMesh(): void;
  46764. private _updateToMesh;
  46765. /**
  46766. * Dispose the helper and release its associated resources.
  46767. */
  46768. dispose(): void;
  46769. }
  46770. }
  46771. declare module BABYLON.Debug {
  46772. /**
  46773. * Class used to render a debug view of a given skeleton
  46774. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46775. */
  46776. export class SkeletonViewer {
  46777. /** defines the skeleton to render */
  46778. skeleton: Skeleton;
  46779. /** defines the mesh attached to the skeleton */
  46780. mesh: AbstractMesh;
  46781. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46782. autoUpdateBonesMatrices: boolean;
  46783. /** defines the rendering group id to use with the viewer */
  46784. renderingGroupId: number;
  46785. /** Gets or sets the color used to render the skeleton */
  46786. color: Color3;
  46787. private _scene;
  46788. private _debugLines;
  46789. private _debugMesh;
  46790. private _isEnabled;
  46791. private _renderFunction;
  46792. private _utilityLayer;
  46793. /**
  46794. * Returns the mesh used to render the bones
  46795. */
  46796. get debugMesh(): Nullable<LinesMesh>;
  46797. /**
  46798. * Creates a new SkeletonViewer
  46799. * @param skeleton defines the skeleton to render
  46800. * @param mesh defines the mesh attached to the skeleton
  46801. * @param scene defines the hosting scene
  46802. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46803. * @param renderingGroupId defines the rendering group id to use with the viewer
  46804. */
  46805. constructor(
  46806. /** defines the skeleton to render */
  46807. skeleton: Skeleton,
  46808. /** defines the mesh attached to the skeleton */
  46809. mesh: AbstractMesh, scene: Scene,
  46810. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46811. autoUpdateBonesMatrices?: boolean,
  46812. /** defines the rendering group id to use with the viewer */
  46813. renderingGroupId?: number);
  46814. /** Gets or sets a boolean indicating if the viewer is enabled */
  46815. set isEnabled(value: boolean);
  46816. get isEnabled(): boolean;
  46817. private _getBonePosition;
  46818. private _getLinesForBonesWithLength;
  46819. private _getLinesForBonesNoLength;
  46820. /** Update the viewer to sync with current skeleton state */
  46821. update(): void;
  46822. /** Release associated resources */
  46823. dispose(): void;
  46824. }
  46825. }
  46826. declare module BABYLON {
  46827. /**
  46828. * Options to create the null engine
  46829. */
  46830. export class NullEngineOptions {
  46831. /**
  46832. * Render width (Default: 512)
  46833. */
  46834. renderWidth: number;
  46835. /**
  46836. * Render height (Default: 256)
  46837. */
  46838. renderHeight: number;
  46839. /**
  46840. * Texture size (Default: 512)
  46841. */
  46842. textureSize: number;
  46843. /**
  46844. * If delta time between frames should be constant
  46845. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46846. */
  46847. deterministicLockstep: boolean;
  46848. /**
  46849. * Maximum about of steps between frames (Default: 4)
  46850. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46851. */
  46852. lockstepMaxSteps: number;
  46853. }
  46854. /**
  46855. * The null engine class provides support for headless version of babylon.js.
  46856. * This can be used in server side scenario or for testing purposes
  46857. */
  46858. export class NullEngine extends Engine {
  46859. private _options;
  46860. /**
  46861. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46862. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46863. * @returns true if engine is in deterministic lock step mode
  46864. */
  46865. isDeterministicLockStep(): boolean;
  46866. /**
  46867. * Gets the max steps when engine is running in deterministic lock step
  46868. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46869. * @returns the max steps
  46870. */
  46871. getLockstepMaxSteps(): number;
  46872. /**
  46873. * Gets the current hardware scaling level.
  46874. * By default the hardware scaling level is computed from the window device ratio.
  46875. * 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.
  46876. * @returns a number indicating the current hardware scaling level
  46877. */
  46878. getHardwareScalingLevel(): number;
  46879. constructor(options?: NullEngineOptions);
  46880. /**
  46881. * Creates a vertex buffer
  46882. * @param vertices the data for the vertex buffer
  46883. * @returns the new WebGL static buffer
  46884. */
  46885. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46886. /**
  46887. * Creates a new index buffer
  46888. * @param indices defines the content of the index buffer
  46889. * @param updatable defines if the index buffer must be updatable
  46890. * @returns a new webGL buffer
  46891. */
  46892. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46893. /**
  46894. * Clear the current render buffer or the current render target (if any is set up)
  46895. * @param color defines the color to use
  46896. * @param backBuffer defines if the back buffer must be cleared
  46897. * @param depth defines if the depth buffer must be cleared
  46898. * @param stencil defines if the stencil buffer must be cleared
  46899. */
  46900. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46901. /**
  46902. * Gets the current render width
  46903. * @param useScreen defines if screen size must be used (or the current render target if any)
  46904. * @returns a number defining the current render width
  46905. */
  46906. getRenderWidth(useScreen?: boolean): number;
  46907. /**
  46908. * Gets the current render height
  46909. * @param useScreen defines if screen size must be used (or the current render target if any)
  46910. * @returns a number defining the current render height
  46911. */
  46912. getRenderHeight(useScreen?: boolean): number;
  46913. /**
  46914. * Set the WebGL's viewport
  46915. * @param viewport defines the viewport element to be used
  46916. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46917. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46918. */
  46919. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46920. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46921. /**
  46922. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46923. * @param pipelineContext defines the pipeline context to use
  46924. * @param uniformsNames defines the list of uniform names
  46925. * @returns an array of webGL uniform locations
  46926. */
  46927. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46928. /**
  46929. * Gets the lsit of active attributes for a given webGL program
  46930. * @param pipelineContext defines the pipeline context to use
  46931. * @param attributesNames defines the list of attribute names to get
  46932. * @returns an array of indices indicating the offset of each attribute
  46933. */
  46934. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46935. /**
  46936. * Binds an effect to the webGL context
  46937. * @param effect defines the effect to bind
  46938. */
  46939. bindSamplers(effect: Effect): void;
  46940. /**
  46941. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46942. * @param effect defines the effect to activate
  46943. */
  46944. enableEffect(effect: Effect): void;
  46945. /**
  46946. * Set various states to the webGL context
  46947. * @param culling defines backface culling state
  46948. * @param zOffset defines the value to apply to zOffset (0 by default)
  46949. * @param force defines if states must be applied even if cache is up to date
  46950. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46951. */
  46952. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46953. /**
  46954. * Set the value of an uniform to an array of int32
  46955. * @param uniform defines the webGL uniform location where to store the value
  46956. * @param array defines the array of int32 to store
  46957. */
  46958. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46959. /**
  46960. * Set the value of an uniform to an array of int32 (stored as vec2)
  46961. * @param uniform defines the webGL uniform location where to store the value
  46962. * @param array defines the array of int32 to store
  46963. */
  46964. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46965. /**
  46966. * Set the value of an uniform to an array of int32 (stored as vec3)
  46967. * @param uniform defines the webGL uniform location where to store the value
  46968. * @param array defines the array of int32 to store
  46969. */
  46970. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46971. /**
  46972. * Set the value of an uniform to an array of int32 (stored as vec4)
  46973. * @param uniform defines the webGL uniform location where to store the value
  46974. * @param array defines the array of int32 to store
  46975. */
  46976. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46977. /**
  46978. * Set the value of an uniform to an array of float32
  46979. * @param uniform defines the webGL uniform location where to store the value
  46980. * @param array defines the array of float32 to store
  46981. */
  46982. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46983. /**
  46984. * Set the value of an uniform to an array of float32 (stored as vec2)
  46985. * @param uniform defines the webGL uniform location where to store the value
  46986. * @param array defines the array of float32 to store
  46987. */
  46988. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46989. /**
  46990. * Set the value of an uniform to an array of float32 (stored as vec3)
  46991. * @param uniform defines the webGL uniform location where to store the value
  46992. * @param array defines the array of float32 to store
  46993. */
  46994. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46995. /**
  46996. * Set the value of an uniform to an array of float32 (stored as vec4)
  46997. * @param uniform defines the webGL uniform location where to store the value
  46998. * @param array defines the array of float32 to store
  46999. */
  47000. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47001. /**
  47002. * Set the value of an uniform to an array of number
  47003. * @param uniform defines the webGL uniform location where to store the value
  47004. * @param array defines the array of number to store
  47005. */
  47006. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47007. /**
  47008. * Set the value of an uniform to an array of number (stored as vec2)
  47009. * @param uniform defines the webGL uniform location where to store the value
  47010. * @param array defines the array of number to store
  47011. */
  47012. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47013. /**
  47014. * Set the value of an uniform to an array of number (stored as vec3)
  47015. * @param uniform defines the webGL uniform location where to store the value
  47016. * @param array defines the array of number to store
  47017. */
  47018. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47019. /**
  47020. * Set the value of an uniform to an array of number (stored as vec4)
  47021. * @param uniform defines the webGL uniform location where to store the value
  47022. * @param array defines the array of number to store
  47023. */
  47024. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47025. /**
  47026. * Set the value of an uniform to an array of float32 (stored as matrices)
  47027. * @param uniform defines the webGL uniform location where to store the value
  47028. * @param matrices defines the array of float32 to store
  47029. */
  47030. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47031. /**
  47032. * Set the value of an uniform to a matrix (3x3)
  47033. * @param uniform defines the webGL uniform location where to store the value
  47034. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47035. */
  47036. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47037. /**
  47038. * Set the value of an uniform to a matrix (2x2)
  47039. * @param uniform defines the webGL uniform location where to store the value
  47040. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47041. */
  47042. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47043. /**
  47044. * Set the value of an uniform to a number (float)
  47045. * @param uniform defines the webGL uniform location where to store the value
  47046. * @param value defines the float number to store
  47047. */
  47048. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47049. /**
  47050. * Set the value of an uniform to a vec2
  47051. * @param uniform defines the webGL uniform location where to store the value
  47052. * @param x defines the 1st component of the value
  47053. * @param y defines the 2nd component of the value
  47054. */
  47055. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47056. /**
  47057. * Set the value of an uniform to a vec3
  47058. * @param uniform defines the webGL uniform location where to store the value
  47059. * @param x defines the 1st component of the value
  47060. * @param y defines the 2nd component of the value
  47061. * @param z defines the 3rd component of the value
  47062. */
  47063. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47064. /**
  47065. * Set the value of an uniform to a boolean
  47066. * @param uniform defines the webGL uniform location where to store the value
  47067. * @param bool defines the boolean to store
  47068. */
  47069. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47070. /**
  47071. * Set the value of an uniform to a vec4
  47072. * @param uniform defines the webGL uniform location where to store the value
  47073. * @param x defines the 1st component of the value
  47074. * @param y defines the 2nd component of the value
  47075. * @param z defines the 3rd component of the value
  47076. * @param w defines the 4th component of the value
  47077. */
  47078. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47079. /**
  47080. * Sets the current alpha mode
  47081. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47082. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47083. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47084. */
  47085. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47086. /**
  47087. * Bind webGl buffers directly to the webGL context
  47088. * @param vertexBuffers defines the vertex buffer to bind
  47089. * @param indexBuffer defines the index buffer to bind
  47090. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47091. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47092. * @param effect defines the effect associated with the vertex buffer
  47093. */
  47094. bindBuffers(vertexBuffers: {
  47095. [key: string]: VertexBuffer;
  47096. }, indexBuffer: DataBuffer, effect: Effect): void;
  47097. /**
  47098. * Force the entire cache to be cleared
  47099. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47100. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47101. */
  47102. wipeCaches(bruteForce?: boolean): void;
  47103. /**
  47104. * Send a draw order
  47105. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47106. * @param indexStart defines the starting index
  47107. * @param indexCount defines the number of index to draw
  47108. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47109. */
  47110. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47111. /**
  47112. * Draw a list of indexed primitives
  47113. * @param fillMode defines the primitive to use
  47114. * @param indexStart defines the starting index
  47115. * @param indexCount defines the number of index to draw
  47116. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47117. */
  47118. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47119. /**
  47120. * Draw a list of unindexed primitives
  47121. * @param fillMode defines the primitive to use
  47122. * @param verticesStart defines the index of first vertex to draw
  47123. * @param verticesCount defines the count of vertices to draw
  47124. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47125. */
  47126. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47127. /** @hidden */
  47128. _createTexture(): WebGLTexture;
  47129. /** @hidden */
  47130. _releaseTexture(texture: InternalTexture): void;
  47131. /**
  47132. * Usually called from Texture.ts.
  47133. * Passed information to create a WebGLTexture
  47134. * @param urlArg defines a value which contains one of the following:
  47135. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47136. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47137. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47138. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47139. * @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)
  47140. * @param scene needed for loading to the correct scene
  47141. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47142. * @param onLoad optional callback to be called upon successful completion
  47143. * @param onError optional callback to be called upon failure
  47144. * @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
  47145. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47146. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47147. * @param forcedExtension defines the extension to use to pick the right loader
  47148. * @param mimeType defines an optional mime type
  47149. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47150. */
  47151. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  47152. /**
  47153. * Creates a new render target texture
  47154. * @param size defines the size of the texture
  47155. * @param options defines the options used to create the texture
  47156. * @returns a new render target texture stored in an InternalTexture
  47157. */
  47158. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47159. /**
  47160. * Update the sampling mode of a given texture
  47161. * @param samplingMode defines the required sampling mode
  47162. * @param texture defines the texture to update
  47163. */
  47164. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47165. /**
  47166. * Binds the frame buffer to the specified texture.
  47167. * @param texture The texture to render to or null for the default canvas
  47168. * @param faceIndex The face of the texture to render to in case of cube texture
  47169. * @param requiredWidth The width of the target to render to
  47170. * @param requiredHeight The height of the target to render to
  47171. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47172. * @param lodLevel defines le lod level to bind to the frame buffer
  47173. */
  47174. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47175. /**
  47176. * Unbind the current render target texture from the webGL context
  47177. * @param texture defines the render target texture to unbind
  47178. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47179. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47180. */
  47181. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47182. /**
  47183. * Creates a dynamic vertex buffer
  47184. * @param vertices the data for the dynamic vertex buffer
  47185. * @returns the new WebGL dynamic buffer
  47186. */
  47187. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47188. /**
  47189. * Update the content of a dynamic texture
  47190. * @param texture defines the texture to update
  47191. * @param canvas defines the canvas containing the source
  47192. * @param invertY defines if data must be stored with Y axis inverted
  47193. * @param premulAlpha defines if alpha is stored as premultiplied
  47194. * @param format defines the format of the data
  47195. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47196. */
  47197. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47198. /**
  47199. * Gets a boolean indicating if all created effects are ready
  47200. * @returns true if all effects are ready
  47201. */
  47202. areAllEffectsReady(): boolean;
  47203. /**
  47204. * @hidden
  47205. * Get the current error code of the webGL context
  47206. * @returns the error code
  47207. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47208. */
  47209. getError(): number;
  47210. /** @hidden */
  47211. _getUnpackAlignement(): number;
  47212. /** @hidden */
  47213. _unpackFlipY(value: boolean): void;
  47214. /**
  47215. * Update a dynamic index buffer
  47216. * @param indexBuffer defines the target index buffer
  47217. * @param indices defines the data to update
  47218. * @param offset defines the offset in the target index buffer where update should start
  47219. */
  47220. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47221. /**
  47222. * Updates a dynamic vertex buffer.
  47223. * @param vertexBuffer the vertex buffer to update
  47224. * @param vertices the data used to update the vertex buffer
  47225. * @param byteOffset the byte offset of the data (optional)
  47226. * @param byteLength the byte length of the data (optional)
  47227. */
  47228. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47229. /** @hidden */
  47230. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47231. /** @hidden */
  47232. _bindTexture(channel: number, texture: InternalTexture): void;
  47233. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47234. /**
  47235. * 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
  47236. */
  47237. releaseEffects(): void;
  47238. displayLoadingUI(): void;
  47239. hideLoadingUI(): void;
  47240. /** @hidden */
  47241. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47242. /** @hidden */
  47243. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47244. /** @hidden */
  47245. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47246. /** @hidden */
  47247. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47248. }
  47249. }
  47250. declare module BABYLON {
  47251. /**
  47252. * @hidden
  47253. **/
  47254. export class _TimeToken {
  47255. _startTimeQuery: Nullable<WebGLQuery>;
  47256. _endTimeQuery: Nullable<WebGLQuery>;
  47257. _timeElapsedQuery: Nullable<WebGLQuery>;
  47258. _timeElapsedQueryEnded: boolean;
  47259. }
  47260. }
  47261. declare module BABYLON {
  47262. /** @hidden */
  47263. export class _OcclusionDataStorage {
  47264. /** @hidden */
  47265. occlusionInternalRetryCounter: number;
  47266. /** @hidden */
  47267. isOcclusionQueryInProgress: boolean;
  47268. /** @hidden */
  47269. isOccluded: boolean;
  47270. /** @hidden */
  47271. occlusionRetryCount: number;
  47272. /** @hidden */
  47273. occlusionType: number;
  47274. /** @hidden */
  47275. occlusionQueryAlgorithmType: number;
  47276. }
  47277. interface Engine {
  47278. /**
  47279. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47280. * @return the new query
  47281. */
  47282. createQuery(): WebGLQuery;
  47283. /**
  47284. * Delete and release a webGL query
  47285. * @param query defines the query to delete
  47286. * @return the current engine
  47287. */
  47288. deleteQuery(query: WebGLQuery): Engine;
  47289. /**
  47290. * Check if a given query has resolved and got its value
  47291. * @param query defines the query to check
  47292. * @returns true if the query got its value
  47293. */
  47294. isQueryResultAvailable(query: WebGLQuery): boolean;
  47295. /**
  47296. * Gets the value of a given query
  47297. * @param query defines the query to check
  47298. * @returns the value of the query
  47299. */
  47300. getQueryResult(query: WebGLQuery): number;
  47301. /**
  47302. * Initiates an occlusion query
  47303. * @param algorithmType defines the algorithm to use
  47304. * @param query defines the query to use
  47305. * @returns the current engine
  47306. * @see http://doc.babylonjs.com/features/occlusionquery
  47307. */
  47308. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47309. /**
  47310. * Ends an occlusion query
  47311. * @see http://doc.babylonjs.com/features/occlusionquery
  47312. * @param algorithmType defines the algorithm to use
  47313. * @returns the current engine
  47314. */
  47315. endOcclusionQuery(algorithmType: number): Engine;
  47316. /**
  47317. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47318. * Please note that only one query can be issued at a time
  47319. * @returns a time token used to track the time span
  47320. */
  47321. startTimeQuery(): Nullable<_TimeToken>;
  47322. /**
  47323. * Ends a time query
  47324. * @param token defines the token used to measure the time span
  47325. * @returns the time spent (in ns)
  47326. */
  47327. endTimeQuery(token: _TimeToken): int;
  47328. /** @hidden */
  47329. _currentNonTimestampToken: Nullable<_TimeToken>;
  47330. /** @hidden */
  47331. _createTimeQuery(): WebGLQuery;
  47332. /** @hidden */
  47333. _deleteTimeQuery(query: WebGLQuery): void;
  47334. /** @hidden */
  47335. _getGlAlgorithmType(algorithmType: number): number;
  47336. /** @hidden */
  47337. _getTimeQueryResult(query: WebGLQuery): any;
  47338. /** @hidden */
  47339. _getTimeQueryAvailability(query: WebGLQuery): any;
  47340. }
  47341. interface AbstractMesh {
  47342. /**
  47343. * Backing filed
  47344. * @hidden
  47345. */
  47346. __occlusionDataStorage: _OcclusionDataStorage;
  47347. /**
  47348. * Access property
  47349. * @hidden
  47350. */
  47351. _occlusionDataStorage: _OcclusionDataStorage;
  47352. /**
  47353. * 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.
  47354. * The default value is -1 which means don't break the query and wait till the result
  47355. * @see http://doc.babylonjs.com/features/occlusionquery
  47356. */
  47357. occlusionRetryCount: number;
  47358. /**
  47359. * 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:
  47360. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47361. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47362. * * 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.
  47363. * @see http://doc.babylonjs.com/features/occlusionquery
  47364. */
  47365. occlusionType: number;
  47366. /**
  47367. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47368. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47369. * * 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.
  47370. * @see http://doc.babylonjs.com/features/occlusionquery
  47371. */
  47372. occlusionQueryAlgorithmType: number;
  47373. /**
  47374. * 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
  47375. * @see http://doc.babylonjs.com/features/occlusionquery
  47376. */
  47377. isOccluded: boolean;
  47378. /**
  47379. * Flag to check the progress status of the query
  47380. * @see http://doc.babylonjs.com/features/occlusionquery
  47381. */
  47382. isOcclusionQueryInProgress: boolean;
  47383. }
  47384. }
  47385. declare module BABYLON {
  47386. /** @hidden */
  47387. export var _forceTransformFeedbackToBundle: boolean;
  47388. interface Engine {
  47389. /**
  47390. * Creates a webGL transform feedback object
  47391. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47392. * @returns the webGL transform feedback object
  47393. */
  47394. createTransformFeedback(): WebGLTransformFeedback;
  47395. /**
  47396. * Delete a webGL transform feedback object
  47397. * @param value defines the webGL transform feedback object to delete
  47398. */
  47399. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47400. /**
  47401. * Bind a webGL transform feedback object to the webgl context
  47402. * @param value defines the webGL transform feedback object to bind
  47403. */
  47404. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47405. /**
  47406. * Begins a transform feedback operation
  47407. * @param usePoints defines if points or triangles must be used
  47408. */
  47409. beginTransformFeedback(usePoints: boolean): void;
  47410. /**
  47411. * Ends a transform feedback operation
  47412. */
  47413. endTransformFeedback(): void;
  47414. /**
  47415. * Specify the varyings to use with transform feedback
  47416. * @param program defines the associated webGL program
  47417. * @param value defines the list of strings representing the varying names
  47418. */
  47419. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47420. /**
  47421. * Bind a webGL buffer for a transform feedback operation
  47422. * @param value defines the webGL buffer to bind
  47423. */
  47424. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47425. }
  47426. }
  47427. declare module BABYLON {
  47428. /**
  47429. * Creation options of the multi render target texture.
  47430. */
  47431. export interface IMultiRenderTargetOptions {
  47432. /**
  47433. * Define if the texture needs to create mip maps after render.
  47434. */
  47435. generateMipMaps?: boolean;
  47436. /**
  47437. * Define the types of all the draw buffers we want to create
  47438. */
  47439. types?: number[];
  47440. /**
  47441. * Define the sampling modes of all the draw buffers we want to create
  47442. */
  47443. samplingModes?: number[];
  47444. /**
  47445. * Define if a depth buffer is required
  47446. */
  47447. generateDepthBuffer?: boolean;
  47448. /**
  47449. * Define if a stencil buffer is required
  47450. */
  47451. generateStencilBuffer?: boolean;
  47452. /**
  47453. * Define if a depth texture is required instead of a depth buffer
  47454. */
  47455. generateDepthTexture?: boolean;
  47456. /**
  47457. * Define the number of desired draw buffers
  47458. */
  47459. textureCount?: number;
  47460. /**
  47461. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47462. */
  47463. doNotChangeAspectRatio?: boolean;
  47464. /**
  47465. * Define the default type of the buffers we are creating
  47466. */
  47467. defaultType?: number;
  47468. }
  47469. /**
  47470. * A multi render target, like a render target provides the ability to render to a texture.
  47471. * Unlike the render target, it can render to several draw buffers in one draw.
  47472. * This is specially interesting in deferred rendering or for any effects requiring more than
  47473. * just one color from a single pass.
  47474. */
  47475. export class MultiRenderTarget extends RenderTargetTexture {
  47476. private _internalTextures;
  47477. private _textures;
  47478. private _multiRenderTargetOptions;
  47479. /**
  47480. * Get if draw buffers are currently supported by the used hardware and browser.
  47481. */
  47482. get isSupported(): boolean;
  47483. /**
  47484. * Get the list of textures generated by the multi render target.
  47485. */
  47486. get textures(): Texture[];
  47487. /**
  47488. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47489. */
  47490. get depthTexture(): Texture;
  47491. /**
  47492. * Set the wrapping mode on U of all the textures we are rendering to.
  47493. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47494. */
  47495. set wrapU(wrap: number);
  47496. /**
  47497. * Set the wrapping mode on V of all the textures we are rendering to.
  47498. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47499. */
  47500. set wrapV(wrap: number);
  47501. /**
  47502. * Instantiate a new multi render target texture.
  47503. * A multi render target, like a render target provides the ability to render to a texture.
  47504. * Unlike the render target, it can render to several draw buffers in one draw.
  47505. * This is specially interesting in deferred rendering or for any effects requiring more than
  47506. * just one color from a single pass.
  47507. * @param name Define the name of the texture
  47508. * @param size Define the size of the buffers to render to
  47509. * @param count Define the number of target we are rendering into
  47510. * @param scene Define the scene the texture belongs to
  47511. * @param options Define the options used to create the multi render target
  47512. */
  47513. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47514. /** @hidden */
  47515. _rebuild(): void;
  47516. private _createInternalTextures;
  47517. private _createTextures;
  47518. /**
  47519. * Define the number of samples used if MSAA is enabled.
  47520. */
  47521. get samples(): number;
  47522. set samples(value: number);
  47523. /**
  47524. * Resize all the textures in the multi render target.
  47525. * Be carrefull as it will recreate all the data in the new texture.
  47526. * @param size Define the new size
  47527. */
  47528. resize(size: any): void;
  47529. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47530. /**
  47531. * Dispose the render targets and their associated resources
  47532. */
  47533. dispose(): void;
  47534. /**
  47535. * Release all the underlying texture used as draw buffers.
  47536. */
  47537. releaseInternalTextures(): void;
  47538. }
  47539. }
  47540. declare module BABYLON {
  47541. interface ThinEngine {
  47542. /**
  47543. * Unbind a list of render target textures from the webGL context
  47544. * This is used only when drawBuffer extension or webGL2 are active
  47545. * @param textures defines the render target textures to unbind
  47546. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47547. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47548. */
  47549. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47550. /**
  47551. * Create a multi render target texture
  47552. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47553. * @param size defines the size of the texture
  47554. * @param options defines the creation options
  47555. * @returns the cube texture as an InternalTexture
  47556. */
  47557. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47558. /**
  47559. * Update the sample count for a given multiple render target texture
  47560. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47561. * @param textures defines the textures to update
  47562. * @param samples defines the sample count to set
  47563. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47564. */
  47565. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47566. }
  47567. }
  47568. declare module BABYLON {
  47569. /**
  47570. * Class used to define an additional view for the engine
  47571. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47572. */
  47573. export class EngineView {
  47574. /** Defines the canvas where to render the view */
  47575. target: HTMLCanvasElement;
  47576. /** Defines an optional camera used to render the view (will use active camera else) */
  47577. camera?: Camera;
  47578. }
  47579. interface Engine {
  47580. /**
  47581. * Gets or sets the HTML element to use for attaching events
  47582. */
  47583. inputElement: Nullable<HTMLElement>;
  47584. /**
  47585. * Gets the current engine view
  47586. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47587. */
  47588. activeView: Nullable<EngineView>;
  47589. /** Gets or sets the list of views */
  47590. views: EngineView[];
  47591. /**
  47592. * Register a new child canvas
  47593. * @param canvas defines the canvas to register
  47594. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47595. * @returns the associated view
  47596. */
  47597. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47598. /**
  47599. * Remove a registered child canvas
  47600. * @param canvas defines the canvas to remove
  47601. * @returns the current engine
  47602. */
  47603. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47604. }
  47605. }
  47606. declare module BABYLON {
  47607. interface Engine {
  47608. /** @hidden */
  47609. _excludedCompressedTextures: string[];
  47610. /** @hidden */
  47611. _textureFormatInUse: string;
  47612. /**
  47613. * Gets the list of texture formats supported
  47614. */
  47615. readonly texturesSupported: Array<string>;
  47616. /**
  47617. * Gets the texture format in use
  47618. */
  47619. readonly textureFormatInUse: Nullable<string>;
  47620. /**
  47621. * Set the compressed texture extensions or file names to skip.
  47622. *
  47623. * @param skippedFiles defines the list of those texture files you want to skip
  47624. * Example: [".dds", ".env", "myfile.png"]
  47625. */
  47626. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  47627. /**
  47628. * Set the compressed texture format to use, based on the formats you have, and the formats
  47629. * supported by the hardware / browser.
  47630. *
  47631. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  47632. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  47633. * to API arguments needed to compressed textures. This puts the burden on the container
  47634. * generator to house the arcane code for determining these for current & future formats.
  47635. *
  47636. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47637. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47638. *
  47639. * Note: The result of this call is not taken into account when a texture is base64.
  47640. *
  47641. * @param formatsAvailable defines the list of those format families you have created
  47642. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  47643. *
  47644. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  47645. * @returns The extension selected.
  47646. */
  47647. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  47648. }
  47649. }
  47650. declare module BABYLON {
  47651. /**
  47652. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47653. */
  47654. export interface CubeMapInfo {
  47655. /**
  47656. * The pixel array for the front face.
  47657. * This is stored in format, left to right, up to down format.
  47658. */
  47659. front: Nullable<ArrayBufferView>;
  47660. /**
  47661. * The pixel array for the back face.
  47662. * This is stored in format, left to right, up to down format.
  47663. */
  47664. back: Nullable<ArrayBufferView>;
  47665. /**
  47666. * The pixel array for the left face.
  47667. * This is stored in format, left to right, up to down format.
  47668. */
  47669. left: Nullable<ArrayBufferView>;
  47670. /**
  47671. * The pixel array for the right face.
  47672. * This is stored in format, left to right, up to down format.
  47673. */
  47674. right: Nullable<ArrayBufferView>;
  47675. /**
  47676. * The pixel array for the up face.
  47677. * This is stored in format, left to right, up to down format.
  47678. */
  47679. up: Nullable<ArrayBufferView>;
  47680. /**
  47681. * The pixel array for the down face.
  47682. * This is stored in format, left to right, up to down format.
  47683. */
  47684. down: Nullable<ArrayBufferView>;
  47685. /**
  47686. * The size of the cubemap stored.
  47687. *
  47688. * Each faces will be size * size pixels.
  47689. */
  47690. size: number;
  47691. /**
  47692. * The format of the texture.
  47693. *
  47694. * RGBA, RGB.
  47695. */
  47696. format: number;
  47697. /**
  47698. * The type of the texture data.
  47699. *
  47700. * UNSIGNED_INT, FLOAT.
  47701. */
  47702. type: number;
  47703. /**
  47704. * Specifies whether the texture is in gamma space.
  47705. */
  47706. gammaSpace: boolean;
  47707. }
  47708. /**
  47709. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47710. */
  47711. export class PanoramaToCubeMapTools {
  47712. private static FACE_FRONT;
  47713. private static FACE_BACK;
  47714. private static FACE_RIGHT;
  47715. private static FACE_LEFT;
  47716. private static FACE_DOWN;
  47717. private static FACE_UP;
  47718. /**
  47719. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47720. *
  47721. * @param float32Array The source data.
  47722. * @param inputWidth The width of the input panorama.
  47723. * @param inputHeight The height of the input panorama.
  47724. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47725. * @return The cubemap data
  47726. */
  47727. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47728. private static CreateCubemapTexture;
  47729. private static CalcProjectionSpherical;
  47730. }
  47731. }
  47732. declare module BABYLON {
  47733. /**
  47734. * Helper class dealing with the extraction of spherical polynomial dataArray
  47735. * from a cube map.
  47736. */
  47737. export class CubeMapToSphericalPolynomialTools {
  47738. private static FileFaces;
  47739. /**
  47740. * Converts a texture to the according Spherical Polynomial data.
  47741. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47742. *
  47743. * @param texture The texture to extract the information from.
  47744. * @return The Spherical Polynomial data.
  47745. */
  47746. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47747. /**
  47748. * Converts a cubemap to the according Spherical Polynomial data.
  47749. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47750. *
  47751. * @param cubeInfo The Cube map to extract the information from.
  47752. * @return The Spherical Polynomial data.
  47753. */
  47754. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47755. }
  47756. }
  47757. declare module BABYLON {
  47758. interface BaseTexture {
  47759. /**
  47760. * Get the polynomial representation of the texture data.
  47761. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47762. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47763. */
  47764. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47765. }
  47766. }
  47767. declare module BABYLON {
  47768. /** @hidden */
  47769. export var rgbdEncodePixelShader: {
  47770. name: string;
  47771. shader: string;
  47772. };
  47773. }
  47774. declare module BABYLON {
  47775. /** @hidden */
  47776. export var rgbdDecodePixelShader: {
  47777. name: string;
  47778. shader: string;
  47779. };
  47780. }
  47781. declare module BABYLON {
  47782. /**
  47783. * Raw texture data and descriptor sufficient for WebGL texture upload
  47784. */
  47785. export interface EnvironmentTextureInfo {
  47786. /**
  47787. * Version of the environment map
  47788. */
  47789. version: number;
  47790. /**
  47791. * Width of image
  47792. */
  47793. width: number;
  47794. /**
  47795. * Irradiance information stored in the file.
  47796. */
  47797. irradiance: any;
  47798. /**
  47799. * Specular information stored in the file.
  47800. */
  47801. specular: any;
  47802. }
  47803. /**
  47804. * Defines One Image in the file. It requires only the position in the file
  47805. * as well as the length.
  47806. */
  47807. interface BufferImageData {
  47808. /**
  47809. * Length of the image data.
  47810. */
  47811. length: number;
  47812. /**
  47813. * Position of the data from the null terminator delimiting the end of the JSON.
  47814. */
  47815. position: number;
  47816. }
  47817. /**
  47818. * Defines the specular data enclosed in the file.
  47819. * This corresponds to the version 1 of the data.
  47820. */
  47821. export interface EnvironmentTextureSpecularInfoV1 {
  47822. /**
  47823. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47824. */
  47825. specularDataPosition?: number;
  47826. /**
  47827. * This contains all the images data needed to reconstruct the cubemap.
  47828. */
  47829. mipmaps: Array<BufferImageData>;
  47830. /**
  47831. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47832. */
  47833. lodGenerationScale: number;
  47834. }
  47835. /**
  47836. * Sets of helpers addressing the serialization and deserialization of environment texture
  47837. * stored in a BabylonJS env file.
  47838. * Those files are usually stored as .env files.
  47839. */
  47840. export class EnvironmentTextureTools {
  47841. /**
  47842. * Magic number identifying the env file.
  47843. */
  47844. private static _MagicBytes;
  47845. /**
  47846. * Gets the environment info from an env file.
  47847. * @param data The array buffer containing the .env bytes.
  47848. * @returns the environment file info (the json header) if successfully parsed.
  47849. */
  47850. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47851. /**
  47852. * Creates an environment texture from a loaded cube texture.
  47853. * @param texture defines the cube texture to convert in env file
  47854. * @return a promise containing the environment data if succesfull.
  47855. */
  47856. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47857. /**
  47858. * Creates a JSON representation of the spherical data.
  47859. * @param texture defines the texture containing the polynomials
  47860. * @return the JSON representation of the spherical info
  47861. */
  47862. private static _CreateEnvTextureIrradiance;
  47863. /**
  47864. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47865. * @param data the image data
  47866. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47867. * @return the views described by info providing access to the underlying buffer
  47868. */
  47869. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47870. /**
  47871. * Uploads the texture info contained in the env file to the GPU.
  47872. * @param texture defines the internal texture to upload to
  47873. * @param data defines the data to load
  47874. * @param info defines the texture info retrieved through the GetEnvInfo method
  47875. * @returns a promise
  47876. */
  47877. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47878. private static _OnImageReadyAsync;
  47879. /**
  47880. * Uploads the levels of image data to the GPU.
  47881. * @param texture defines the internal texture to upload to
  47882. * @param imageData defines the array buffer views of image data [mipmap][face]
  47883. * @returns a promise
  47884. */
  47885. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47886. /**
  47887. * Uploads spherical polynomials information to the texture.
  47888. * @param texture defines the texture we are trying to upload the information to
  47889. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47890. */
  47891. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47892. /** @hidden */
  47893. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47894. }
  47895. }
  47896. declare module BABYLON {
  47897. /**
  47898. * Contains position and normal vectors for a vertex
  47899. */
  47900. export class PositionNormalVertex {
  47901. /** the position of the vertex (defaut: 0,0,0) */
  47902. position: Vector3;
  47903. /** the normal of the vertex (defaut: 0,1,0) */
  47904. normal: Vector3;
  47905. /**
  47906. * Creates a PositionNormalVertex
  47907. * @param position the position of the vertex (defaut: 0,0,0)
  47908. * @param normal the normal of the vertex (defaut: 0,1,0)
  47909. */
  47910. constructor(
  47911. /** the position of the vertex (defaut: 0,0,0) */
  47912. position?: Vector3,
  47913. /** the normal of the vertex (defaut: 0,1,0) */
  47914. normal?: Vector3);
  47915. /**
  47916. * Clones the PositionNormalVertex
  47917. * @returns the cloned PositionNormalVertex
  47918. */
  47919. clone(): PositionNormalVertex;
  47920. }
  47921. /**
  47922. * Contains position, normal and uv vectors for a vertex
  47923. */
  47924. export class PositionNormalTextureVertex {
  47925. /** the position of the vertex (defaut: 0,0,0) */
  47926. position: Vector3;
  47927. /** the normal of the vertex (defaut: 0,1,0) */
  47928. normal: Vector3;
  47929. /** the uv of the vertex (default: 0,0) */
  47930. uv: Vector2;
  47931. /**
  47932. * Creates a PositionNormalTextureVertex
  47933. * @param position the position of the vertex (defaut: 0,0,0)
  47934. * @param normal the normal of the vertex (defaut: 0,1,0)
  47935. * @param uv the uv of the vertex (default: 0,0)
  47936. */
  47937. constructor(
  47938. /** the position of the vertex (defaut: 0,0,0) */
  47939. position?: Vector3,
  47940. /** the normal of the vertex (defaut: 0,1,0) */
  47941. normal?: Vector3,
  47942. /** the uv of the vertex (default: 0,0) */
  47943. uv?: Vector2);
  47944. /**
  47945. * Clones the PositionNormalTextureVertex
  47946. * @returns the cloned PositionNormalTextureVertex
  47947. */
  47948. clone(): PositionNormalTextureVertex;
  47949. }
  47950. }
  47951. declare module BABYLON {
  47952. /** @hidden */
  47953. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47954. private _genericAttributeLocation;
  47955. private _varyingLocationCount;
  47956. private _varyingLocationMap;
  47957. private _replacements;
  47958. private _textureCount;
  47959. private _uniforms;
  47960. lineProcessor(line: string): string;
  47961. attributeProcessor(attribute: string): string;
  47962. varyingProcessor(varying: string, isFragment: boolean): string;
  47963. uniformProcessor(uniform: string): string;
  47964. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47965. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47966. }
  47967. }
  47968. declare module BABYLON {
  47969. /**
  47970. * Container for accessors for natively-stored mesh data buffers.
  47971. */
  47972. class NativeDataBuffer extends DataBuffer {
  47973. /**
  47974. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47975. */
  47976. nativeIndexBuffer?: any;
  47977. /**
  47978. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47979. */
  47980. nativeVertexBuffer?: any;
  47981. }
  47982. /** @hidden */
  47983. class NativeTexture extends InternalTexture {
  47984. getInternalTexture(): InternalTexture;
  47985. getViewCount(): number;
  47986. }
  47987. /** @hidden */
  47988. export class NativeEngine extends Engine {
  47989. private readonly _native;
  47990. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47991. private readonly INVALID_HANDLE;
  47992. getHardwareScalingLevel(): number;
  47993. constructor();
  47994. /**
  47995. * Can be used to override the current requestAnimationFrame requester.
  47996. * @hidden
  47997. */
  47998. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47999. /**
  48000. * Override default engine behavior.
  48001. * @param color
  48002. * @param backBuffer
  48003. * @param depth
  48004. * @param stencil
  48005. */
  48006. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48007. /**
  48008. * Gets host document
  48009. * @returns the host document object
  48010. */
  48011. getHostDocument(): Nullable<Document>;
  48012. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48013. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48014. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48015. recordVertexArrayObject(vertexBuffers: {
  48016. [key: string]: VertexBuffer;
  48017. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48018. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48019. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48020. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48021. /**
  48022. * Draw a list of indexed primitives
  48023. * @param fillMode defines the primitive to use
  48024. * @param indexStart defines the starting index
  48025. * @param indexCount defines the number of index to draw
  48026. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48027. */
  48028. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48029. /**
  48030. * Draw a list of unindexed primitives
  48031. * @param fillMode defines the primitive to use
  48032. * @param verticesStart defines the index of first vertex to draw
  48033. * @param verticesCount defines the count of vertices to draw
  48034. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48035. */
  48036. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48037. createPipelineContext(): IPipelineContext;
  48038. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48039. /** @hidden */
  48040. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48041. /** @hidden */
  48042. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48043. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48044. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48045. protected _setProgram(program: WebGLProgram): void;
  48046. _releaseEffect(effect: Effect): void;
  48047. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48048. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48049. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48050. bindSamplers(effect: Effect): void;
  48051. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48052. getRenderWidth(useScreen?: boolean): number;
  48053. getRenderHeight(useScreen?: boolean): number;
  48054. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48055. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48056. /**
  48057. * Set the z offset to apply to current rendering
  48058. * @param value defines the offset to apply
  48059. */
  48060. setZOffset(value: number): void;
  48061. /**
  48062. * Gets the current value of the zOffset
  48063. * @returns the current zOffset state
  48064. */
  48065. getZOffset(): number;
  48066. /**
  48067. * Enable or disable depth buffering
  48068. * @param enable defines the state to set
  48069. */
  48070. setDepthBuffer(enable: boolean): void;
  48071. /**
  48072. * Gets a boolean indicating if depth writing is enabled
  48073. * @returns the current depth writing state
  48074. */
  48075. getDepthWrite(): boolean;
  48076. /**
  48077. * Enable or disable depth writing
  48078. * @param enable defines the state to set
  48079. */
  48080. setDepthWrite(enable: boolean): void;
  48081. /**
  48082. * Enable or disable color writing
  48083. * @param enable defines the state to set
  48084. */
  48085. setColorWrite(enable: boolean): void;
  48086. /**
  48087. * Gets a boolean indicating if color writing is enabled
  48088. * @returns the current color writing state
  48089. */
  48090. getColorWrite(): boolean;
  48091. /**
  48092. * Sets alpha constants used by some alpha blending modes
  48093. * @param r defines the red component
  48094. * @param g defines the green component
  48095. * @param b defines the blue component
  48096. * @param a defines the alpha component
  48097. */
  48098. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48099. /**
  48100. * Sets the current alpha mode
  48101. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48102. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48103. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48104. */
  48105. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48106. /**
  48107. * Gets the current alpha mode
  48108. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48109. * @returns the current alpha mode
  48110. */
  48111. getAlphaMode(): number;
  48112. setInt(uniform: WebGLUniformLocation, int: number): void;
  48113. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48114. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48115. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48116. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48117. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48118. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48119. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48120. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48121. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48122. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48123. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48124. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48125. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48126. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48127. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48128. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48129. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48130. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48131. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48132. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48133. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48134. wipeCaches(bruteForce?: boolean): void;
  48135. _createTexture(): WebGLTexture;
  48136. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48137. /**
  48138. * Usually called from Texture.ts.
  48139. * Passed information to create a WebGLTexture
  48140. * @param urlArg defines a value which contains one of the following:
  48141. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48142. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48143. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48144. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48145. * @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)
  48146. * @param scene needed for loading to the correct scene
  48147. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48148. * @param onLoad optional callback to be called upon successful completion
  48149. * @param onError optional callback to be called upon failure
  48150. * @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
  48151. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48152. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48153. * @param forcedExtension defines the extension to use to pick the right loader
  48154. * @param mimeType defines an optional mime type
  48155. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48156. */
  48157. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  48158. /**
  48159. * Creates a cube texture
  48160. * @param rootUrl defines the url where the files to load is located
  48161. * @param scene defines the current scene
  48162. * @param files defines the list of files to load (1 per face)
  48163. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48164. * @param onLoad defines an optional callback raised when the texture is loaded
  48165. * @param onError defines an optional callback raised if there is an issue to load the texture
  48166. * @param format defines the format of the data
  48167. * @param forcedExtension defines the extension to use to pick the right loader
  48168. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48169. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48170. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48171. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48172. * @returns the cube texture as an InternalTexture
  48173. */
  48174. 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;
  48175. private _getSamplingFilter;
  48176. private static _GetNativeTextureFormat;
  48177. createRenderTargetTexture(size: number | {
  48178. width: number;
  48179. height: number;
  48180. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48181. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48182. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48183. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48184. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48185. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48186. /**
  48187. * Updates a dynamic vertex buffer.
  48188. * @param vertexBuffer the vertex buffer to update
  48189. * @param data the data used to update the vertex buffer
  48190. * @param byteOffset the byte offset of the data (optional)
  48191. * @param byteLength the byte length of the data (optional)
  48192. */
  48193. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48194. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48195. private _updateAnisotropicLevel;
  48196. private _getAddressMode;
  48197. /** @hidden */
  48198. _bindTexture(channel: number, texture: InternalTexture): void;
  48199. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48200. releaseEffects(): void;
  48201. /** @hidden */
  48202. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48203. /** @hidden */
  48204. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48205. /** @hidden */
  48206. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48207. /** @hidden */
  48208. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48209. }
  48210. }
  48211. declare module BABYLON {
  48212. /**
  48213. * Gather the list of clipboard event types as constants.
  48214. */
  48215. export class ClipboardEventTypes {
  48216. /**
  48217. * The clipboard event is fired when a copy command is active (pressed).
  48218. */
  48219. static readonly COPY: number;
  48220. /**
  48221. * The clipboard event is fired when a cut command is active (pressed).
  48222. */
  48223. static readonly CUT: number;
  48224. /**
  48225. * The clipboard event is fired when a paste command is active (pressed).
  48226. */
  48227. static readonly PASTE: number;
  48228. }
  48229. /**
  48230. * This class is used to store clipboard related info for the onClipboardObservable event.
  48231. */
  48232. export class ClipboardInfo {
  48233. /**
  48234. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48235. */
  48236. type: number;
  48237. /**
  48238. * Defines the related dom event
  48239. */
  48240. event: ClipboardEvent;
  48241. /**
  48242. *Creates an instance of ClipboardInfo.
  48243. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48244. * @param event Defines the related dom event
  48245. */
  48246. constructor(
  48247. /**
  48248. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48249. */
  48250. type: number,
  48251. /**
  48252. * Defines the related dom event
  48253. */
  48254. event: ClipboardEvent);
  48255. /**
  48256. * Get the clipboard event's type from the keycode.
  48257. * @param keyCode Defines the keyCode for the current keyboard event.
  48258. * @return {number}
  48259. */
  48260. static GetTypeFromCharacter(keyCode: number): number;
  48261. }
  48262. }
  48263. declare module BABYLON {
  48264. /**
  48265. * Google Daydream controller
  48266. */
  48267. export class DaydreamController extends WebVRController {
  48268. /**
  48269. * Base Url for the controller model.
  48270. */
  48271. static MODEL_BASE_URL: string;
  48272. /**
  48273. * File name for the controller model.
  48274. */
  48275. static MODEL_FILENAME: string;
  48276. /**
  48277. * Gamepad Id prefix used to identify Daydream Controller.
  48278. */
  48279. static readonly GAMEPAD_ID_PREFIX: string;
  48280. /**
  48281. * Creates a new DaydreamController from a gamepad
  48282. * @param vrGamepad the gamepad that the controller should be created from
  48283. */
  48284. constructor(vrGamepad: any);
  48285. /**
  48286. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48287. * @param scene scene in which to add meshes
  48288. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48289. */
  48290. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48291. /**
  48292. * Called once for each button that changed state since the last frame
  48293. * @param buttonIdx Which button index changed
  48294. * @param state New state of the button
  48295. * @param changes Which properties on the state changed since last frame
  48296. */
  48297. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48298. }
  48299. }
  48300. declare module BABYLON {
  48301. /**
  48302. * Gear VR Controller
  48303. */
  48304. export class GearVRController extends WebVRController {
  48305. /**
  48306. * Base Url for the controller model.
  48307. */
  48308. static MODEL_BASE_URL: string;
  48309. /**
  48310. * File name for the controller model.
  48311. */
  48312. static MODEL_FILENAME: string;
  48313. /**
  48314. * Gamepad Id prefix used to identify this controller.
  48315. */
  48316. static readonly GAMEPAD_ID_PREFIX: string;
  48317. private readonly _buttonIndexToObservableNameMap;
  48318. /**
  48319. * Creates a new GearVRController from a gamepad
  48320. * @param vrGamepad the gamepad that the controller should be created from
  48321. */
  48322. constructor(vrGamepad: any);
  48323. /**
  48324. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48325. * @param scene scene in which to add meshes
  48326. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48327. */
  48328. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48329. /**
  48330. * Called once for each button that changed state since the last frame
  48331. * @param buttonIdx Which button index changed
  48332. * @param state New state of the button
  48333. * @param changes Which properties on the state changed since last frame
  48334. */
  48335. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48336. }
  48337. }
  48338. declare module BABYLON {
  48339. /**
  48340. * Generic Controller
  48341. */
  48342. export class GenericController extends WebVRController {
  48343. /**
  48344. * Base Url for the controller model.
  48345. */
  48346. static readonly MODEL_BASE_URL: string;
  48347. /**
  48348. * File name for the controller model.
  48349. */
  48350. static readonly MODEL_FILENAME: string;
  48351. /**
  48352. * Creates a new GenericController from a gamepad
  48353. * @param vrGamepad the gamepad that the controller should be created from
  48354. */
  48355. constructor(vrGamepad: any);
  48356. /**
  48357. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48358. * @param scene scene in which to add meshes
  48359. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48360. */
  48361. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48362. /**
  48363. * Called once for each button that changed state since the last frame
  48364. * @param buttonIdx Which button index changed
  48365. * @param state New state of the button
  48366. * @param changes Which properties on the state changed since last frame
  48367. */
  48368. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48369. }
  48370. }
  48371. declare module BABYLON {
  48372. /**
  48373. * Oculus Touch Controller
  48374. */
  48375. export class OculusTouchController extends WebVRController {
  48376. /**
  48377. * Base Url for the controller model.
  48378. */
  48379. static MODEL_BASE_URL: string;
  48380. /**
  48381. * File name for the left controller model.
  48382. */
  48383. static MODEL_LEFT_FILENAME: string;
  48384. /**
  48385. * File name for the right controller model.
  48386. */
  48387. static MODEL_RIGHT_FILENAME: string;
  48388. /**
  48389. * Base Url for the Quest controller model.
  48390. */
  48391. static QUEST_MODEL_BASE_URL: string;
  48392. /**
  48393. * @hidden
  48394. * If the controllers are running on a device that needs the updated Quest controller models
  48395. */
  48396. static _IsQuest: boolean;
  48397. /**
  48398. * Fired when the secondary trigger on this controller is modified
  48399. */
  48400. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48401. /**
  48402. * Fired when the thumb rest on this controller is modified
  48403. */
  48404. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48405. /**
  48406. * Creates a new OculusTouchController from a gamepad
  48407. * @param vrGamepad the gamepad that the controller should be created from
  48408. */
  48409. constructor(vrGamepad: any);
  48410. /**
  48411. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48412. * @param scene scene in which to add meshes
  48413. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48414. */
  48415. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48416. /**
  48417. * Fired when the A button on this controller is modified
  48418. */
  48419. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48420. /**
  48421. * Fired when the B button on this controller is modified
  48422. */
  48423. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48424. /**
  48425. * Fired when the X button on this controller is modified
  48426. */
  48427. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48428. /**
  48429. * Fired when the Y button on this controller is modified
  48430. */
  48431. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48432. /**
  48433. * Called once for each button that changed state since the last frame
  48434. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48435. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48436. * 2) secondary trigger (same)
  48437. * 3) A (right) X (left), touch, pressed = value
  48438. * 4) B / Y
  48439. * 5) thumb rest
  48440. * @param buttonIdx Which button index changed
  48441. * @param state New state of the button
  48442. * @param changes Which properties on the state changed since last frame
  48443. */
  48444. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48445. }
  48446. }
  48447. declare module BABYLON {
  48448. /**
  48449. * Vive Controller
  48450. */
  48451. export class ViveController extends WebVRController {
  48452. /**
  48453. * Base Url for the controller model.
  48454. */
  48455. static MODEL_BASE_URL: string;
  48456. /**
  48457. * File name for the controller model.
  48458. */
  48459. static MODEL_FILENAME: string;
  48460. /**
  48461. * Creates a new ViveController from a gamepad
  48462. * @param vrGamepad the gamepad that the controller should be created from
  48463. */
  48464. constructor(vrGamepad: any);
  48465. /**
  48466. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48467. * @param scene scene in which to add meshes
  48468. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48469. */
  48470. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48471. /**
  48472. * Fired when the left button on this controller is modified
  48473. */
  48474. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48475. /**
  48476. * Fired when the right button on this controller is modified
  48477. */
  48478. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48479. /**
  48480. * Fired when the menu button on this controller is modified
  48481. */
  48482. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48483. /**
  48484. * Called once for each button that changed state since the last frame
  48485. * Vive mapping:
  48486. * 0: touchpad
  48487. * 1: trigger
  48488. * 2: left AND right buttons
  48489. * 3: menu button
  48490. * @param buttonIdx Which button index changed
  48491. * @param state New state of the button
  48492. * @param changes Which properties on the state changed since last frame
  48493. */
  48494. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48495. }
  48496. }
  48497. declare module BABYLON {
  48498. /**
  48499. * Defines the WindowsMotionController object that the state of the windows motion controller
  48500. */
  48501. export class WindowsMotionController extends WebVRController {
  48502. /**
  48503. * The base url used to load the left and right controller models
  48504. */
  48505. static MODEL_BASE_URL: string;
  48506. /**
  48507. * The name of the left controller model file
  48508. */
  48509. static MODEL_LEFT_FILENAME: string;
  48510. /**
  48511. * The name of the right controller model file
  48512. */
  48513. static MODEL_RIGHT_FILENAME: string;
  48514. /**
  48515. * The controller name prefix for this controller type
  48516. */
  48517. static readonly GAMEPAD_ID_PREFIX: string;
  48518. /**
  48519. * The controller id pattern for this controller type
  48520. */
  48521. private static readonly GAMEPAD_ID_PATTERN;
  48522. private _loadedMeshInfo;
  48523. protected readonly _mapping: {
  48524. buttons: string[];
  48525. buttonMeshNames: {
  48526. trigger: string;
  48527. menu: string;
  48528. grip: string;
  48529. thumbstick: string;
  48530. trackpad: string;
  48531. };
  48532. buttonObservableNames: {
  48533. trigger: string;
  48534. menu: string;
  48535. grip: string;
  48536. thumbstick: string;
  48537. trackpad: string;
  48538. };
  48539. axisMeshNames: string[];
  48540. pointingPoseMeshName: string;
  48541. };
  48542. /**
  48543. * Fired when the trackpad on this controller is clicked
  48544. */
  48545. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48546. /**
  48547. * Fired when the trackpad on this controller is modified
  48548. */
  48549. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48550. /**
  48551. * The current x and y values of this controller's trackpad
  48552. */
  48553. trackpad: StickValues;
  48554. /**
  48555. * Creates a new WindowsMotionController from a gamepad
  48556. * @param vrGamepad the gamepad that the controller should be created from
  48557. */
  48558. constructor(vrGamepad: any);
  48559. /**
  48560. * Fired when the trigger on this controller is modified
  48561. */
  48562. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48563. /**
  48564. * Fired when the menu button on this controller is modified
  48565. */
  48566. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48567. /**
  48568. * Fired when the grip button on this controller is modified
  48569. */
  48570. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48571. /**
  48572. * Fired when the thumbstick button on this controller is modified
  48573. */
  48574. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48575. /**
  48576. * Fired when the touchpad button on this controller is modified
  48577. */
  48578. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48579. /**
  48580. * Fired when the touchpad values on this controller are modified
  48581. */
  48582. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48583. protected _updateTrackpad(): void;
  48584. /**
  48585. * Called once per frame by the engine.
  48586. */
  48587. update(): void;
  48588. /**
  48589. * Called once for each button that changed state since the last frame
  48590. * @param buttonIdx Which button index changed
  48591. * @param state New state of the button
  48592. * @param changes Which properties on the state changed since last frame
  48593. */
  48594. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48595. /**
  48596. * Moves the buttons on the controller mesh based on their current state
  48597. * @param buttonName the name of the button to move
  48598. * @param buttonValue the value of the button which determines the buttons new position
  48599. */
  48600. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48601. /**
  48602. * Moves the axis on the controller mesh based on its current state
  48603. * @param axis the index of the axis
  48604. * @param axisValue the value of the axis which determines the meshes new position
  48605. * @hidden
  48606. */
  48607. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48608. /**
  48609. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48610. * @param scene scene in which to add meshes
  48611. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48612. */
  48613. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48614. /**
  48615. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48616. * can be transformed by button presses and axes values, based on this._mapping.
  48617. *
  48618. * @param scene scene in which the meshes exist
  48619. * @param meshes list of meshes that make up the controller model to process
  48620. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48621. */
  48622. private processModel;
  48623. private createMeshInfo;
  48624. /**
  48625. * Gets the ray of the controller in the direction the controller is pointing
  48626. * @param length the length the resulting ray should be
  48627. * @returns a ray in the direction the controller is pointing
  48628. */
  48629. getForwardRay(length?: number): Ray;
  48630. /**
  48631. * Disposes of the controller
  48632. */
  48633. dispose(): void;
  48634. }
  48635. /**
  48636. * This class represents a new windows motion controller in XR.
  48637. */
  48638. export class XRWindowsMotionController extends WindowsMotionController {
  48639. /**
  48640. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48641. */
  48642. protected readonly _mapping: {
  48643. buttons: string[];
  48644. buttonMeshNames: {
  48645. trigger: string;
  48646. menu: string;
  48647. grip: string;
  48648. thumbstick: string;
  48649. trackpad: string;
  48650. };
  48651. buttonObservableNames: {
  48652. trigger: string;
  48653. menu: string;
  48654. grip: string;
  48655. thumbstick: string;
  48656. trackpad: string;
  48657. };
  48658. axisMeshNames: string[];
  48659. pointingPoseMeshName: string;
  48660. };
  48661. /**
  48662. * Construct a new XR-Based windows motion controller
  48663. *
  48664. * @param gamepadInfo the gamepad object from the browser
  48665. */
  48666. constructor(gamepadInfo: any);
  48667. /**
  48668. * holds the thumbstick values (X,Y)
  48669. */
  48670. thumbstickValues: StickValues;
  48671. /**
  48672. * Fired when the thumbstick on this controller is clicked
  48673. */
  48674. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48675. /**
  48676. * Fired when the thumbstick on this controller is modified
  48677. */
  48678. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48679. /**
  48680. * Fired when the touchpad button on this controller is modified
  48681. */
  48682. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48683. /**
  48684. * Fired when the touchpad values on this controller are modified
  48685. */
  48686. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48687. /**
  48688. * Fired when the thumbstick button on this controller is modified
  48689. * here to prevent breaking changes
  48690. */
  48691. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48692. /**
  48693. * updating the thumbstick(!) and not the trackpad.
  48694. * This is named this way due to the difference between WebVR and XR and to avoid
  48695. * changing the parent class.
  48696. */
  48697. protected _updateTrackpad(): void;
  48698. /**
  48699. * Disposes the class with joy
  48700. */
  48701. dispose(): void;
  48702. }
  48703. }
  48704. declare module BABYLON {
  48705. /**
  48706. * Class containing static functions to help procedurally build meshes
  48707. */
  48708. export class PolyhedronBuilder {
  48709. /**
  48710. * Creates a polyhedron mesh
  48711. * * 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
  48712. * * The parameter `size` (positive float, default 1) sets the polygon size
  48713. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48714. * * 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`
  48715. * * 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
  48716. * * 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)`)
  48717. * * 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
  48718. * * 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
  48719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48720. * * 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
  48721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48722. * @param name defines the name of the mesh
  48723. * @param options defines the options used to create the mesh
  48724. * @param scene defines the hosting scene
  48725. * @returns the polyhedron mesh
  48726. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48727. */
  48728. static CreatePolyhedron(name: string, options: {
  48729. type?: number;
  48730. size?: number;
  48731. sizeX?: number;
  48732. sizeY?: number;
  48733. sizeZ?: number;
  48734. custom?: any;
  48735. faceUV?: Vector4[];
  48736. faceColors?: Color4[];
  48737. flat?: boolean;
  48738. updatable?: boolean;
  48739. sideOrientation?: number;
  48740. frontUVs?: Vector4;
  48741. backUVs?: Vector4;
  48742. }, scene?: Nullable<Scene>): Mesh;
  48743. }
  48744. }
  48745. declare module BABYLON {
  48746. /**
  48747. * Gizmo that enables scaling a mesh along 3 axis
  48748. */
  48749. export class ScaleGizmo extends Gizmo {
  48750. /**
  48751. * Internal gizmo used for interactions on the x axis
  48752. */
  48753. xGizmo: AxisScaleGizmo;
  48754. /**
  48755. * Internal gizmo used for interactions on the y axis
  48756. */
  48757. yGizmo: AxisScaleGizmo;
  48758. /**
  48759. * Internal gizmo used for interactions on the z axis
  48760. */
  48761. zGizmo: AxisScaleGizmo;
  48762. /**
  48763. * Internal gizmo used to scale all axis equally
  48764. */
  48765. uniformScaleGizmo: AxisScaleGizmo;
  48766. private _meshAttached;
  48767. private _updateGizmoRotationToMatchAttachedMesh;
  48768. private _snapDistance;
  48769. private _scaleRatio;
  48770. private _uniformScalingMesh;
  48771. private _octahedron;
  48772. private _sensitivity;
  48773. /** Fires an event when any of it's sub gizmos are dragged */
  48774. onDragStartObservable: Observable<unknown>;
  48775. /** Fires an event when any of it's sub gizmos are released from dragging */
  48776. onDragEndObservable: Observable<unknown>;
  48777. get attachedMesh(): Nullable<AbstractMesh>;
  48778. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48779. /**
  48780. * Creates a ScaleGizmo
  48781. * @param gizmoLayer The utility layer the gizmo will be added to
  48782. */
  48783. constructor(gizmoLayer?: UtilityLayerRenderer);
  48784. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48785. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48786. /**
  48787. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48788. */
  48789. set snapDistance(value: number);
  48790. get snapDistance(): number;
  48791. /**
  48792. * Ratio for the scale of the gizmo (Default: 1)
  48793. */
  48794. set scaleRatio(value: number);
  48795. get scaleRatio(): number;
  48796. /**
  48797. * Sensitivity factor for dragging (Default: 1)
  48798. */
  48799. set sensitivity(value: number);
  48800. get sensitivity(): number;
  48801. /**
  48802. * Disposes of the gizmo
  48803. */
  48804. dispose(): void;
  48805. }
  48806. }
  48807. declare module BABYLON {
  48808. /**
  48809. * Single axis scale gizmo
  48810. */
  48811. export class AxisScaleGizmo extends Gizmo {
  48812. /**
  48813. * Drag behavior responsible for the gizmos dragging interactions
  48814. */
  48815. dragBehavior: PointerDragBehavior;
  48816. private _pointerObserver;
  48817. /**
  48818. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48819. */
  48820. snapDistance: number;
  48821. /**
  48822. * Event that fires each time the gizmo snaps to a new location.
  48823. * * snapDistance is the the change in distance
  48824. */
  48825. onSnapObservable: Observable<{
  48826. snapDistance: number;
  48827. }>;
  48828. /**
  48829. * If the scaling operation should be done on all axis (default: false)
  48830. */
  48831. uniformScaling: boolean;
  48832. /**
  48833. * Custom sensitivity value for the drag strength
  48834. */
  48835. sensitivity: number;
  48836. private _isEnabled;
  48837. private _parent;
  48838. private _arrow;
  48839. private _coloredMaterial;
  48840. private _hoverMaterial;
  48841. /**
  48842. * Creates an AxisScaleGizmo
  48843. * @param gizmoLayer The utility layer the gizmo will be added to
  48844. * @param dragAxis The axis which the gizmo will be able to scale on
  48845. * @param color The color of the gizmo
  48846. */
  48847. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48848. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48849. /**
  48850. * If the gizmo is enabled
  48851. */
  48852. set isEnabled(value: boolean);
  48853. get isEnabled(): boolean;
  48854. /**
  48855. * Disposes of the gizmo
  48856. */
  48857. dispose(): void;
  48858. /**
  48859. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48860. * @param mesh The mesh to replace the default mesh of the gizmo
  48861. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48862. */
  48863. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48864. }
  48865. }
  48866. declare module BABYLON {
  48867. /**
  48868. * Bounding box gizmo
  48869. */
  48870. export class BoundingBoxGizmo extends Gizmo {
  48871. private _lineBoundingBox;
  48872. private _rotateSpheresParent;
  48873. private _scaleBoxesParent;
  48874. private _boundingDimensions;
  48875. private _renderObserver;
  48876. private _pointerObserver;
  48877. private _scaleDragSpeed;
  48878. private _tmpQuaternion;
  48879. private _tmpVector;
  48880. private _tmpRotationMatrix;
  48881. /**
  48882. * 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)
  48883. */
  48884. ignoreChildren: boolean;
  48885. /**
  48886. * 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)
  48887. */
  48888. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48889. /**
  48890. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48891. */
  48892. rotationSphereSize: number;
  48893. /**
  48894. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48895. */
  48896. scaleBoxSize: number;
  48897. /**
  48898. * 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)
  48899. */
  48900. fixedDragMeshScreenSize: boolean;
  48901. /**
  48902. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48903. */
  48904. fixedDragMeshScreenSizeDistanceFactor: number;
  48905. /**
  48906. * Fired when a rotation sphere or scale box is dragged
  48907. */
  48908. onDragStartObservable: Observable<{}>;
  48909. /**
  48910. * Fired when a scale box is dragged
  48911. */
  48912. onScaleBoxDragObservable: Observable<{}>;
  48913. /**
  48914. * Fired when a scale box drag is ended
  48915. */
  48916. onScaleBoxDragEndObservable: Observable<{}>;
  48917. /**
  48918. * Fired when a rotation sphere is dragged
  48919. */
  48920. onRotationSphereDragObservable: Observable<{}>;
  48921. /**
  48922. * Fired when a rotation sphere drag is ended
  48923. */
  48924. onRotationSphereDragEndObservable: Observable<{}>;
  48925. /**
  48926. * 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)
  48927. */
  48928. scalePivot: Nullable<Vector3>;
  48929. /**
  48930. * Mesh used as a pivot to rotate the attached mesh
  48931. */
  48932. private _anchorMesh;
  48933. private _existingMeshScale;
  48934. private _dragMesh;
  48935. private pointerDragBehavior;
  48936. private coloredMaterial;
  48937. private hoverColoredMaterial;
  48938. /**
  48939. * Sets the color of the bounding box gizmo
  48940. * @param color the color to set
  48941. */
  48942. setColor(color: Color3): void;
  48943. /**
  48944. * Creates an BoundingBoxGizmo
  48945. * @param gizmoLayer The utility layer the gizmo will be added to
  48946. * @param color The color of the gizmo
  48947. */
  48948. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48949. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48950. private _selectNode;
  48951. /**
  48952. * Updates the bounding box information for the Gizmo
  48953. */
  48954. updateBoundingBox(): void;
  48955. private _updateRotationSpheres;
  48956. private _updateScaleBoxes;
  48957. /**
  48958. * Enables rotation on the specified axis and disables rotation on the others
  48959. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48960. */
  48961. setEnabledRotationAxis(axis: string): void;
  48962. /**
  48963. * Enables/disables scaling
  48964. * @param enable if scaling should be enabled
  48965. * @param homogeneousScaling defines if scaling should only be homogeneous
  48966. */
  48967. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  48968. private _updateDummy;
  48969. /**
  48970. * Enables a pointer drag behavior on the bounding box of the gizmo
  48971. */
  48972. enableDragBehavior(): void;
  48973. /**
  48974. * Disposes of the gizmo
  48975. */
  48976. dispose(): void;
  48977. /**
  48978. * 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)
  48979. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48980. * @returns the bounding box mesh with the passed in mesh as a child
  48981. */
  48982. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48983. /**
  48984. * CustomMeshes are not supported by this gizmo
  48985. * @param mesh The mesh to replace the default mesh of the gizmo
  48986. */
  48987. setCustomMesh(mesh: Mesh): void;
  48988. }
  48989. }
  48990. declare module BABYLON {
  48991. /**
  48992. * Single plane rotation gizmo
  48993. */
  48994. export class PlaneRotationGizmo extends Gizmo {
  48995. /**
  48996. * Drag behavior responsible for the gizmos dragging interactions
  48997. */
  48998. dragBehavior: PointerDragBehavior;
  48999. private _pointerObserver;
  49000. /**
  49001. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49002. */
  49003. snapDistance: number;
  49004. /**
  49005. * Event that fires each time the gizmo snaps to a new location.
  49006. * * snapDistance is the the change in distance
  49007. */
  49008. onSnapObservable: Observable<{
  49009. snapDistance: number;
  49010. }>;
  49011. private _isEnabled;
  49012. private _parent;
  49013. /**
  49014. * Creates a PlaneRotationGizmo
  49015. * @param gizmoLayer The utility layer the gizmo will be added to
  49016. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49017. * @param color The color of the gizmo
  49018. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49019. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49020. */
  49021. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49022. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49023. /**
  49024. * If the gizmo is enabled
  49025. */
  49026. set isEnabled(value: boolean);
  49027. get isEnabled(): boolean;
  49028. /**
  49029. * Disposes of the gizmo
  49030. */
  49031. dispose(): void;
  49032. }
  49033. }
  49034. declare module BABYLON {
  49035. /**
  49036. * Gizmo that enables rotating a mesh along 3 axis
  49037. */
  49038. export class RotationGizmo extends Gizmo {
  49039. /**
  49040. * Internal gizmo used for interactions on the x axis
  49041. */
  49042. xGizmo: PlaneRotationGizmo;
  49043. /**
  49044. * Internal gizmo used for interactions on the y axis
  49045. */
  49046. yGizmo: PlaneRotationGizmo;
  49047. /**
  49048. * Internal gizmo used for interactions on the z axis
  49049. */
  49050. zGizmo: PlaneRotationGizmo;
  49051. /** Fires an event when any of it's sub gizmos are dragged */
  49052. onDragStartObservable: Observable<unknown>;
  49053. /** Fires an event when any of it's sub gizmos are released from dragging */
  49054. onDragEndObservable: Observable<unknown>;
  49055. private _meshAttached;
  49056. get attachedMesh(): Nullable<AbstractMesh>;
  49057. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49058. /**
  49059. * Creates a RotationGizmo
  49060. * @param gizmoLayer The utility layer the gizmo will be added to
  49061. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49062. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49063. */
  49064. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49065. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49066. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49067. /**
  49068. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49069. */
  49070. set snapDistance(value: number);
  49071. get snapDistance(): number;
  49072. /**
  49073. * Ratio for the scale of the gizmo (Default: 1)
  49074. */
  49075. set scaleRatio(value: number);
  49076. get scaleRatio(): number;
  49077. /**
  49078. * Disposes of the gizmo
  49079. */
  49080. dispose(): void;
  49081. /**
  49082. * CustomMeshes are not supported by this gizmo
  49083. * @param mesh The mesh to replace the default mesh of the gizmo
  49084. */
  49085. setCustomMesh(mesh: Mesh): void;
  49086. }
  49087. }
  49088. declare module BABYLON {
  49089. /**
  49090. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49091. */
  49092. export class GizmoManager implements IDisposable {
  49093. private scene;
  49094. /**
  49095. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49096. */
  49097. gizmos: {
  49098. positionGizmo: Nullable<PositionGizmo>;
  49099. rotationGizmo: Nullable<RotationGizmo>;
  49100. scaleGizmo: Nullable<ScaleGizmo>;
  49101. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49102. };
  49103. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49104. clearGizmoOnEmptyPointerEvent: boolean;
  49105. /** Fires an event when the manager is attached to a mesh */
  49106. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49107. private _gizmosEnabled;
  49108. private _pointerObserver;
  49109. private _attachedMesh;
  49110. private _boundingBoxColor;
  49111. private _defaultUtilityLayer;
  49112. private _defaultKeepDepthUtilityLayer;
  49113. /**
  49114. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49115. */
  49116. boundingBoxDragBehavior: SixDofDragBehavior;
  49117. /**
  49118. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49119. */
  49120. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49121. /**
  49122. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49123. */
  49124. usePointerToAttachGizmos: boolean;
  49125. /**
  49126. * Utility layer that the bounding box gizmo belongs to
  49127. */
  49128. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49129. /**
  49130. * Utility layer that all gizmos besides bounding box belong to
  49131. */
  49132. get utilityLayer(): UtilityLayerRenderer;
  49133. /**
  49134. * Instatiates a gizmo manager
  49135. * @param scene the scene to overlay the gizmos on top of
  49136. */
  49137. constructor(scene: Scene);
  49138. /**
  49139. * Attaches a set of gizmos to the specified mesh
  49140. * @param mesh The mesh the gizmo's should be attached to
  49141. */
  49142. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49143. /**
  49144. * If the position gizmo is enabled
  49145. */
  49146. set positionGizmoEnabled(value: boolean);
  49147. get positionGizmoEnabled(): boolean;
  49148. /**
  49149. * If the rotation gizmo is enabled
  49150. */
  49151. set rotationGizmoEnabled(value: boolean);
  49152. get rotationGizmoEnabled(): boolean;
  49153. /**
  49154. * If the scale gizmo is enabled
  49155. */
  49156. set scaleGizmoEnabled(value: boolean);
  49157. get scaleGizmoEnabled(): boolean;
  49158. /**
  49159. * If the boundingBox gizmo is enabled
  49160. */
  49161. set boundingBoxGizmoEnabled(value: boolean);
  49162. get boundingBoxGizmoEnabled(): boolean;
  49163. /**
  49164. * Disposes of the gizmo manager
  49165. */
  49166. dispose(): void;
  49167. }
  49168. }
  49169. declare module BABYLON {
  49170. /**
  49171. * A directional light is defined by a direction (what a surprise!).
  49172. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49173. * 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.
  49174. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49175. */
  49176. export class DirectionalLight extends ShadowLight {
  49177. private _shadowFrustumSize;
  49178. /**
  49179. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49180. */
  49181. get shadowFrustumSize(): number;
  49182. /**
  49183. * Specifies a fix frustum size for the shadow generation.
  49184. */
  49185. set shadowFrustumSize(value: number);
  49186. private _shadowOrthoScale;
  49187. /**
  49188. * Gets the shadow projection scale against the optimal computed one.
  49189. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49190. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49191. */
  49192. get shadowOrthoScale(): number;
  49193. /**
  49194. * Sets the shadow projection scale against the optimal computed one.
  49195. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49196. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49197. */
  49198. set shadowOrthoScale(value: number);
  49199. /**
  49200. * Automatically compute the projection matrix to best fit (including all the casters)
  49201. * on each frame.
  49202. */
  49203. autoUpdateExtends: boolean;
  49204. /**
  49205. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49206. * on each frame. autoUpdateExtends must be set to true for this to work
  49207. */
  49208. autoCalcShadowZBounds: boolean;
  49209. private _orthoLeft;
  49210. private _orthoRight;
  49211. private _orthoTop;
  49212. private _orthoBottom;
  49213. /**
  49214. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49215. * The directional light is emitted from everywhere in the given direction.
  49216. * It can cast shadows.
  49217. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49218. * @param name The friendly name of the light
  49219. * @param direction The direction of the light
  49220. * @param scene The scene the light belongs to
  49221. */
  49222. constructor(name: string, direction: Vector3, scene: Scene);
  49223. /**
  49224. * Returns the string "DirectionalLight".
  49225. * @return The class name
  49226. */
  49227. getClassName(): string;
  49228. /**
  49229. * Returns the integer 1.
  49230. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49231. */
  49232. getTypeID(): number;
  49233. /**
  49234. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49235. * Returns the DirectionalLight Shadow projection matrix.
  49236. */
  49237. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49238. /**
  49239. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49240. * Returns the DirectionalLight Shadow projection matrix.
  49241. */
  49242. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49243. /**
  49244. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49245. * Returns the DirectionalLight Shadow projection matrix.
  49246. */
  49247. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49248. protected _buildUniformLayout(): void;
  49249. /**
  49250. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49251. * @param effect The effect to update
  49252. * @param lightIndex The index of the light in the effect to update
  49253. * @returns The directional light
  49254. */
  49255. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49256. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49257. /**
  49258. * Gets the minZ used for shadow according to both the scene and the light.
  49259. *
  49260. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49261. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49262. * @param activeCamera The camera we are returning the min for
  49263. * @returns the depth min z
  49264. */
  49265. getDepthMinZ(activeCamera: Camera): number;
  49266. /**
  49267. * Gets the maxZ used for shadow according to both the scene and the light.
  49268. *
  49269. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49270. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49271. * @param activeCamera The camera we are returning the max for
  49272. * @returns the depth max z
  49273. */
  49274. getDepthMaxZ(activeCamera: Camera): number;
  49275. /**
  49276. * Prepares the list of defines specific to the light type.
  49277. * @param defines the list of defines
  49278. * @param lightIndex defines the index of the light for the effect
  49279. */
  49280. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49281. }
  49282. }
  49283. declare module BABYLON {
  49284. /**
  49285. * Class containing static functions to help procedurally build meshes
  49286. */
  49287. export class HemisphereBuilder {
  49288. /**
  49289. * Creates a hemisphere mesh
  49290. * @param name defines the name of the mesh
  49291. * @param options defines the options used to create the mesh
  49292. * @param scene defines the hosting scene
  49293. * @returns the hemisphere mesh
  49294. */
  49295. static CreateHemisphere(name: string, options: {
  49296. segments?: number;
  49297. diameter?: number;
  49298. sideOrientation?: number;
  49299. }, scene: any): Mesh;
  49300. }
  49301. }
  49302. declare module BABYLON {
  49303. /**
  49304. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49305. * These values define a cone of light starting from the position, emitting toward the direction.
  49306. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49307. * and the exponent defines the speed of the decay of the light with distance (reach).
  49308. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49309. */
  49310. export class SpotLight extends ShadowLight {
  49311. private _angle;
  49312. private _innerAngle;
  49313. private _cosHalfAngle;
  49314. private _lightAngleScale;
  49315. private _lightAngleOffset;
  49316. /**
  49317. * Gets the cone angle of the spot light in Radians.
  49318. */
  49319. get angle(): number;
  49320. /**
  49321. * Sets the cone angle of the spot light in Radians.
  49322. */
  49323. set angle(value: number);
  49324. /**
  49325. * Only used in gltf falloff mode, this defines the angle where
  49326. * the directional falloff will start before cutting at angle which could be seen
  49327. * as outer angle.
  49328. */
  49329. get innerAngle(): number;
  49330. /**
  49331. * Only used in gltf falloff mode, this defines the angle where
  49332. * the directional falloff will start before cutting at angle which could be seen
  49333. * as outer angle.
  49334. */
  49335. set innerAngle(value: number);
  49336. private _shadowAngleScale;
  49337. /**
  49338. * Allows scaling the angle of the light for shadow generation only.
  49339. */
  49340. get shadowAngleScale(): number;
  49341. /**
  49342. * Allows scaling the angle of the light for shadow generation only.
  49343. */
  49344. set shadowAngleScale(value: number);
  49345. /**
  49346. * The light decay speed with the distance from the emission spot.
  49347. */
  49348. exponent: number;
  49349. private _projectionTextureMatrix;
  49350. /**
  49351. * Allows reading the projecton texture
  49352. */
  49353. get projectionTextureMatrix(): Matrix;
  49354. protected _projectionTextureLightNear: number;
  49355. /**
  49356. * Gets the near clip of the Spotlight for texture projection.
  49357. */
  49358. get projectionTextureLightNear(): number;
  49359. /**
  49360. * Sets the near clip of the Spotlight for texture projection.
  49361. */
  49362. set projectionTextureLightNear(value: number);
  49363. protected _projectionTextureLightFar: number;
  49364. /**
  49365. * Gets the far clip of the Spotlight for texture projection.
  49366. */
  49367. get projectionTextureLightFar(): number;
  49368. /**
  49369. * Sets the far clip of the Spotlight for texture projection.
  49370. */
  49371. set projectionTextureLightFar(value: number);
  49372. protected _projectionTextureUpDirection: Vector3;
  49373. /**
  49374. * Gets the Up vector of the Spotlight for texture projection.
  49375. */
  49376. get projectionTextureUpDirection(): Vector3;
  49377. /**
  49378. * Sets the Up vector of the Spotlight for texture projection.
  49379. */
  49380. set projectionTextureUpDirection(value: Vector3);
  49381. private _projectionTexture;
  49382. /**
  49383. * Gets the projection texture of the light.
  49384. */
  49385. get projectionTexture(): Nullable<BaseTexture>;
  49386. /**
  49387. * Sets the projection texture of the light.
  49388. */
  49389. set projectionTexture(value: Nullable<BaseTexture>);
  49390. private _projectionTextureViewLightDirty;
  49391. private _projectionTextureProjectionLightDirty;
  49392. private _projectionTextureDirty;
  49393. private _projectionTextureViewTargetVector;
  49394. private _projectionTextureViewLightMatrix;
  49395. private _projectionTextureProjectionLightMatrix;
  49396. private _projectionTextureScalingMatrix;
  49397. /**
  49398. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49399. * It can cast shadows.
  49400. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49401. * @param name The light friendly name
  49402. * @param position The position of the spot light in the scene
  49403. * @param direction The direction of the light in the scene
  49404. * @param angle The cone angle of the light in Radians
  49405. * @param exponent The light decay speed with the distance from the emission spot
  49406. * @param scene The scene the lights belongs to
  49407. */
  49408. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49409. /**
  49410. * Returns the string "SpotLight".
  49411. * @returns the class name
  49412. */
  49413. getClassName(): string;
  49414. /**
  49415. * Returns the integer 2.
  49416. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49417. */
  49418. getTypeID(): number;
  49419. /**
  49420. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49421. */
  49422. protected _setDirection(value: Vector3): void;
  49423. /**
  49424. * Overrides the position setter to recompute the projection texture view light Matrix.
  49425. */
  49426. protected _setPosition(value: Vector3): void;
  49427. /**
  49428. * 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.
  49429. * Returns the SpotLight.
  49430. */
  49431. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49432. protected _computeProjectionTextureViewLightMatrix(): void;
  49433. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49434. /**
  49435. * Main function for light texture projection matrix computing.
  49436. */
  49437. protected _computeProjectionTextureMatrix(): void;
  49438. protected _buildUniformLayout(): void;
  49439. private _computeAngleValues;
  49440. /**
  49441. * Sets the passed Effect "effect" with the Light textures.
  49442. * @param effect The effect to update
  49443. * @param lightIndex The index of the light in the effect to update
  49444. * @returns The light
  49445. */
  49446. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49447. /**
  49448. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49449. * @param effect The effect to update
  49450. * @param lightIndex The index of the light in the effect to update
  49451. * @returns The spot light
  49452. */
  49453. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49454. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49455. /**
  49456. * Disposes the light and the associated resources.
  49457. */
  49458. dispose(): void;
  49459. /**
  49460. * Prepares the list of defines specific to the light type.
  49461. * @param defines the list of defines
  49462. * @param lightIndex defines the index of the light for the effect
  49463. */
  49464. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49465. }
  49466. }
  49467. declare module BABYLON {
  49468. /**
  49469. * Gizmo that enables viewing a light
  49470. */
  49471. export class LightGizmo extends Gizmo {
  49472. private _lightMesh;
  49473. private _material;
  49474. private _cachedPosition;
  49475. private _cachedForward;
  49476. private _attachedMeshParent;
  49477. /**
  49478. * Creates a LightGizmo
  49479. * @param gizmoLayer The utility layer the gizmo will be added to
  49480. */
  49481. constructor(gizmoLayer?: UtilityLayerRenderer);
  49482. private _light;
  49483. /**
  49484. * The light that the gizmo is attached to
  49485. */
  49486. set light(light: Nullable<Light>);
  49487. get light(): Nullable<Light>;
  49488. /**
  49489. * Gets the material used to render the light gizmo
  49490. */
  49491. get material(): StandardMaterial;
  49492. /**
  49493. * @hidden
  49494. * Updates the gizmo to match the attached mesh's position/rotation
  49495. */
  49496. protected _update(): void;
  49497. private static _Scale;
  49498. /**
  49499. * Creates the lines for a light mesh
  49500. */
  49501. private static _CreateLightLines;
  49502. /**
  49503. * Disposes of the light gizmo
  49504. */
  49505. dispose(): void;
  49506. private static _CreateHemisphericLightMesh;
  49507. private static _CreatePointLightMesh;
  49508. private static _CreateSpotLightMesh;
  49509. private static _CreateDirectionalLightMesh;
  49510. }
  49511. }
  49512. declare module BABYLON {
  49513. /** @hidden */
  49514. export var backgroundFragmentDeclaration: {
  49515. name: string;
  49516. shader: string;
  49517. };
  49518. }
  49519. declare module BABYLON {
  49520. /** @hidden */
  49521. export var backgroundUboDeclaration: {
  49522. name: string;
  49523. shader: string;
  49524. };
  49525. }
  49526. declare module BABYLON {
  49527. /** @hidden */
  49528. export var backgroundPixelShader: {
  49529. name: string;
  49530. shader: string;
  49531. };
  49532. }
  49533. declare module BABYLON {
  49534. /** @hidden */
  49535. export var backgroundVertexDeclaration: {
  49536. name: string;
  49537. shader: string;
  49538. };
  49539. }
  49540. declare module BABYLON {
  49541. /** @hidden */
  49542. export var backgroundVertexShader: {
  49543. name: string;
  49544. shader: string;
  49545. };
  49546. }
  49547. declare module BABYLON {
  49548. /**
  49549. * Background material used to create an efficient environement around your scene.
  49550. */
  49551. export class BackgroundMaterial extends PushMaterial {
  49552. /**
  49553. * Standard reflectance value at parallel view angle.
  49554. */
  49555. static StandardReflectance0: number;
  49556. /**
  49557. * Standard reflectance value at grazing angle.
  49558. */
  49559. static StandardReflectance90: number;
  49560. protected _primaryColor: Color3;
  49561. /**
  49562. * Key light Color (multiply against the environement texture)
  49563. */
  49564. primaryColor: Color3;
  49565. protected __perceptualColor: Nullable<Color3>;
  49566. /**
  49567. * Experimental Internal Use Only.
  49568. *
  49569. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49570. * This acts as a helper to set the primary color to a more "human friendly" value.
  49571. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49572. * output color as close as possible from the chosen value.
  49573. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49574. * part of lighting setup.)
  49575. */
  49576. get _perceptualColor(): Nullable<Color3>;
  49577. set _perceptualColor(value: Nullable<Color3>);
  49578. protected _primaryColorShadowLevel: float;
  49579. /**
  49580. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49581. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49582. */
  49583. get primaryColorShadowLevel(): float;
  49584. set primaryColorShadowLevel(value: float);
  49585. protected _primaryColorHighlightLevel: float;
  49586. /**
  49587. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49588. * The primary color is used at the level chosen to define what the white area would look.
  49589. */
  49590. get primaryColorHighlightLevel(): float;
  49591. set primaryColorHighlightLevel(value: float);
  49592. protected _reflectionTexture: Nullable<BaseTexture>;
  49593. /**
  49594. * Reflection Texture used in the material.
  49595. * Should be author in a specific way for the best result (refer to the documentation).
  49596. */
  49597. reflectionTexture: Nullable<BaseTexture>;
  49598. protected _reflectionBlur: float;
  49599. /**
  49600. * Reflection Texture level of blur.
  49601. *
  49602. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49603. * texture twice.
  49604. */
  49605. reflectionBlur: float;
  49606. protected _diffuseTexture: Nullable<BaseTexture>;
  49607. /**
  49608. * Diffuse Texture used in the material.
  49609. * Should be author in a specific way for the best result (refer to the documentation).
  49610. */
  49611. diffuseTexture: Nullable<BaseTexture>;
  49612. protected _shadowLights: Nullable<IShadowLight[]>;
  49613. /**
  49614. * Specify the list of lights casting shadow on the material.
  49615. * All scene shadow lights will be included if null.
  49616. */
  49617. shadowLights: Nullable<IShadowLight[]>;
  49618. protected _shadowLevel: float;
  49619. /**
  49620. * Helps adjusting the shadow to a softer level if required.
  49621. * 0 means black shadows and 1 means no shadows.
  49622. */
  49623. shadowLevel: float;
  49624. protected _sceneCenter: Vector3;
  49625. /**
  49626. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49627. * It is usually zero but might be interesting to modify according to your setup.
  49628. */
  49629. sceneCenter: Vector3;
  49630. protected _opacityFresnel: boolean;
  49631. /**
  49632. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49633. * This helps ensuring a nice transition when the camera goes under the ground.
  49634. */
  49635. opacityFresnel: boolean;
  49636. protected _reflectionFresnel: boolean;
  49637. /**
  49638. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49639. * This helps adding a mirror texture on the ground.
  49640. */
  49641. reflectionFresnel: boolean;
  49642. protected _reflectionFalloffDistance: number;
  49643. /**
  49644. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49645. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49646. */
  49647. reflectionFalloffDistance: number;
  49648. protected _reflectionAmount: number;
  49649. /**
  49650. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49651. */
  49652. reflectionAmount: number;
  49653. protected _reflectionReflectance0: number;
  49654. /**
  49655. * This specifies the weight of the reflection at grazing angle.
  49656. */
  49657. reflectionReflectance0: number;
  49658. protected _reflectionReflectance90: number;
  49659. /**
  49660. * This specifies the weight of the reflection at a perpendicular point of view.
  49661. */
  49662. reflectionReflectance90: number;
  49663. /**
  49664. * Sets the reflection reflectance fresnel values according to the default standard
  49665. * empirically know to work well :-)
  49666. */
  49667. set reflectionStandardFresnelWeight(value: number);
  49668. protected _useRGBColor: boolean;
  49669. /**
  49670. * Helps to directly use the maps channels instead of their level.
  49671. */
  49672. useRGBColor: boolean;
  49673. protected _enableNoise: boolean;
  49674. /**
  49675. * This helps reducing the banding effect that could occur on the background.
  49676. */
  49677. enableNoise: boolean;
  49678. /**
  49679. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49680. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49681. * Recommended to be keep at 1.0 except for special cases.
  49682. */
  49683. get fovMultiplier(): number;
  49684. set fovMultiplier(value: number);
  49685. private _fovMultiplier;
  49686. /**
  49687. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49688. */
  49689. useEquirectangularFOV: boolean;
  49690. private _maxSimultaneousLights;
  49691. /**
  49692. * Number of Simultaneous lights allowed on the material.
  49693. */
  49694. maxSimultaneousLights: int;
  49695. /**
  49696. * Default configuration related to image processing available in the Background Material.
  49697. */
  49698. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49699. /**
  49700. * Keep track of the image processing observer to allow dispose and replace.
  49701. */
  49702. private _imageProcessingObserver;
  49703. /**
  49704. * Attaches a new image processing configuration to the PBR Material.
  49705. * @param configuration (if null the scene configuration will be use)
  49706. */
  49707. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49708. /**
  49709. * Gets the image processing configuration used either in this material.
  49710. */
  49711. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49712. /**
  49713. * Sets the Default image processing configuration used either in the this material.
  49714. *
  49715. * If sets to null, the scene one is in use.
  49716. */
  49717. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49718. /**
  49719. * Gets wether the color curves effect is enabled.
  49720. */
  49721. get cameraColorCurvesEnabled(): boolean;
  49722. /**
  49723. * Sets wether the color curves effect is enabled.
  49724. */
  49725. set cameraColorCurvesEnabled(value: boolean);
  49726. /**
  49727. * Gets wether the color grading effect is enabled.
  49728. */
  49729. get cameraColorGradingEnabled(): boolean;
  49730. /**
  49731. * Gets wether the color grading effect is enabled.
  49732. */
  49733. set cameraColorGradingEnabled(value: boolean);
  49734. /**
  49735. * Gets wether tonemapping is enabled or not.
  49736. */
  49737. get cameraToneMappingEnabled(): boolean;
  49738. /**
  49739. * Sets wether tonemapping is enabled or not
  49740. */
  49741. set cameraToneMappingEnabled(value: boolean);
  49742. /**
  49743. * The camera exposure used on this material.
  49744. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49745. * This corresponds to a photographic exposure.
  49746. */
  49747. get cameraExposure(): float;
  49748. /**
  49749. * The camera exposure used on this material.
  49750. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49751. * This corresponds to a photographic exposure.
  49752. */
  49753. set cameraExposure(value: float);
  49754. /**
  49755. * Gets The camera contrast used on this material.
  49756. */
  49757. get cameraContrast(): float;
  49758. /**
  49759. * Sets The camera contrast used on this material.
  49760. */
  49761. set cameraContrast(value: float);
  49762. /**
  49763. * Gets the Color Grading 2D Lookup Texture.
  49764. */
  49765. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49766. /**
  49767. * Sets the Color Grading 2D Lookup Texture.
  49768. */
  49769. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49770. /**
  49771. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49772. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49773. * 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;
  49774. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49775. */
  49776. get cameraColorCurves(): Nullable<ColorCurves>;
  49777. /**
  49778. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49779. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49780. * 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;
  49781. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49782. */
  49783. set cameraColorCurves(value: Nullable<ColorCurves>);
  49784. /**
  49785. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49786. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49787. */
  49788. switchToBGR: boolean;
  49789. private _renderTargets;
  49790. private _reflectionControls;
  49791. private _white;
  49792. private _primaryShadowColor;
  49793. private _primaryHighlightColor;
  49794. /**
  49795. * Instantiates a Background Material in the given scene
  49796. * @param name The friendly name of the material
  49797. * @param scene The scene to add the material to
  49798. */
  49799. constructor(name: string, scene: Scene);
  49800. /**
  49801. * Gets a boolean indicating that current material needs to register RTT
  49802. */
  49803. get hasRenderTargetTextures(): boolean;
  49804. /**
  49805. * The entire material has been created in order to prevent overdraw.
  49806. * @returns false
  49807. */
  49808. needAlphaTesting(): boolean;
  49809. /**
  49810. * The entire material has been created in order to prevent overdraw.
  49811. * @returns true if blending is enable
  49812. */
  49813. needAlphaBlending(): boolean;
  49814. /**
  49815. * Checks wether the material is ready to be rendered for a given mesh.
  49816. * @param mesh The mesh to render
  49817. * @param subMesh The submesh to check against
  49818. * @param useInstances Specify wether or not the material is used with instances
  49819. * @returns true if all the dependencies are ready (Textures, Effects...)
  49820. */
  49821. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49822. /**
  49823. * Compute the primary color according to the chosen perceptual color.
  49824. */
  49825. private _computePrimaryColorFromPerceptualColor;
  49826. /**
  49827. * Compute the highlights and shadow colors according to their chosen levels.
  49828. */
  49829. private _computePrimaryColors;
  49830. /**
  49831. * Build the uniform buffer used in the material.
  49832. */
  49833. buildUniformLayout(): void;
  49834. /**
  49835. * Unbind the material.
  49836. */
  49837. unbind(): void;
  49838. /**
  49839. * Bind only the world matrix to the material.
  49840. * @param world The world matrix to bind.
  49841. */
  49842. bindOnlyWorldMatrix(world: Matrix): void;
  49843. /**
  49844. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49845. * @param world The world matrix to bind.
  49846. * @param subMesh The submesh to bind for.
  49847. */
  49848. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49849. /**
  49850. * Checks to see if a texture is used in the material.
  49851. * @param texture - Base texture to use.
  49852. * @returns - Boolean specifying if a texture is used in the material.
  49853. */
  49854. hasTexture(texture: BaseTexture): boolean;
  49855. /**
  49856. * Dispose the material.
  49857. * @param forceDisposeEffect Force disposal of the associated effect.
  49858. * @param forceDisposeTextures Force disposal of the associated textures.
  49859. */
  49860. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49861. /**
  49862. * Clones the material.
  49863. * @param name The cloned name.
  49864. * @returns The cloned material.
  49865. */
  49866. clone(name: string): BackgroundMaterial;
  49867. /**
  49868. * Serializes the current material to its JSON representation.
  49869. * @returns The JSON representation.
  49870. */
  49871. serialize(): any;
  49872. /**
  49873. * Gets the class name of the material
  49874. * @returns "BackgroundMaterial"
  49875. */
  49876. getClassName(): string;
  49877. /**
  49878. * Parse a JSON input to create back a background material.
  49879. * @param source The JSON data to parse
  49880. * @param scene The scene to create the parsed material in
  49881. * @param rootUrl The root url of the assets the material depends upon
  49882. * @returns the instantiated BackgroundMaterial.
  49883. */
  49884. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49885. }
  49886. }
  49887. declare module BABYLON {
  49888. /**
  49889. * Represents the different options available during the creation of
  49890. * a Environment helper.
  49891. *
  49892. * This can control the default ground, skybox and image processing setup of your scene.
  49893. */
  49894. export interface IEnvironmentHelperOptions {
  49895. /**
  49896. * Specifies whether or not to create a ground.
  49897. * True by default.
  49898. */
  49899. createGround: boolean;
  49900. /**
  49901. * Specifies the ground size.
  49902. * 15 by default.
  49903. */
  49904. groundSize: number;
  49905. /**
  49906. * The texture used on the ground for the main color.
  49907. * Comes from the BabylonJS CDN by default.
  49908. *
  49909. * Remarks: Can be either a texture or a url.
  49910. */
  49911. groundTexture: string | BaseTexture;
  49912. /**
  49913. * The color mixed in the ground texture by default.
  49914. * BabylonJS clearColor by default.
  49915. */
  49916. groundColor: Color3;
  49917. /**
  49918. * Specifies the ground opacity.
  49919. * 1 by default.
  49920. */
  49921. groundOpacity: number;
  49922. /**
  49923. * Enables the ground to receive shadows.
  49924. * True by default.
  49925. */
  49926. enableGroundShadow: boolean;
  49927. /**
  49928. * Helps preventing the shadow to be fully black on the ground.
  49929. * 0.5 by default.
  49930. */
  49931. groundShadowLevel: number;
  49932. /**
  49933. * Creates a mirror texture attach to the ground.
  49934. * false by default.
  49935. */
  49936. enableGroundMirror: boolean;
  49937. /**
  49938. * Specifies the ground mirror size ratio.
  49939. * 0.3 by default as the default kernel is 64.
  49940. */
  49941. groundMirrorSizeRatio: number;
  49942. /**
  49943. * Specifies the ground mirror blur kernel size.
  49944. * 64 by default.
  49945. */
  49946. groundMirrorBlurKernel: number;
  49947. /**
  49948. * Specifies the ground mirror visibility amount.
  49949. * 1 by default
  49950. */
  49951. groundMirrorAmount: number;
  49952. /**
  49953. * Specifies the ground mirror reflectance weight.
  49954. * This uses the standard weight of the background material to setup the fresnel effect
  49955. * of the mirror.
  49956. * 1 by default.
  49957. */
  49958. groundMirrorFresnelWeight: number;
  49959. /**
  49960. * Specifies the ground mirror Falloff distance.
  49961. * This can helps reducing the size of the reflection.
  49962. * 0 by Default.
  49963. */
  49964. groundMirrorFallOffDistance: number;
  49965. /**
  49966. * Specifies the ground mirror texture type.
  49967. * Unsigned Int by Default.
  49968. */
  49969. groundMirrorTextureType: number;
  49970. /**
  49971. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49972. * the shown objects.
  49973. */
  49974. groundYBias: number;
  49975. /**
  49976. * Specifies whether or not to create a skybox.
  49977. * True by default.
  49978. */
  49979. createSkybox: boolean;
  49980. /**
  49981. * Specifies the skybox size.
  49982. * 20 by default.
  49983. */
  49984. skyboxSize: number;
  49985. /**
  49986. * The texture used on the skybox for the main color.
  49987. * Comes from the BabylonJS CDN by default.
  49988. *
  49989. * Remarks: Can be either a texture or a url.
  49990. */
  49991. skyboxTexture: string | BaseTexture;
  49992. /**
  49993. * The color mixed in the skybox texture by default.
  49994. * BabylonJS clearColor by default.
  49995. */
  49996. skyboxColor: Color3;
  49997. /**
  49998. * The background rotation around the Y axis of the scene.
  49999. * This helps aligning the key lights of your scene with the background.
  50000. * 0 by default.
  50001. */
  50002. backgroundYRotation: number;
  50003. /**
  50004. * Compute automatically the size of the elements to best fit with the scene.
  50005. */
  50006. sizeAuto: boolean;
  50007. /**
  50008. * Default position of the rootMesh if autoSize is not true.
  50009. */
  50010. rootPosition: Vector3;
  50011. /**
  50012. * Sets up the image processing in the scene.
  50013. * true by default.
  50014. */
  50015. setupImageProcessing: boolean;
  50016. /**
  50017. * The texture used as your environment texture in the scene.
  50018. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50019. *
  50020. * Remarks: Can be either a texture or a url.
  50021. */
  50022. environmentTexture: string | BaseTexture;
  50023. /**
  50024. * The value of the exposure to apply to the scene.
  50025. * 0.6 by default if setupImageProcessing is true.
  50026. */
  50027. cameraExposure: number;
  50028. /**
  50029. * The value of the contrast to apply to the scene.
  50030. * 1.6 by default if setupImageProcessing is true.
  50031. */
  50032. cameraContrast: number;
  50033. /**
  50034. * Specifies whether or not tonemapping should be enabled in the scene.
  50035. * true by default if setupImageProcessing is true.
  50036. */
  50037. toneMappingEnabled: boolean;
  50038. }
  50039. /**
  50040. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50041. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50042. * It also helps with the default setup of your imageProcessing configuration.
  50043. */
  50044. export class EnvironmentHelper {
  50045. /**
  50046. * Default ground texture URL.
  50047. */
  50048. private static _groundTextureCDNUrl;
  50049. /**
  50050. * Default skybox texture URL.
  50051. */
  50052. private static _skyboxTextureCDNUrl;
  50053. /**
  50054. * Default environment texture URL.
  50055. */
  50056. private static _environmentTextureCDNUrl;
  50057. /**
  50058. * Creates the default options for the helper.
  50059. */
  50060. private static _getDefaultOptions;
  50061. private _rootMesh;
  50062. /**
  50063. * Gets the root mesh created by the helper.
  50064. */
  50065. get rootMesh(): Mesh;
  50066. private _skybox;
  50067. /**
  50068. * Gets the skybox created by the helper.
  50069. */
  50070. get skybox(): Nullable<Mesh>;
  50071. private _skyboxTexture;
  50072. /**
  50073. * Gets the skybox texture created by the helper.
  50074. */
  50075. get skyboxTexture(): Nullable<BaseTexture>;
  50076. private _skyboxMaterial;
  50077. /**
  50078. * Gets the skybox material created by the helper.
  50079. */
  50080. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50081. private _ground;
  50082. /**
  50083. * Gets the ground mesh created by the helper.
  50084. */
  50085. get ground(): Nullable<Mesh>;
  50086. private _groundTexture;
  50087. /**
  50088. * Gets the ground texture created by the helper.
  50089. */
  50090. get groundTexture(): Nullable<BaseTexture>;
  50091. private _groundMirror;
  50092. /**
  50093. * Gets the ground mirror created by the helper.
  50094. */
  50095. get groundMirror(): Nullable<MirrorTexture>;
  50096. /**
  50097. * Gets the ground mirror render list to helps pushing the meshes
  50098. * you wish in the ground reflection.
  50099. */
  50100. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50101. private _groundMaterial;
  50102. /**
  50103. * Gets the ground material created by the helper.
  50104. */
  50105. get groundMaterial(): Nullable<BackgroundMaterial>;
  50106. /**
  50107. * Stores the creation options.
  50108. */
  50109. private readonly _scene;
  50110. private _options;
  50111. /**
  50112. * This observable will be notified with any error during the creation of the environment,
  50113. * mainly texture creation errors.
  50114. */
  50115. onErrorObservable: Observable<{
  50116. message?: string;
  50117. exception?: any;
  50118. }>;
  50119. /**
  50120. * constructor
  50121. * @param options Defines the options we want to customize the helper
  50122. * @param scene The scene to add the material to
  50123. */
  50124. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50125. /**
  50126. * Updates the background according to the new options
  50127. * @param options
  50128. */
  50129. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50130. /**
  50131. * Sets the primary color of all the available elements.
  50132. * @param color the main color to affect to the ground and the background
  50133. */
  50134. setMainColor(color: Color3): void;
  50135. /**
  50136. * Setup the image processing according to the specified options.
  50137. */
  50138. private _setupImageProcessing;
  50139. /**
  50140. * Setup the environment texture according to the specified options.
  50141. */
  50142. private _setupEnvironmentTexture;
  50143. /**
  50144. * Setup the background according to the specified options.
  50145. */
  50146. private _setupBackground;
  50147. /**
  50148. * Get the scene sizes according to the setup.
  50149. */
  50150. private _getSceneSize;
  50151. /**
  50152. * Setup the ground according to the specified options.
  50153. */
  50154. private _setupGround;
  50155. /**
  50156. * Setup the ground material according to the specified options.
  50157. */
  50158. private _setupGroundMaterial;
  50159. /**
  50160. * Setup the ground diffuse texture according to the specified options.
  50161. */
  50162. private _setupGroundDiffuseTexture;
  50163. /**
  50164. * Setup the ground mirror texture according to the specified options.
  50165. */
  50166. private _setupGroundMirrorTexture;
  50167. /**
  50168. * Setup the ground to receive the mirror texture.
  50169. */
  50170. private _setupMirrorInGroundMaterial;
  50171. /**
  50172. * Setup the skybox according to the specified options.
  50173. */
  50174. private _setupSkybox;
  50175. /**
  50176. * Setup the skybox material according to the specified options.
  50177. */
  50178. private _setupSkyboxMaterial;
  50179. /**
  50180. * Setup the skybox reflection texture according to the specified options.
  50181. */
  50182. private _setupSkyboxReflectionTexture;
  50183. private _errorHandler;
  50184. /**
  50185. * Dispose all the elements created by the Helper.
  50186. */
  50187. dispose(): void;
  50188. }
  50189. }
  50190. declare module BABYLON {
  50191. /**
  50192. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50193. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50194. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50195. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50196. */
  50197. export class PhotoDome extends TransformNode {
  50198. /**
  50199. * Define the image as a Monoscopic panoramic 360 image.
  50200. */
  50201. static readonly MODE_MONOSCOPIC: number;
  50202. /**
  50203. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50204. */
  50205. static readonly MODE_TOPBOTTOM: number;
  50206. /**
  50207. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50208. */
  50209. static readonly MODE_SIDEBYSIDE: number;
  50210. private _useDirectMapping;
  50211. /**
  50212. * The texture being displayed on the sphere
  50213. */
  50214. protected _photoTexture: Texture;
  50215. /**
  50216. * Gets or sets the texture being displayed on the sphere
  50217. */
  50218. get photoTexture(): Texture;
  50219. set photoTexture(value: Texture);
  50220. /**
  50221. * Observable raised when an error occured while loading the 360 image
  50222. */
  50223. onLoadErrorObservable: Observable<string>;
  50224. /**
  50225. * The skybox material
  50226. */
  50227. protected _material: BackgroundMaterial;
  50228. /**
  50229. * The surface used for the skybox
  50230. */
  50231. protected _mesh: Mesh;
  50232. /**
  50233. * Gets the mesh used for the skybox.
  50234. */
  50235. get mesh(): Mesh;
  50236. /**
  50237. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50238. * Also see the options.resolution property.
  50239. */
  50240. get fovMultiplier(): number;
  50241. set fovMultiplier(value: number);
  50242. private _imageMode;
  50243. /**
  50244. * Gets or set the current video mode for the video. It can be:
  50245. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50246. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50247. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50248. */
  50249. get imageMode(): number;
  50250. set imageMode(value: number);
  50251. /**
  50252. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50253. * @param name Element's name, child elements will append suffixes for their own names.
  50254. * @param urlsOfPhoto defines the url of the photo to display
  50255. * @param options defines an object containing optional or exposed sub element properties
  50256. * @param onError defines a callback called when an error occured while loading the texture
  50257. */
  50258. constructor(name: string, urlOfPhoto: string, options: {
  50259. resolution?: number;
  50260. size?: number;
  50261. useDirectMapping?: boolean;
  50262. faceForward?: boolean;
  50263. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50264. private _onBeforeCameraRenderObserver;
  50265. private _changeImageMode;
  50266. /**
  50267. * Releases resources associated with this node.
  50268. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50269. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50270. */
  50271. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50272. }
  50273. }
  50274. declare module BABYLON {
  50275. /**
  50276. * Class used to host RGBD texture specific utilities
  50277. */
  50278. export class RGBDTextureTools {
  50279. /**
  50280. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50281. * @param texture the texture to expand.
  50282. */
  50283. static ExpandRGBDTexture(texture: Texture): void;
  50284. }
  50285. }
  50286. declare module BABYLON {
  50287. /**
  50288. * Class used to host texture specific utilities
  50289. */
  50290. export class BRDFTextureTools {
  50291. /**
  50292. * Prevents texture cache collision
  50293. */
  50294. private static _instanceNumber;
  50295. /**
  50296. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50297. * @param scene defines the hosting scene
  50298. * @returns the environment BRDF texture
  50299. */
  50300. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50301. private static _environmentBRDFBase64Texture;
  50302. }
  50303. }
  50304. declare module BABYLON {
  50305. /**
  50306. * @hidden
  50307. */
  50308. export interface IMaterialClearCoatDefines {
  50309. CLEARCOAT: boolean;
  50310. CLEARCOAT_DEFAULTIOR: boolean;
  50311. CLEARCOAT_TEXTURE: boolean;
  50312. CLEARCOAT_TEXTUREDIRECTUV: number;
  50313. CLEARCOAT_BUMP: boolean;
  50314. CLEARCOAT_BUMPDIRECTUV: number;
  50315. CLEARCOAT_TINT: boolean;
  50316. CLEARCOAT_TINT_TEXTURE: boolean;
  50317. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50318. /** @hidden */
  50319. _areTexturesDirty: boolean;
  50320. }
  50321. /**
  50322. * Define the code related to the clear coat parameters of the pbr material.
  50323. */
  50324. export class PBRClearCoatConfiguration {
  50325. /**
  50326. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50327. * The default fits with a polyurethane material.
  50328. */
  50329. private static readonly _DefaultIndexOfRefraction;
  50330. private _isEnabled;
  50331. /**
  50332. * Defines if the clear coat is enabled in the material.
  50333. */
  50334. isEnabled: boolean;
  50335. /**
  50336. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50337. */
  50338. intensity: number;
  50339. /**
  50340. * Defines the clear coat layer roughness.
  50341. */
  50342. roughness: number;
  50343. private _indexOfRefraction;
  50344. /**
  50345. * Defines the index of refraction of the clear coat.
  50346. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50347. * The default fits with a polyurethane material.
  50348. * Changing the default value is more performance intensive.
  50349. */
  50350. indexOfRefraction: number;
  50351. private _texture;
  50352. /**
  50353. * Stores the clear coat values in a texture.
  50354. */
  50355. texture: Nullable<BaseTexture>;
  50356. private _bumpTexture;
  50357. /**
  50358. * Define the clear coat specific bump texture.
  50359. */
  50360. bumpTexture: Nullable<BaseTexture>;
  50361. private _isTintEnabled;
  50362. /**
  50363. * Defines if the clear coat tint is enabled in the material.
  50364. */
  50365. isTintEnabled: boolean;
  50366. /**
  50367. * Defines the clear coat tint of the material.
  50368. * This is only use if tint is enabled
  50369. */
  50370. tintColor: Color3;
  50371. /**
  50372. * Defines the distance at which the tint color should be found in the
  50373. * clear coat media.
  50374. * This is only use if tint is enabled
  50375. */
  50376. tintColorAtDistance: number;
  50377. /**
  50378. * Defines the clear coat layer thickness.
  50379. * This is only use if tint is enabled
  50380. */
  50381. tintThickness: number;
  50382. private _tintTexture;
  50383. /**
  50384. * Stores the clear tint values in a texture.
  50385. * rgb is tint
  50386. * a is a thickness factor
  50387. */
  50388. tintTexture: Nullable<BaseTexture>;
  50389. /** @hidden */
  50390. private _internalMarkAllSubMeshesAsTexturesDirty;
  50391. /** @hidden */
  50392. _markAllSubMeshesAsTexturesDirty(): void;
  50393. /**
  50394. * Instantiate a new istance of clear coat configuration.
  50395. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50396. */
  50397. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50398. /**
  50399. * Gets wehter the submesh is ready to be used or not.
  50400. * @param defines the list of "defines" to update.
  50401. * @param scene defines the scene the material belongs to.
  50402. * @param engine defines the engine the material belongs to.
  50403. * @param disableBumpMap defines wether the material disables bump or not.
  50404. * @returns - boolean indicating that the submesh is ready or not.
  50405. */
  50406. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50407. /**
  50408. * Checks to see if a texture is used in the material.
  50409. * @param defines the list of "defines" to update.
  50410. * @param scene defines the scene to the material belongs to.
  50411. */
  50412. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50413. /**
  50414. * Binds the material data.
  50415. * @param uniformBuffer defines the Uniform buffer to fill in.
  50416. * @param scene defines the scene the material belongs to.
  50417. * @param engine defines the engine the material belongs to.
  50418. * @param disableBumpMap defines wether the material disables bump or not.
  50419. * @param isFrozen defines wether the material is frozen or not.
  50420. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50421. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50422. */
  50423. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50424. /**
  50425. * Checks to see if a texture is used in the material.
  50426. * @param texture - Base texture to use.
  50427. * @returns - Boolean specifying if a texture is used in the material.
  50428. */
  50429. hasTexture(texture: BaseTexture): boolean;
  50430. /**
  50431. * Returns an array of the actively used textures.
  50432. * @param activeTextures Array of BaseTextures
  50433. */
  50434. getActiveTextures(activeTextures: BaseTexture[]): void;
  50435. /**
  50436. * Returns the animatable textures.
  50437. * @param animatables Array of animatable textures.
  50438. */
  50439. getAnimatables(animatables: IAnimatable[]): void;
  50440. /**
  50441. * Disposes the resources of the material.
  50442. * @param forceDisposeTextures - Forces the disposal of all textures.
  50443. */
  50444. dispose(forceDisposeTextures?: boolean): void;
  50445. /**
  50446. * Get the current class name of the texture useful for serialization or dynamic coding.
  50447. * @returns "PBRClearCoatConfiguration"
  50448. */
  50449. getClassName(): string;
  50450. /**
  50451. * Add fallbacks to the effect fallbacks list.
  50452. * @param defines defines the Base texture to use.
  50453. * @param fallbacks defines the current fallback list.
  50454. * @param currentRank defines the current fallback rank.
  50455. * @returns the new fallback rank.
  50456. */
  50457. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50458. /**
  50459. * Add the required uniforms to the current list.
  50460. * @param uniforms defines the current uniform list.
  50461. */
  50462. static AddUniforms(uniforms: string[]): void;
  50463. /**
  50464. * Add the required samplers to the current list.
  50465. * @param samplers defines the current sampler list.
  50466. */
  50467. static AddSamplers(samplers: string[]): void;
  50468. /**
  50469. * Add the required uniforms to the current buffer.
  50470. * @param uniformBuffer defines the current uniform buffer.
  50471. */
  50472. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50473. /**
  50474. * Makes a duplicate of the current configuration into another one.
  50475. * @param clearCoatConfiguration define the config where to copy the info
  50476. */
  50477. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50478. /**
  50479. * Serializes this clear coat configuration.
  50480. * @returns - An object with the serialized config.
  50481. */
  50482. serialize(): any;
  50483. /**
  50484. * Parses a anisotropy Configuration from a serialized object.
  50485. * @param source - Serialized object.
  50486. * @param scene Defines the scene we are parsing for
  50487. * @param rootUrl Defines the rootUrl to load from
  50488. */
  50489. parse(source: any, scene: Scene, rootUrl: string): void;
  50490. }
  50491. }
  50492. declare module BABYLON {
  50493. /**
  50494. * @hidden
  50495. */
  50496. export interface IMaterialAnisotropicDefines {
  50497. ANISOTROPIC: boolean;
  50498. ANISOTROPIC_TEXTURE: boolean;
  50499. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50500. MAINUV1: boolean;
  50501. _areTexturesDirty: boolean;
  50502. _needUVs: boolean;
  50503. }
  50504. /**
  50505. * Define the code related to the anisotropic parameters of the pbr material.
  50506. */
  50507. export class PBRAnisotropicConfiguration {
  50508. private _isEnabled;
  50509. /**
  50510. * Defines if the anisotropy is enabled in the material.
  50511. */
  50512. isEnabled: boolean;
  50513. /**
  50514. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50515. */
  50516. intensity: number;
  50517. /**
  50518. * Defines if the effect is along the tangents, bitangents or in between.
  50519. * By default, the effect is "strectching" the highlights along the tangents.
  50520. */
  50521. direction: Vector2;
  50522. private _texture;
  50523. /**
  50524. * Stores the anisotropy values in a texture.
  50525. * rg is direction (like normal from -1 to 1)
  50526. * b is a intensity
  50527. */
  50528. texture: Nullable<BaseTexture>;
  50529. /** @hidden */
  50530. private _internalMarkAllSubMeshesAsTexturesDirty;
  50531. /** @hidden */
  50532. _markAllSubMeshesAsTexturesDirty(): void;
  50533. /**
  50534. * Instantiate a new istance of anisotropy configuration.
  50535. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50536. */
  50537. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50538. /**
  50539. * Specifies that the submesh is ready to be used.
  50540. * @param defines the list of "defines" to update.
  50541. * @param scene defines the scene the material belongs to.
  50542. * @returns - boolean indicating that the submesh is ready or not.
  50543. */
  50544. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50545. /**
  50546. * Checks to see if a texture is used in the material.
  50547. * @param defines the list of "defines" to update.
  50548. * @param mesh the mesh we are preparing the defines for.
  50549. * @param scene defines the scene the material belongs to.
  50550. */
  50551. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50552. /**
  50553. * Binds the material data.
  50554. * @param uniformBuffer defines the Uniform buffer to fill in.
  50555. * @param scene defines the scene the material belongs to.
  50556. * @param isFrozen defines wether the material is frozen or not.
  50557. */
  50558. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50559. /**
  50560. * Checks to see if a texture is used in the material.
  50561. * @param texture - Base texture to use.
  50562. * @returns - Boolean specifying if a texture is used in the material.
  50563. */
  50564. hasTexture(texture: BaseTexture): boolean;
  50565. /**
  50566. * Returns an array of the actively used textures.
  50567. * @param activeTextures Array of BaseTextures
  50568. */
  50569. getActiveTextures(activeTextures: BaseTexture[]): void;
  50570. /**
  50571. * Returns the animatable textures.
  50572. * @param animatables Array of animatable textures.
  50573. */
  50574. getAnimatables(animatables: IAnimatable[]): void;
  50575. /**
  50576. * Disposes the resources of the material.
  50577. * @param forceDisposeTextures - Forces the disposal of all textures.
  50578. */
  50579. dispose(forceDisposeTextures?: boolean): void;
  50580. /**
  50581. * Get the current class name of the texture useful for serialization or dynamic coding.
  50582. * @returns "PBRAnisotropicConfiguration"
  50583. */
  50584. getClassName(): string;
  50585. /**
  50586. * Add fallbacks to the effect fallbacks list.
  50587. * @param defines defines the Base texture to use.
  50588. * @param fallbacks defines the current fallback list.
  50589. * @param currentRank defines the current fallback rank.
  50590. * @returns the new fallback rank.
  50591. */
  50592. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50593. /**
  50594. * Add the required uniforms to the current list.
  50595. * @param uniforms defines the current uniform list.
  50596. */
  50597. static AddUniforms(uniforms: string[]): void;
  50598. /**
  50599. * Add the required uniforms to the current buffer.
  50600. * @param uniformBuffer defines the current uniform buffer.
  50601. */
  50602. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50603. /**
  50604. * Add the required samplers to the current list.
  50605. * @param samplers defines the current sampler list.
  50606. */
  50607. static AddSamplers(samplers: string[]): void;
  50608. /**
  50609. * Makes a duplicate of the current configuration into another one.
  50610. * @param anisotropicConfiguration define the config where to copy the info
  50611. */
  50612. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50613. /**
  50614. * Serializes this anisotropy configuration.
  50615. * @returns - An object with the serialized config.
  50616. */
  50617. serialize(): any;
  50618. /**
  50619. * Parses a anisotropy Configuration from a serialized object.
  50620. * @param source - Serialized object.
  50621. * @param scene Defines the scene we are parsing for
  50622. * @param rootUrl Defines the rootUrl to load from
  50623. */
  50624. parse(source: any, scene: Scene, rootUrl: string): void;
  50625. }
  50626. }
  50627. declare module BABYLON {
  50628. /**
  50629. * @hidden
  50630. */
  50631. export interface IMaterialBRDFDefines {
  50632. BRDF_V_HEIGHT_CORRELATED: boolean;
  50633. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50634. SPHERICAL_HARMONICS: boolean;
  50635. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50636. /** @hidden */
  50637. _areMiscDirty: boolean;
  50638. }
  50639. /**
  50640. * Define the code related to the BRDF parameters of the pbr material.
  50641. */
  50642. export class PBRBRDFConfiguration {
  50643. /**
  50644. * Default value used for the energy conservation.
  50645. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50646. */
  50647. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50648. /**
  50649. * Default value used for the Smith Visibility Height Correlated mode.
  50650. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50651. */
  50652. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50653. /**
  50654. * Default value used for the IBL diffuse part.
  50655. * This can help switching back to the polynomials mode globally which is a tiny bit
  50656. * less GPU intensive at the drawback of a lower quality.
  50657. */
  50658. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50659. /**
  50660. * Default value used for activating energy conservation for the specular workflow.
  50661. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50662. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50663. */
  50664. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50665. private _useEnergyConservation;
  50666. /**
  50667. * Defines if the material uses energy conservation.
  50668. */
  50669. useEnergyConservation: boolean;
  50670. private _useSmithVisibilityHeightCorrelated;
  50671. /**
  50672. * LEGACY Mode set to false
  50673. * Defines if the material uses height smith correlated visibility term.
  50674. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50675. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50676. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50677. * Not relying on height correlated will also disable energy conservation.
  50678. */
  50679. useSmithVisibilityHeightCorrelated: boolean;
  50680. private _useSphericalHarmonics;
  50681. /**
  50682. * LEGACY Mode set to false
  50683. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50684. * diffuse part of the IBL.
  50685. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50686. * to the ground truth.
  50687. */
  50688. useSphericalHarmonics: boolean;
  50689. private _useSpecularGlossinessInputEnergyConservation;
  50690. /**
  50691. * Defines if the material uses energy conservation, when the specular workflow is active.
  50692. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50693. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50694. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50695. */
  50696. useSpecularGlossinessInputEnergyConservation: boolean;
  50697. /** @hidden */
  50698. private _internalMarkAllSubMeshesAsMiscDirty;
  50699. /** @hidden */
  50700. _markAllSubMeshesAsMiscDirty(): void;
  50701. /**
  50702. * Instantiate a new istance of clear coat configuration.
  50703. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50704. */
  50705. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50706. /**
  50707. * Checks to see if a texture is used in the material.
  50708. * @param defines the list of "defines" to update.
  50709. */
  50710. prepareDefines(defines: IMaterialBRDFDefines): void;
  50711. /**
  50712. * Get the current class name of the texture useful for serialization or dynamic coding.
  50713. * @returns "PBRClearCoatConfiguration"
  50714. */
  50715. getClassName(): string;
  50716. /**
  50717. * Makes a duplicate of the current configuration into another one.
  50718. * @param brdfConfiguration define the config where to copy the info
  50719. */
  50720. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50721. /**
  50722. * Serializes this BRDF configuration.
  50723. * @returns - An object with the serialized config.
  50724. */
  50725. serialize(): any;
  50726. /**
  50727. * Parses a anisotropy Configuration from a serialized object.
  50728. * @param source - Serialized object.
  50729. * @param scene Defines the scene we are parsing for
  50730. * @param rootUrl Defines the rootUrl to load from
  50731. */
  50732. parse(source: any, scene: Scene, rootUrl: string): void;
  50733. }
  50734. }
  50735. declare module BABYLON {
  50736. /**
  50737. * @hidden
  50738. */
  50739. export interface IMaterialSheenDefines {
  50740. SHEEN: boolean;
  50741. SHEEN_TEXTURE: boolean;
  50742. SHEEN_TEXTUREDIRECTUV: number;
  50743. SHEEN_LINKWITHALBEDO: boolean;
  50744. SHEEN_ROUGHNESS: boolean;
  50745. SHEEN_ALBEDOSCALING: boolean;
  50746. /** @hidden */
  50747. _areTexturesDirty: boolean;
  50748. }
  50749. /**
  50750. * Define the code related to the Sheen parameters of the pbr material.
  50751. */
  50752. export class PBRSheenConfiguration {
  50753. private _isEnabled;
  50754. /**
  50755. * Defines if the material uses sheen.
  50756. */
  50757. isEnabled: boolean;
  50758. private _linkSheenWithAlbedo;
  50759. /**
  50760. * Defines if the sheen is linked to the sheen color.
  50761. */
  50762. linkSheenWithAlbedo: boolean;
  50763. /**
  50764. * Defines the sheen intensity.
  50765. */
  50766. intensity: number;
  50767. /**
  50768. * Defines the sheen color.
  50769. */
  50770. color: Color3;
  50771. private _texture;
  50772. /**
  50773. * Stores the sheen tint values in a texture.
  50774. * rgb is tint
  50775. * a is a intensity
  50776. */
  50777. texture: Nullable<BaseTexture>;
  50778. private _roughness;
  50779. /**
  50780. * Defines the sheen roughness.
  50781. * It is not taken into account if linkSheenWithAlbedo is true.
  50782. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  50783. */
  50784. roughness: Nullable<number>;
  50785. private _albedoScaling;
  50786. /**
  50787. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  50788. * It allows the strength of the sheen effect to not depend on the base color of the material,
  50789. * making it easier to setup and tweak the effect
  50790. */
  50791. albedoScaling: boolean;
  50792. /** @hidden */
  50793. private _internalMarkAllSubMeshesAsTexturesDirty;
  50794. /** @hidden */
  50795. _markAllSubMeshesAsTexturesDirty(): void;
  50796. /**
  50797. * Instantiate a new istance of clear coat configuration.
  50798. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50799. */
  50800. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50801. /**
  50802. * Specifies that the submesh is ready to be used.
  50803. * @param defines the list of "defines" to update.
  50804. * @param scene defines the scene the material belongs to.
  50805. * @returns - boolean indicating that the submesh is ready or not.
  50806. */
  50807. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50808. /**
  50809. * Checks to see if a texture is used in the material.
  50810. * @param defines the list of "defines" to update.
  50811. * @param scene defines the scene the material belongs to.
  50812. */
  50813. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50814. /**
  50815. * Binds the material data.
  50816. * @param uniformBuffer defines the Uniform buffer to fill in.
  50817. * @param scene defines the scene the material belongs to.
  50818. * @param isFrozen defines wether the material is frozen or not.
  50819. */
  50820. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50821. /**
  50822. * Checks to see if a texture is used in the material.
  50823. * @param texture - Base texture to use.
  50824. * @returns - Boolean specifying if a texture is used in the material.
  50825. */
  50826. hasTexture(texture: BaseTexture): boolean;
  50827. /**
  50828. * Returns an array of the actively used textures.
  50829. * @param activeTextures Array of BaseTextures
  50830. */
  50831. getActiveTextures(activeTextures: BaseTexture[]): void;
  50832. /**
  50833. * Returns the animatable textures.
  50834. * @param animatables Array of animatable textures.
  50835. */
  50836. getAnimatables(animatables: IAnimatable[]): void;
  50837. /**
  50838. * Disposes the resources of the material.
  50839. * @param forceDisposeTextures - Forces the disposal of all textures.
  50840. */
  50841. dispose(forceDisposeTextures?: boolean): void;
  50842. /**
  50843. * Get the current class name of the texture useful for serialization or dynamic coding.
  50844. * @returns "PBRSheenConfiguration"
  50845. */
  50846. getClassName(): string;
  50847. /**
  50848. * Add fallbacks to the effect fallbacks list.
  50849. * @param defines defines the Base texture to use.
  50850. * @param fallbacks defines the current fallback list.
  50851. * @param currentRank defines the current fallback rank.
  50852. * @returns the new fallback rank.
  50853. */
  50854. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50855. /**
  50856. * Add the required uniforms to the current list.
  50857. * @param uniforms defines the current uniform list.
  50858. */
  50859. static AddUniforms(uniforms: string[]): void;
  50860. /**
  50861. * Add the required uniforms to the current buffer.
  50862. * @param uniformBuffer defines the current uniform buffer.
  50863. */
  50864. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50865. /**
  50866. * Add the required samplers to the current list.
  50867. * @param samplers defines the current sampler list.
  50868. */
  50869. static AddSamplers(samplers: string[]): void;
  50870. /**
  50871. * Makes a duplicate of the current configuration into another one.
  50872. * @param sheenConfiguration define the config where to copy the info
  50873. */
  50874. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50875. /**
  50876. * Serializes this BRDF configuration.
  50877. * @returns - An object with the serialized config.
  50878. */
  50879. serialize(): any;
  50880. /**
  50881. * Parses a anisotropy Configuration from a serialized object.
  50882. * @param source - Serialized object.
  50883. * @param scene Defines the scene we are parsing for
  50884. * @param rootUrl Defines the rootUrl to load from
  50885. */
  50886. parse(source: any, scene: Scene, rootUrl: string): void;
  50887. }
  50888. }
  50889. declare module BABYLON {
  50890. /**
  50891. * @hidden
  50892. */
  50893. export interface IMaterialSubSurfaceDefines {
  50894. SUBSURFACE: boolean;
  50895. SS_REFRACTION: boolean;
  50896. SS_TRANSLUCENCY: boolean;
  50897. SS_SCATERRING: boolean;
  50898. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50899. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50900. SS_REFRACTIONMAP_3D: boolean;
  50901. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50902. SS_LODINREFRACTIONALPHA: boolean;
  50903. SS_GAMMAREFRACTION: boolean;
  50904. SS_RGBDREFRACTION: boolean;
  50905. SS_LINEARSPECULARREFRACTION: boolean;
  50906. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50907. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50908. /** @hidden */
  50909. _areTexturesDirty: boolean;
  50910. }
  50911. /**
  50912. * Define the code related to the sub surface parameters of the pbr material.
  50913. */
  50914. export class PBRSubSurfaceConfiguration {
  50915. private _isRefractionEnabled;
  50916. /**
  50917. * Defines if the refraction is enabled in the material.
  50918. */
  50919. isRefractionEnabled: boolean;
  50920. private _isTranslucencyEnabled;
  50921. /**
  50922. * Defines if the translucency is enabled in the material.
  50923. */
  50924. isTranslucencyEnabled: boolean;
  50925. private _isScatteringEnabled;
  50926. /**
  50927. * Defines the refraction intensity of the material.
  50928. * The refraction when enabled replaces the Diffuse part of the material.
  50929. * The intensity helps transitionning between diffuse and refraction.
  50930. */
  50931. refractionIntensity: number;
  50932. /**
  50933. * Defines the translucency intensity of the material.
  50934. * When translucency has been enabled, this defines how much of the "translucency"
  50935. * is addded to the diffuse part of the material.
  50936. */
  50937. translucencyIntensity: number;
  50938. /**
  50939. * Defines the scattering intensity of the material.
  50940. * When scattering has been enabled, this defines how much of the "scattered light"
  50941. * is addded to the diffuse part of the material.
  50942. */
  50943. scatteringIntensity: number;
  50944. private _thicknessTexture;
  50945. /**
  50946. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50947. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50948. * 0 would mean minimumThickness
  50949. * 1 would mean maximumThickness
  50950. * The other channels might be use as a mask to vary the different effects intensity.
  50951. */
  50952. thicknessTexture: Nullable<BaseTexture>;
  50953. private _refractionTexture;
  50954. /**
  50955. * Defines the texture to use for refraction.
  50956. */
  50957. refractionTexture: Nullable<BaseTexture>;
  50958. private _indexOfRefraction;
  50959. /**
  50960. * Defines the index of refraction used in the material.
  50961. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50962. */
  50963. indexOfRefraction: number;
  50964. private _invertRefractionY;
  50965. /**
  50966. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50967. */
  50968. invertRefractionY: boolean;
  50969. private _linkRefractionWithTransparency;
  50970. /**
  50971. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50972. * Materials half opaque for instance using refraction could benefit from this control.
  50973. */
  50974. linkRefractionWithTransparency: boolean;
  50975. /**
  50976. * Defines the minimum thickness stored in the thickness map.
  50977. * If no thickness map is defined, this value will be used to simulate thickness.
  50978. */
  50979. minimumThickness: number;
  50980. /**
  50981. * Defines the maximum thickness stored in the thickness map.
  50982. */
  50983. maximumThickness: number;
  50984. /**
  50985. * Defines the volume tint of the material.
  50986. * This is used for both translucency and scattering.
  50987. */
  50988. tintColor: Color3;
  50989. /**
  50990. * Defines the distance at which the tint color should be found in the media.
  50991. * This is used for refraction only.
  50992. */
  50993. tintColorAtDistance: number;
  50994. /**
  50995. * Defines how far each channel transmit through the media.
  50996. * It is defined as a color to simplify it selection.
  50997. */
  50998. diffusionDistance: Color3;
  50999. private _useMaskFromThicknessTexture;
  51000. /**
  51001. * Stores the intensity of the different subsurface effects in the thickness texture.
  51002. * * the green channel is the translucency intensity.
  51003. * * the blue channel is the scattering intensity.
  51004. * * the alpha channel is the refraction intensity.
  51005. */
  51006. useMaskFromThicknessTexture: boolean;
  51007. /** @hidden */
  51008. private _internalMarkAllSubMeshesAsTexturesDirty;
  51009. /** @hidden */
  51010. _markAllSubMeshesAsTexturesDirty(): void;
  51011. /**
  51012. * Instantiate a new istance of sub surface configuration.
  51013. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51014. */
  51015. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51016. /**
  51017. * Gets wehter the submesh is ready to be used or not.
  51018. * @param defines the list of "defines" to update.
  51019. * @param scene defines the scene the material belongs to.
  51020. * @returns - boolean indicating that the submesh is ready or not.
  51021. */
  51022. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51023. /**
  51024. * Checks to see if a texture is used in the material.
  51025. * @param defines the list of "defines" to update.
  51026. * @param scene defines the scene to the material belongs to.
  51027. */
  51028. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51029. /**
  51030. * Binds the material data.
  51031. * @param uniformBuffer defines the Uniform buffer to fill in.
  51032. * @param scene defines the scene the material belongs to.
  51033. * @param engine defines the engine the material belongs to.
  51034. * @param isFrozen defines wether the material is frozen or not.
  51035. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51036. */
  51037. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51038. /**
  51039. * Unbinds the material from the mesh.
  51040. * @param activeEffect defines the effect that should be unbound from.
  51041. * @returns true if unbound, otherwise false
  51042. */
  51043. unbind(activeEffect: Effect): boolean;
  51044. /**
  51045. * Returns the texture used for refraction or null if none is used.
  51046. * @param scene defines the scene the material belongs to.
  51047. * @returns - Refraction texture if present. If no refraction texture and refraction
  51048. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51049. */
  51050. private _getRefractionTexture;
  51051. /**
  51052. * Returns true if alpha blending should be disabled.
  51053. */
  51054. get disableAlphaBlending(): boolean;
  51055. /**
  51056. * Fills the list of render target textures.
  51057. * @param renderTargets the list of render targets to update
  51058. */
  51059. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51060. /**
  51061. * Checks to see if a texture is used in the material.
  51062. * @param texture - Base texture to use.
  51063. * @returns - Boolean specifying if a texture is used in the material.
  51064. */
  51065. hasTexture(texture: BaseTexture): boolean;
  51066. /**
  51067. * Gets a boolean indicating that current material needs to register RTT
  51068. * @returns true if this uses a render target otherwise false.
  51069. */
  51070. hasRenderTargetTextures(): boolean;
  51071. /**
  51072. * Returns an array of the actively used textures.
  51073. * @param activeTextures Array of BaseTextures
  51074. */
  51075. getActiveTextures(activeTextures: BaseTexture[]): void;
  51076. /**
  51077. * Returns the animatable textures.
  51078. * @param animatables Array of animatable textures.
  51079. */
  51080. getAnimatables(animatables: IAnimatable[]): void;
  51081. /**
  51082. * Disposes the resources of the material.
  51083. * @param forceDisposeTextures - Forces the disposal of all textures.
  51084. */
  51085. dispose(forceDisposeTextures?: boolean): void;
  51086. /**
  51087. * Get the current class name of the texture useful for serialization or dynamic coding.
  51088. * @returns "PBRSubSurfaceConfiguration"
  51089. */
  51090. getClassName(): string;
  51091. /**
  51092. * Add fallbacks to the effect fallbacks list.
  51093. * @param defines defines the Base texture to use.
  51094. * @param fallbacks defines the current fallback list.
  51095. * @param currentRank defines the current fallback rank.
  51096. * @returns the new fallback rank.
  51097. */
  51098. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51099. /**
  51100. * Add the required uniforms to the current list.
  51101. * @param uniforms defines the current uniform list.
  51102. */
  51103. static AddUniforms(uniforms: string[]): void;
  51104. /**
  51105. * Add the required samplers to the current list.
  51106. * @param samplers defines the current sampler list.
  51107. */
  51108. static AddSamplers(samplers: string[]): void;
  51109. /**
  51110. * Add the required uniforms to the current buffer.
  51111. * @param uniformBuffer defines the current uniform buffer.
  51112. */
  51113. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51114. /**
  51115. * Makes a duplicate of the current configuration into another one.
  51116. * @param configuration define the config where to copy the info
  51117. */
  51118. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51119. /**
  51120. * Serializes this Sub Surface configuration.
  51121. * @returns - An object with the serialized config.
  51122. */
  51123. serialize(): any;
  51124. /**
  51125. * Parses a anisotropy Configuration from a serialized object.
  51126. * @param source - Serialized object.
  51127. * @param scene Defines the scene we are parsing for
  51128. * @param rootUrl Defines the rootUrl to load from
  51129. */
  51130. parse(source: any, scene: Scene, rootUrl: string): void;
  51131. }
  51132. }
  51133. declare module BABYLON {
  51134. /** @hidden */
  51135. export var pbrFragmentDeclaration: {
  51136. name: string;
  51137. shader: string;
  51138. };
  51139. }
  51140. declare module BABYLON {
  51141. /** @hidden */
  51142. export var pbrUboDeclaration: {
  51143. name: string;
  51144. shader: string;
  51145. };
  51146. }
  51147. declare module BABYLON {
  51148. /** @hidden */
  51149. export var pbrFragmentExtraDeclaration: {
  51150. name: string;
  51151. shader: string;
  51152. };
  51153. }
  51154. declare module BABYLON {
  51155. /** @hidden */
  51156. export var pbrFragmentSamplersDeclaration: {
  51157. name: string;
  51158. shader: string;
  51159. };
  51160. }
  51161. declare module BABYLON {
  51162. /** @hidden */
  51163. export var pbrHelperFunctions: {
  51164. name: string;
  51165. shader: string;
  51166. };
  51167. }
  51168. declare module BABYLON {
  51169. /** @hidden */
  51170. export var harmonicsFunctions: {
  51171. name: string;
  51172. shader: string;
  51173. };
  51174. }
  51175. declare module BABYLON {
  51176. /** @hidden */
  51177. export var pbrDirectLightingSetupFunctions: {
  51178. name: string;
  51179. shader: string;
  51180. };
  51181. }
  51182. declare module BABYLON {
  51183. /** @hidden */
  51184. export var pbrDirectLightingFalloffFunctions: {
  51185. name: string;
  51186. shader: string;
  51187. };
  51188. }
  51189. declare module BABYLON {
  51190. /** @hidden */
  51191. export var pbrBRDFFunctions: {
  51192. name: string;
  51193. shader: string;
  51194. };
  51195. }
  51196. declare module BABYLON {
  51197. /** @hidden */
  51198. export var pbrDirectLightingFunctions: {
  51199. name: string;
  51200. shader: string;
  51201. };
  51202. }
  51203. declare module BABYLON {
  51204. /** @hidden */
  51205. export var pbrIBLFunctions: {
  51206. name: string;
  51207. shader: string;
  51208. };
  51209. }
  51210. declare module BABYLON {
  51211. /** @hidden */
  51212. export var pbrBlockAlbedoOpacity: {
  51213. name: string;
  51214. shader: string;
  51215. };
  51216. }
  51217. declare module BABYLON {
  51218. /** @hidden */
  51219. export var pbrBlockReflectivity: {
  51220. name: string;
  51221. shader: string;
  51222. };
  51223. }
  51224. declare module BABYLON {
  51225. /** @hidden */
  51226. export var pbrBlockAmbientOcclusion: {
  51227. name: string;
  51228. shader: string;
  51229. };
  51230. }
  51231. declare module BABYLON {
  51232. /** @hidden */
  51233. export var pbrBlockAlphaFresnel: {
  51234. name: string;
  51235. shader: string;
  51236. };
  51237. }
  51238. declare module BABYLON {
  51239. /** @hidden */
  51240. export var pbrBlockAnisotropic: {
  51241. name: string;
  51242. shader: string;
  51243. };
  51244. }
  51245. declare module BABYLON {
  51246. /** @hidden */
  51247. export var pbrBlockReflection: {
  51248. name: string;
  51249. shader: string;
  51250. };
  51251. }
  51252. declare module BABYLON {
  51253. /** @hidden */
  51254. export var pbrBlockSheen: {
  51255. name: string;
  51256. shader: string;
  51257. };
  51258. }
  51259. declare module BABYLON {
  51260. /** @hidden */
  51261. export var pbrBlockClearcoat: {
  51262. name: string;
  51263. shader: string;
  51264. };
  51265. }
  51266. declare module BABYLON {
  51267. /** @hidden */
  51268. export var pbrBlockSubSurface: {
  51269. name: string;
  51270. shader: string;
  51271. };
  51272. }
  51273. declare module BABYLON {
  51274. /** @hidden */
  51275. export var pbrBlockNormalGeometric: {
  51276. name: string;
  51277. shader: string;
  51278. };
  51279. }
  51280. declare module BABYLON {
  51281. /** @hidden */
  51282. export var pbrBlockNormalFinal: {
  51283. name: string;
  51284. shader: string;
  51285. };
  51286. }
  51287. declare module BABYLON {
  51288. /** @hidden */
  51289. export var pbrBlockGeometryInfo: {
  51290. name: string;
  51291. shader: string;
  51292. };
  51293. }
  51294. declare module BABYLON {
  51295. /** @hidden */
  51296. export var pbrBlockReflectance0: {
  51297. name: string;
  51298. shader: string;
  51299. };
  51300. }
  51301. declare module BABYLON {
  51302. /** @hidden */
  51303. export var pbrBlockReflectance: {
  51304. name: string;
  51305. shader: string;
  51306. };
  51307. }
  51308. declare module BABYLON {
  51309. /** @hidden */
  51310. export var pbrBlockDirectLighting: {
  51311. name: string;
  51312. shader: string;
  51313. };
  51314. }
  51315. declare module BABYLON {
  51316. /** @hidden */
  51317. export var pbrBlockFinalLitComponents: {
  51318. name: string;
  51319. shader: string;
  51320. };
  51321. }
  51322. declare module BABYLON {
  51323. /** @hidden */
  51324. export var pbrBlockFinalUnlitComponents: {
  51325. name: string;
  51326. shader: string;
  51327. };
  51328. }
  51329. declare module BABYLON {
  51330. /** @hidden */
  51331. export var pbrBlockFinalColorComposition: {
  51332. name: string;
  51333. shader: string;
  51334. };
  51335. }
  51336. declare module BABYLON {
  51337. /** @hidden */
  51338. export var pbrBlockImageProcessing: {
  51339. name: string;
  51340. shader: string;
  51341. };
  51342. }
  51343. declare module BABYLON {
  51344. /** @hidden */
  51345. export var pbrDebug: {
  51346. name: string;
  51347. shader: string;
  51348. };
  51349. }
  51350. declare module BABYLON {
  51351. /** @hidden */
  51352. export var pbrPixelShader: {
  51353. name: string;
  51354. shader: string;
  51355. };
  51356. }
  51357. declare module BABYLON {
  51358. /** @hidden */
  51359. export var pbrVertexDeclaration: {
  51360. name: string;
  51361. shader: string;
  51362. };
  51363. }
  51364. declare module BABYLON {
  51365. /** @hidden */
  51366. export var pbrVertexShader: {
  51367. name: string;
  51368. shader: string;
  51369. };
  51370. }
  51371. declare module BABYLON {
  51372. /**
  51373. * Manages the defines for the PBR Material.
  51374. * @hidden
  51375. */
  51376. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51377. PBR: boolean;
  51378. MAINUV1: boolean;
  51379. MAINUV2: boolean;
  51380. UV1: boolean;
  51381. UV2: boolean;
  51382. ALBEDO: boolean;
  51383. GAMMAALBEDO: boolean;
  51384. ALBEDODIRECTUV: number;
  51385. VERTEXCOLOR: boolean;
  51386. AMBIENT: boolean;
  51387. AMBIENTDIRECTUV: number;
  51388. AMBIENTINGRAYSCALE: boolean;
  51389. OPACITY: boolean;
  51390. VERTEXALPHA: boolean;
  51391. OPACITYDIRECTUV: number;
  51392. OPACITYRGB: boolean;
  51393. ALPHATEST: boolean;
  51394. DEPTHPREPASS: boolean;
  51395. ALPHABLEND: boolean;
  51396. ALPHAFROMALBEDO: boolean;
  51397. ALPHATESTVALUE: string;
  51398. SPECULAROVERALPHA: boolean;
  51399. RADIANCEOVERALPHA: boolean;
  51400. ALPHAFRESNEL: boolean;
  51401. LINEARALPHAFRESNEL: boolean;
  51402. PREMULTIPLYALPHA: boolean;
  51403. EMISSIVE: boolean;
  51404. EMISSIVEDIRECTUV: number;
  51405. REFLECTIVITY: boolean;
  51406. REFLECTIVITYDIRECTUV: number;
  51407. SPECULARTERM: boolean;
  51408. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51409. MICROSURFACEAUTOMATIC: boolean;
  51410. LODBASEDMICROSFURACE: boolean;
  51411. MICROSURFACEMAP: boolean;
  51412. MICROSURFACEMAPDIRECTUV: number;
  51413. METALLICWORKFLOW: boolean;
  51414. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51415. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51416. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51417. AOSTOREINMETALMAPRED: boolean;
  51418. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51419. ENVIRONMENTBRDF: boolean;
  51420. ENVIRONMENTBRDF_RGBD: boolean;
  51421. NORMAL: boolean;
  51422. TANGENT: boolean;
  51423. BUMP: boolean;
  51424. BUMPDIRECTUV: number;
  51425. OBJECTSPACE_NORMALMAP: boolean;
  51426. PARALLAX: boolean;
  51427. PARALLAXOCCLUSION: boolean;
  51428. NORMALXYSCALE: boolean;
  51429. LIGHTMAP: boolean;
  51430. LIGHTMAPDIRECTUV: number;
  51431. USELIGHTMAPASSHADOWMAP: boolean;
  51432. GAMMALIGHTMAP: boolean;
  51433. RGBDLIGHTMAP: boolean;
  51434. REFLECTION: boolean;
  51435. REFLECTIONMAP_3D: boolean;
  51436. REFLECTIONMAP_SPHERICAL: boolean;
  51437. REFLECTIONMAP_PLANAR: boolean;
  51438. REFLECTIONMAP_CUBIC: boolean;
  51439. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51440. REFLECTIONMAP_PROJECTION: boolean;
  51441. REFLECTIONMAP_SKYBOX: boolean;
  51442. REFLECTIONMAP_EXPLICIT: boolean;
  51443. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51444. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51445. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51446. INVERTCUBICMAP: boolean;
  51447. USESPHERICALFROMREFLECTIONMAP: boolean;
  51448. USEIRRADIANCEMAP: boolean;
  51449. SPHERICAL_HARMONICS: boolean;
  51450. USESPHERICALINVERTEX: boolean;
  51451. REFLECTIONMAP_OPPOSITEZ: boolean;
  51452. LODINREFLECTIONALPHA: boolean;
  51453. GAMMAREFLECTION: boolean;
  51454. RGBDREFLECTION: boolean;
  51455. LINEARSPECULARREFLECTION: boolean;
  51456. RADIANCEOCCLUSION: boolean;
  51457. HORIZONOCCLUSION: boolean;
  51458. INSTANCES: boolean;
  51459. NUM_BONE_INFLUENCERS: number;
  51460. BonesPerMesh: number;
  51461. BONETEXTURE: boolean;
  51462. NONUNIFORMSCALING: boolean;
  51463. MORPHTARGETS: boolean;
  51464. MORPHTARGETS_NORMAL: boolean;
  51465. MORPHTARGETS_TANGENT: boolean;
  51466. MORPHTARGETS_UV: boolean;
  51467. NUM_MORPH_INFLUENCERS: number;
  51468. IMAGEPROCESSING: boolean;
  51469. VIGNETTE: boolean;
  51470. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51471. VIGNETTEBLENDMODEOPAQUE: boolean;
  51472. TONEMAPPING: boolean;
  51473. TONEMAPPING_ACES: boolean;
  51474. CONTRAST: boolean;
  51475. COLORCURVES: boolean;
  51476. COLORGRADING: boolean;
  51477. COLORGRADING3D: boolean;
  51478. SAMPLER3DGREENDEPTH: boolean;
  51479. SAMPLER3DBGRMAP: boolean;
  51480. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51481. EXPOSURE: boolean;
  51482. MULTIVIEW: boolean;
  51483. USEPHYSICALLIGHTFALLOFF: boolean;
  51484. USEGLTFLIGHTFALLOFF: boolean;
  51485. TWOSIDEDLIGHTING: boolean;
  51486. SHADOWFLOAT: boolean;
  51487. CLIPPLANE: boolean;
  51488. CLIPPLANE2: boolean;
  51489. CLIPPLANE3: boolean;
  51490. CLIPPLANE4: boolean;
  51491. CLIPPLANE5: boolean;
  51492. CLIPPLANE6: boolean;
  51493. POINTSIZE: boolean;
  51494. FOG: boolean;
  51495. LOGARITHMICDEPTH: boolean;
  51496. FORCENORMALFORWARD: boolean;
  51497. SPECULARAA: boolean;
  51498. CLEARCOAT: boolean;
  51499. CLEARCOAT_DEFAULTIOR: boolean;
  51500. CLEARCOAT_TEXTURE: boolean;
  51501. CLEARCOAT_TEXTUREDIRECTUV: number;
  51502. CLEARCOAT_BUMP: boolean;
  51503. CLEARCOAT_BUMPDIRECTUV: number;
  51504. CLEARCOAT_TINT: boolean;
  51505. CLEARCOAT_TINT_TEXTURE: boolean;
  51506. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51507. ANISOTROPIC: boolean;
  51508. ANISOTROPIC_TEXTURE: boolean;
  51509. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51510. BRDF_V_HEIGHT_CORRELATED: boolean;
  51511. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51512. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51513. SHEEN: boolean;
  51514. SHEEN_TEXTURE: boolean;
  51515. SHEEN_TEXTUREDIRECTUV: number;
  51516. SHEEN_LINKWITHALBEDO: boolean;
  51517. SHEEN_ROUGHNESS: boolean;
  51518. SHEEN_ALBEDOSCALING: boolean;
  51519. SUBSURFACE: boolean;
  51520. SS_REFRACTION: boolean;
  51521. SS_TRANSLUCENCY: boolean;
  51522. SS_SCATERRING: boolean;
  51523. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51524. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51525. SS_REFRACTIONMAP_3D: boolean;
  51526. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51527. SS_LODINREFRACTIONALPHA: boolean;
  51528. SS_GAMMAREFRACTION: boolean;
  51529. SS_RGBDREFRACTION: boolean;
  51530. SS_LINEARSPECULARREFRACTION: boolean;
  51531. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51532. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51533. UNLIT: boolean;
  51534. DEBUGMODE: number;
  51535. /**
  51536. * Initializes the PBR Material defines.
  51537. */
  51538. constructor();
  51539. /**
  51540. * Resets the PBR Material defines.
  51541. */
  51542. reset(): void;
  51543. }
  51544. /**
  51545. * The Physically based material base class of BJS.
  51546. *
  51547. * This offers the main features of a standard PBR material.
  51548. * For more information, please refer to the documentation :
  51549. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51550. */
  51551. export abstract class PBRBaseMaterial extends PushMaterial {
  51552. /**
  51553. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51554. */
  51555. static readonly PBRMATERIAL_OPAQUE: number;
  51556. /**
  51557. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51558. */
  51559. static readonly PBRMATERIAL_ALPHATEST: number;
  51560. /**
  51561. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51562. */
  51563. static readonly PBRMATERIAL_ALPHABLEND: number;
  51564. /**
  51565. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51566. * They are also discarded below the alpha cutoff threshold to improve performances.
  51567. */
  51568. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51569. /**
  51570. * Defines the default value of how much AO map is occluding the analytical lights
  51571. * (point spot...).
  51572. */
  51573. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51574. /**
  51575. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51576. */
  51577. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51578. /**
  51579. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51580. * to enhance interoperability with other engines.
  51581. */
  51582. static readonly LIGHTFALLOFF_GLTF: number;
  51583. /**
  51584. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51585. * to enhance interoperability with other materials.
  51586. */
  51587. static readonly LIGHTFALLOFF_STANDARD: number;
  51588. /**
  51589. * Intensity of the direct lights e.g. the four lights available in your scene.
  51590. * This impacts both the direct diffuse and specular highlights.
  51591. */
  51592. protected _directIntensity: number;
  51593. /**
  51594. * Intensity of the emissive part of the material.
  51595. * This helps controlling the emissive effect without modifying the emissive color.
  51596. */
  51597. protected _emissiveIntensity: number;
  51598. /**
  51599. * Intensity of the environment e.g. how much the environment will light the object
  51600. * either through harmonics for rough material or through the refelction for shiny ones.
  51601. */
  51602. protected _environmentIntensity: number;
  51603. /**
  51604. * This is a special control allowing the reduction of the specular highlights coming from the
  51605. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51606. */
  51607. protected _specularIntensity: number;
  51608. /**
  51609. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51610. */
  51611. private _lightingInfos;
  51612. /**
  51613. * Debug Control allowing disabling the bump map on this material.
  51614. */
  51615. protected _disableBumpMap: boolean;
  51616. /**
  51617. * AKA Diffuse Texture in standard nomenclature.
  51618. */
  51619. protected _albedoTexture: Nullable<BaseTexture>;
  51620. /**
  51621. * AKA Occlusion Texture in other nomenclature.
  51622. */
  51623. protected _ambientTexture: Nullable<BaseTexture>;
  51624. /**
  51625. * AKA Occlusion Texture Intensity in other nomenclature.
  51626. */
  51627. protected _ambientTextureStrength: number;
  51628. /**
  51629. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51630. * 1 means it completely occludes it
  51631. * 0 mean it has no impact
  51632. */
  51633. protected _ambientTextureImpactOnAnalyticalLights: number;
  51634. /**
  51635. * Stores the alpha values in a texture.
  51636. */
  51637. protected _opacityTexture: Nullable<BaseTexture>;
  51638. /**
  51639. * Stores the reflection values in a texture.
  51640. */
  51641. protected _reflectionTexture: Nullable<BaseTexture>;
  51642. /**
  51643. * Stores the emissive values in a texture.
  51644. */
  51645. protected _emissiveTexture: Nullable<BaseTexture>;
  51646. /**
  51647. * AKA Specular texture in other nomenclature.
  51648. */
  51649. protected _reflectivityTexture: Nullable<BaseTexture>;
  51650. /**
  51651. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51652. */
  51653. protected _metallicTexture: Nullable<BaseTexture>;
  51654. /**
  51655. * Specifies the metallic scalar of the metallic/roughness workflow.
  51656. * Can also be used to scale the metalness values of the metallic texture.
  51657. */
  51658. protected _metallic: Nullable<number>;
  51659. /**
  51660. * Specifies the roughness scalar of the metallic/roughness workflow.
  51661. * Can also be used to scale the roughness values of the metallic texture.
  51662. */
  51663. protected _roughness: Nullable<number>;
  51664. /**
  51665. * Specifies the an F0 factor to help configuring the material F0.
  51666. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51667. * to 0.5 the previously hard coded value stays the same.
  51668. * Can also be used to scale the F0 values of the metallic texture.
  51669. */
  51670. protected _metallicF0Factor: number;
  51671. /**
  51672. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51673. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51674. * your expectation as it multiplies with the texture data.
  51675. */
  51676. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51677. /**
  51678. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51679. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51680. */
  51681. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51682. /**
  51683. * Stores surface normal data used to displace a mesh in a texture.
  51684. */
  51685. protected _bumpTexture: Nullable<BaseTexture>;
  51686. /**
  51687. * Stores the pre-calculated light information of a mesh in a texture.
  51688. */
  51689. protected _lightmapTexture: Nullable<BaseTexture>;
  51690. /**
  51691. * The color of a material in ambient lighting.
  51692. */
  51693. protected _ambientColor: Color3;
  51694. /**
  51695. * AKA Diffuse Color in other nomenclature.
  51696. */
  51697. protected _albedoColor: Color3;
  51698. /**
  51699. * AKA Specular Color in other nomenclature.
  51700. */
  51701. protected _reflectivityColor: Color3;
  51702. /**
  51703. * The color applied when light is reflected from a material.
  51704. */
  51705. protected _reflectionColor: Color3;
  51706. /**
  51707. * The color applied when light is emitted from a material.
  51708. */
  51709. protected _emissiveColor: Color3;
  51710. /**
  51711. * AKA Glossiness in other nomenclature.
  51712. */
  51713. protected _microSurface: number;
  51714. /**
  51715. * Specifies that the material will use the light map as a show map.
  51716. */
  51717. protected _useLightmapAsShadowmap: boolean;
  51718. /**
  51719. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51720. * makes the reflect vector face the model (under horizon).
  51721. */
  51722. protected _useHorizonOcclusion: boolean;
  51723. /**
  51724. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51725. * too much the area relying on ambient texture to define their ambient occlusion.
  51726. */
  51727. protected _useRadianceOcclusion: boolean;
  51728. /**
  51729. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51730. */
  51731. protected _useAlphaFromAlbedoTexture: boolean;
  51732. /**
  51733. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51734. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51735. */
  51736. protected _useSpecularOverAlpha: boolean;
  51737. /**
  51738. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51739. */
  51740. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51741. /**
  51742. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51743. */
  51744. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51745. /**
  51746. * Specifies if the metallic texture contains the roughness information in its green channel.
  51747. */
  51748. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51749. /**
  51750. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51751. */
  51752. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51753. /**
  51754. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51755. */
  51756. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51757. /**
  51758. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51759. */
  51760. protected _useAmbientInGrayScale: boolean;
  51761. /**
  51762. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51763. * The material will try to infer what glossiness each pixel should be.
  51764. */
  51765. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51766. /**
  51767. * Defines the falloff type used in this material.
  51768. * It by default is Physical.
  51769. */
  51770. protected _lightFalloff: number;
  51771. /**
  51772. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51773. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51774. */
  51775. protected _useRadianceOverAlpha: boolean;
  51776. /**
  51777. * Allows using an object space normal map (instead of tangent space).
  51778. */
  51779. protected _useObjectSpaceNormalMap: boolean;
  51780. /**
  51781. * Allows using the bump map in parallax mode.
  51782. */
  51783. protected _useParallax: boolean;
  51784. /**
  51785. * Allows using the bump map in parallax occlusion mode.
  51786. */
  51787. protected _useParallaxOcclusion: boolean;
  51788. /**
  51789. * Controls the scale bias of the parallax mode.
  51790. */
  51791. protected _parallaxScaleBias: number;
  51792. /**
  51793. * If sets to true, disables all the lights affecting the material.
  51794. */
  51795. protected _disableLighting: boolean;
  51796. /**
  51797. * Number of Simultaneous lights allowed on the material.
  51798. */
  51799. protected _maxSimultaneousLights: number;
  51800. /**
  51801. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51802. */
  51803. protected _invertNormalMapX: boolean;
  51804. /**
  51805. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51806. */
  51807. protected _invertNormalMapY: boolean;
  51808. /**
  51809. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51810. */
  51811. protected _twoSidedLighting: boolean;
  51812. /**
  51813. * Defines the alpha limits in alpha test mode.
  51814. */
  51815. protected _alphaCutOff: number;
  51816. /**
  51817. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51818. */
  51819. protected _forceAlphaTest: boolean;
  51820. /**
  51821. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51822. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51823. */
  51824. protected _useAlphaFresnel: boolean;
  51825. /**
  51826. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51827. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51828. */
  51829. protected _useLinearAlphaFresnel: boolean;
  51830. /**
  51831. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51832. * from cos thetav and roughness:
  51833. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51834. */
  51835. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51836. /**
  51837. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51838. */
  51839. protected _forceIrradianceInFragment: boolean;
  51840. /**
  51841. * Force normal to face away from face.
  51842. */
  51843. protected _forceNormalForward: boolean;
  51844. /**
  51845. * Enables specular anti aliasing in the PBR shader.
  51846. * It will both interacts on the Geometry for analytical and IBL lighting.
  51847. * It also prefilter the roughness map based on the bump values.
  51848. */
  51849. protected _enableSpecularAntiAliasing: boolean;
  51850. /**
  51851. * Default configuration related to image processing available in the PBR Material.
  51852. */
  51853. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51854. /**
  51855. * Keep track of the image processing observer to allow dispose and replace.
  51856. */
  51857. private _imageProcessingObserver;
  51858. /**
  51859. * Attaches a new image processing configuration to the PBR Material.
  51860. * @param configuration
  51861. */
  51862. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51863. /**
  51864. * Stores the available render targets.
  51865. */
  51866. private _renderTargets;
  51867. /**
  51868. * Sets the global ambient color for the material used in lighting calculations.
  51869. */
  51870. private _globalAmbientColor;
  51871. /**
  51872. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51873. */
  51874. private _useLogarithmicDepth;
  51875. /**
  51876. * If set to true, no lighting calculations will be applied.
  51877. */
  51878. private _unlit;
  51879. private _debugMode;
  51880. /**
  51881. * @hidden
  51882. * This is reserved for the inspector.
  51883. * Defines the material debug mode.
  51884. * It helps seeing only some components of the material while troubleshooting.
  51885. */
  51886. debugMode: number;
  51887. /**
  51888. * @hidden
  51889. * This is reserved for the inspector.
  51890. * Specify from where on screen the debug mode should start.
  51891. * The value goes from -1 (full screen) to 1 (not visible)
  51892. * It helps with side by side comparison against the final render
  51893. * This defaults to -1
  51894. */
  51895. private debugLimit;
  51896. /**
  51897. * @hidden
  51898. * This is reserved for the inspector.
  51899. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51900. * You can use the factor to better multiply the final value.
  51901. */
  51902. private debugFactor;
  51903. /**
  51904. * Defines the clear coat layer parameters for the material.
  51905. */
  51906. readonly clearCoat: PBRClearCoatConfiguration;
  51907. /**
  51908. * Defines the anisotropic parameters for the material.
  51909. */
  51910. readonly anisotropy: PBRAnisotropicConfiguration;
  51911. /**
  51912. * Defines the BRDF parameters for the material.
  51913. */
  51914. readonly brdf: PBRBRDFConfiguration;
  51915. /**
  51916. * Defines the Sheen parameters for the material.
  51917. */
  51918. readonly sheen: PBRSheenConfiguration;
  51919. /**
  51920. * Defines the SubSurface parameters for the material.
  51921. */
  51922. readonly subSurface: PBRSubSurfaceConfiguration;
  51923. /**
  51924. * Custom callback helping to override the default shader used in the material.
  51925. */
  51926. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines, attributes?: string[]) => string;
  51927. protected _rebuildInParallel: boolean;
  51928. /**
  51929. * Instantiates a new PBRMaterial instance.
  51930. *
  51931. * @param name The material name
  51932. * @param scene The scene the material will be use in.
  51933. */
  51934. constructor(name: string, scene: Scene);
  51935. /**
  51936. * Gets a boolean indicating that current material needs to register RTT
  51937. */
  51938. get hasRenderTargetTextures(): boolean;
  51939. /**
  51940. * Gets the name of the material class.
  51941. */
  51942. getClassName(): string;
  51943. /**
  51944. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51945. */
  51946. get useLogarithmicDepth(): boolean;
  51947. /**
  51948. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51949. */
  51950. set useLogarithmicDepth(value: boolean);
  51951. /**
  51952. * Returns true if alpha blending should be disabled.
  51953. */
  51954. protected get _disableAlphaBlending(): boolean;
  51955. /**
  51956. * Specifies whether or not this material should be rendered in alpha blend mode.
  51957. */
  51958. needAlphaBlending(): boolean;
  51959. /**
  51960. * Specifies whether or not this material should be rendered in alpha test mode.
  51961. */
  51962. needAlphaTesting(): boolean;
  51963. /**
  51964. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51965. */
  51966. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51967. /**
  51968. * Gets the texture used for the alpha test.
  51969. */
  51970. getAlphaTestTexture(): Nullable<BaseTexture>;
  51971. /**
  51972. * Specifies that the submesh is ready to be used.
  51973. * @param mesh - BJS mesh.
  51974. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51975. * @param useInstances - Specifies that instances should be used.
  51976. * @returns - boolean indicating that the submesh is ready or not.
  51977. */
  51978. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51979. /**
  51980. * Specifies if the material uses metallic roughness workflow.
  51981. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51982. */
  51983. isMetallicWorkflow(): boolean;
  51984. private _prepareEffect;
  51985. private _prepareDefines;
  51986. /**
  51987. * Force shader compilation
  51988. */
  51989. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51990. /**
  51991. * Initializes the uniform buffer layout for the shader.
  51992. */
  51993. buildUniformLayout(): void;
  51994. /**
  51995. * Unbinds the material from the mesh
  51996. */
  51997. unbind(): void;
  51998. /**
  51999. * Binds the submesh data.
  52000. * @param world - The world matrix.
  52001. * @param mesh - The BJS mesh.
  52002. * @param subMesh - A submesh of the BJS mesh.
  52003. */
  52004. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52005. /**
  52006. * Returns the animatable textures.
  52007. * @returns - Array of animatable textures.
  52008. */
  52009. getAnimatables(): IAnimatable[];
  52010. /**
  52011. * Returns the texture used for reflections.
  52012. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52013. */
  52014. private _getReflectionTexture;
  52015. /**
  52016. * Returns an array of the actively used textures.
  52017. * @returns - Array of BaseTextures
  52018. */
  52019. getActiveTextures(): BaseTexture[];
  52020. /**
  52021. * Checks to see if a texture is used in the material.
  52022. * @param texture - Base texture to use.
  52023. * @returns - Boolean specifying if a texture is used in the material.
  52024. */
  52025. hasTexture(texture: BaseTexture): boolean;
  52026. /**
  52027. * Disposes the resources of the material.
  52028. * @param forceDisposeEffect - Forces the disposal of effects.
  52029. * @param forceDisposeTextures - Forces the disposal of all textures.
  52030. */
  52031. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52032. }
  52033. }
  52034. declare module BABYLON {
  52035. /**
  52036. * The Physically based material of BJS.
  52037. *
  52038. * This offers the main features of a standard PBR material.
  52039. * For more information, please refer to the documentation :
  52040. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52041. */
  52042. export class PBRMaterial extends PBRBaseMaterial {
  52043. /**
  52044. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52045. */
  52046. static readonly PBRMATERIAL_OPAQUE: number;
  52047. /**
  52048. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52049. */
  52050. static readonly PBRMATERIAL_ALPHATEST: number;
  52051. /**
  52052. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52053. */
  52054. static readonly PBRMATERIAL_ALPHABLEND: number;
  52055. /**
  52056. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52057. * They are also discarded below the alpha cutoff threshold to improve performances.
  52058. */
  52059. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52060. /**
  52061. * Defines the default value of how much AO map is occluding the analytical lights
  52062. * (point spot...).
  52063. */
  52064. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52065. /**
  52066. * Intensity of the direct lights e.g. the four lights available in your scene.
  52067. * This impacts both the direct diffuse and specular highlights.
  52068. */
  52069. directIntensity: number;
  52070. /**
  52071. * Intensity of the emissive part of the material.
  52072. * This helps controlling the emissive effect without modifying the emissive color.
  52073. */
  52074. emissiveIntensity: number;
  52075. /**
  52076. * Intensity of the environment e.g. how much the environment will light the object
  52077. * either through harmonics for rough material or through the refelction for shiny ones.
  52078. */
  52079. environmentIntensity: number;
  52080. /**
  52081. * This is a special control allowing the reduction of the specular highlights coming from the
  52082. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52083. */
  52084. specularIntensity: number;
  52085. /**
  52086. * Debug Control allowing disabling the bump map on this material.
  52087. */
  52088. disableBumpMap: boolean;
  52089. /**
  52090. * AKA Diffuse Texture in standard nomenclature.
  52091. */
  52092. albedoTexture: BaseTexture;
  52093. /**
  52094. * AKA Occlusion Texture in other nomenclature.
  52095. */
  52096. ambientTexture: BaseTexture;
  52097. /**
  52098. * AKA Occlusion Texture Intensity in other nomenclature.
  52099. */
  52100. ambientTextureStrength: number;
  52101. /**
  52102. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52103. * 1 means it completely occludes it
  52104. * 0 mean it has no impact
  52105. */
  52106. ambientTextureImpactOnAnalyticalLights: number;
  52107. /**
  52108. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52109. */
  52110. opacityTexture: BaseTexture;
  52111. /**
  52112. * Stores the reflection values in a texture.
  52113. */
  52114. reflectionTexture: Nullable<BaseTexture>;
  52115. /**
  52116. * Stores the emissive values in a texture.
  52117. */
  52118. emissiveTexture: BaseTexture;
  52119. /**
  52120. * AKA Specular texture in other nomenclature.
  52121. */
  52122. reflectivityTexture: BaseTexture;
  52123. /**
  52124. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52125. */
  52126. metallicTexture: BaseTexture;
  52127. /**
  52128. * Specifies the metallic scalar of the metallic/roughness workflow.
  52129. * Can also be used to scale the metalness values of the metallic texture.
  52130. */
  52131. metallic: Nullable<number>;
  52132. /**
  52133. * Specifies the roughness scalar of the metallic/roughness workflow.
  52134. * Can also be used to scale the roughness values of the metallic texture.
  52135. */
  52136. roughness: Nullable<number>;
  52137. /**
  52138. * Specifies the an F0 factor to help configuring the material F0.
  52139. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52140. * to 0.5 the previously hard coded value stays the same.
  52141. * Can also be used to scale the F0 values of the metallic texture.
  52142. */
  52143. metallicF0Factor: number;
  52144. /**
  52145. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52146. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52147. * your expectation as it multiplies with the texture data.
  52148. */
  52149. useMetallicF0FactorFromMetallicTexture: boolean;
  52150. /**
  52151. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52152. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52153. */
  52154. microSurfaceTexture: BaseTexture;
  52155. /**
  52156. * Stores surface normal data used to displace a mesh in a texture.
  52157. */
  52158. bumpTexture: BaseTexture;
  52159. /**
  52160. * Stores the pre-calculated light information of a mesh in a texture.
  52161. */
  52162. lightmapTexture: BaseTexture;
  52163. /**
  52164. * Stores the refracted light information in a texture.
  52165. */
  52166. get refractionTexture(): Nullable<BaseTexture>;
  52167. set refractionTexture(value: Nullable<BaseTexture>);
  52168. /**
  52169. * The color of a material in ambient lighting.
  52170. */
  52171. ambientColor: Color3;
  52172. /**
  52173. * AKA Diffuse Color in other nomenclature.
  52174. */
  52175. albedoColor: Color3;
  52176. /**
  52177. * AKA Specular Color in other nomenclature.
  52178. */
  52179. reflectivityColor: Color3;
  52180. /**
  52181. * The color reflected from the material.
  52182. */
  52183. reflectionColor: Color3;
  52184. /**
  52185. * The color emitted from the material.
  52186. */
  52187. emissiveColor: Color3;
  52188. /**
  52189. * AKA Glossiness in other nomenclature.
  52190. */
  52191. microSurface: number;
  52192. /**
  52193. * source material index of refraction (IOR)' / 'destination material IOR.
  52194. */
  52195. get indexOfRefraction(): number;
  52196. set indexOfRefraction(value: number);
  52197. /**
  52198. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52199. */
  52200. get invertRefractionY(): boolean;
  52201. set invertRefractionY(value: boolean);
  52202. /**
  52203. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52204. * Materials half opaque for instance using refraction could benefit from this control.
  52205. */
  52206. get linkRefractionWithTransparency(): boolean;
  52207. set linkRefractionWithTransparency(value: boolean);
  52208. /**
  52209. * If true, the light map contains occlusion information instead of lighting info.
  52210. */
  52211. useLightmapAsShadowmap: boolean;
  52212. /**
  52213. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52214. */
  52215. useAlphaFromAlbedoTexture: boolean;
  52216. /**
  52217. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52218. */
  52219. forceAlphaTest: boolean;
  52220. /**
  52221. * Defines the alpha limits in alpha test mode.
  52222. */
  52223. alphaCutOff: number;
  52224. /**
  52225. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52226. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52227. */
  52228. useSpecularOverAlpha: boolean;
  52229. /**
  52230. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52231. */
  52232. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52233. /**
  52234. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52235. */
  52236. useRoughnessFromMetallicTextureAlpha: boolean;
  52237. /**
  52238. * Specifies if the metallic texture contains the roughness information in its green channel.
  52239. */
  52240. useRoughnessFromMetallicTextureGreen: boolean;
  52241. /**
  52242. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52243. */
  52244. useMetallnessFromMetallicTextureBlue: boolean;
  52245. /**
  52246. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52247. */
  52248. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52249. /**
  52250. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52251. */
  52252. useAmbientInGrayScale: boolean;
  52253. /**
  52254. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52255. * The material will try to infer what glossiness each pixel should be.
  52256. */
  52257. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52258. /**
  52259. * BJS is using an harcoded light falloff based on a manually sets up range.
  52260. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52261. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52262. */
  52263. get usePhysicalLightFalloff(): boolean;
  52264. /**
  52265. * BJS is using an harcoded light falloff based on a manually sets up range.
  52266. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52267. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52268. */
  52269. set usePhysicalLightFalloff(value: boolean);
  52270. /**
  52271. * In order to support the falloff compatibility with gltf, a special mode has been added
  52272. * to reproduce the gltf light falloff.
  52273. */
  52274. get useGLTFLightFalloff(): boolean;
  52275. /**
  52276. * In order to support the falloff compatibility with gltf, a special mode has been added
  52277. * to reproduce the gltf light falloff.
  52278. */
  52279. set useGLTFLightFalloff(value: boolean);
  52280. /**
  52281. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52282. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52283. */
  52284. useRadianceOverAlpha: boolean;
  52285. /**
  52286. * Allows using an object space normal map (instead of tangent space).
  52287. */
  52288. useObjectSpaceNormalMap: boolean;
  52289. /**
  52290. * Allows using the bump map in parallax mode.
  52291. */
  52292. useParallax: boolean;
  52293. /**
  52294. * Allows using the bump map in parallax occlusion mode.
  52295. */
  52296. useParallaxOcclusion: boolean;
  52297. /**
  52298. * Controls the scale bias of the parallax mode.
  52299. */
  52300. parallaxScaleBias: number;
  52301. /**
  52302. * If sets to true, disables all the lights affecting the material.
  52303. */
  52304. disableLighting: boolean;
  52305. /**
  52306. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52307. */
  52308. forceIrradianceInFragment: boolean;
  52309. /**
  52310. * Number of Simultaneous lights allowed on the material.
  52311. */
  52312. maxSimultaneousLights: number;
  52313. /**
  52314. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52315. */
  52316. invertNormalMapX: boolean;
  52317. /**
  52318. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52319. */
  52320. invertNormalMapY: boolean;
  52321. /**
  52322. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52323. */
  52324. twoSidedLighting: boolean;
  52325. /**
  52326. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52327. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52328. */
  52329. useAlphaFresnel: boolean;
  52330. /**
  52331. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52332. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52333. */
  52334. useLinearAlphaFresnel: boolean;
  52335. /**
  52336. * Let user defines the brdf lookup texture used for IBL.
  52337. * A default 8bit version is embedded but you could point at :
  52338. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52339. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52340. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52341. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52342. */
  52343. environmentBRDFTexture: Nullable<BaseTexture>;
  52344. /**
  52345. * Force normal to face away from face.
  52346. */
  52347. forceNormalForward: boolean;
  52348. /**
  52349. * Enables specular anti aliasing in the PBR shader.
  52350. * It will both interacts on the Geometry for analytical and IBL lighting.
  52351. * It also prefilter the roughness map based on the bump values.
  52352. */
  52353. enableSpecularAntiAliasing: boolean;
  52354. /**
  52355. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52356. * makes the reflect vector face the model (under horizon).
  52357. */
  52358. useHorizonOcclusion: boolean;
  52359. /**
  52360. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52361. * too much the area relying on ambient texture to define their ambient occlusion.
  52362. */
  52363. useRadianceOcclusion: boolean;
  52364. /**
  52365. * If set to true, no lighting calculations will be applied.
  52366. */
  52367. unlit: boolean;
  52368. /**
  52369. * Gets the image processing configuration used either in this material.
  52370. */
  52371. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52372. /**
  52373. * Sets the Default image processing configuration used either in the this material.
  52374. *
  52375. * If sets to null, the scene one is in use.
  52376. */
  52377. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52378. /**
  52379. * Gets wether the color curves effect is enabled.
  52380. */
  52381. get cameraColorCurvesEnabled(): boolean;
  52382. /**
  52383. * Sets wether the color curves effect is enabled.
  52384. */
  52385. set cameraColorCurvesEnabled(value: boolean);
  52386. /**
  52387. * Gets wether the color grading effect is enabled.
  52388. */
  52389. get cameraColorGradingEnabled(): boolean;
  52390. /**
  52391. * Gets wether the color grading effect is enabled.
  52392. */
  52393. set cameraColorGradingEnabled(value: boolean);
  52394. /**
  52395. * Gets wether tonemapping is enabled or not.
  52396. */
  52397. get cameraToneMappingEnabled(): boolean;
  52398. /**
  52399. * Sets wether tonemapping is enabled or not
  52400. */
  52401. set cameraToneMappingEnabled(value: boolean);
  52402. /**
  52403. * The camera exposure used on this material.
  52404. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52405. * This corresponds to a photographic exposure.
  52406. */
  52407. get cameraExposure(): number;
  52408. /**
  52409. * The camera exposure used on this material.
  52410. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52411. * This corresponds to a photographic exposure.
  52412. */
  52413. set cameraExposure(value: number);
  52414. /**
  52415. * Gets The camera contrast used on this material.
  52416. */
  52417. get cameraContrast(): number;
  52418. /**
  52419. * Sets The camera contrast used on this material.
  52420. */
  52421. set cameraContrast(value: number);
  52422. /**
  52423. * Gets the Color Grading 2D Lookup Texture.
  52424. */
  52425. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52426. /**
  52427. * Sets the Color Grading 2D Lookup Texture.
  52428. */
  52429. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52430. /**
  52431. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52432. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52433. * 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;
  52434. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52435. */
  52436. get cameraColorCurves(): Nullable<ColorCurves>;
  52437. /**
  52438. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52439. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52440. * 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;
  52441. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52442. */
  52443. set cameraColorCurves(value: Nullable<ColorCurves>);
  52444. /**
  52445. * Instantiates a new PBRMaterial instance.
  52446. *
  52447. * @param name The material name
  52448. * @param scene The scene the material will be use in.
  52449. */
  52450. constructor(name: string, scene: Scene);
  52451. /**
  52452. * Returns the name of this material class.
  52453. */
  52454. getClassName(): string;
  52455. /**
  52456. * Makes a duplicate of the current material.
  52457. * @param name - name to use for the new material.
  52458. */
  52459. clone(name: string): PBRMaterial;
  52460. /**
  52461. * Serializes this PBR Material.
  52462. * @returns - An object with the serialized material.
  52463. */
  52464. serialize(): any;
  52465. /**
  52466. * Parses a PBR Material from a serialized object.
  52467. * @param source - Serialized object.
  52468. * @param scene - BJS scene instance.
  52469. * @param rootUrl - url for the scene object
  52470. * @returns - PBRMaterial
  52471. */
  52472. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52473. }
  52474. }
  52475. declare module BABYLON {
  52476. /**
  52477. * Direct draw surface info
  52478. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52479. */
  52480. export interface DDSInfo {
  52481. /**
  52482. * Width of the texture
  52483. */
  52484. width: number;
  52485. /**
  52486. * Width of the texture
  52487. */
  52488. height: number;
  52489. /**
  52490. * Number of Mipmaps for the texture
  52491. * @see https://en.wikipedia.org/wiki/Mipmap
  52492. */
  52493. mipmapCount: number;
  52494. /**
  52495. * If the textures format is a known fourCC format
  52496. * @see https://www.fourcc.org/
  52497. */
  52498. isFourCC: boolean;
  52499. /**
  52500. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52501. */
  52502. isRGB: boolean;
  52503. /**
  52504. * If the texture is a lumincance format
  52505. */
  52506. isLuminance: boolean;
  52507. /**
  52508. * If this is a cube texture
  52509. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52510. */
  52511. isCube: boolean;
  52512. /**
  52513. * If the texture is a compressed format eg. FOURCC_DXT1
  52514. */
  52515. isCompressed: boolean;
  52516. /**
  52517. * The dxgiFormat of the texture
  52518. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52519. */
  52520. dxgiFormat: number;
  52521. /**
  52522. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52523. */
  52524. textureType: number;
  52525. /**
  52526. * Sphericle polynomial created for the dds texture
  52527. */
  52528. sphericalPolynomial?: SphericalPolynomial;
  52529. }
  52530. /**
  52531. * Class used to provide DDS decompression tools
  52532. */
  52533. export class DDSTools {
  52534. /**
  52535. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52536. */
  52537. static StoreLODInAlphaChannel: boolean;
  52538. /**
  52539. * Gets DDS information from an array buffer
  52540. * @param data defines the array buffer view to read data from
  52541. * @returns the DDS information
  52542. */
  52543. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52544. private static _FloatView;
  52545. private static _Int32View;
  52546. private static _ToHalfFloat;
  52547. private static _FromHalfFloat;
  52548. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52549. private static _GetHalfFloatRGBAArrayBuffer;
  52550. private static _GetFloatRGBAArrayBuffer;
  52551. private static _GetFloatAsUIntRGBAArrayBuffer;
  52552. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52553. private static _GetRGBAArrayBuffer;
  52554. private static _ExtractLongWordOrder;
  52555. private static _GetRGBArrayBuffer;
  52556. private static _GetLuminanceArrayBuffer;
  52557. /**
  52558. * Uploads DDS Levels to a Babylon Texture
  52559. * @hidden
  52560. */
  52561. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52562. }
  52563. interface ThinEngine {
  52564. /**
  52565. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52566. * @param rootUrl defines the url where the file to load is located
  52567. * @param scene defines the current scene
  52568. * @param lodScale defines scale to apply to the mip map selection
  52569. * @param lodOffset defines offset to apply to the mip map selection
  52570. * @param onLoad defines an optional callback raised when the texture is loaded
  52571. * @param onError defines an optional callback raised if there is an issue to load the texture
  52572. * @param format defines the format of the data
  52573. * @param forcedExtension defines the extension to use to pick the right loader
  52574. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52575. * @returns the cube texture as an InternalTexture
  52576. */
  52577. 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;
  52578. }
  52579. }
  52580. declare module BABYLON {
  52581. /**
  52582. * Implementation of the DDS Texture Loader.
  52583. * @hidden
  52584. */
  52585. export class _DDSTextureLoader implements IInternalTextureLoader {
  52586. /**
  52587. * Defines wether the loader supports cascade loading the different faces.
  52588. */
  52589. readonly supportCascades: boolean;
  52590. /**
  52591. * This returns if the loader support the current file information.
  52592. * @param extension defines the file extension of the file being loaded
  52593. * @returns true if the loader can load the specified file
  52594. */
  52595. canLoad(extension: string): boolean;
  52596. /**
  52597. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52598. * @param data contains the texture data
  52599. * @param texture defines the BabylonJS internal texture
  52600. * @param createPolynomials will be true if polynomials have been requested
  52601. * @param onLoad defines the callback to trigger once the texture is ready
  52602. * @param onError defines the callback to trigger in case of error
  52603. */
  52604. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52605. /**
  52606. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52607. * @param data contains the texture data
  52608. * @param texture defines the BabylonJS internal texture
  52609. * @param callback defines the method to call once ready to upload
  52610. */
  52611. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52612. }
  52613. }
  52614. declare module BABYLON {
  52615. /**
  52616. * Implementation of the ENV Texture Loader.
  52617. * @hidden
  52618. */
  52619. export class _ENVTextureLoader implements IInternalTextureLoader {
  52620. /**
  52621. * Defines wether the loader supports cascade loading the different faces.
  52622. */
  52623. readonly supportCascades: boolean;
  52624. /**
  52625. * This returns if the loader support the current file information.
  52626. * @param extension defines the file extension of the file being loaded
  52627. * @returns true if the loader can load the specified file
  52628. */
  52629. canLoad(extension: string): boolean;
  52630. /**
  52631. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52632. * @param data contains the texture data
  52633. * @param texture defines the BabylonJS internal texture
  52634. * @param createPolynomials will be true if polynomials have been requested
  52635. * @param onLoad defines the callback to trigger once the texture is ready
  52636. * @param onError defines the callback to trigger in case of error
  52637. */
  52638. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52639. /**
  52640. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52641. * @param data contains the texture data
  52642. * @param texture defines the BabylonJS internal texture
  52643. * @param callback defines the method to call once ready to upload
  52644. */
  52645. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52646. }
  52647. }
  52648. declare module BABYLON {
  52649. /**
  52650. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52651. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52652. */
  52653. export class KhronosTextureContainer {
  52654. /** contents of the KTX container file */
  52655. data: ArrayBufferView;
  52656. private static HEADER_LEN;
  52657. private static COMPRESSED_2D;
  52658. private static COMPRESSED_3D;
  52659. private static TEX_2D;
  52660. private static TEX_3D;
  52661. /**
  52662. * Gets the openGL type
  52663. */
  52664. glType: number;
  52665. /**
  52666. * Gets the openGL type size
  52667. */
  52668. glTypeSize: number;
  52669. /**
  52670. * Gets the openGL format
  52671. */
  52672. glFormat: number;
  52673. /**
  52674. * Gets the openGL internal format
  52675. */
  52676. glInternalFormat: number;
  52677. /**
  52678. * Gets the base internal format
  52679. */
  52680. glBaseInternalFormat: number;
  52681. /**
  52682. * Gets image width in pixel
  52683. */
  52684. pixelWidth: number;
  52685. /**
  52686. * Gets image height in pixel
  52687. */
  52688. pixelHeight: number;
  52689. /**
  52690. * Gets image depth in pixels
  52691. */
  52692. pixelDepth: number;
  52693. /**
  52694. * Gets the number of array elements
  52695. */
  52696. numberOfArrayElements: number;
  52697. /**
  52698. * Gets the number of faces
  52699. */
  52700. numberOfFaces: number;
  52701. /**
  52702. * Gets the number of mipmap levels
  52703. */
  52704. numberOfMipmapLevels: number;
  52705. /**
  52706. * Gets the bytes of key value data
  52707. */
  52708. bytesOfKeyValueData: number;
  52709. /**
  52710. * Gets the load type
  52711. */
  52712. loadType: number;
  52713. /**
  52714. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52715. */
  52716. isInvalid: boolean;
  52717. /**
  52718. * Creates a new KhronosTextureContainer
  52719. * @param data contents of the KTX container file
  52720. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52721. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52722. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52723. */
  52724. constructor(
  52725. /** contents of the KTX container file */
  52726. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52727. /**
  52728. * Uploads KTX content to a Babylon Texture.
  52729. * It is assumed that the texture has already been created & is currently bound
  52730. * @hidden
  52731. */
  52732. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52733. private _upload2DCompressedLevels;
  52734. /**
  52735. * Checks if the given data starts with a KTX file identifier.
  52736. * @param data the data to check
  52737. * @returns true if the data is a KTX file or false otherwise
  52738. */
  52739. static IsValid(data: ArrayBufferView): boolean;
  52740. }
  52741. }
  52742. declare module BABYLON {
  52743. /**
  52744. * Class for loading KTX2 files
  52745. * !!! Experimental Extension Subject to Changes !!!
  52746. * @hidden
  52747. */
  52748. export class KhronosTextureContainer2 {
  52749. private static _ModulePromise;
  52750. private static _TranscodeFormat;
  52751. constructor(engine: ThinEngine);
  52752. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52753. private _determineTranscodeFormat;
  52754. /**
  52755. * Checks if the given data starts with a KTX2 file identifier.
  52756. * @param data the data to check
  52757. * @returns true if the data is a KTX2 file or false otherwise
  52758. */
  52759. static IsValid(data: ArrayBufferView): boolean;
  52760. }
  52761. }
  52762. declare module BABYLON {
  52763. /**
  52764. * Implementation of the KTX Texture Loader.
  52765. * @hidden
  52766. */
  52767. export class _KTXTextureLoader implements IInternalTextureLoader {
  52768. /**
  52769. * Defines wether the loader supports cascade loading the different faces.
  52770. */
  52771. readonly supportCascades: boolean;
  52772. /**
  52773. * This returns if the loader support the current file information.
  52774. * @param extension defines the file extension of the file being loaded
  52775. * @returns true if the loader can load the specified file
  52776. */
  52777. canLoad(extension: string): boolean;
  52778. /**
  52779. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52780. * @param data contains the texture data
  52781. * @param texture defines the BabylonJS internal texture
  52782. * @param createPolynomials will be true if polynomials have been requested
  52783. * @param onLoad defines the callback to trigger once the texture is ready
  52784. * @param onError defines the callback to trigger in case of error
  52785. */
  52786. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52787. /**
  52788. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52789. * @param data contains the texture data
  52790. * @param texture defines the BabylonJS internal texture
  52791. * @param callback defines the method to call once ready to upload
  52792. */
  52793. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52794. }
  52795. }
  52796. declare module BABYLON {
  52797. /** @hidden */
  52798. export var _forceSceneHelpersToBundle: boolean;
  52799. interface Scene {
  52800. /**
  52801. * Creates a default light for the scene.
  52802. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52803. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52804. */
  52805. createDefaultLight(replace?: boolean): void;
  52806. /**
  52807. * Creates a default camera for the scene.
  52808. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52809. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52810. * @param replace has default false, when true replaces the active camera in the scene
  52811. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52812. */
  52813. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52814. /**
  52815. * Creates a default camera and a default light.
  52816. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52817. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52818. * @param replace has the default false, when true replaces the active camera/light in the scene
  52819. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52820. */
  52821. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52822. /**
  52823. * Creates a new sky box
  52824. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52825. * @param environmentTexture defines the texture to use as environment texture
  52826. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52827. * @param scale defines the overall scale of the skybox
  52828. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52829. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52830. * @returns a new mesh holding the sky box
  52831. */
  52832. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52833. /**
  52834. * Creates a new environment
  52835. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52836. * @param options defines the options you can use to configure the environment
  52837. * @returns the new EnvironmentHelper
  52838. */
  52839. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52840. /**
  52841. * Creates a new VREXperienceHelper
  52842. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52843. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52844. * @returns a new VREXperienceHelper
  52845. */
  52846. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52847. /**
  52848. * Creates a new WebXRDefaultExperience
  52849. * @see http://doc.babylonjs.com/how_to/webxr
  52850. * @param options experience options
  52851. * @returns a promise for a new WebXRDefaultExperience
  52852. */
  52853. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52854. }
  52855. }
  52856. declare module BABYLON {
  52857. /**
  52858. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52859. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52860. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52861. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52862. */
  52863. export class VideoDome extends TransformNode {
  52864. /**
  52865. * Define the video source as a Monoscopic panoramic 360 video.
  52866. */
  52867. static readonly MODE_MONOSCOPIC: number;
  52868. /**
  52869. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52870. */
  52871. static readonly MODE_TOPBOTTOM: number;
  52872. /**
  52873. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52874. */
  52875. static readonly MODE_SIDEBYSIDE: number;
  52876. private _halfDome;
  52877. private _useDirectMapping;
  52878. /**
  52879. * The video texture being displayed on the sphere
  52880. */
  52881. protected _videoTexture: VideoTexture;
  52882. /**
  52883. * Gets the video texture being displayed on the sphere
  52884. */
  52885. get videoTexture(): VideoTexture;
  52886. /**
  52887. * The skybox material
  52888. */
  52889. protected _material: BackgroundMaterial;
  52890. /**
  52891. * The surface used for the skybox
  52892. */
  52893. protected _mesh: Mesh;
  52894. /**
  52895. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52896. */
  52897. private _halfDomeMask;
  52898. /**
  52899. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52900. * Also see the options.resolution property.
  52901. */
  52902. get fovMultiplier(): number;
  52903. set fovMultiplier(value: number);
  52904. private _videoMode;
  52905. /**
  52906. * Gets or set the current video mode for the video. It can be:
  52907. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52908. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52909. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52910. */
  52911. get videoMode(): number;
  52912. set videoMode(value: number);
  52913. /**
  52914. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52915. *
  52916. */
  52917. get halfDome(): boolean;
  52918. /**
  52919. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52920. */
  52921. set halfDome(enabled: boolean);
  52922. /**
  52923. * Oberserver used in Stereoscopic VR Mode.
  52924. */
  52925. private _onBeforeCameraRenderObserver;
  52926. /**
  52927. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52928. * @param name Element's name, child elements will append suffixes for their own names.
  52929. * @param urlsOrVideo defines the url(s) or the video element to use
  52930. * @param options An object containing optional or exposed sub element properties
  52931. */
  52932. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52933. resolution?: number;
  52934. clickToPlay?: boolean;
  52935. autoPlay?: boolean;
  52936. loop?: boolean;
  52937. size?: number;
  52938. poster?: string;
  52939. faceForward?: boolean;
  52940. useDirectMapping?: boolean;
  52941. halfDomeMode?: boolean;
  52942. }, scene: Scene);
  52943. private _changeVideoMode;
  52944. /**
  52945. * Releases resources associated with this node.
  52946. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52947. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52948. */
  52949. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52950. }
  52951. }
  52952. declare module BABYLON {
  52953. /**
  52954. * This class can be used to get instrumentation data from a Babylon engine
  52955. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52956. */
  52957. export class EngineInstrumentation implements IDisposable {
  52958. /**
  52959. * Define the instrumented engine.
  52960. */
  52961. engine: Engine;
  52962. private _captureGPUFrameTime;
  52963. private _gpuFrameTimeToken;
  52964. private _gpuFrameTime;
  52965. private _captureShaderCompilationTime;
  52966. private _shaderCompilationTime;
  52967. private _onBeginFrameObserver;
  52968. private _onEndFrameObserver;
  52969. private _onBeforeShaderCompilationObserver;
  52970. private _onAfterShaderCompilationObserver;
  52971. /**
  52972. * Gets the perf counter used for GPU frame time
  52973. */
  52974. get gpuFrameTimeCounter(): PerfCounter;
  52975. /**
  52976. * Gets the GPU frame time capture status
  52977. */
  52978. get captureGPUFrameTime(): boolean;
  52979. /**
  52980. * Enable or disable the GPU frame time capture
  52981. */
  52982. set captureGPUFrameTime(value: boolean);
  52983. /**
  52984. * Gets the perf counter used for shader compilation time
  52985. */
  52986. get shaderCompilationTimeCounter(): PerfCounter;
  52987. /**
  52988. * Gets the shader compilation time capture status
  52989. */
  52990. get captureShaderCompilationTime(): boolean;
  52991. /**
  52992. * Enable or disable the shader compilation time capture
  52993. */
  52994. set captureShaderCompilationTime(value: boolean);
  52995. /**
  52996. * Instantiates a new engine instrumentation.
  52997. * This class can be used to get instrumentation data from a Babylon engine
  52998. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52999. * @param engine Defines the engine to instrument
  53000. */
  53001. constructor(
  53002. /**
  53003. * Define the instrumented engine.
  53004. */
  53005. engine: Engine);
  53006. /**
  53007. * Dispose and release associated resources.
  53008. */
  53009. dispose(): void;
  53010. }
  53011. }
  53012. declare module BABYLON {
  53013. /**
  53014. * This class can be used to get instrumentation data from a Babylon engine
  53015. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53016. */
  53017. export class SceneInstrumentation implements IDisposable {
  53018. /**
  53019. * Defines the scene to instrument
  53020. */
  53021. scene: Scene;
  53022. private _captureActiveMeshesEvaluationTime;
  53023. private _activeMeshesEvaluationTime;
  53024. private _captureRenderTargetsRenderTime;
  53025. private _renderTargetsRenderTime;
  53026. private _captureFrameTime;
  53027. private _frameTime;
  53028. private _captureRenderTime;
  53029. private _renderTime;
  53030. private _captureInterFrameTime;
  53031. private _interFrameTime;
  53032. private _captureParticlesRenderTime;
  53033. private _particlesRenderTime;
  53034. private _captureSpritesRenderTime;
  53035. private _spritesRenderTime;
  53036. private _capturePhysicsTime;
  53037. private _physicsTime;
  53038. private _captureAnimationsTime;
  53039. private _animationsTime;
  53040. private _captureCameraRenderTime;
  53041. private _cameraRenderTime;
  53042. private _onBeforeActiveMeshesEvaluationObserver;
  53043. private _onAfterActiveMeshesEvaluationObserver;
  53044. private _onBeforeRenderTargetsRenderObserver;
  53045. private _onAfterRenderTargetsRenderObserver;
  53046. private _onAfterRenderObserver;
  53047. private _onBeforeDrawPhaseObserver;
  53048. private _onAfterDrawPhaseObserver;
  53049. private _onBeforeAnimationsObserver;
  53050. private _onBeforeParticlesRenderingObserver;
  53051. private _onAfterParticlesRenderingObserver;
  53052. private _onBeforeSpritesRenderingObserver;
  53053. private _onAfterSpritesRenderingObserver;
  53054. private _onBeforePhysicsObserver;
  53055. private _onAfterPhysicsObserver;
  53056. private _onAfterAnimationsObserver;
  53057. private _onBeforeCameraRenderObserver;
  53058. private _onAfterCameraRenderObserver;
  53059. /**
  53060. * Gets the perf counter used for active meshes evaluation time
  53061. */
  53062. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53063. /**
  53064. * Gets the active meshes evaluation time capture status
  53065. */
  53066. get captureActiveMeshesEvaluationTime(): boolean;
  53067. /**
  53068. * Enable or disable the active meshes evaluation time capture
  53069. */
  53070. set captureActiveMeshesEvaluationTime(value: boolean);
  53071. /**
  53072. * Gets the perf counter used for render targets render time
  53073. */
  53074. get renderTargetsRenderTimeCounter(): PerfCounter;
  53075. /**
  53076. * Gets the render targets render time capture status
  53077. */
  53078. get captureRenderTargetsRenderTime(): boolean;
  53079. /**
  53080. * Enable or disable the render targets render time capture
  53081. */
  53082. set captureRenderTargetsRenderTime(value: boolean);
  53083. /**
  53084. * Gets the perf counter used for particles render time
  53085. */
  53086. get particlesRenderTimeCounter(): PerfCounter;
  53087. /**
  53088. * Gets the particles render time capture status
  53089. */
  53090. get captureParticlesRenderTime(): boolean;
  53091. /**
  53092. * Enable or disable the particles render time capture
  53093. */
  53094. set captureParticlesRenderTime(value: boolean);
  53095. /**
  53096. * Gets the perf counter used for sprites render time
  53097. */
  53098. get spritesRenderTimeCounter(): PerfCounter;
  53099. /**
  53100. * Gets the sprites render time capture status
  53101. */
  53102. get captureSpritesRenderTime(): boolean;
  53103. /**
  53104. * Enable or disable the sprites render time capture
  53105. */
  53106. set captureSpritesRenderTime(value: boolean);
  53107. /**
  53108. * Gets the perf counter used for physics time
  53109. */
  53110. get physicsTimeCounter(): PerfCounter;
  53111. /**
  53112. * Gets the physics time capture status
  53113. */
  53114. get capturePhysicsTime(): boolean;
  53115. /**
  53116. * Enable or disable the physics time capture
  53117. */
  53118. set capturePhysicsTime(value: boolean);
  53119. /**
  53120. * Gets the perf counter used for animations time
  53121. */
  53122. get animationsTimeCounter(): PerfCounter;
  53123. /**
  53124. * Gets the animations time capture status
  53125. */
  53126. get captureAnimationsTime(): boolean;
  53127. /**
  53128. * Enable or disable the animations time capture
  53129. */
  53130. set captureAnimationsTime(value: boolean);
  53131. /**
  53132. * Gets the perf counter used for frame time capture
  53133. */
  53134. get frameTimeCounter(): PerfCounter;
  53135. /**
  53136. * Gets the frame time capture status
  53137. */
  53138. get captureFrameTime(): boolean;
  53139. /**
  53140. * Enable or disable the frame time capture
  53141. */
  53142. set captureFrameTime(value: boolean);
  53143. /**
  53144. * Gets the perf counter used for inter-frames time capture
  53145. */
  53146. get interFrameTimeCounter(): PerfCounter;
  53147. /**
  53148. * Gets the inter-frames time capture status
  53149. */
  53150. get captureInterFrameTime(): boolean;
  53151. /**
  53152. * Enable or disable the inter-frames time capture
  53153. */
  53154. set captureInterFrameTime(value: boolean);
  53155. /**
  53156. * Gets the perf counter used for render time capture
  53157. */
  53158. get renderTimeCounter(): PerfCounter;
  53159. /**
  53160. * Gets the render time capture status
  53161. */
  53162. get captureRenderTime(): boolean;
  53163. /**
  53164. * Enable or disable the render time capture
  53165. */
  53166. set captureRenderTime(value: boolean);
  53167. /**
  53168. * Gets the perf counter used for camera render time capture
  53169. */
  53170. get cameraRenderTimeCounter(): PerfCounter;
  53171. /**
  53172. * Gets the camera render time capture status
  53173. */
  53174. get captureCameraRenderTime(): boolean;
  53175. /**
  53176. * Enable or disable the camera render time capture
  53177. */
  53178. set captureCameraRenderTime(value: boolean);
  53179. /**
  53180. * Gets the perf counter used for draw calls
  53181. */
  53182. get drawCallsCounter(): PerfCounter;
  53183. /**
  53184. * Instantiates a new scene instrumentation.
  53185. * This class can be used to get instrumentation data from a Babylon engine
  53186. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53187. * @param scene Defines the scene to instrument
  53188. */
  53189. constructor(
  53190. /**
  53191. * Defines the scene to instrument
  53192. */
  53193. scene: Scene);
  53194. /**
  53195. * Dispose and release associated resources.
  53196. */
  53197. dispose(): void;
  53198. }
  53199. }
  53200. declare module BABYLON {
  53201. /** @hidden */
  53202. export var glowMapGenerationPixelShader: {
  53203. name: string;
  53204. shader: string;
  53205. };
  53206. }
  53207. declare module BABYLON {
  53208. /** @hidden */
  53209. export var glowMapGenerationVertexShader: {
  53210. name: string;
  53211. shader: string;
  53212. };
  53213. }
  53214. declare module BABYLON {
  53215. /**
  53216. * Effect layer options. This helps customizing the behaviour
  53217. * of the effect layer.
  53218. */
  53219. export interface IEffectLayerOptions {
  53220. /**
  53221. * Multiplication factor apply to the canvas size to compute the render target size
  53222. * used to generated the objects (the smaller the faster).
  53223. */
  53224. mainTextureRatio: number;
  53225. /**
  53226. * Enforces a fixed size texture to ensure effect stability across devices.
  53227. */
  53228. mainTextureFixedSize?: number;
  53229. /**
  53230. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53231. */
  53232. alphaBlendingMode: number;
  53233. /**
  53234. * The camera attached to the layer.
  53235. */
  53236. camera: Nullable<Camera>;
  53237. /**
  53238. * The rendering group to draw the layer in.
  53239. */
  53240. renderingGroupId: number;
  53241. }
  53242. /**
  53243. * The effect layer Helps adding post process effect blended with the main pass.
  53244. *
  53245. * This can be for instance use to generate glow or higlight effects on the scene.
  53246. *
  53247. * The effect layer class can not be used directly and is intented to inherited from to be
  53248. * customized per effects.
  53249. */
  53250. export abstract class EffectLayer {
  53251. private _vertexBuffers;
  53252. private _indexBuffer;
  53253. private _cachedDefines;
  53254. private _effectLayerMapGenerationEffect;
  53255. private _effectLayerOptions;
  53256. private _mergeEffect;
  53257. protected _scene: Scene;
  53258. protected _engine: Engine;
  53259. protected _maxSize: number;
  53260. protected _mainTextureDesiredSize: ISize;
  53261. protected _mainTexture: RenderTargetTexture;
  53262. protected _shouldRender: boolean;
  53263. protected _postProcesses: PostProcess[];
  53264. protected _textures: BaseTexture[];
  53265. protected _emissiveTextureAndColor: {
  53266. texture: Nullable<BaseTexture>;
  53267. color: Color4;
  53268. };
  53269. /**
  53270. * The name of the layer
  53271. */
  53272. name: string;
  53273. /**
  53274. * The clear color of the texture used to generate the glow map.
  53275. */
  53276. neutralColor: Color4;
  53277. /**
  53278. * Specifies whether the highlight layer is enabled or not.
  53279. */
  53280. isEnabled: boolean;
  53281. /**
  53282. * Gets the camera attached to the layer.
  53283. */
  53284. get camera(): Nullable<Camera>;
  53285. /**
  53286. * Gets the rendering group id the layer should render in.
  53287. */
  53288. get renderingGroupId(): number;
  53289. set renderingGroupId(renderingGroupId: number);
  53290. /**
  53291. * An event triggered when the effect layer has been disposed.
  53292. */
  53293. onDisposeObservable: Observable<EffectLayer>;
  53294. /**
  53295. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53296. */
  53297. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53298. /**
  53299. * An event triggered when the generated texture is being merged in the scene.
  53300. */
  53301. onBeforeComposeObservable: Observable<EffectLayer>;
  53302. /**
  53303. * An event triggered when the mesh is rendered into the effect render target.
  53304. */
  53305. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53306. /**
  53307. * An event triggered after the mesh has been rendered into the effect render target.
  53308. */
  53309. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53310. /**
  53311. * An event triggered when the generated texture has been merged in the scene.
  53312. */
  53313. onAfterComposeObservable: Observable<EffectLayer>;
  53314. /**
  53315. * An event triggered when the efffect layer changes its size.
  53316. */
  53317. onSizeChangedObservable: Observable<EffectLayer>;
  53318. /** @hidden */
  53319. static _SceneComponentInitialization: (scene: Scene) => void;
  53320. /**
  53321. * Instantiates a new effect Layer and references it in the scene.
  53322. * @param name The name of the layer
  53323. * @param scene The scene to use the layer in
  53324. */
  53325. constructor(
  53326. /** The Friendly of the effect in the scene */
  53327. name: string, scene: Scene);
  53328. /**
  53329. * Get the effect name of the layer.
  53330. * @return The effect name
  53331. */
  53332. abstract getEffectName(): string;
  53333. /**
  53334. * Checks for the readiness of the element composing the layer.
  53335. * @param subMesh the mesh to check for
  53336. * @param useInstances specify whether or not to use instances to render the mesh
  53337. * @return true if ready otherwise, false
  53338. */
  53339. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53340. /**
  53341. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53342. * @returns true if the effect requires stencil during the main canvas render pass.
  53343. */
  53344. abstract needStencil(): boolean;
  53345. /**
  53346. * Create the merge effect. This is the shader use to blit the information back
  53347. * to the main canvas at the end of the scene rendering.
  53348. * @returns The effect containing the shader used to merge the effect on the main canvas
  53349. */
  53350. protected abstract _createMergeEffect(): Effect;
  53351. /**
  53352. * Creates the render target textures and post processes used in the effect layer.
  53353. */
  53354. protected abstract _createTextureAndPostProcesses(): void;
  53355. /**
  53356. * Implementation specific of rendering the generating effect on the main canvas.
  53357. * @param effect The effect used to render through
  53358. */
  53359. protected abstract _internalRender(effect: Effect): void;
  53360. /**
  53361. * Sets the required values for both the emissive texture and and the main color.
  53362. */
  53363. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53364. /**
  53365. * Free any resources and references associated to a mesh.
  53366. * Internal use
  53367. * @param mesh The mesh to free.
  53368. */
  53369. abstract _disposeMesh(mesh: Mesh): void;
  53370. /**
  53371. * Serializes this layer (Glow or Highlight for example)
  53372. * @returns a serialized layer object
  53373. */
  53374. abstract serialize?(): any;
  53375. /**
  53376. * Initializes the effect layer with the required options.
  53377. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53378. */
  53379. protected _init(options: Partial<IEffectLayerOptions>): void;
  53380. /**
  53381. * Generates the index buffer of the full screen quad blending to the main canvas.
  53382. */
  53383. private _generateIndexBuffer;
  53384. /**
  53385. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53386. */
  53387. private _generateVertexBuffer;
  53388. /**
  53389. * Sets the main texture desired size which is the closest power of two
  53390. * of the engine canvas size.
  53391. */
  53392. private _setMainTextureSize;
  53393. /**
  53394. * Creates the main texture for the effect layer.
  53395. */
  53396. protected _createMainTexture(): void;
  53397. /**
  53398. * Adds specific effects defines.
  53399. * @param defines The defines to add specifics to.
  53400. */
  53401. protected _addCustomEffectDefines(defines: string[]): void;
  53402. /**
  53403. * Checks for the readiness of the element composing the layer.
  53404. * @param subMesh the mesh to check for
  53405. * @param useInstances specify whether or not to use instances to render the mesh
  53406. * @param emissiveTexture the associated emissive texture used to generate the glow
  53407. * @return true if ready otherwise, false
  53408. */
  53409. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53410. /**
  53411. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53412. */
  53413. render(): void;
  53414. /**
  53415. * Determine if a given mesh will be used in the current effect.
  53416. * @param mesh mesh to test
  53417. * @returns true if the mesh will be used
  53418. */
  53419. hasMesh(mesh: AbstractMesh): boolean;
  53420. /**
  53421. * Returns true if the layer contains information to display, otherwise false.
  53422. * @returns true if the glow layer should be rendered
  53423. */
  53424. shouldRender(): boolean;
  53425. /**
  53426. * Returns true if the mesh should render, otherwise false.
  53427. * @param mesh The mesh to render
  53428. * @returns true if it should render otherwise false
  53429. */
  53430. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53431. /**
  53432. * Returns true if the mesh can be rendered, otherwise false.
  53433. * @param mesh The mesh to render
  53434. * @param material The material used on the mesh
  53435. * @returns true if it can be rendered otherwise false
  53436. */
  53437. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53438. /**
  53439. * Returns true if the mesh should render, otherwise false.
  53440. * @param mesh The mesh to render
  53441. * @returns true if it should render otherwise false
  53442. */
  53443. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53444. /**
  53445. * Renders the submesh passed in parameter to the generation map.
  53446. */
  53447. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53448. /**
  53449. * Defines whether the current material of the mesh should be use to render the effect.
  53450. * @param mesh defines the current mesh to render
  53451. */
  53452. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53453. /**
  53454. * Rebuild the required buffers.
  53455. * @hidden Internal use only.
  53456. */
  53457. _rebuild(): void;
  53458. /**
  53459. * Dispose only the render target textures and post process.
  53460. */
  53461. private _disposeTextureAndPostProcesses;
  53462. /**
  53463. * Dispose the highlight layer and free resources.
  53464. */
  53465. dispose(): void;
  53466. /**
  53467. * Gets the class name of the effect layer
  53468. * @returns the string with the class name of the effect layer
  53469. */
  53470. getClassName(): string;
  53471. /**
  53472. * Creates an effect layer from parsed effect layer data
  53473. * @param parsedEffectLayer defines effect layer data
  53474. * @param scene defines the current scene
  53475. * @param rootUrl defines the root URL containing the effect layer information
  53476. * @returns a parsed effect Layer
  53477. */
  53478. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53479. }
  53480. }
  53481. declare module BABYLON {
  53482. interface AbstractScene {
  53483. /**
  53484. * The list of effect layers (highlights/glow) added to the scene
  53485. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53486. * @see http://doc.babylonjs.com/how_to/glow_layer
  53487. */
  53488. effectLayers: Array<EffectLayer>;
  53489. /**
  53490. * Removes the given effect layer from this scene.
  53491. * @param toRemove defines the effect layer to remove
  53492. * @returns the index of the removed effect layer
  53493. */
  53494. removeEffectLayer(toRemove: EffectLayer): number;
  53495. /**
  53496. * Adds the given effect layer to this scene
  53497. * @param newEffectLayer defines the effect layer to add
  53498. */
  53499. addEffectLayer(newEffectLayer: EffectLayer): void;
  53500. }
  53501. /**
  53502. * Defines the layer scene component responsible to manage any effect layers
  53503. * in a given scene.
  53504. */
  53505. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53506. /**
  53507. * The component name helpfull to identify the component in the list of scene components.
  53508. */
  53509. readonly name: string;
  53510. /**
  53511. * The scene the component belongs to.
  53512. */
  53513. scene: Scene;
  53514. private _engine;
  53515. private _renderEffects;
  53516. private _needStencil;
  53517. private _previousStencilState;
  53518. /**
  53519. * Creates a new instance of the component for the given scene
  53520. * @param scene Defines the scene to register the component in
  53521. */
  53522. constructor(scene: Scene);
  53523. /**
  53524. * Registers the component in a given scene
  53525. */
  53526. register(): void;
  53527. /**
  53528. * Rebuilds the elements related to this component in case of
  53529. * context lost for instance.
  53530. */
  53531. rebuild(): void;
  53532. /**
  53533. * Serializes the component data to the specified json object
  53534. * @param serializationObject The object to serialize to
  53535. */
  53536. serialize(serializationObject: any): void;
  53537. /**
  53538. * Adds all the elements from the container to the scene
  53539. * @param container the container holding the elements
  53540. */
  53541. addFromContainer(container: AbstractScene): void;
  53542. /**
  53543. * Removes all the elements in the container from the scene
  53544. * @param container contains the elements to remove
  53545. * @param dispose if the removed element should be disposed (default: false)
  53546. */
  53547. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53548. /**
  53549. * Disposes the component and the associated ressources.
  53550. */
  53551. dispose(): void;
  53552. private _isReadyForMesh;
  53553. private _renderMainTexture;
  53554. private _setStencil;
  53555. private _setStencilBack;
  53556. private _draw;
  53557. private _drawCamera;
  53558. private _drawRenderingGroup;
  53559. }
  53560. }
  53561. declare module BABYLON {
  53562. /** @hidden */
  53563. export var glowMapMergePixelShader: {
  53564. name: string;
  53565. shader: string;
  53566. };
  53567. }
  53568. declare module BABYLON {
  53569. /** @hidden */
  53570. export var glowMapMergeVertexShader: {
  53571. name: string;
  53572. shader: string;
  53573. };
  53574. }
  53575. declare module BABYLON {
  53576. interface AbstractScene {
  53577. /**
  53578. * Return a the first highlight layer of the scene with a given name.
  53579. * @param name The name of the highlight layer to look for.
  53580. * @return The highlight layer if found otherwise null.
  53581. */
  53582. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53583. }
  53584. /**
  53585. * Glow layer options. This helps customizing the behaviour
  53586. * of the glow layer.
  53587. */
  53588. export interface IGlowLayerOptions {
  53589. /**
  53590. * Multiplication factor apply to the canvas size to compute the render target size
  53591. * used to generated the glowing objects (the smaller the faster).
  53592. */
  53593. mainTextureRatio: number;
  53594. /**
  53595. * Enforces a fixed size texture to ensure resize independant blur.
  53596. */
  53597. mainTextureFixedSize?: number;
  53598. /**
  53599. * How big is the kernel of the blur texture.
  53600. */
  53601. blurKernelSize: number;
  53602. /**
  53603. * The camera attached to the layer.
  53604. */
  53605. camera: Nullable<Camera>;
  53606. /**
  53607. * Enable MSAA by chosing the number of samples.
  53608. */
  53609. mainTextureSamples?: number;
  53610. /**
  53611. * The rendering group to draw the layer in.
  53612. */
  53613. renderingGroupId: number;
  53614. }
  53615. /**
  53616. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53617. *
  53618. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53619. *
  53620. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53621. */
  53622. export class GlowLayer extends EffectLayer {
  53623. /**
  53624. * Effect Name of the layer.
  53625. */
  53626. static readonly EffectName: string;
  53627. /**
  53628. * The default blur kernel size used for the glow.
  53629. */
  53630. static DefaultBlurKernelSize: number;
  53631. /**
  53632. * The default texture size ratio used for the glow.
  53633. */
  53634. static DefaultTextureRatio: number;
  53635. /**
  53636. * Sets the kernel size of the blur.
  53637. */
  53638. set blurKernelSize(value: number);
  53639. /**
  53640. * Gets the kernel size of the blur.
  53641. */
  53642. get blurKernelSize(): number;
  53643. /**
  53644. * Sets the glow intensity.
  53645. */
  53646. set intensity(value: number);
  53647. /**
  53648. * Gets the glow intensity.
  53649. */
  53650. get intensity(): number;
  53651. private _options;
  53652. private _intensity;
  53653. private _horizontalBlurPostprocess1;
  53654. private _verticalBlurPostprocess1;
  53655. private _horizontalBlurPostprocess2;
  53656. private _verticalBlurPostprocess2;
  53657. private _blurTexture1;
  53658. private _blurTexture2;
  53659. private _postProcesses1;
  53660. private _postProcesses2;
  53661. private _includedOnlyMeshes;
  53662. private _excludedMeshes;
  53663. private _meshesUsingTheirOwnMaterials;
  53664. /**
  53665. * Callback used to let the user override the color selection on a per mesh basis
  53666. */
  53667. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53668. /**
  53669. * Callback used to let the user override the texture selection on a per mesh basis
  53670. */
  53671. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53672. /**
  53673. * Instantiates a new glow Layer and references it to the scene.
  53674. * @param name The name of the layer
  53675. * @param scene The scene to use the layer in
  53676. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53677. */
  53678. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53679. /**
  53680. * Get the effect name of the layer.
  53681. * @return The effect name
  53682. */
  53683. getEffectName(): string;
  53684. /**
  53685. * Create the merge effect. This is the shader use to blit the information back
  53686. * to the main canvas at the end of the scene rendering.
  53687. */
  53688. protected _createMergeEffect(): Effect;
  53689. /**
  53690. * Creates the render target textures and post processes used in the glow layer.
  53691. */
  53692. protected _createTextureAndPostProcesses(): void;
  53693. /**
  53694. * Checks for the readiness of the element composing the layer.
  53695. * @param subMesh the mesh to check for
  53696. * @param useInstances specify wether or not to use instances to render the mesh
  53697. * @param emissiveTexture the associated emissive texture used to generate the glow
  53698. * @return true if ready otherwise, false
  53699. */
  53700. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53701. /**
  53702. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53703. */
  53704. needStencil(): boolean;
  53705. /**
  53706. * Returns true if the mesh can be rendered, otherwise false.
  53707. * @param mesh The mesh to render
  53708. * @param material The material used on the mesh
  53709. * @returns true if it can be rendered otherwise false
  53710. */
  53711. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53712. /**
  53713. * Implementation specific of rendering the generating effect on the main canvas.
  53714. * @param effect The effect used to render through
  53715. */
  53716. protected _internalRender(effect: Effect): void;
  53717. /**
  53718. * Sets the required values for both the emissive texture and and the main color.
  53719. */
  53720. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53721. /**
  53722. * Returns true if the mesh should render, otherwise false.
  53723. * @param mesh The mesh to render
  53724. * @returns true if it should render otherwise false
  53725. */
  53726. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53727. /**
  53728. * Adds specific effects defines.
  53729. * @param defines The defines to add specifics to.
  53730. */
  53731. protected _addCustomEffectDefines(defines: string[]): void;
  53732. /**
  53733. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53734. * @param mesh The mesh to exclude from the glow layer
  53735. */
  53736. addExcludedMesh(mesh: Mesh): void;
  53737. /**
  53738. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53739. * @param mesh The mesh to remove
  53740. */
  53741. removeExcludedMesh(mesh: Mesh): void;
  53742. /**
  53743. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53744. * @param mesh The mesh to include in the glow layer
  53745. */
  53746. addIncludedOnlyMesh(mesh: Mesh): void;
  53747. /**
  53748. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53749. * @param mesh The mesh to remove
  53750. */
  53751. removeIncludedOnlyMesh(mesh: Mesh): void;
  53752. /**
  53753. * Determine if a given mesh will be used in the glow layer
  53754. * @param mesh The mesh to test
  53755. * @returns true if the mesh will be highlighted by the current glow layer
  53756. */
  53757. hasMesh(mesh: AbstractMesh): boolean;
  53758. /**
  53759. * Defines whether the current material of the mesh should be use to render the effect.
  53760. * @param mesh defines the current mesh to render
  53761. */
  53762. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53763. /**
  53764. * Add a mesh to be rendered through its own material and not with emissive only.
  53765. * @param mesh The mesh for which we need to use its material
  53766. */
  53767. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53768. /**
  53769. * Remove a mesh from being rendered through its own material and not with emissive only.
  53770. * @param mesh The mesh for which we need to not use its material
  53771. */
  53772. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53773. /**
  53774. * Free any resources and references associated to a mesh.
  53775. * Internal use
  53776. * @param mesh The mesh to free.
  53777. * @hidden
  53778. */
  53779. _disposeMesh(mesh: Mesh): void;
  53780. /**
  53781. * Gets the class name of the effect layer
  53782. * @returns the string with the class name of the effect layer
  53783. */
  53784. getClassName(): string;
  53785. /**
  53786. * Serializes this glow layer
  53787. * @returns a serialized glow layer object
  53788. */
  53789. serialize(): any;
  53790. /**
  53791. * Creates a Glow Layer from parsed glow layer data
  53792. * @param parsedGlowLayer defines glow layer data
  53793. * @param scene defines the current scene
  53794. * @param rootUrl defines the root URL containing the glow layer information
  53795. * @returns a parsed Glow Layer
  53796. */
  53797. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53798. }
  53799. }
  53800. declare module BABYLON {
  53801. /** @hidden */
  53802. export var glowBlurPostProcessPixelShader: {
  53803. name: string;
  53804. shader: string;
  53805. };
  53806. }
  53807. declare module BABYLON {
  53808. interface AbstractScene {
  53809. /**
  53810. * Return a the first highlight layer of the scene with a given name.
  53811. * @param name The name of the highlight layer to look for.
  53812. * @return The highlight layer if found otherwise null.
  53813. */
  53814. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53815. }
  53816. /**
  53817. * Highlight layer options. This helps customizing the behaviour
  53818. * of the highlight layer.
  53819. */
  53820. export interface IHighlightLayerOptions {
  53821. /**
  53822. * Multiplication factor apply to the canvas size to compute the render target size
  53823. * used to generated the glowing objects (the smaller the faster).
  53824. */
  53825. mainTextureRatio: number;
  53826. /**
  53827. * Enforces a fixed size texture to ensure resize independant blur.
  53828. */
  53829. mainTextureFixedSize?: number;
  53830. /**
  53831. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53832. * of the picture to blur (the smaller the faster).
  53833. */
  53834. blurTextureSizeRatio: number;
  53835. /**
  53836. * How big in texel of the blur texture is the vertical blur.
  53837. */
  53838. blurVerticalSize: number;
  53839. /**
  53840. * How big in texel of the blur texture is the horizontal blur.
  53841. */
  53842. blurHorizontalSize: number;
  53843. /**
  53844. * Alpha blending mode used to apply the blur. Default is combine.
  53845. */
  53846. alphaBlendingMode: number;
  53847. /**
  53848. * The camera attached to the layer.
  53849. */
  53850. camera: Nullable<Camera>;
  53851. /**
  53852. * Should we display highlight as a solid stroke?
  53853. */
  53854. isStroke?: boolean;
  53855. /**
  53856. * The rendering group to draw the layer in.
  53857. */
  53858. renderingGroupId: number;
  53859. }
  53860. /**
  53861. * The highlight layer Helps adding a glow effect around a mesh.
  53862. *
  53863. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53864. * glowy meshes to your scene.
  53865. *
  53866. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53867. */
  53868. export class HighlightLayer extends EffectLayer {
  53869. name: string;
  53870. /**
  53871. * Effect Name of the highlight layer.
  53872. */
  53873. static readonly EffectName: string;
  53874. /**
  53875. * The neutral color used during the preparation of the glow effect.
  53876. * This is black by default as the blend operation is a blend operation.
  53877. */
  53878. static NeutralColor: Color4;
  53879. /**
  53880. * Stencil value used for glowing meshes.
  53881. */
  53882. static GlowingMeshStencilReference: number;
  53883. /**
  53884. * Stencil value used for the other meshes in the scene.
  53885. */
  53886. static NormalMeshStencilReference: number;
  53887. /**
  53888. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53889. */
  53890. innerGlow: boolean;
  53891. /**
  53892. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53893. */
  53894. outerGlow: boolean;
  53895. /**
  53896. * Specifies the horizontal size of the blur.
  53897. */
  53898. set blurHorizontalSize(value: number);
  53899. /**
  53900. * Specifies the vertical size of the blur.
  53901. */
  53902. set blurVerticalSize(value: number);
  53903. /**
  53904. * Gets the horizontal size of the blur.
  53905. */
  53906. get blurHorizontalSize(): number;
  53907. /**
  53908. * Gets the vertical size of the blur.
  53909. */
  53910. get blurVerticalSize(): number;
  53911. /**
  53912. * An event triggered when the highlight layer is being blurred.
  53913. */
  53914. onBeforeBlurObservable: Observable<HighlightLayer>;
  53915. /**
  53916. * An event triggered when the highlight layer has been blurred.
  53917. */
  53918. onAfterBlurObservable: Observable<HighlightLayer>;
  53919. private _instanceGlowingMeshStencilReference;
  53920. private _options;
  53921. private _downSamplePostprocess;
  53922. private _horizontalBlurPostprocess;
  53923. private _verticalBlurPostprocess;
  53924. private _blurTexture;
  53925. private _meshes;
  53926. private _excludedMeshes;
  53927. /**
  53928. * Instantiates a new highlight Layer and references it to the scene..
  53929. * @param name The name of the layer
  53930. * @param scene The scene to use the layer in
  53931. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53932. */
  53933. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53934. /**
  53935. * Get the effect name of the layer.
  53936. * @return The effect name
  53937. */
  53938. getEffectName(): string;
  53939. /**
  53940. * Create the merge effect. This is the shader use to blit the information back
  53941. * to the main canvas at the end of the scene rendering.
  53942. */
  53943. protected _createMergeEffect(): Effect;
  53944. /**
  53945. * Creates the render target textures and post processes used in the highlight layer.
  53946. */
  53947. protected _createTextureAndPostProcesses(): void;
  53948. /**
  53949. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53950. */
  53951. needStencil(): boolean;
  53952. /**
  53953. * Checks for the readiness of the element composing the layer.
  53954. * @param subMesh the mesh to check for
  53955. * @param useInstances specify wether or not to use instances to render the mesh
  53956. * @param emissiveTexture the associated emissive texture used to generate the glow
  53957. * @return true if ready otherwise, false
  53958. */
  53959. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53960. /**
  53961. * Implementation specific of rendering the generating effect on the main canvas.
  53962. * @param effect The effect used to render through
  53963. */
  53964. protected _internalRender(effect: Effect): void;
  53965. /**
  53966. * Returns true if the layer contains information to display, otherwise false.
  53967. */
  53968. shouldRender(): boolean;
  53969. /**
  53970. * Returns true if the mesh should render, otherwise false.
  53971. * @param mesh The mesh to render
  53972. * @returns true if it should render otherwise false
  53973. */
  53974. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53975. /**
  53976. * Sets the required values for both the emissive texture and and the main color.
  53977. */
  53978. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53979. /**
  53980. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53981. * @param mesh The mesh to exclude from the highlight layer
  53982. */
  53983. addExcludedMesh(mesh: Mesh): void;
  53984. /**
  53985. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53986. * @param mesh The mesh to highlight
  53987. */
  53988. removeExcludedMesh(mesh: Mesh): void;
  53989. /**
  53990. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53991. * @param mesh mesh to test
  53992. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53993. */
  53994. hasMesh(mesh: AbstractMesh): boolean;
  53995. /**
  53996. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53997. * @param mesh The mesh to highlight
  53998. * @param color The color of the highlight
  53999. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54000. */
  54001. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54002. /**
  54003. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54004. * @param mesh The mesh to highlight
  54005. */
  54006. removeMesh(mesh: Mesh): void;
  54007. /**
  54008. * Remove all the meshes currently referenced in the highlight layer
  54009. */
  54010. removeAllMeshes(): void;
  54011. /**
  54012. * Force the stencil to the normal expected value for none glowing parts
  54013. */
  54014. private _defaultStencilReference;
  54015. /**
  54016. * Free any resources and references associated to a mesh.
  54017. * Internal use
  54018. * @param mesh The mesh to free.
  54019. * @hidden
  54020. */
  54021. _disposeMesh(mesh: Mesh): void;
  54022. /**
  54023. * Dispose the highlight layer and free resources.
  54024. */
  54025. dispose(): void;
  54026. /**
  54027. * Gets the class name of the effect layer
  54028. * @returns the string with the class name of the effect layer
  54029. */
  54030. getClassName(): string;
  54031. /**
  54032. * Serializes this Highlight layer
  54033. * @returns a serialized Highlight layer object
  54034. */
  54035. serialize(): any;
  54036. /**
  54037. * Creates a Highlight layer from parsed Highlight layer data
  54038. * @param parsedHightlightLayer defines the Highlight layer data
  54039. * @param scene defines the current scene
  54040. * @param rootUrl defines the root URL containing the Highlight layer information
  54041. * @returns a parsed Highlight layer
  54042. */
  54043. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54044. }
  54045. }
  54046. declare module BABYLON {
  54047. interface AbstractScene {
  54048. /**
  54049. * The list of layers (background and foreground) of the scene
  54050. */
  54051. layers: Array<Layer>;
  54052. }
  54053. /**
  54054. * Defines the layer scene component responsible to manage any layers
  54055. * in a given scene.
  54056. */
  54057. export class LayerSceneComponent implements ISceneComponent {
  54058. /**
  54059. * The component name helpfull to identify the component in the list of scene components.
  54060. */
  54061. readonly name: string;
  54062. /**
  54063. * The scene the component belongs to.
  54064. */
  54065. scene: Scene;
  54066. private _engine;
  54067. /**
  54068. * Creates a new instance of the component for the given scene
  54069. * @param scene Defines the scene to register the component in
  54070. */
  54071. constructor(scene: Scene);
  54072. /**
  54073. * Registers the component in a given scene
  54074. */
  54075. register(): void;
  54076. /**
  54077. * Rebuilds the elements related to this component in case of
  54078. * context lost for instance.
  54079. */
  54080. rebuild(): void;
  54081. /**
  54082. * Disposes the component and the associated ressources.
  54083. */
  54084. dispose(): void;
  54085. private _draw;
  54086. private _drawCameraPredicate;
  54087. private _drawCameraBackground;
  54088. private _drawCameraForeground;
  54089. private _drawRenderTargetPredicate;
  54090. private _drawRenderTargetBackground;
  54091. private _drawRenderTargetForeground;
  54092. /**
  54093. * Adds all the elements from the container to the scene
  54094. * @param container the container holding the elements
  54095. */
  54096. addFromContainer(container: AbstractScene): void;
  54097. /**
  54098. * Removes all the elements in the container from the scene
  54099. * @param container contains the elements to remove
  54100. * @param dispose if the removed element should be disposed (default: false)
  54101. */
  54102. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54103. }
  54104. }
  54105. declare module BABYLON {
  54106. /** @hidden */
  54107. export var layerPixelShader: {
  54108. name: string;
  54109. shader: string;
  54110. };
  54111. }
  54112. declare module BABYLON {
  54113. /** @hidden */
  54114. export var layerVertexShader: {
  54115. name: string;
  54116. shader: string;
  54117. };
  54118. }
  54119. declare module BABYLON {
  54120. /**
  54121. * This represents a full screen 2d layer.
  54122. * This can be useful to display a picture in the background of your scene for instance.
  54123. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54124. */
  54125. export class Layer {
  54126. /**
  54127. * Define the name of the layer.
  54128. */
  54129. name: string;
  54130. /**
  54131. * Define the texture the layer should display.
  54132. */
  54133. texture: Nullable<Texture>;
  54134. /**
  54135. * Is the layer in background or foreground.
  54136. */
  54137. isBackground: boolean;
  54138. /**
  54139. * Define the color of the layer (instead of texture).
  54140. */
  54141. color: Color4;
  54142. /**
  54143. * Define the scale of the layer in order to zoom in out of the texture.
  54144. */
  54145. scale: Vector2;
  54146. /**
  54147. * Define an offset for the layer in order to shift the texture.
  54148. */
  54149. offset: Vector2;
  54150. /**
  54151. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54152. */
  54153. alphaBlendingMode: number;
  54154. /**
  54155. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54156. * Alpha test will not mix with the background color in case of transparency.
  54157. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54158. */
  54159. alphaTest: boolean;
  54160. /**
  54161. * Define a mask to restrict the layer to only some of the scene cameras.
  54162. */
  54163. layerMask: number;
  54164. /**
  54165. * Define the list of render target the layer is visible into.
  54166. */
  54167. renderTargetTextures: RenderTargetTexture[];
  54168. /**
  54169. * Define if the layer is only used in renderTarget or if it also
  54170. * renders in the main frame buffer of the canvas.
  54171. */
  54172. renderOnlyInRenderTargetTextures: boolean;
  54173. private _scene;
  54174. private _vertexBuffers;
  54175. private _indexBuffer;
  54176. private _effect;
  54177. private _previousDefines;
  54178. /**
  54179. * An event triggered when the layer is disposed.
  54180. */
  54181. onDisposeObservable: Observable<Layer>;
  54182. private _onDisposeObserver;
  54183. /**
  54184. * Back compatibility with callback before the onDisposeObservable existed.
  54185. * The set callback will be triggered when the layer has been disposed.
  54186. */
  54187. set onDispose(callback: () => void);
  54188. /**
  54189. * An event triggered before rendering the scene
  54190. */
  54191. onBeforeRenderObservable: Observable<Layer>;
  54192. private _onBeforeRenderObserver;
  54193. /**
  54194. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54195. * The set callback will be triggered just before rendering the layer.
  54196. */
  54197. set onBeforeRender(callback: () => void);
  54198. /**
  54199. * An event triggered after rendering the scene
  54200. */
  54201. onAfterRenderObservable: Observable<Layer>;
  54202. private _onAfterRenderObserver;
  54203. /**
  54204. * Back compatibility with callback before the onAfterRenderObservable existed.
  54205. * The set callback will be triggered just after rendering the layer.
  54206. */
  54207. set onAfterRender(callback: () => void);
  54208. /**
  54209. * Instantiates a new layer.
  54210. * This represents a full screen 2d layer.
  54211. * This can be useful to display a picture in the background of your scene for instance.
  54212. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54213. * @param name Define the name of the layer in the scene
  54214. * @param imgUrl Define the url of the texture to display in the layer
  54215. * @param scene Define the scene the layer belongs to
  54216. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54217. * @param color Defines a color for the layer
  54218. */
  54219. constructor(
  54220. /**
  54221. * Define the name of the layer.
  54222. */
  54223. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54224. private _createIndexBuffer;
  54225. /** @hidden */
  54226. _rebuild(): void;
  54227. /**
  54228. * Renders the layer in the scene.
  54229. */
  54230. render(): void;
  54231. /**
  54232. * Disposes and releases the associated ressources.
  54233. */
  54234. dispose(): void;
  54235. }
  54236. }
  54237. declare module BABYLON {
  54238. /** @hidden */
  54239. export var lensFlarePixelShader: {
  54240. name: string;
  54241. shader: string;
  54242. };
  54243. }
  54244. declare module BABYLON {
  54245. /** @hidden */
  54246. export var lensFlareVertexShader: {
  54247. name: string;
  54248. shader: string;
  54249. };
  54250. }
  54251. declare module BABYLON {
  54252. /**
  54253. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54254. * It is usually composed of several `lensFlare`.
  54255. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54256. */
  54257. export class LensFlareSystem {
  54258. /**
  54259. * Define the name of the lens flare system
  54260. */
  54261. name: string;
  54262. /**
  54263. * List of lens flares used in this system.
  54264. */
  54265. lensFlares: LensFlare[];
  54266. /**
  54267. * Define a limit from the border the lens flare can be visible.
  54268. */
  54269. borderLimit: number;
  54270. /**
  54271. * Define a viewport border we do not want to see the lens flare in.
  54272. */
  54273. viewportBorder: number;
  54274. /**
  54275. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54276. */
  54277. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54278. /**
  54279. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54280. */
  54281. layerMask: number;
  54282. /**
  54283. * Define the id of the lens flare system in the scene.
  54284. * (equal to name by default)
  54285. */
  54286. id: string;
  54287. private _scene;
  54288. private _emitter;
  54289. private _vertexBuffers;
  54290. private _indexBuffer;
  54291. private _effect;
  54292. private _positionX;
  54293. private _positionY;
  54294. private _isEnabled;
  54295. /** @hidden */
  54296. static _SceneComponentInitialization: (scene: Scene) => void;
  54297. /**
  54298. * Instantiates a lens flare system.
  54299. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54300. * It is usually composed of several `lensFlare`.
  54301. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54302. * @param name Define the name of the lens flare system in the scene
  54303. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54304. * @param scene Define the scene the lens flare system belongs to
  54305. */
  54306. constructor(
  54307. /**
  54308. * Define the name of the lens flare system
  54309. */
  54310. name: string, emitter: any, scene: Scene);
  54311. /**
  54312. * Define if the lens flare system is enabled.
  54313. */
  54314. get isEnabled(): boolean;
  54315. set isEnabled(value: boolean);
  54316. /**
  54317. * Get the scene the effects belongs to.
  54318. * @returns the scene holding the lens flare system
  54319. */
  54320. getScene(): Scene;
  54321. /**
  54322. * Get the emitter of the lens flare system.
  54323. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54324. * @returns the emitter of the lens flare system
  54325. */
  54326. getEmitter(): any;
  54327. /**
  54328. * Set the emitter of the lens flare system.
  54329. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54330. * @param newEmitter Define the new emitter of the system
  54331. */
  54332. setEmitter(newEmitter: any): void;
  54333. /**
  54334. * Get the lens flare system emitter position.
  54335. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54336. * @returns the position
  54337. */
  54338. getEmitterPosition(): Vector3;
  54339. /**
  54340. * @hidden
  54341. */
  54342. computeEffectivePosition(globalViewport: Viewport): boolean;
  54343. /** @hidden */
  54344. _isVisible(): boolean;
  54345. /**
  54346. * @hidden
  54347. */
  54348. render(): boolean;
  54349. /**
  54350. * Dispose and release the lens flare with its associated resources.
  54351. */
  54352. dispose(): void;
  54353. /**
  54354. * Parse a lens flare system from a JSON repressentation
  54355. * @param parsedLensFlareSystem Define the JSON to parse
  54356. * @param scene Define the scene the parsed system should be instantiated in
  54357. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54358. * @returns the parsed system
  54359. */
  54360. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54361. /**
  54362. * Serialize the current Lens Flare System into a JSON representation.
  54363. * @returns the serialized JSON
  54364. */
  54365. serialize(): any;
  54366. }
  54367. }
  54368. declare module BABYLON {
  54369. /**
  54370. * This represents one of the lens effect in a `lensFlareSystem`.
  54371. * It controls one of the indiviual texture used in the effect.
  54372. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54373. */
  54374. export class LensFlare {
  54375. /**
  54376. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54377. */
  54378. size: number;
  54379. /**
  54380. * 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.
  54381. */
  54382. position: number;
  54383. /**
  54384. * Define the lens color.
  54385. */
  54386. color: Color3;
  54387. /**
  54388. * Define the lens texture.
  54389. */
  54390. texture: Nullable<Texture>;
  54391. /**
  54392. * Define the alpha mode to render this particular lens.
  54393. */
  54394. alphaMode: number;
  54395. private _system;
  54396. /**
  54397. * Creates a new Lens Flare.
  54398. * This represents one of the lens effect in a `lensFlareSystem`.
  54399. * It controls one of the indiviual texture used in the effect.
  54400. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54401. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54402. * @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.
  54403. * @param color Define the lens color
  54404. * @param imgUrl Define the lens texture url
  54405. * @param system Define the `lensFlareSystem` this flare is part of
  54406. * @returns The newly created Lens Flare
  54407. */
  54408. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54409. /**
  54410. * Instantiates a new Lens Flare.
  54411. * This represents one of the lens effect in a `lensFlareSystem`.
  54412. * It controls one of the indiviual texture used in the effect.
  54413. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54414. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54415. * @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.
  54416. * @param color Define the lens color
  54417. * @param imgUrl Define the lens texture url
  54418. * @param system Define the `lensFlareSystem` this flare is part of
  54419. */
  54420. constructor(
  54421. /**
  54422. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54423. */
  54424. size: number,
  54425. /**
  54426. * 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.
  54427. */
  54428. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54429. /**
  54430. * Dispose and release the lens flare with its associated resources.
  54431. */
  54432. dispose(): void;
  54433. }
  54434. }
  54435. declare module BABYLON {
  54436. interface AbstractScene {
  54437. /**
  54438. * The list of lens flare system added to the scene
  54439. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54440. */
  54441. lensFlareSystems: Array<LensFlareSystem>;
  54442. /**
  54443. * Removes the given lens flare system from this scene.
  54444. * @param toRemove The lens flare system to remove
  54445. * @returns The index of the removed lens flare system
  54446. */
  54447. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54448. /**
  54449. * Adds the given lens flare system to this scene
  54450. * @param newLensFlareSystem The lens flare system to add
  54451. */
  54452. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54453. /**
  54454. * Gets a lens flare system using its name
  54455. * @param name defines the name to look for
  54456. * @returns the lens flare system or null if not found
  54457. */
  54458. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54459. /**
  54460. * Gets a lens flare system using its id
  54461. * @param id defines the id to look for
  54462. * @returns the lens flare system or null if not found
  54463. */
  54464. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54465. }
  54466. /**
  54467. * Defines the lens flare scene component responsible to manage any lens flares
  54468. * in a given scene.
  54469. */
  54470. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54471. /**
  54472. * The component name helpfull to identify the component in the list of scene components.
  54473. */
  54474. readonly name: string;
  54475. /**
  54476. * The scene the component belongs to.
  54477. */
  54478. scene: Scene;
  54479. /**
  54480. * Creates a new instance of the component for the given scene
  54481. * @param scene Defines the scene to register the component in
  54482. */
  54483. constructor(scene: Scene);
  54484. /**
  54485. * Registers the component in a given scene
  54486. */
  54487. register(): void;
  54488. /**
  54489. * Rebuilds the elements related to this component in case of
  54490. * context lost for instance.
  54491. */
  54492. rebuild(): void;
  54493. /**
  54494. * Adds all the elements from the container to the scene
  54495. * @param container the container holding the elements
  54496. */
  54497. addFromContainer(container: AbstractScene): void;
  54498. /**
  54499. * Removes all the elements in the container from the scene
  54500. * @param container contains the elements to remove
  54501. * @param dispose if the removed element should be disposed (default: false)
  54502. */
  54503. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54504. /**
  54505. * Serializes the component data to the specified json object
  54506. * @param serializationObject The object to serialize to
  54507. */
  54508. serialize(serializationObject: any): void;
  54509. /**
  54510. * Disposes the component and the associated ressources.
  54511. */
  54512. dispose(): void;
  54513. private _draw;
  54514. }
  54515. }
  54516. declare module BABYLON {
  54517. /** @hidden */
  54518. export var depthPixelShader: {
  54519. name: string;
  54520. shader: string;
  54521. };
  54522. }
  54523. declare module BABYLON {
  54524. /** @hidden */
  54525. export var depthVertexShader: {
  54526. name: string;
  54527. shader: string;
  54528. };
  54529. }
  54530. declare module BABYLON {
  54531. /**
  54532. * This represents a depth renderer in Babylon.
  54533. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54534. */
  54535. export class DepthRenderer {
  54536. private _scene;
  54537. private _depthMap;
  54538. private _effect;
  54539. private readonly _storeNonLinearDepth;
  54540. private readonly _clearColor;
  54541. /** Get if the depth renderer is using packed depth or not */
  54542. readonly isPacked: boolean;
  54543. private _cachedDefines;
  54544. private _camera;
  54545. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54546. enabled: boolean;
  54547. /**
  54548. * Specifiess that the depth renderer will only be used within
  54549. * the camera it is created for.
  54550. * This can help forcing its rendering during the camera processing.
  54551. */
  54552. useOnlyInActiveCamera: boolean;
  54553. /** @hidden */
  54554. static _SceneComponentInitialization: (scene: Scene) => void;
  54555. /**
  54556. * Instantiates a depth renderer
  54557. * @param scene The scene the renderer belongs to
  54558. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54559. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54560. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54561. */
  54562. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54563. /**
  54564. * Creates the depth rendering effect and checks if the effect is ready.
  54565. * @param subMesh The submesh to be used to render the depth map of
  54566. * @param useInstances If multiple world instances should be used
  54567. * @returns if the depth renderer is ready to render the depth map
  54568. */
  54569. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54570. /**
  54571. * Gets the texture which the depth map will be written to.
  54572. * @returns The depth map texture
  54573. */
  54574. getDepthMap(): RenderTargetTexture;
  54575. /**
  54576. * Disposes of the depth renderer.
  54577. */
  54578. dispose(): void;
  54579. }
  54580. }
  54581. declare module BABYLON {
  54582. /** @hidden */
  54583. export var minmaxReduxPixelShader: {
  54584. name: string;
  54585. shader: string;
  54586. };
  54587. }
  54588. declare module BABYLON {
  54589. /**
  54590. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54591. * and maximum values from all values of the texture.
  54592. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54593. * The source values are read from the red channel of the texture.
  54594. */
  54595. export class MinMaxReducer {
  54596. /**
  54597. * Observable triggered when the computation has been performed
  54598. */
  54599. onAfterReductionPerformed: Observable<{
  54600. min: number;
  54601. max: number;
  54602. }>;
  54603. protected _camera: Camera;
  54604. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54605. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54606. protected _postProcessManager: PostProcessManager;
  54607. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54608. protected _forceFullscreenViewport: boolean;
  54609. /**
  54610. * Creates a min/max reducer
  54611. * @param camera The camera to use for the post processes
  54612. */
  54613. constructor(camera: Camera);
  54614. /**
  54615. * Gets the texture used to read the values from.
  54616. */
  54617. get sourceTexture(): Nullable<RenderTargetTexture>;
  54618. /**
  54619. * Sets the source texture to read the values from.
  54620. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54621. * because in such textures '1' value must not be taken into account to compute the maximum
  54622. * as this value is used to clear the texture.
  54623. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54624. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54625. * @param depthRedux Indicates if the texture is a depth texture or not
  54626. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54627. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54628. */
  54629. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54630. /**
  54631. * Defines the refresh rate of the computation.
  54632. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54633. */
  54634. get refreshRate(): number;
  54635. set refreshRate(value: number);
  54636. protected _activated: boolean;
  54637. /**
  54638. * Gets the activation status of the reducer
  54639. */
  54640. get activated(): boolean;
  54641. /**
  54642. * Activates the reduction computation.
  54643. * When activated, the observers registered in onAfterReductionPerformed are
  54644. * called after the compuation is performed
  54645. */
  54646. activate(): void;
  54647. /**
  54648. * Deactivates the reduction computation.
  54649. */
  54650. deactivate(): void;
  54651. /**
  54652. * Disposes the min/max reducer
  54653. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  54654. */
  54655. dispose(disposeAll?: boolean): void;
  54656. }
  54657. }
  54658. declare module BABYLON {
  54659. /**
  54660. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54661. */
  54662. export class DepthReducer extends MinMaxReducer {
  54663. private _depthRenderer;
  54664. private _depthRendererId;
  54665. /**
  54666. * Gets the depth renderer used for the computation.
  54667. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54668. */
  54669. get depthRenderer(): Nullable<DepthRenderer>;
  54670. /**
  54671. * Creates a depth reducer
  54672. * @param camera The camera used to render the depth texture
  54673. */
  54674. constructor(camera: Camera);
  54675. /**
  54676. * Sets the depth renderer to use to generate the depth map
  54677. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54678. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54679. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54680. */
  54681. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54682. /** @hidden */
  54683. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54684. /**
  54685. * Activates the reduction computation.
  54686. * When activated, the observers registered in onAfterReductionPerformed are
  54687. * called after the compuation is performed
  54688. */
  54689. activate(): void;
  54690. /**
  54691. * Deactivates the reduction computation.
  54692. */
  54693. deactivate(): void;
  54694. /**
  54695. * Disposes the depth reducer
  54696. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  54697. */
  54698. dispose(disposeAll?: boolean): void;
  54699. }
  54700. }
  54701. declare module BABYLON {
  54702. /**
  54703. * A CSM implementation allowing casting shadows on large scenes.
  54704. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54705. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54706. */
  54707. export class CascadedShadowGenerator extends ShadowGenerator {
  54708. private static readonly frustumCornersNDCSpace;
  54709. /**
  54710. * Name of the CSM class
  54711. */
  54712. static CLASSNAME: string;
  54713. /**
  54714. * Defines the default number of cascades used by the CSM.
  54715. */
  54716. static readonly DEFAULT_CASCADES_COUNT: number;
  54717. /**
  54718. * Defines the minimum number of cascades used by the CSM.
  54719. */
  54720. static readonly MIN_CASCADES_COUNT: number;
  54721. /**
  54722. * Defines the maximum number of cascades used by the CSM.
  54723. */
  54724. static readonly MAX_CASCADES_COUNT: number;
  54725. protected _validateFilter(filter: number): number;
  54726. /**
  54727. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54728. */
  54729. penumbraDarkness: number;
  54730. private _numCascades;
  54731. /**
  54732. * Gets or set the number of cascades used by the CSM.
  54733. */
  54734. get numCascades(): number;
  54735. set numCascades(value: number);
  54736. /**
  54737. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54738. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54739. */
  54740. stabilizeCascades: boolean;
  54741. private _freezeShadowCastersBoundingInfo;
  54742. private _freezeShadowCastersBoundingInfoObservable;
  54743. /**
  54744. * Enables or disables the shadow casters bounding info computation.
  54745. * If your shadow casters don't move, you can disable this feature.
  54746. * If it is enabled, the bounding box computation is done every frame.
  54747. */
  54748. get freezeShadowCastersBoundingInfo(): boolean;
  54749. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54750. private _scbiMin;
  54751. private _scbiMax;
  54752. protected _computeShadowCastersBoundingInfo(): void;
  54753. protected _shadowCastersBoundingInfo: BoundingInfo;
  54754. /**
  54755. * Gets or sets the shadow casters bounding info.
  54756. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54757. * so that the system won't overwrite the bounds you provide
  54758. */
  54759. get shadowCastersBoundingInfo(): BoundingInfo;
  54760. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54761. protected _breaksAreDirty: boolean;
  54762. protected _minDistance: number;
  54763. protected _maxDistance: number;
  54764. /**
  54765. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54766. *
  54767. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54768. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54769. * @param min minimal distance for the breaks (default to 0.)
  54770. * @param max maximal distance for the breaks (default to 1.)
  54771. */
  54772. setMinMaxDistance(min: number, max: number): void;
  54773. /** Gets the minimal distance used in the cascade break computation */
  54774. get minDistance(): number;
  54775. /** Gets the maximal distance used in the cascade break computation */
  54776. get maxDistance(): number;
  54777. /**
  54778. * Gets the class name of that object
  54779. * @returns "CascadedShadowGenerator"
  54780. */
  54781. getClassName(): string;
  54782. private _cascadeMinExtents;
  54783. private _cascadeMaxExtents;
  54784. /**
  54785. * Gets a cascade minimum extents
  54786. * @param cascadeIndex index of the cascade
  54787. * @returns the minimum cascade extents
  54788. */
  54789. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54790. /**
  54791. * Gets a cascade maximum extents
  54792. * @param cascadeIndex index of the cascade
  54793. * @returns the maximum cascade extents
  54794. */
  54795. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54796. private _cascades;
  54797. private _currentLayer;
  54798. private _viewSpaceFrustumsZ;
  54799. private _viewMatrices;
  54800. private _projectionMatrices;
  54801. private _transformMatrices;
  54802. private _transformMatricesAsArray;
  54803. private _frustumLengths;
  54804. private _lightSizeUVCorrection;
  54805. private _depthCorrection;
  54806. private _frustumCornersWorldSpace;
  54807. private _frustumCenter;
  54808. private _shadowCameraPos;
  54809. private _shadowMaxZ;
  54810. /**
  54811. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54812. * It defaults to camera.maxZ
  54813. */
  54814. get shadowMaxZ(): number;
  54815. /**
  54816. * Sets the shadow max z distance.
  54817. */
  54818. set shadowMaxZ(value: number);
  54819. protected _debug: boolean;
  54820. /**
  54821. * Gets or sets the debug flag.
  54822. * When enabled, the cascades are materialized by different colors on the screen.
  54823. */
  54824. get debug(): boolean;
  54825. set debug(dbg: boolean);
  54826. private _depthClamp;
  54827. /**
  54828. * Gets or sets the depth clamping value.
  54829. *
  54830. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54831. * to account for the shadow casters far away.
  54832. *
  54833. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54834. */
  54835. get depthClamp(): boolean;
  54836. set depthClamp(value: boolean);
  54837. private _cascadeBlendPercentage;
  54838. /**
  54839. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54840. * It defaults to 0.1 (10% blending).
  54841. */
  54842. get cascadeBlendPercentage(): number;
  54843. set cascadeBlendPercentage(value: number);
  54844. private _lambda;
  54845. /**
  54846. * Gets or set the lambda parameter.
  54847. * This parameter is used to split the camera frustum and create the cascades.
  54848. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  54849. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54850. */
  54851. get lambda(): number;
  54852. set lambda(value: number);
  54853. /**
  54854. * Gets the view matrix corresponding to a given cascade
  54855. * @param cascadeNum cascade to retrieve the view matrix from
  54856. * @returns the cascade view matrix
  54857. */
  54858. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54859. /**
  54860. * Gets the projection matrix corresponding to a given cascade
  54861. * @param cascadeNum cascade to retrieve the projection matrix from
  54862. * @returns the cascade projection matrix
  54863. */
  54864. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54865. /**
  54866. * Gets the transformation matrix corresponding to a given cascade
  54867. * @param cascadeNum cascade to retrieve the transformation matrix from
  54868. * @returns the cascade transformation matrix
  54869. */
  54870. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54871. private _depthRenderer;
  54872. /**
  54873. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54874. *
  54875. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54876. *
  54877. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54878. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54879. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  54880. */
  54881. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54882. private _depthReducer;
  54883. private _autoCalcDepthBounds;
  54884. /**
  54885. * Gets or sets the autoCalcDepthBounds property.
  54886. *
  54887. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54888. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54889. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54890. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54891. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54892. */
  54893. get autoCalcDepthBounds(): boolean;
  54894. set autoCalcDepthBounds(value: boolean);
  54895. /**
  54896. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54897. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54898. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54899. * for setting the refresh rate on the renderer yourself!
  54900. */
  54901. get autoCalcDepthBoundsRefreshRate(): number;
  54902. set autoCalcDepthBoundsRefreshRate(value: number);
  54903. /**
  54904. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54905. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54906. * you change the camera near/far planes!
  54907. */
  54908. splitFrustum(): void;
  54909. private _splitFrustum;
  54910. private _computeMatrices;
  54911. private _computeFrustumInWorldSpace;
  54912. private _computeCascadeFrustum;
  54913. /**
  54914. * Support test.
  54915. */
  54916. static get IsSupported(): boolean;
  54917. /** @hidden */
  54918. static _SceneComponentInitialization: (scene: Scene) => void;
  54919. /**
  54920. * Creates a Cascaded Shadow Generator object.
  54921. * A ShadowGenerator is the required tool to use the shadows.
  54922. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54923. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54924. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54925. * @param light The directional light object generating the shadows.
  54926. * @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.
  54927. */
  54928. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54929. protected _initializeGenerator(): void;
  54930. protected _createTargetRenderTexture(): void;
  54931. protected _initializeShadowMap(): void;
  54932. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54933. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54934. /**
  54935. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54936. * @param defines Defines of the material we want to update
  54937. * @param lightIndex Index of the light in the enabled light list of the material
  54938. */
  54939. prepareDefines(defines: any, lightIndex: number): void;
  54940. /**
  54941. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54942. * defined in the generator but impacting the effect).
  54943. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54944. * @param effect The effect we are binfing the information for
  54945. */
  54946. bindShadowLight(lightIndex: string, effect: Effect): void;
  54947. /**
  54948. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54949. * (eq to view projection * shadow projection matrices)
  54950. * @returns The transform matrix used to create the shadow map
  54951. */
  54952. getTransformMatrix(): Matrix;
  54953. /**
  54954. * Disposes the ShadowGenerator.
  54955. * Returns nothing.
  54956. */
  54957. dispose(): void;
  54958. /**
  54959. * Serializes the shadow generator setup to a json object.
  54960. * @returns The serialized JSON object
  54961. */
  54962. serialize(): any;
  54963. /**
  54964. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54965. * @param parsedShadowGenerator The JSON object to parse
  54966. * @param scene The scene to create the shadow map for
  54967. * @returns The parsed shadow generator
  54968. */
  54969. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54970. }
  54971. }
  54972. declare module BABYLON {
  54973. /**
  54974. * Defines the shadow generator component responsible to manage any shadow generators
  54975. * in a given scene.
  54976. */
  54977. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54978. /**
  54979. * The component name helpfull to identify the component in the list of scene components.
  54980. */
  54981. readonly name: string;
  54982. /**
  54983. * The scene the component belongs to.
  54984. */
  54985. scene: Scene;
  54986. /**
  54987. * Creates a new instance of the component for the given scene
  54988. * @param scene Defines the scene to register the component in
  54989. */
  54990. constructor(scene: Scene);
  54991. /**
  54992. * Registers the component in a given scene
  54993. */
  54994. register(): void;
  54995. /**
  54996. * Rebuilds the elements related to this component in case of
  54997. * context lost for instance.
  54998. */
  54999. rebuild(): void;
  55000. /**
  55001. * Serializes the component data to the specified json object
  55002. * @param serializationObject The object to serialize to
  55003. */
  55004. serialize(serializationObject: any): void;
  55005. /**
  55006. * Adds all the elements from the container to the scene
  55007. * @param container the container holding the elements
  55008. */
  55009. addFromContainer(container: AbstractScene): void;
  55010. /**
  55011. * Removes all the elements in the container from the scene
  55012. * @param container contains the elements to remove
  55013. * @param dispose if the removed element should be disposed (default: false)
  55014. */
  55015. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55016. /**
  55017. * Rebuilds the elements related to this component in case of
  55018. * context lost for instance.
  55019. */
  55020. dispose(): void;
  55021. private _gatherRenderTargets;
  55022. }
  55023. }
  55024. declare module BABYLON {
  55025. /**
  55026. * A point light is a light defined by an unique point in world space.
  55027. * The light is emitted in every direction from this point.
  55028. * A good example of a point light is a standard light bulb.
  55029. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55030. */
  55031. export class PointLight extends ShadowLight {
  55032. private _shadowAngle;
  55033. /**
  55034. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55035. * This specifies what angle the shadow will use to be created.
  55036. *
  55037. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55038. */
  55039. get shadowAngle(): number;
  55040. /**
  55041. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55042. * This specifies what angle the shadow will use to be created.
  55043. *
  55044. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55045. */
  55046. set shadowAngle(value: number);
  55047. /**
  55048. * Gets the direction if it has been set.
  55049. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55050. */
  55051. get direction(): Vector3;
  55052. /**
  55053. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55054. */
  55055. set direction(value: Vector3);
  55056. /**
  55057. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55058. * A PointLight emits the light in every direction.
  55059. * It can cast shadows.
  55060. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55061. * ```javascript
  55062. * var pointLight = new PointLight("pl", camera.position, scene);
  55063. * ```
  55064. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55065. * @param name The light friendly name
  55066. * @param position The position of the point light in the scene
  55067. * @param scene The scene the lights belongs to
  55068. */
  55069. constructor(name: string, position: Vector3, scene: Scene);
  55070. /**
  55071. * Returns the string "PointLight"
  55072. * @returns the class name
  55073. */
  55074. getClassName(): string;
  55075. /**
  55076. * Returns the integer 0.
  55077. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55078. */
  55079. getTypeID(): number;
  55080. /**
  55081. * Specifies wether or not the shadowmap should be a cube texture.
  55082. * @returns true if the shadowmap needs to be a cube texture.
  55083. */
  55084. needCube(): boolean;
  55085. /**
  55086. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55087. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55088. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55089. */
  55090. getShadowDirection(faceIndex?: number): Vector3;
  55091. /**
  55092. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55093. * - fov = PI / 2
  55094. * - aspect ratio : 1.0
  55095. * - z-near and far equal to the active camera minZ and maxZ.
  55096. * Returns the PointLight.
  55097. */
  55098. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55099. protected _buildUniformLayout(): void;
  55100. /**
  55101. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55102. * @param effect The effect to update
  55103. * @param lightIndex The index of the light in the effect to update
  55104. * @returns The point light
  55105. */
  55106. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55107. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55108. /**
  55109. * Prepares the list of defines specific to the light type.
  55110. * @param defines the list of defines
  55111. * @param lightIndex defines the index of the light for the effect
  55112. */
  55113. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55114. }
  55115. }
  55116. declare module BABYLON {
  55117. /**
  55118. * Header information of HDR texture files.
  55119. */
  55120. export interface HDRInfo {
  55121. /**
  55122. * The height of the texture in pixels.
  55123. */
  55124. height: number;
  55125. /**
  55126. * The width of the texture in pixels.
  55127. */
  55128. width: number;
  55129. /**
  55130. * The index of the beginning of the data in the binary file.
  55131. */
  55132. dataPosition: number;
  55133. }
  55134. /**
  55135. * This groups tools to convert HDR texture to native colors array.
  55136. */
  55137. export class HDRTools {
  55138. private static Ldexp;
  55139. private static Rgbe2float;
  55140. private static readStringLine;
  55141. /**
  55142. * Reads header information from an RGBE texture stored in a native array.
  55143. * More information on this format are available here:
  55144. * https://en.wikipedia.org/wiki/RGBE_image_format
  55145. *
  55146. * @param uint8array The binary file stored in native array.
  55147. * @return The header information.
  55148. */
  55149. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55150. /**
  55151. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55152. * This RGBE texture needs to store the information as a panorama.
  55153. *
  55154. * More information on this format are available here:
  55155. * https://en.wikipedia.org/wiki/RGBE_image_format
  55156. *
  55157. * @param buffer The binary file stored in an array buffer.
  55158. * @param size The expected size of the extracted cubemap.
  55159. * @return The Cube Map information.
  55160. */
  55161. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55162. /**
  55163. * Returns the pixels data extracted from an RGBE texture.
  55164. * This pixels will be stored left to right up to down in the R G B order in one array.
  55165. *
  55166. * More information on this format are available here:
  55167. * https://en.wikipedia.org/wiki/RGBE_image_format
  55168. *
  55169. * @param uint8array The binary file stored in an array buffer.
  55170. * @param hdrInfo The header information of the file.
  55171. * @return The pixels data in RGB right to left up to down order.
  55172. */
  55173. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55174. private static RGBE_ReadPixels_RLE;
  55175. }
  55176. }
  55177. declare module BABYLON {
  55178. /**
  55179. * This represents a texture coming from an HDR input.
  55180. *
  55181. * The only supported format is currently panorama picture stored in RGBE format.
  55182. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55183. */
  55184. export class HDRCubeTexture extends BaseTexture {
  55185. private static _facesMapping;
  55186. private _generateHarmonics;
  55187. private _noMipmap;
  55188. private _textureMatrix;
  55189. private _size;
  55190. private _onLoad;
  55191. private _onError;
  55192. /**
  55193. * The texture URL.
  55194. */
  55195. url: string;
  55196. /**
  55197. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55198. */
  55199. coordinatesMode: number;
  55200. protected _isBlocking: boolean;
  55201. /**
  55202. * Sets wether or not the texture is blocking during loading.
  55203. */
  55204. set isBlocking(value: boolean);
  55205. /**
  55206. * Gets wether or not the texture is blocking during loading.
  55207. */
  55208. get isBlocking(): boolean;
  55209. protected _rotationY: number;
  55210. /**
  55211. * Sets texture matrix rotation angle around Y axis in radians.
  55212. */
  55213. set rotationY(value: number);
  55214. /**
  55215. * Gets texture matrix rotation angle around Y axis radians.
  55216. */
  55217. get rotationY(): number;
  55218. /**
  55219. * Gets or sets the center of the bounding box associated with the cube texture
  55220. * It must define where the camera used to render the texture was set
  55221. */
  55222. boundingBoxPosition: Vector3;
  55223. private _boundingBoxSize;
  55224. /**
  55225. * Gets or sets the size of the bounding box associated with the cube texture
  55226. * When defined, the cubemap will switch to local mode
  55227. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55228. * @example https://www.babylonjs-playground.com/#RNASML
  55229. */
  55230. set boundingBoxSize(value: Vector3);
  55231. get boundingBoxSize(): Vector3;
  55232. /**
  55233. * Instantiates an HDRTexture from the following parameters.
  55234. *
  55235. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55236. * @param scene The scene the texture will be used in
  55237. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55238. * @param noMipmap Forces to not generate the mipmap if true
  55239. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55240. * @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)
  55241. * @param reserved Reserved flag for internal use.
  55242. */
  55243. 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>);
  55244. /**
  55245. * Get the current class name of the texture useful for serialization or dynamic coding.
  55246. * @returns "HDRCubeTexture"
  55247. */
  55248. getClassName(): string;
  55249. /**
  55250. * Occurs when the file is raw .hdr file.
  55251. */
  55252. private loadTexture;
  55253. clone(): HDRCubeTexture;
  55254. delayLoad(): void;
  55255. /**
  55256. * Get the texture reflection matrix used to rotate/transform the reflection.
  55257. * @returns the reflection matrix
  55258. */
  55259. getReflectionTextureMatrix(): Matrix;
  55260. /**
  55261. * Set the texture reflection matrix used to rotate/transform the reflection.
  55262. * @param value Define the reflection matrix to set
  55263. */
  55264. setReflectionTextureMatrix(value: Matrix): void;
  55265. /**
  55266. * Parses a JSON representation of an HDR Texture in order to create the texture
  55267. * @param parsedTexture Define the JSON representation
  55268. * @param scene Define the scene the texture should be created in
  55269. * @param rootUrl Define the root url in case we need to load relative dependencies
  55270. * @returns the newly created texture after parsing
  55271. */
  55272. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55273. serialize(): any;
  55274. }
  55275. }
  55276. declare module BABYLON {
  55277. /**
  55278. * Class used to control physics engine
  55279. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55280. */
  55281. export class PhysicsEngine implements IPhysicsEngine {
  55282. private _physicsPlugin;
  55283. /**
  55284. * Global value used to control the smallest number supported by the simulation
  55285. */
  55286. static Epsilon: number;
  55287. private _impostors;
  55288. private _joints;
  55289. private _subTimeStep;
  55290. /**
  55291. * Gets the gravity vector used by the simulation
  55292. */
  55293. gravity: Vector3;
  55294. /**
  55295. * Factory used to create the default physics plugin.
  55296. * @returns The default physics plugin
  55297. */
  55298. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55299. /**
  55300. * Creates a new Physics Engine
  55301. * @param gravity defines the gravity vector used by the simulation
  55302. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55303. */
  55304. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55305. /**
  55306. * Sets the gravity vector used by the simulation
  55307. * @param gravity defines the gravity vector to use
  55308. */
  55309. setGravity(gravity: Vector3): void;
  55310. /**
  55311. * Set the time step of the physics engine.
  55312. * Default is 1/60.
  55313. * To slow it down, enter 1/600 for example.
  55314. * To speed it up, 1/30
  55315. * @param newTimeStep defines the new timestep to apply to this world.
  55316. */
  55317. setTimeStep(newTimeStep?: number): void;
  55318. /**
  55319. * Get the time step of the physics engine.
  55320. * @returns the current time step
  55321. */
  55322. getTimeStep(): number;
  55323. /**
  55324. * Set the sub time step of the physics engine.
  55325. * Default is 0 meaning there is no sub steps
  55326. * To increase physics resolution precision, set a small value (like 1 ms)
  55327. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55328. */
  55329. setSubTimeStep(subTimeStep?: number): void;
  55330. /**
  55331. * Get the sub time step of the physics engine.
  55332. * @returns the current sub time step
  55333. */
  55334. getSubTimeStep(): number;
  55335. /**
  55336. * Release all resources
  55337. */
  55338. dispose(): void;
  55339. /**
  55340. * Gets the name of the current physics plugin
  55341. * @returns the name of the plugin
  55342. */
  55343. getPhysicsPluginName(): string;
  55344. /**
  55345. * Adding a new impostor for the impostor tracking.
  55346. * This will be done by the impostor itself.
  55347. * @param impostor the impostor to add
  55348. */
  55349. addImpostor(impostor: PhysicsImpostor): void;
  55350. /**
  55351. * Remove an impostor from the engine.
  55352. * This impostor and its mesh will not longer be updated by the physics engine.
  55353. * @param impostor the impostor to remove
  55354. */
  55355. removeImpostor(impostor: PhysicsImpostor): void;
  55356. /**
  55357. * Add a joint to the physics engine
  55358. * @param mainImpostor defines the main impostor to which the joint is added.
  55359. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55360. * @param joint defines the joint that will connect both impostors.
  55361. */
  55362. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55363. /**
  55364. * Removes a joint from the simulation
  55365. * @param mainImpostor defines the impostor used with the joint
  55366. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55367. * @param joint defines the joint to remove
  55368. */
  55369. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55370. /**
  55371. * Called by the scene. No need to call it.
  55372. * @param delta defines the timespam between frames
  55373. */
  55374. _step(delta: number): void;
  55375. /**
  55376. * Gets the current plugin used to run the simulation
  55377. * @returns current plugin
  55378. */
  55379. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55380. /**
  55381. * Gets the list of physic impostors
  55382. * @returns an array of PhysicsImpostor
  55383. */
  55384. getImpostors(): Array<PhysicsImpostor>;
  55385. /**
  55386. * Gets the impostor for a physics enabled object
  55387. * @param object defines the object impersonated by the impostor
  55388. * @returns the PhysicsImpostor or null if not found
  55389. */
  55390. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55391. /**
  55392. * Gets the impostor for a physics body object
  55393. * @param body defines physics body used by the impostor
  55394. * @returns the PhysicsImpostor or null if not found
  55395. */
  55396. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55397. /**
  55398. * Does a raycast in the physics world
  55399. * @param from when should the ray start?
  55400. * @param to when should the ray end?
  55401. * @returns PhysicsRaycastResult
  55402. */
  55403. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55404. }
  55405. }
  55406. declare module BABYLON {
  55407. /** @hidden */
  55408. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55409. private _useDeltaForWorldStep;
  55410. world: any;
  55411. name: string;
  55412. private _physicsMaterials;
  55413. private _fixedTimeStep;
  55414. private _cannonRaycastResult;
  55415. private _raycastResult;
  55416. private _physicsBodysToRemoveAfterStep;
  55417. BJSCANNON: any;
  55418. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55419. setGravity(gravity: Vector3): void;
  55420. setTimeStep(timeStep: number): void;
  55421. getTimeStep(): number;
  55422. executeStep(delta: number): void;
  55423. private _removeMarkedPhysicsBodiesFromWorld;
  55424. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55425. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55426. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55427. private _processChildMeshes;
  55428. removePhysicsBody(impostor: PhysicsImpostor): void;
  55429. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55430. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55431. private _addMaterial;
  55432. private _checkWithEpsilon;
  55433. private _createShape;
  55434. private _createHeightmap;
  55435. private _minus90X;
  55436. private _plus90X;
  55437. private _tmpPosition;
  55438. private _tmpDeltaPosition;
  55439. private _tmpUnityRotation;
  55440. private _updatePhysicsBodyTransformation;
  55441. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55442. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55443. isSupported(): boolean;
  55444. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55445. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55446. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55447. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55448. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55449. getBodyMass(impostor: PhysicsImpostor): number;
  55450. getBodyFriction(impostor: PhysicsImpostor): number;
  55451. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55452. getBodyRestitution(impostor: PhysicsImpostor): number;
  55453. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55454. sleepBody(impostor: PhysicsImpostor): void;
  55455. wakeUpBody(impostor: PhysicsImpostor): void;
  55456. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55457. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55458. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55459. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55460. getRadius(impostor: PhysicsImpostor): number;
  55461. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55462. dispose(): void;
  55463. private _extendNamespace;
  55464. /**
  55465. * Does a raycast in the physics world
  55466. * @param from when should the ray start?
  55467. * @param to when should the ray end?
  55468. * @returns PhysicsRaycastResult
  55469. */
  55470. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55471. }
  55472. }
  55473. declare module BABYLON {
  55474. /** @hidden */
  55475. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55476. world: any;
  55477. name: string;
  55478. BJSOIMO: any;
  55479. private _raycastResult;
  55480. constructor(iterations?: number, oimoInjection?: any);
  55481. setGravity(gravity: Vector3): void;
  55482. setTimeStep(timeStep: number): void;
  55483. getTimeStep(): number;
  55484. private _tmpImpostorsArray;
  55485. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55486. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55487. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55488. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55489. private _tmpPositionVector;
  55490. removePhysicsBody(impostor: PhysicsImpostor): void;
  55491. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55492. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55493. isSupported(): boolean;
  55494. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55495. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55496. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55497. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55498. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55499. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55500. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55501. getBodyMass(impostor: PhysicsImpostor): number;
  55502. getBodyFriction(impostor: PhysicsImpostor): number;
  55503. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55504. getBodyRestitution(impostor: PhysicsImpostor): number;
  55505. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55506. sleepBody(impostor: PhysicsImpostor): void;
  55507. wakeUpBody(impostor: PhysicsImpostor): void;
  55508. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55509. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55510. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55511. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55512. getRadius(impostor: PhysicsImpostor): number;
  55513. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55514. dispose(): void;
  55515. /**
  55516. * Does a raycast in the physics world
  55517. * @param from when should the ray start?
  55518. * @param to when should the ray end?
  55519. * @returns PhysicsRaycastResult
  55520. */
  55521. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55522. }
  55523. }
  55524. declare module BABYLON {
  55525. /**
  55526. * Class containing static functions to help procedurally build meshes
  55527. */
  55528. export class RibbonBuilder {
  55529. /**
  55530. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55531. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55532. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55533. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55534. * * 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
  55535. * * 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
  55536. * * 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
  55537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55538. * * 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
  55539. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55540. * * 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
  55541. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55542. * * 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
  55543. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55545. * @param name defines the name of the mesh
  55546. * @param options defines the options used to create the mesh
  55547. * @param scene defines the hosting scene
  55548. * @returns the ribbon mesh
  55549. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55550. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55551. */
  55552. static CreateRibbon(name: string, options: {
  55553. pathArray: Vector3[][];
  55554. closeArray?: boolean;
  55555. closePath?: boolean;
  55556. offset?: number;
  55557. updatable?: boolean;
  55558. sideOrientation?: number;
  55559. frontUVs?: Vector4;
  55560. backUVs?: Vector4;
  55561. instance?: Mesh;
  55562. invertUV?: boolean;
  55563. uvs?: Vector2[];
  55564. colors?: Color4[];
  55565. }, scene?: Nullable<Scene>): Mesh;
  55566. }
  55567. }
  55568. declare module BABYLON {
  55569. /**
  55570. * Class containing static functions to help procedurally build meshes
  55571. */
  55572. export class ShapeBuilder {
  55573. /**
  55574. * 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.
  55575. * * 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.
  55576. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55577. * * 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.
  55578. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55579. * * 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
  55580. * * 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
  55581. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55583. * * 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
  55584. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55586. * @param name defines the name of the mesh
  55587. * @param options defines the options used to create the mesh
  55588. * @param scene defines the hosting scene
  55589. * @returns the extruded shape mesh
  55590. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55591. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55592. */
  55593. static ExtrudeShape(name: string, options: {
  55594. shape: Vector3[];
  55595. path: Vector3[];
  55596. scale?: number;
  55597. rotation?: number;
  55598. cap?: number;
  55599. updatable?: boolean;
  55600. sideOrientation?: number;
  55601. frontUVs?: Vector4;
  55602. backUVs?: Vector4;
  55603. instance?: Mesh;
  55604. invertUV?: boolean;
  55605. }, scene?: Nullable<Scene>): Mesh;
  55606. /**
  55607. * Creates an custom extruded shape mesh.
  55608. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55609. * * 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.
  55610. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55611. * * 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
  55612. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55613. * * 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
  55614. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55615. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55616. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55617. * * 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
  55618. * * 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
  55619. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55621. * * 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
  55622. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55624. * @param name defines the name of the mesh
  55625. * @param options defines the options used to create the mesh
  55626. * @param scene defines the hosting scene
  55627. * @returns the custom extruded shape mesh
  55628. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55629. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55630. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55631. */
  55632. static ExtrudeShapeCustom(name: string, options: {
  55633. shape: Vector3[];
  55634. path: Vector3[];
  55635. scaleFunction?: any;
  55636. rotationFunction?: any;
  55637. ribbonCloseArray?: boolean;
  55638. ribbonClosePath?: boolean;
  55639. cap?: number;
  55640. updatable?: boolean;
  55641. sideOrientation?: number;
  55642. frontUVs?: Vector4;
  55643. backUVs?: Vector4;
  55644. instance?: Mesh;
  55645. invertUV?: boolean;
  55646. }, scene?: Nullable<Scene>): Mesh;
  55647. private static _ExtrudeShapeGeneric;
  55648. }
  55649. }
  55650. declare module BABYLON {
  55651. /**
  55652. * AmmoJS Physics plugin
  55653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55654. * @see https://github.com/kripken/ammo.js/
  55655. */
  55656. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55657. private _useDeltaForWorldStep;
  55658. /**
  55659. * Reference to the Ammo library
  55660. */
  55661. bjsAMMO: any;
  55662. /**
  55663. * Created ammoJS world which physics bodies are added to
  55664. */
  55665. world: any;
  55666. /**
  55667. * Name of the plugin
  55668. */
  55669. name: string;
  55670. private _timeStep;
  55671. private _fixedTimeStep;
  55672. private _maxSteps;
  55673. private _tmpQuaternion;
  55674. private _tmpAmmoTransform;
  55675. private _tmpAmmoQuaternion;
  55676. private _tmpAmmoConcreteContactResultCallback;
  55677. private _collisionConfiguration;
  55678. private _dispatcher;
  55679. private _overlappingPairCache;
  55680. private _solver;
  55681. private _softBodySolver;
  55682. private _tmpAmmoVectorA;
  55683. private _tmpAmmoVectorB;
  55684. private _tmpAmmoVectorC;
  55685. private _tmpAmmoVectorD;
  55686. private _tmpContactCallbackResult;
  55687. private _tmpAmmoVectorRCA;
  55688. private _tmpAmmoVectorRCB;
  55689. private _raycastResult;
  55690. private static readonly DISABLE_COLLISION_FLAG;
  55691. private static readonly KINEMATIC_FLAG;
  55692. private static readonly DISABLE_DEACTIVATION_FLAG;
  55693. /**
  55694. * Initializes the ammoJS plugin
  55695. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55696. * @param ammoInjection can be used to inject your own ammo reference
  55697. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55698. */
  55699. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55700. /**
  55701. * Sets the gravity of the physics world (m/(s^2))
  55702. * @param gravity Gravity to set
  55703. */
  55704. setGravity(gravity: Vector3): void;
  55705. /**
  55706. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55707. * @param timeStep timestep to use in seconds
  55708. */
  55709. setTimeStep(timeStep: number): void;
  55710. /**
  55711. * 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)
  55712. * @param fixedTimeStep fixedTimeStep to use in seconds
  55713. */
  55714. setFixedTimeStep(fixedTimeStep: number): void;
  55715. /**
  55716. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55717. * @param maxSteps the maximum number of steps by the physics engine per frame
  55718. */
  55719. setMaxSteps(maxSteps: number): void;
  55720. /**
  55721. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55722. * @returns the current timestep in seconds
  55723. */
  55724. getTimeStep(): number;
  55725. /**
  55726. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55727. */
  55728. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55729. private _isImpostorInContact;
  55730. private _isImpostorPairInContact;
  55731. private _stepSimulation;
  55732. /**
  55733. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55734. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55735. * After the step the babylon meshes are set to the position of the physics imposters
  55736. * @param delta amount of time to step forward
  55737. * @param impostors array of imposters to update before/after the step
  55738. */
  55739. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55740. /**
  55741. * Update babylon mesh to match physics world object
  55742. * @param impostor imposter to match
  55743. */
  55744. private _afterSoftStep;
  55745. /**
  55746. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55747. * @param impostor imposter to match
  55748. */
  55749. private _ropeStep;
  55750. /**
  55751. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55752. * @param impostor imposter to match
  55753. */
  55754. private _softbodyOrClothStep;
  55755. private _tmpVector;
  55756. private _tmpMatrix;
  55757. /**
  55758. * Applies an impulse on the imposter
  55759. * @param impostor imposter to apply impulse to
  55760. * @param force amount of force to be applied to the imposter
  55761. * @param contactPoint the location to apply the impulse on the imposter
  55762. */
  55763. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55764. /**
  55765. * Applies a force on the imposter
  55766. * @param impostor imposter to apply force
  55767. * @param force amount of force to be applied to the imposter
  55768. * @param contactPoint the location to apply the force on the imposter
  55769. */
  55770. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55771. /**
  55772. * Creates a physics body using the plugin
  55773. * @param impostor the imposter to create the physics body on
  55774. */
  55775. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55776. /**
  55777. * Removes the physics body from the imposter and disposes of the body's memory
  55778. * @param impostor imposter to remove the physics body from
  55779. */
  55780. removePhysicsBody(impostor: PhysicsImpostor): void;
  55781. /**
  55782. * Generates a joint
  55783. * @param impostorJoint the imposter joint to create the joint with
  55784. */
  55785. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55786. /**
  55787. * Removes a joint
  55788. * @param impostorJoint the imposter joint to remove the joint from
  55789. */
  55790. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55791. private _addMeshVerts;
  55792. /**
  55793. * Initialise the soft body vertices to match its object's (mesh) vertices
  55794. * Softbody vertices (nodes) are in world space and to match this
  55795. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55796. * @param impostor to create the softbody for
  55797. */
  55798. private _softVertexData;
  55799. /**
  55800. * Create an impostor's soft body
  55801. * @param impostor to create the softbody for
  55802. */
  55803. private _createSoftbody;
  55804. /**
  55805. * Create cloth for an impostor
  55806. * @param impostor to create the softbody for
  55807. */
  55808. private _createCloth;
  55809. /**
  55810. * Create rope for an impostor
  55811. * @param impostor to create the softbody for
  55812. */
  55813. private _createRope;
  55814. /**
  55815. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55816. * @param impostor to create the custom physics shape for
  55817. */
  55818. private _createCustom;
  55819. private _addHullVerts;
  55820. private _createShape;
  55821. /**
  55822. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55823. * @param impostor imposter containing the physics body and babylon object
  55824. */
  55825. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55826. /**
  55827. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55828. * @param impostor imposter containing the physics body and babylon object
  55829. * @param newPosition new position
  55830. * @param newRotation new rotation
  55831. */
  55832. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55833. /**
  55834. * If this plugin is supported
  55835. * @returns true if its supported
  55836. */
  55837. isSupported(): boolean;
  55838. /**
  55839. * Sets the linear velocity of the physics body
  55840. * @param impostor imposter to set the velocity on
  55841. * @param velocity velocity to set
  55842. */
  55843. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55844. /**
  55845. * Sets the angular velocity of the physics body
  55846. * @param impostor imposter to set the velocity on
  55847. * @param velocity velocity to set
  55848. */
  55849. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55850. /**
  55851. * gets the linear velocity
  55852. * @param impostor imposter to get linear velocity from
  55853. * @returns linear velocity
  55854. */
  55855. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55856. /**
  55857. * gets the angular velocity
  55858. * @param impostor imposter to get angular velocity from
  55859. * @returns angular velocity
  55860. */
  55861. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55862. /**
  55863. * Sets the mass of physics body
  55864. * @param impostor imposter to set the mass on
  55865. * @param mass mass to set
  55866. */
  55867. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55868. /**
  55869. * Gets the mass of the physics body
  55870. * @param impostor imposter to get the mass from
  55871. * @returns mass
  55872. */
  55873. getBodyMass(impostor: PhysicsImpostor): number;
  55874. /**
  55875. * Gets friction of the impostor
  55876. * @param impostor impostor to get friction from
  55877. * @returns friction value
  55878. */
  55879. getBodyFriction(impostor: PhysicsImpostor): number;
  55880. /**
  55881. * Sets friction of the impostor
  55882. * @param impostor impostor to set friction on
  55883. * @param friction friction value
  55884. */
  55885. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55886. /**
  55887. * Gets restitution of the impostor
  55888. * @param impostor impostor to get restitution from
  55889. * @returns restitution value
  55890. */
  55891. getBodyRestitution(impostor: PhysicsImpostor): number;
  55892. /**
  55893. * Sets resitution of the impostor
  55894. * @param impostor impostor to set resitution on
  55895. * @param restitution resitution value
  55896. */
  55897. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55898. /**
  55899. * Gets pressure inside the impostor
  55900. * @param impostor impostor to get pressure from
  55901. * @returns pressure value
  55902. */
  55903. getBodyPressure(impostor: PhysicsImpostor): number;
  55904. /**
  55905. * Sets pressure inside a soft body impostor
  55906. * Cloth and rope must remain 0 pressure
  55907. * @param impostor impostor to set pressure on
  55908. * @param pressure pressure value
  55909. */
  55910. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55911. /**
  55912. * Gets stiffness of the impostor
  55913. * @param impostor impostor to get stiffness from
  55914. * @returns pressure value
  55915. */
  55916. getBodyStiffness(impostor: PhysicsImpostor): number;
  55917. /**
  55918. * Sets stiffness of the impostor
  55919. * @param impostor impostor to set stiffness on
  55920. * @param stiffness stiffness value from 0 to 1
  55921. */
  55922. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55923. /**
  55924. * Gets velocityIterations of the impostor
  55925. * @param impostor impostor to get velocity iterations from
  55926. * @returns velocityIterations value
  55927. */
  55928. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55929. /**
  55930. * Sets velocityIterations of the impostor
  55931. * @param impostor impostor to set velocity iterations on
  55932. * @param velocityIterations velocityIterations value
  55933. */
  55934. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55935. /**
  55936. * Gets positionIterations of the impostor
  55937. * @param impostor impostor to get position iterations from
  55938. * @returns positionIterations value
  55939. */
  55940. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55941. /**
  55942. * Sets positionIterations of the impostor
  55943. * @param impostor impostor to set position on
  55944. * @param positionIterations positionIterations value
  55945. */
  55946. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55947. /**
  55948. * Append an anchor to a cloth object
  55949. * @param impostor is the cloth impostor to add anchor to
  55950. * @param otherImpostor is the rigid impostor to anchor to
  55951. * @param width ratio across width from 0 to 1
  55952. * @param height ratio up height from 0 to 1
  55953. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55954. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55955. */
  55956. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55957. /**
  55958. * Append an hook to a rope object
  55959. * @param impostor is the rope impostor to add hook to
  55960. * @param otherImpostor is the rigid impostor to hook to
  55961. * @param length ratio along the rope from 0 to 1
  55962. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55963. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55964. */
  55965. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55966. /**
  55967. * Sleeps the physics body and stops it from being active
  55968. * @param impostor impostor to sleep
  55969. */
  55970. sleepBody(impostor: PhysicsImpostor): void;
  55971. /**
  55972. * Activates the physics body
  55973. * @param impostor impostor to activate
  55974. */
  55975. wakeUpBody(impostor: PhysicsImpostor): void;
  55976. /**
  55977. * Updates the distance parameters of the joint
  55978. * @param joint joint to update
  55979. * @param maxDistance maximum distance of the joint
  55980. * @param minDistance minimum distance of the joint
  55981. */
  55982. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55983. /**
  55984. * Sets a motor on the joint
  55985. * @param joint joint to set motor on
  55986. * @param speed speed of the motor
  55987. * @param maxForce maximum force of the motor
  55988. * @param motorIndex index of the motor
  55989. */
  55990. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55991. /**
  55992. * Sets the motors limit
  55993. * @param joint joint to set limit on
  55994. * @param upperLimit upper limit
  55995. * @param lowerLimit lower limit
  55996. */
  55997. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55998. /**
  55999. * Syncs the position and rotation of a mesh with the impostor
  56000. * @param mesh mesh to sync
  56001. * @param impostor impostor to update the mesh with
  56002. */
  56003. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56004. /**
  56005. * Gets the radius of the impostor
  56006. * @param impostor impostor to get radius from
  56007. * @returns the radius
  56008. */
  56009. getRadius(impostor: PhysicsImpostor): number;
  56010. /**
  56011. * Gets the box size of the impostor
  56012. * @param impostor impostor to get box size from
  56013. * @param result the resulting box size
  56014. */
  56015. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56016. /**
  56017. * Disposes of the impostor
  56018. */
  56019. dispose(): void;
  56020. /**
  56021. * Does a raycast in the physics world
  56022. * @param from when should the ray start?
  56023. * @param to when should the ray end?
  56024. * @returns PhysicsRaycastResult
  56025. */
  56026. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56027. }
  56028. }
  56029. declare module BABYLON {
  56030. interface AbstractScene {
  56031. /**
  56032. * The list of reflection probes added to the scene
  56033. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56034. */
  56035. reflectionProbes: Array<ReflectionProbe>;
  56036. /**
  56037. * Removes the given reflection probe from this scene.
  56038. * @param toRemove The reflection probe to remove
  56039. * @returns The index of the removed reflection probe
  56040. */
  56041. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56042. /**
  56043. * Adds the given reflection probe to this scene.
  56044. * @param newReflectionProbe The reflection probe to add
  56045. */
  56046. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56047. }
  56048. /**
  56049. * Class used to generate realtime reflection / refraction cube textures
  56050. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56051. */
  56052. export class ReflectionProbe {
  56053. /** defines the name of the probe */
  56054. name: string;
  56055. private _scene;
  56056. private _renderTargetTexture;
  56057. private _projectionMatrix;
  56058. private _viewMatrix;
  56059. private _target;
  56060. private _add;
  56061. private _attachedMesh;
  56062. private _invertYAxis;
  56063. /** Gets or sets probe position (center of the cube map) */
  56064. position: Vector3;
  56065. /**
  56066. * Creates a new reflection probe
  56067. * @param name defines the name of the probe
  56068. * @param size defines the texture resolution (for each face)
  56069. * @param scene defines the hosting scene
  56070. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56071. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56072. */
  56073. constructor(
  56074. /** defines the name of the probe */
  56075. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56076. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56077. get samples(): number;
  56078. set samples(value: number);
  56079. /** Gets or sets the refresh rate to use (on every frame by default) */
  56080. get refreshRate(): number;
  56081. set refreshRate(value: number);
  56082. /**
  56083. * Gets the hosting scene
  56084. * @returns a Scene
  56085. */
  56086. getScene(): Scene;
  56087. /** Gets the internal CubeTexture used to render to */
  56088. get cubeTexture(): RenderTargetTexture;
  56089. /** Gets the list of meshes to render */
  56090. get renderList(): Nullable<AbstractMesh[]>;
  56091. /**
  56092. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56093. * @param mesh defines the mesh to attach to
  56094. */
  56095. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56096. /**
  56097. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56098. * @param renderingGroupId The rendering group id corresponding to its index
  56099. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56100. */
  56101. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56102. /**
  56103. * Clean all associated resources
  56104. */
  56105. dispose(): void;
  56106. /**
  56107. * Converts the reflection probe information to a readable string for debug purpose.
  56108. * @param fullDetails Supports for multiple levels of logging within scene loading
  56109. * @returns the human readable reflection probe info
  56110. */
  56111. toString(fullDetails?: boolean): string;
  56112. /**
  56113. * Get the class name of the relfection probe.
  56114. * @returns "ReflectionProbe"
  56115. */
  56116. getClassName(): string;
  56117. /**
  56118. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56119. * @returns The JSON representation of the texture
  56120. */
  56121. serialize(): any;
  56122. /**
  56123. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56124. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56125. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56126. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56127. * @returns The parsed reflection probe if successful
  56128. */
  56129. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56130. }
  56131. }
  56132. declare module BABYLON {
  56133. /** @hidden */
  56134. export var _BabylonLoaderRegistered: boolean;
  56135. /**
  56136. * Helps setting up some configuration for the babylon file loader.
  56137. */
  56138. export class BabylonFileLoaderConfiguration {
  56139. /**
  56140. * The loader does not allow injecting custom physix engine into the plugins.
  56141. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56142. * So you could set this variable to your engine import to make it work.
  56143. */
  56144. static LoaderInjectedPhysicsEngine: any;
  56145. }
  56146. }
  56147. declare module BABYLON {
  56148. /**
  56149. * The Physically based simple base material of BJS.
  56150. *
  56151. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56152. * It is used as the base class for both the specGloss and metalRough conventions.
  56153. */
  56154. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56155. /**
  56156. * Number of Simultaneous lights allowed on the material.
  56157. */
  56158. maxSimultaneousLights: number;
  56159. /**
  56160. * If sets to true, disables all the lights affecting the material.
  56161. */
  56162. disableLighting: boolean;
  56163. /**
  56164. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56165. */
  56166. environmentTexture: BaseTexture;
  56167. /**
  56168. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56169. */
  56170. invertNormalMapX: boolean;
  56171. /**
  56172. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56173. */
  56174. invertNormalMapY: boolean;
  56175. /**
  56176. * Normal map used in the model.
  56177. */
  56178. normalTexture: BaseTexture;
  56179. /**
  56180. * Emissivie color used to self-illuminate the model.
  56181. */
  56182. emissiveColor: Color3;
  56183. /**
  56184. * Emissivie texture used to self-illuminate the model.
  56185. */
  56186. emissiveTexture: BaseTexture;
  56187. /**
  56188. * Occlusion Channel Strenght.
  56189. */
  56190. occlusionStrength: number;
  56191. /**
  56192. * Occlusion Texture of the material (adding extra occlusion effects).
  56193. */
  56194. occlusionTexture: BaseTexture;
  56195. /**
  56196. * Defines the alpha limits in alpha test mode.
  56197. */
  56198. alphaCutOff: number;
  56199. /**
  56200. * Gets the current double sided mode.
  56201. */
  56202. get doubleSided(): boolean;
  56203. /**
  56204. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56205. */
  56206. set doubleSided(value: boolean);
  56207. /**
  56208. * Stores the pre-calculated light information of a mesh in a texture.
  56209. */
  56210. lightmapTexture: BaseTexture;
  56211. /**
  56212. * If true, the light map contains occlusion information instead of lighting info.
  56213. */
  56214. useLightmapAsShadowmap: boolean;
  56215. /**
  56216. * Instantiates a new PBRMaterial instance.
  56217. *
  56218. * @param name The material name
  56219. * @param scene The scene the material will be use in.
  56220. */
  56221. constructor(name: string, scene: Scene);
  56222. getClassName(): string;
  56223. }
  56224. }
  56225. declare module BABYLON {
  56226. /**
  56227. * The PBR material of BJS following the metal roughness convention.
  56228. *
  56229. * This fits to the PBR convention in the GLTF definition:
  56230. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56231. */
  56232. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56233. /**
  56234. * The base color has two different interpretations depending on the value of metalness.
  56235. * When the material is a metal, the base color is the specific measured reflectance value
  56236. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56237. * of the material.
  56238. */
  56239. baseColor: Color3;
  56240. /**
  56241. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56242. * well as opacity information in the alpha channel.
  56243. */
  56244. baseTexture: BaseTexture;
  56245. /**
  56246. * Specifies the metallic scalar value of the material.
  56247. * Can also be used to scale the metalness values of the metallic texture.
  56248. */
  56249. metallic: number;
  56250. /**
  56251. * Specifies the roughness scalar value of the material.
  56252. * Can also be used to scale the roughness values of the metallic texture.
  56253. */
  56254. roughness: number;
  56255. /**
  56256. * Texture containing both the metallic value in the B channel and the
  56257. * roughness value in the G channel to keep better precision.
  56258. */
  56259. metallicRoughnessTexture: BaseTexture;
  56260. /**
  56261. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56262. *
  56263. * @param name The material name
  56264. * @param scene The scene the material will be use in.
  56265. */
  56266. constructor(name: string, scene: Scene);
  56267. /**
  56268. * Return the currrent class name of the material.
  56269. */
  56270. getClassName(): string;
  56271. /**
  56272. * Makes a duplicate of the current material.
  56273. * @param name - name to use for the new material.
  56274. */
  56275. clone(name: string): PBRMetallicRoughnessMaterial;
  56276. /**
  56277. * Serialize the material to a parsable JSON object.
  56278. */
  56279. serialize(): any;
  56280. /**
  56281. * Parses a JSON object correponding to the serialize function.
  56282. */
  56283. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56284. }
  56285. }
  56286. declare module BABYLON {
  56287. /**
  56288. * The PBR material of BJS following the specular glossiness convention.
  56289. *
  56290. * This fits to the PBR convention in the GLTF definition:
  56291. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56292. */
  56293. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56294. /**
  56295. * Specifies the diffuse color of the material.
  56296. */
  56297. diffuseColor: Color3;
  56298. /**
  56299. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56300. * channel.
  56301. */
  56302. diffuseTexture: BaseTexture;
  56303. /**
  56304. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56305. */
  56306. specularColor: Color3;
  56307. /**
  56308. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56309. */
  56310. glossiness: number;
  56311. /**
  56312. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56313. */
  56314. specularGlossinessTexture: BaseTexture;
  56315. /**
  56316. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56317. *
  56318. * @param name The material name
  56319. * @param scene The scene the material will be use in.
  56320. */
  56321. constructor(name: string, scene: Scene);
  56322. /**
  56323. * Return the currrent class name of the material.
  56324. */
  56325. getClassName(): string;
  56326. /**
  56327. * Makes a duplicate of the current material.
  56328. * @param name - name to use for the new material.
  56329. */
  56330. clone(name: string): PBRSpecularGlossinessMaterial;
  56331. /**
  56332. * Serialize the material to a parsable JSON object.
  56333. */
  56334. serialize(): any;
  56335. /**
  56336. * Parses a JSON object correponding to the serialize function.
  56337. */
  56338. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56339. }
  56340. }
  56341. declare module BABYLON {
  56342. /**
  56343. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56344. * It can help converting any input color in a desired output one. This can then be used to create effects
  56345. * from sepia, black and white to sixties or futuristic rendering...
  56346. *
  56347. * The only supported format is currently 3dl.
  56348. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56349. */
  56350. export class ColorGradingTexture extends BaseTexture {
  56351. /**
  56352. * The current texture matrix. (will always be identity in color grading texture)
  56353. */
  56354. private _textureMatrix;
  56355. /**
  56356. * The texture URL.
  56357. */
  56358. url: string;
  56359. /**
  56360. * Empty line regex stored for GC.
  56361. */
  56362. private static _noneEmptyLineRegex;
  56363. private _engine;
  56364. /**
  56365. * Instantiates a ColorGradingTexture from the following parameters.
  56366. *
  56367. * @param url The location of the color gradind data (currently only supporting 3dl)
  56368. * @param scene The scene the texture will be used in
  56369. */
  56370. constructor(url: string, scene: Scene);
  56371. /**
  56372. * Returns the texture matrix used in most of the material.
  56373. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56374. */
  56375. getTextureMatrix(): Matrix;
  56376. /**
  56377. * Occurs when the file being loaded is a .3dl LUT file.
  56378. */
  56379. private load3dlTexture;
  56380. /**
  56381. * Starts the loading process of the texture.
  56382. */
  56383. private loadTexture;
  56384. /**
  56385. * Clones the color gradind texture.
  56386. */
  56387. clone(): ColorGradingTexture;
  56388. /**
  56389. * Called during delayed load for textures.
  56390. */
  56391. delayLoad(): void;
  56392. /**
  56393. * Parses a color grading texture serialized by Babylon.
  56394. * @param parsedTexture The texture information being parsedTexture
  56395. * @param scene The scene to load the texture in
  56396. * @param rootUrl The root url of the data assets to load
  56397. * @return A color gradind texture
  56398. */
  56399. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56400. /**
  56401. * Serializes the LUT texture to json format.
  56402. */
  56403. serialize(): any;
  56404. }
  56405. }
  56406. declare module BABYLON {
  56407. /**
  56408. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56409. */
  56410. export class EquiRectangularCubeTexture extends BaseTexture {
  56411. /** The six faces of the cube. */
  56412. private static _FacesMapping;
  56413. private _noMipmap;
  56414. private _onLoad;
  56415. private _onError;
  56416. /** The size of the cubemap. */
  56417. private _size;
  56418. /** The buffer of the image. */
  56419. private _buffer;
  56420. /** The width of the input image. */
  56421. private _width;
  56422. /** The height of the input image. */
  56423. private _height;
  56424. /** The URL to the image. */
  56425. url: string;
  56426. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56427. coordinatesMode: number;
  56428. /**
  56429. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56430. * @param url The location of the image
  56431. * @param scene The scene the texture will be used in
  56432. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56433. * @param noMipmap Forces to not generate the mipmap if true
  56434. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56435. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56436. * @param onLoad — defines a callback called when texture is loaded
  56437. * @param onError — defines a callback called if there is an error
  56438. */
  56439. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56440. /**
  56441. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56442. */
  56443. private loadImage;
  56444. /**
  56445. * Convert the image buffer into a cubemap and create a CubeTexture.
  56446. */
  56447. private loadTexture;
  56448. /**
  56449. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56450. * @param buffer The ArrayBuffer that should be converted.
  56451. * @returns The buffer as Float32Array.
  56452. */
  56453. private getFloat32ArrayFromArrayBuffer;
  56454. /**
  56455. * Get the current class name of the texture useful for serialization or dynamic coding.
  56456. * @returns "EquiRectangularCubeTexture"
  56457. */
  56458. getClassName(): string;
  56459. /**
  56460. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56461. * @returns A clone of the current EquiRectangularCubeTexture.
  56462. */
  56463. clone(): EquiRectangularCubeTexture;
  56464. }
  56465. }
  56466. declare module BABYLON {
  56467. /**
  56468. * Based on jsTGALoader - Javascript loader for TGA file
  56469. * By Vincent Thibault
  56470. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56471. */
  56472. export class TGATools {
  56473. private static _TYPE_INDEXED;
  56474. private static _TYPE_RGB;
  56475. private static _TYPE_GREY;
  56476. private static _TYPE_RLE_INDEXED;
  56477. private static _TYPE_RLE_RGB;
  56478. private static _TYPE_RLE_GREY;
  56479. private static _ORIGIN_MASK;
  56480. private static _ORIGIN_SHIFT;
  56481. private static _ORIGIN_BL;
  56482. private static _ORIGIN_BR;
  56483. private static _ORIGIN_UL;
  56484. private static _ORIGIN_UR;
  56485. /**
  56486. * Gets the header of a TGA file
  56487. * @param data defines the TGA data
  56488. * @returns the header
  56489. */
  56490. static GetTGAHeader(data: Uint8Array): any;
  56491. /**
  56492. * Uploads TGA content to a Babylon Texture
  56493. * @hidden
  56494. */
  56495. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56496. /** @hidden */
  56497. 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;
  56498. /** @hidden */
  56499. 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;
  56500. /** @hidden */
  56501. 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;
  56502. /** @hidden */
  56503. 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;
  56504. /** @hidden */
  56505. 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;
  56506. /** @hidden */
  56507. 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;
  56508. }
  56509. }
  56510. declare module BABYLON {
  56511. /**
  56512. * Implementation of the TGA Texture Loader.
  56513. * @hidden
  56514. */
  56515. export class _TGATextureLoader implements IInternalTextureLoader {
  56516. /**
  56517. * Defines wether the loader supports cascade loading the different faces.
  56518. */
  56519. readonly supportCascades: boolean;
  56520. /**
  56521. * This returns if the loader support the current file information.
  56522. * @param extension defines the file extension of the file being loaded
  56523. * @returns true if the loader can load the specified file
  56524. */
  56525. canLoad(extension: string): boolean;
  56526. /**
  56527. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56528. * @param data contains the texture data
  56529. * @param texture defines the BabylonJS internal texture
  56530. * @param createPolynomials will be true if polynomials have been requested
  56531. * @param onLoad defines the callback to trigger once the texture is ready
  56532. * @param onError defines the callback to trigger in case of error
  56533. */
  56534. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56535. /**
  56536. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56537. * @param data contains the texture data
  56538. * @param texture defines the BabylonJS internal texture
  56539. * @param callback defines the method to call once ready to upload
  56540. */
  56541. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56542. }
  56543. }
  56544. declare module BABYLON {
  56545. /**
  56546. * Info about the .basis files
  56547. */
  56548. class BasisFileInfo {
  56549. /**
  56550. * If the file has alpha
  56551. */
  56552. hasAlpha: boolean;
  56553. /**
  56554. * Info about each image of the basis file
  56555. */
  56556. images: Array<{
  56557. levels: Array<{
  56558. width: number;
  56559. height: number;
  56560. transcodedPixels: ArrayBufferView;
  56561. }>;
  56562. }>;
  56563. }
  56564. /**
  56565. * Result of transcoding a basis file
  56566. */
  56567. class TranscodeResult {
  56568. /**
  56569. * Info about the .basis file
  56570. */
  56571. fileInfo: BasisFileInfo;
  56572. /**
  56573. * Format to use when loading the file
  56574. */
  56575. format: number;
  56576. }
  56577. /**
  56578. * Configuration options for the Basis transcoder
  56579. */
  56580. export class BasisTranscodeConfiguration {
  56581. /**
  56582. * Supported compression formats used to determine the supported output format of the transcoder
  56583. */
  56584. supportedCompressionFormats?: {
  56585. /**
  56586. * etc1 compression format
  56587. */
  56588. etc1?: boolean;
  56589. /**
  56590. * s3tc compression format
  56591. */
  56592. s3tc?: boolean;
  56593. /**
  56594. * pvrtc compression format
  56595. */
  56596. pvrtc?: boolean;
  56597. /**
  56598. * etc2 compression format
  56599. */
  56600. etc2?: boolean;
  56601. };
  56602. /**
  56603. * If mipmap levels should be loaded for transcoded images (Default: true)
  56604. */
  56605. loadMipmapLevels?: boolean;
  56606. /**
  56607. * Index of a single image to load (Default: all images)
  56608. */
  56609. loadSingleImage?: number;
  56610. }
  56611. /**
  56612. * Used to load .Basis files
  56613. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56614. */
  56615. export class BasisTools {
  56616. private static _IgnoreSupportedFormats;
  56617. /**
  56618. * URL to use when loading the basis transcoder
  56619. */
  56620. static JSModuleURL: string;
  56621. /**
  56622. * URL to use when loading the wasm module for the transcoder
  56623. */
  56624. static WasmModuleURL: string;
  56625. /**
  56626. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56627. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56628. * @returns internal format corresponding to the Basis format
  56629. */
  56630. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56631. private static _WorkerPromise;
  56632. private static _Worker;
  56633. private static _actionId;
  56634. private static _CreateWorkerAsync;
  56635. /**
  56636. * Transcodes a loaded image file to compressed pixel data
  56637. * @param data image data to transcode
  56638. * @param config configuration options for the transcoding
  56639. * @returns a promise resulting in the transcoded image
  56640. */
  56641. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56642. /**
  56643. * Loads a texture from the transcode result
  56644. * @param texture texture load to
  56645. * @param transcodeResult the result of transcoding the basis file to load from
  56646. */
  56647. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56648. }
  56649. }
  56650. declare module BABYLON {
  56651. /**
  56652. * Loader for .basis file format
  56653. */
  56654. export class _BasisTextureLoader implements IInternalTextureLoader {
  56655. /**
  56656. * Defines whether the loader supports cascade loading the different faces.
  56657. */
  56658. readonly supportCascades: boolean;
  56659. /**
  56660. * This returns if the loader support the current file information.
  56661. * @param extension defines the file extension of the file being loaded
  56662. * @returns true if the loader can load the specified file
  56663. */
  56664. canLoad(extension: string): boolean;
  56665. /**
  56666. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56667. * @param data contains the texture data
  56668. * @param texture defines the BabylonJS internal texture
  56669. * @param createPolynomials will be true if polynomials have been requested
  56670. * @param onLoad defines the callback to trigger once the texture is ready
  56671. * @param onError defines the callback to trigger in case of error
  56672. */
  56673. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56674. /**
  56675. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56676. * @param data contains the texture data
  56677. * @param texture defines the BabylonJS internal texture
  56678. * @param callback defines the method to call once ready to upload
  56679. */
  56680. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56681. }
  56682. }
  56683. declare module BABYLON {
  56684. /**
  56685. * 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.
  56686. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56687. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56688. */
  56689. export class CustomProceduralTexture extends ProceduralTexture {
  56690. private _animate;
  56691. private _time;
  56692. private _config;
  56693. private _texturePath;
  56694. /**
  56695. * Instantiates a new Custom Procedural Texture.
  56696. * 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.
  56697. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56698. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56699. * @param name Define the name of the texture
  56700. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56701. * @param size Define the size of the texture to create
  56702. * @param scene Define the scene the texture belongs to
  56703. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56704. * @param generateMipMaps Define if the texture should creates mip maps or not
  56705. */
  56706. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56707. private _loadJson;
  56708. /**
  56709. * Is the texture ready to be used ? (rendered at least once)
  56710. * @returns true if ready, otherwise, false.
  56711. */
  56712. isReady(): boolean;
  56713. /**
  56714. * Render the texture to its associated render target.
  56715. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56716. */
  56717. render(useCameraPostProcess?: boolean): void;
  56718. /**
  56719. * Update the list of dependant textures samplers in the shader.
  56720. */
  56721. updateTextures(): void;
  56722. /**
  56723. * Update the uniform values of the procedural texture in the shader.
  56724. */
  56725. updateShaderUniforms(): void;
  56726. /**
  56727. * Define if the texture animates or not.
  56728. */
  56729. get animate(): boolean;
  56730. set animate(value: boolean);
  56731. }
  56732. }
  56733. declare module BABYLON {
  56734. /** @hidden */
  56735. export var noisePixelShader: {
  56736. name: string;
  56737. shader: string;
  56738. };
  56739. }
  56740. declare module BABYLON {
  56741. /**
  56742. * Class used to generate noise procedural textures
  56743. */
  56744. export class NoiseProceduralTexture extends ProceduralTexture {
  56745. private _time;
  56746. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56747. brightness: number;
  56748. /** Defines the number of octaves to process */
  56749. octaves: number;
  56750. /** Defines the level of persistence (0.8 by default) */
  56751. persistence: number;
  56752. /** Gets or sets animation speed factor (default is 1) */
  56753. animationSpeedFactor: number;
  56754. /**
  56755. * Creates a new NoiseProceduralTexture
  56756. * @param name defines the name fo the texture
  56757. * @param size defines the size of the texture (default is 256)
  56758. * @param scene defines the hosting scene
  56759. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56760. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56761. */
  56762. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56763. private _updateShaderUniforms;
  56764. protected _getDefines(): string;
  56765. /** Generate the current state of the procedural texture */
  56766. render(useCameraPostProcess?: boolean): void;
  56767. /**
  56768. * Serializes this noise procedural texture
  56769. * @returns a serialized noise procedural texture object
  56770. */
  56771. serialize(): any;
  56772. /**
  56773. * Clone the texture.
  56774. * @returns the cloned texture
  56775. */
  56776. clone(): NoiseProceduralTexture;
  56777. /**
  56778. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56779. * @param parsedTexture defines parsed texture data
  56780. * @param scene defines the current scene
  56781. * @param rootUrl defines the root URL containing noise procedural texture information
  56782. * @returns a parsed NoiseProceduralTexture
  56783. */
  56784. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56785. }
  56786. }
  56787. declare module BABYLON {
  56788. /**
  56789. * Raw cube texture where the raw buffers are passed in
  56790. */
  56791. export class RawCubeTexture extends CubeTexture {
  56792. /**
  56793. * Creates a cube texture where the raw buffers are passed in.
  56794. * @param scene defines the scene the texture is attached to
  56795. * @param data defines the array of data to use to create each face
  56796. * @param size defines the size of the textures
  56797. * @param format defines the format of the data
  56798. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56799. * @param generateMipMaps defines if the engine should generate the mip levels
  56800. * @param invertY defines if data must be stored with Y axis inverted
  56801. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56802. * @param compression defines the compression used (null by default)
  56803. */
  56804. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56805. /**
  56806. * Updates the raw cube texture.
  56807. * @param data defines the data to store
  56808. * @param format defines the data format
  56809. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56810. * @param invertY defines if data must be stored with Y axis inverted
  56811. * @param compression defines the compression used (null by default)
  56812. * @param level defines which level of the texture to update
  56813. */
  56814. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56815. /**
  56816. * Updates a raw cube texture with RGBD encoded data.
  56817. * @param data defines the array of data [mipmap][face] to use to create each face
  56818. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56819. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56820. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56821. * @returns a promsie that resolves when the operation is complete
  56822. */
  56823. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56824. /**
  56825. * Clones the raw cube texture.
  56826. * @return a new cube texture
  56827. */
  56828. clone(): CubeTexture;
  56829. /** @hidden */
  56830. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56831. }
  56832. }
  56833. declare module BABYLON {
  56834. /**
  56835. * Class used to store 3D textures containing user data
  56836. */
  56837. export class RawTexture3D extends Texture {
  56838. /** Gets or sets the texture format to use */
  56839. format: number;
  56840. private _engine;
  56841. /**
  56842. * Create a new RawTexture3D
  56843. * @param data defines the data of the texture
  56844. * @param width defines the width of the texture
  56845. * @param height defines the height of the texture
  56846. * @param depth defines the depth of the texture
  56847. * @param format defines the texture format to use
  56848. * @param scene defines the hosting scene
  56849. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56850. * @param invertY defines if texture must be stored with Y axis inverted
  56851. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56852. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56853. */
  56854. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56855. /** Gets or sets the texture format to use */
  56856. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56857. /**
  56858. * Update the texture with new data
  56859. * @param data defines the data to store in the texture
  56860. */
  56861. update(data: ArrayBufferView): void;
  56862. }
  56863. }
  56864. declare module BABYLON {
  56865. /**
  56866. * Class used to store 2D array textures containing user data
  56867. */
  56868. export class RawTexture2DArray extends Texture {
  56869. /** Gets or sets the texture format to use */
  56870. format: number;
  56871. private _engine;
  56872. /**
  56873. * Create a new RawTexture2DArray
  56874. * @param data defines the data of the texture
  56875. * @param width defines the width of the texture
  56876. * @param height defines the height of the texture
  56877. * @param depth defines the number of layers of the texture
  56878. * @param format defines the texture format to use
  56879. * @param scene defines the hosting scene
  56880. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56881. * @param invertY defines if texture must be stored with Y axis inverted
  56882. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56883. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56884. */
  56885. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56886. /** Gets or sets the texture format to use */
  56887. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56888. /**
  56889. * Update the texture with new data
  56890. * @param data defines the data to store in the texture
  56891. */
  56892. update(data: ArrayBufferView): void;
  56893. }
  56894. }
  56895. declare module BABYLON {
  56896. /**
  56897. * Creates a refraction texture used by refraction channel of the standard material.
  56898. * It is like a mirror but to see through a material.
  56899. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56900. */
  56901. export class RefractionTexture extends RenderTargetTexture {
  56902. /**
  56903. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56904. * 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.
  56905. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56906. */
  56907. refractionPlane: Plane;
  56908. /**
  56909. * Define how deep under the surface we should see.
  56910. */
  56911. depth: number;
  56912. /**
  56913. * Creates a refraction texture used by refraction channel of the standard material.
  56914. * It is like a mirror but to see through a material.
  56915. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56916. * @param name Define the texture name
  56917. * @param size Define the size of the underlying texture
  56918. * @param scene Define the scene the refraction belongs to
  56919. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56920. */
  56921. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56922. /**
  56923. * Clone the refraction texture.
  56924. * @returns the cloned texture
  56925. */
  56926. clone(): RefractionTexture;
  56927. /**
  56928. * Serialize the texture to a JSON representation you could use in Parse later on
  56929. * @returns the serialized JSON representation
  56930. */
  56931. serialize(): any;
  56932. }
  56933. }
  56934. declare module BABYLON {
  56935. /**
  56936. * Defines the options related to the creation of an HtmlElementTexture
  56937. */
  56938. export interface IHtmlElementTextureOptions {
  56939. /**
  56940. * Defines wether mip maps should be created or not.
  56941. */
  56942. generateMipMaps?: boolean;
  56943. /**
  56944. * Defines the sampling mode of the texture.
  56945. */
  56946. samplingMode?: number;
  56947. /**
  56948. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56949. */
  56950. engine: Nullable<ThinEngine>;
  56951. /**
  56952. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56953. */
  56954. scene: Nullable<Scene>;
  56955. }
  56956. /**
  56957. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56958. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56959. * is automatically managed.
  56960. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56961. * in your application.
  56962. *
  56963. * As the update is not automatic, you need to call them manually.
  56964. */
  56965. export class HtmlElementTexture extends BaseTexture {
  56966. /**
  56967. * The texture URL.
  56968. */
  56969. element: HTMLVideoElement | HTMLCanvasElement;
  56970. private static readonly DefaultOptions;
  56971. private _textureMatrix;
  56972. private _engine;
  56973. private _isVideo;
  56974. private _generateMipMaps;
  56975. private _samplingMode;
  56976. /**
  56977. * Instantiates a HtmlElementTexture from the following parameters.
  56978. *
  56979. * @param name Defines the name of the texture
  56980. * @param element Defines the video or canvas the texture is filled with
  56981. * @param options Defines the other none mandatory texture creation options
  56982. */
  56983. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56984. private _createInternalTexture;
  56985. /**
  56986. * Returns the texture matrix used in most of the material.
  56987. */
  56988. getTextureMatrix(): Matrix;
  56989. /**
  56990. * Updates the content of the texture.
  56991. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56992. */
  56993. update(invertY?: Nullable<boolean>): void;
  56994. }
  56995. }
  56996. declare module BABYLON {
  56997. /**
  56998. * Defines the basic options interface of a TexturePacker Frame
  56999. */
  57000. export interface ITexturePackerFrame {
  57001. /**
  57002. * The frame ID
  57003. */
  57004. id: number;
  57005. /**
  57006. * The frames Scale
  57007. */
  57008. scale: Vector2;
  57009. /**
  57010. * The Frames offset
  57011. */
  57012. offset: Vector2;
  57013. }
  57014. /**
  57015. * This is a support class for frame Data on texture packer sets.
  57016. */
  57017. export class TexturePackerFrame implements ITexturePackerFrame {
  57018. /**
  57019. * The frame ID
  57020. */
  57021. id: number;
  57022. /**
  57023. * The frames Scale
  57024. */
  57025. scale: Vector2;
  57026. /**
  57027. * The Frames offset
  57028. */
  57029. offset: Vector2;
  57030. /**
  57031. * Initializes a texture package frame.
  57032. * @param id The numerical frame identifier
  57033. * @param scale Scalar Vector2 for UV frame
  57034. * @param offset Vector2 for the frame position in UV units.
  57035. * @returns TexturePackerFrame
  57036. */
  57037. constructor(id: number, scale: Vector2, offset: Vector2);
  57038. }
  57039. }
  57040. declare module BABYLON {
  57041. /**
  57042. * Defines the basic options interface of a TexturePacker
  57043. */
  57044. export interface ITexturePackerOptions {
  57045. /**
  57046. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  57047. */
  57048. map?: string[];
  57049. /**
  57050. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57051. */
  57052. uvsIn?: string;
  57053. /**
  57054. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57055. */
  57056. uvsOut?: string;
  57057. /**
  57058. * number representing the layout style. Defaults to LAYOUT_STRIP
  57059. */
  57060. layout?: number;
  57061. /**
  57062. * number of columns if using custom column count layout(2). This defaults to 4.
  57063. */
  57064. colnum?: number;
  57065. /**
  57066. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  57067. */
  57068. updateInputMeshes?: boolean;
  57069. /**
  57070. * boolean flag to dispose all the source textures. Defaults to true.
  57071. */
  57072. disposeSources?: boolean;
  57073. /**
  57074. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  57075. */
  57076. fillBlanks?: boolean;
  57077. /**
  57078. * string value representing the context fill style color. Defaults to 'black'.
  57079. */
  57080. customFillColor?: string;
  57081. /**
  57082. * Width and Height Value of each Frame in the TexturePacker Sets
  57083. */
  57084. frameSize?: number;
  57085. /**
  57086. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  57087. */
  57088. paddingRatio?: number;
  57089. /**
  57090. * Number that declares the fill method for the padding gutter.
  57091. */
  57092. paddingMode?: number;
  57093. /**
  57094. * If in SUBUV_COLOR padding mode what color to use.
  57095. */
  57096. paddingColor?: Color3 | Color4;
  57097. }
  57098. /**
  57099. * Defines the basic interface of a TexturePacker JSON File
  57100. */
  57101. export interface ITexturePackerJSON {
  57102. /**
  57103. * The frame ID
  57104. */
  57105. name: string;
  57106. /**
  57107. * The base64 channel data
  57108. */
  57109. sets: any;
  57110. /**
  57111. * The options of the Packer
  57112. */
  57113. options: ITexturePackerOptions;
  57114. /**
  57115. * The frame data of the Packer
  57116. */
  57117. frames: Array<number>;
  57118. }
  57119. /**
  57120. * This is a support class that generates a series of packed texture sets.
  57121. * @see https://doc.babylonjs.com/babylon101/materials
  57122. */
  57123. export class TexturePacker {
  57124. /** Packer Layout Constant 0 */
  57125. static readonly LAYOUT_STRIP: number;
  57126. /** Packer Layout Constant 1 */
  57127. static readonly LAYOUT_POWER2: number;
  57128. /** Packer Layout Constant 2 */
  57129. static readonly LAYOUT_COLNUM: number;
  57130. /** Packer Layout Constant 0 */
  57131. static readonly SUBUV_WRAP: number;
  57132. /** Packer Layout Constant 1 */
  57133. static readonly SUBUV_EXTEND: number;
  57134. /** Packer Layout Constant 2 */
  57135. static readonly SUBUV_COLOR: number;
  57136. /** The Name of the Texture Package */
  57137. name: string;
  57138. /** The scene scope of the TexturePacker */
  57139. scene: Scene;
  57140. /** The Meshes to target */
  57141. meshes: AbstractMesh[];
  57142. /** Arguments passed with the Constructor */
  57143. options: ITexturePackerOptions;
  57144. /** The promise that is started upon initialization */
  57145. promise: Nullable<Promise<TexturePacker | string>>;
  57146. /** The Container object for the channel sets that are generated */
  57147. sets: object;
  57148. /** The Container array for the frames that are generated */
  57149. frames: TexturePackerFrame[];
  57150. /** The expected number of textures the system is parsing. */
  57151. private _expecting;
  57152. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  57153. private _paddingValue;
  57154. /**
  57155. * Initializes a texture package series from an array of meshes or a single mesh.
  57156. * @param name The name of the package
  57157. * @param meshes The target meshes to compose the package from
  57158. * @param options The arguments that texture packer should follow while building.
  57159. * @param scene The scene which the textures are scoped to.
  57160. * @returns TexturePacker
  57161. */
  57162. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  57163. /**
  57164. * Starts the package process
  57165. * @param resolve The promises resolution function
  57166. * @returns TexturePacker
  57167. */
  57168. private _createFrames;
  57169. /**
  57170. * Calculates the Size of the Channel Sets
  57171. * @returns Vector2
  57172. */
  57173. private _calculateSize;
  57174. /**
  57175. * Calculates the UV data for the frames.
  57176. * @param baseSize the base frameSize
  57177. * @param padding the base frame padding
  57178. * @param dtSize size of the Dynamic Texture for that channel
  57179. * @param dtUnits is 1/dtSize
  57180. * @param update flag to update the input meshes
  57181. */
  57182. private _calculateMeshUVFrames;
  57183. /**
  57184. * Calculates the frames Offset.
  57185. * @param index of the frame
  57186. * @returns Vector2
  57187. */
  57188. private _getFrameOffset;
  57189. /**
  57190. * Updates a Mesh to the frame data
  57191. * @param mesh that is the target
  57192. * @param frameID or the frame index
  57193. */
  57194. private _updateMeshUV;
  57195. /**
  57196. * Updates a Meshes materials to use the texture packer channels
  57197. * @param m is the mesh to target
  57198. * @param force all channels on the packer to be set.
  57199. */
  57200. private _updateTextureReferences;
  57201. /**
  57202. * Public method to set a Mesh to a frame
  57203. * @param m that is the target
  57204. * @param frameID or the frame index
  57205. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  57206. */
  57207. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  57208. /**
  57209. * Starts the async promise to compile the texture packer.
  57210. * @returns Promise<void>
  57211. */
  57212. processAsync(): Promise<void>;
  57213. /**
  57214. * Disposes all textures associated with this packer
  57215. */
  57216. dispose(): void;
  57217. /**
  57218. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  57219. * @param imageType is the image type to use.
  57220. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  57221. */
  57222. download(imageType?: string, quality?: number): void;
  57223. /**
  57224. * Public method to load a texturePacker JSON file.
  57225. * @param data of the JSON file in string format.
  57226. */
  57227. updateFromJSON(data: string): void;
  57228. }
  57229. }
  57230. declare module BABYLON {
  57231. /**
  57232. * Enum used to define the target of a block
  57233. */
  57234. export enum NodeMaterialBlockTargets {
  57235. /** Vertex shader */
  57236. Vertex = 1,
  57237. /** Fragment shader */
  57238. Fragment = 2,
  57239. /** Neutral */
  57240. Neutral = 4,
  57241. /** Vertex and Fragment */
  57242. VertexAndFragment = 3
  57243. }
  57244. }
  57245. declare module BABYLON {
  57246. /**
  57247. * Defines the kind of connection point for node based material
  57248. */
  57249. export enum NodeMaterialBlockConnectionPointTypes {
  57250. /** Float */
  57251. Float = 1,
  57252. /** Int */
  57253. Int = 2,
  57254. /** Vector2 */
  57255. Vector2 = 4,
  57256. /** Vector3 */
  57257. Vector3 = 8,
  57258. /** Vector4 */
  57259. Vector4 = 16,
  57260. /** Color3 */
  57261. Color3 = 32,
  57262. /** Color4 */
  57263. Color4 = 64,
  57264. /** Matrix */
  57265. Matrix = 128,
  57266. /** Detect type based on connection */
  57267. AutoDetect = 1024,
  57268. /** Output type that will be defined by input type */
  57269. BasedOnInput = 2048
  57270. }
  57271. }
  57272. declare module BABYLON {
  57273. /**
  57274. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57275. */
  57276. export enum NodeMaterialBlockConnectionPointMode {
  57277. /** Value is an uniform */
  57278. Uniform = 0,
  57279. /** Value is a mesh attribute */
  57280. Attribute = 1,
  57281. /** Value is a varying between vertex and fragment shaders */
  57282. Varying = 2,
  57283. /** Mode is undefined */
  57284. Undefined = 3
  57285. }
  57286. }
  57287. declare module BABYLON {
  57288. /**
  57289. * Enum used to define system values e.g. values automatically provided by the system
  57290. */
  57291. export enum NodeMaterialSystemValues {
  57292. /** World */
  57293. World = 1,
  57294. /** View */
  57295. View = 2,
  57296. /** Projection */
  57297. Projection = 3,
  57298. /** ViewProjection */
  57299. ViewProjection = 4,
  57300. /** WorldView */
  57301. WorldView = 5,
  57302. /** WorldViewProjection */
  57303. WorldViewProjection = 6,
  57304. /** CameraPosition */
  57305. CameraPosition = 7,
  57306. /** Fog Color */
  57307. FogColor = 8,
  57308. /** Delta time */
  57309. DeltaTime = 9
  57310. }
  57311. }
  57312. declare module BABYLON {
  57313. /**
  57314. * Root class for all node material optimizers
  57315. */
  57316. export class NodeMaterialOptimizer {
  57317. /**
  57318. * Function used to optimize a NodeMaterial graph
  57319. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57320. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57321. */
  57322. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57323. }
  57324. }
  57325. declare module BABYLON {
  57326. /**
  57327. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57328. */
  57329. export class TransformBlock extends NodeMaterialBlock {
  57330. /**
  57331. * Defines the value to use to complement W value to transform it to a Vector4
  57332. */
  57333. complementW: number;
  57334. /**
  57335. * Defines the value to use to complement z value to transform it to a Vector4
  57336. */
  57337. complementZ: number;
  57338. /**
  57339. * Creates a new TransformBlock
  57340. * @param name defines the block name
  57341. */
  57342. constructor(name: string);
  57343. /**
  57344. * Gets the current class name
  57345. * @returns the class name
  57346. */
  57347. getClassName(): string;
  57348. /**
  57349. * Gets the vector input
  57350. */
  57351. get vector(): NodeMaterialConnectionPoint;
  57352. /**
  57353. * Gets the output component
  57354. */
  57355. get output(): NodeMaterialConnectionPoint;
  57356. /**
  57357. * Gets the xyz output component
  57358. */
  57359. get xyz(): NodeMaterialConnectionPoint;
  57360. /**
  57361. * Gets the matrix transform input
  57362. */
  57363. get transform(): NodeMaterialConnectionPoint;
  57364. protected _buildBlock(state: NodeMaterialBuildState): this;
  57365. serialize(): any;
  57366. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57367. protected _dumpPropertiesCode(): string;
  57368. }
  57369. }
  57370. declare module BABYLON {
  57371. /**
  57372. * Block used to output the vertex position
  57373. */
  57374. export class VertexOutputBlock extends NodeMaterialBlock {
  57375. /**
  57376. * Creates a new VertexOutputBlock
  57377. * @param name defines the block name
  57378. */
  57379. constructor(name: string);
  57380. /**
  57381. * Gets the current class name
  57382. * @returns the class name
  57383. */
  57384. getClassName(): string;
  57385. /**
  57386. * Gets the vector input component
  57387. */
  57388. get vector(): NodeMaterialConnectionPoint;
  57389. protected _buildBlock(state: NodeMaterialBuildState): this;
  57390. }
  57391. }
  57392. declare module BABYLON {
  57393. /**
  57394. * Block used to output the final color
  57395. */
  57396. export class FragmentOutputBlock extends NodeMaterialBlock {
  57397. /**
  57398. * Create a new FragmentOutputBlock
  57399. * @param name defines the block name
  57400. */
  57401. constructor(name: string);
  57402. /**
  57403. * Gets the current class name
  57404. * @returns the class name
  57405. */
  57406. getClassName(): string;
  57407. /**
  57408. * Gets the rgba input component
  57409. */
  57410. get rgba(): NodeMaterialConnectionPoint;
  57411. /**
  57412. * Gets the rgb input component
  57413. */
  57414. get rgb(): NodeMaterialConnectionPoint;
  57415. /**
  57416. * Gets the a input component
  57417. */
  57418. get a(): NodeMaterialConnectionPoint;
  57419. protected _buildBlock(state: NodeMaterialBuildState): this;
  57420. }
  57421. }
  57422. declare module BABYLON {
  57423. /**
  57424. * Block used to read a reflection texture from a sampler
  57425. */
  57426. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57427. private _define3DName;
  57428. private _defineCubicName;
  57429. private _defineExplicitName;
  57430. private _defineProjectionName;
  57431. private _defineLocalCubicName;
  57432. private _defineSphericalName;
  57433. private _definePlanarName;
  57434. private _defineEquirectangularName;
  57435. private _defineMirroredEquirectangularFixedName;
  57436. private _defineEquirectangularFixedName;
  57437. private _defineSkyboxName;
  57438. private _cubeSamplerName;
  57439. private _2DSamplerName;
  57440. private _positionUVWName;
  57441. private _directionWName;
  57442. private _reflectionCoordsName;
  57443. private _reflection2DCoordsName;
  57444. private _reflectionColorName;
  57445. private _reflectionMatrixName;
  57446. /**
  57447. * Gets or sets the texture associated with the node
  57448. */
  57449. texture: Nullable<BaseTexture>;
  57450. /**
  57451. * Create a new TextureBlock
  57452. * @param name defines the block name
  57453. */
  57454. constructor(name: string);
  57455. /**
  57456. * Gets the current class name
  57457. * @returns the class name
  57458. */
  57459. getClassName(): string;
  57460. /**
  57461. * Gets the world position input component
  57462. */
  57463. get position(): NodeMaterialConnectionPoint;
  57464. /**
  57465. * Gets the world position input component
  57466. */
  57467. get worldPosition(): NodeMaterialConnectionPoint;
  57468. /**
  57469. * Gets the world normal input component
  57470. */
  57471. get worldNormal(): NodeMaterialConnectionPoint;
  57472. /**
  57473. * Gets the world input component
  57474. */
  57475. get world(): NodeMaterialConnectionPoint;
  57476. /**
  57477. * Gets the camera (or eye) position component
  57478. */
  57479. get cameraPosition(): NodeMaterialConnectionPoint;
  57480. /**
  57481. * Gets the view input component
  57482. */
  57483. get view(): NodeMaterialConnectionPoint;
  57484. /**
  57485. * Gets the rgb output component
  57486. */
  57487. get rgb(): NodeMaterialConnectionPoint;
  57488. /**
  57489. * Gets the r output component
  57490. */
  57491. get r(): NodeMaterialConnectionPoint;
  57492. /**
  57493. * Gets the g output component
  57494. */
  57495. get g(): NodeMaterialConnectionPoint;
  57496. /**
  57497. * Gets the b output component
  57498. */
  57499. get b(): NodeMaterialConnectionPoint;
  57500. autoConfigure(material: NodeMaterial): void;
  57501. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57502. isReady(): boolean;
  57503. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57504. private _injectVertexCode;
  57505. private _writeOutput;
  57506. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57507. protected _dumpPropertiesCode(): string;
  57508. serialize(): any;
  57509. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57510. }
  57511. }
  57512. declare module BABYLON {
  57513. /**
  57514. * Interface used to configure the node material editor
  57515. */
  57516. export interface INodeMaterialEditorOptions {
  57517. /** Define the URl to load node editor script */
  57518. editorURL?: string;
  57519. }
  57520. /** @hidden */
  57521. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57522. NORMAL: boolean;
  57523. TANGENT: boolean;
  57524. UV1: boolean;
  57525. /** BONES */
  57526. NUM_BONE_INFLUENCERS: number;
  57527. BonesPerMesh: number;
  57528. BONETEXTURE: boolean;
  57529. /** MORPH TARGETS */
  57530. MORPHTARGETS: boolean;
  57531. MORPHTARGETS_NORMAL: boolean;
  57532. MORPHTARGETS_TANGENT: boolean;
  57533. MORPHTARGETS_UV: boolean;
  57534. NUM_MORPH_INFLUENCERS: number;
  57535. /** IMAGE PROCESSING */
  57536. IMAGEPROCESSING: boolean;
  57537. VIGNETTE: boolean;
  57538. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57539. VIGNETTEBLENDMODEOPAQUE: boolean;
  57540. TONEMAPPING: boolean;
  57541. TONEMAPPING_ACES: boolean;
  57542. CONTRAST: boolean;
  57543. EXPOSURE: boolean;
  57544. COLORCURVES: boolean;
  57545. COLORGRADING: boolean;
  57546. COLORGRADING3D: boolean;
  57547. SAMPLER3DGREENDEPTH: boolean;
  57548. SAMPLER3DBGRMAP: boolean;
  57549. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57550. /** MISC. */
  57551. BUMPDIRECTUV: number;
  57552. constructor();
  57553. setValue(name: string, value: boolean): void;
  57554. }
  57555. /**
  57556. * Class used to configure NodeMaterial
  57557. */
  57558. export interface INodeMaterialOptions {
  57559. /**
  57560. * Defines if blocks should emit comments
  57561. */
  57562. emitComments: boolean;
  57563. }
  57564. /**
  57565. * Class used to create a node based material built by assembling shader blocks
  57566. */
  57567. export class NodeMaterial extends PushMaterial {
  57568. private static _BuildIdGenerator;
  57569. private _options;
  57570. private _vertexCompilationState;
  57571. private _fragmentCompilationState;
  57572. private _sharedData;
  57573. private _buildId;
  57574. private _buildWasSuccessful;
  57575. private _cachedWorldViewMatrix;
  57576. private _cachedWorldViewProjectionMatrix;
  57577. private _optimizers;
  57578. private _animationFrame;
  57579. /** Define the Url to load node editor script */
  57580. static EditorURL: string;
  57581. /** Define the Url to load snippets */
  57582. static SnippetUrl: string;
  57583. private BJSNODEMATERIALEDITOR;
  57584. /** Get the inspector from bundle or global */
  57585. private _getGlobalNodeMaterialEditor;
  57586. /**
  57587. * Snippet ID if the material was created from the snippet server
  57588. */
  57589. snippetId: string;
  57590. /**
  57591. * Gets or sets data used by visual editor
  57592. * @see https://nme.babylonjs.com
  57593. */
  57594. editorData: any;
  57595. /**
  57596. * 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)
  57597. */
  57598. ignoreAlpha: boolean;
  57599. /**
  57600. * Defines the maximum number of lights that can be used in the material
  57601. */
  57602. maxSimultaneousLights: number;
  57603. /**
  57604. * Observable raised when the material is built
  57605. */
  57606. onBuildObservable: Observable<NodeMaterial>;
  57607. /**
  57608. * Gets or sets the root nodes of the material vertex shader
  57609. */
  57610. _vertexOutputNodes: NodeMaterialBlock[];
  57611. /**
  57612. * Gets or sets the root nodes of the material fragment (pixel) shader
  57613. */
  57614. _fragmentOutputNodes: NodeMaterialBlock[];
  57615. /** Gets or sets options to control the node material overall behavior */
  57616. get options(): INodeMaterialOptions;
  57617. set options(options: INodeMaterialOptions);
  57618. /**
  57619. * Default configuration related to image processing available in the standard Material.
  57620. */
  57621. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57622. /**
  57623. * Gets the image processing configuration used either in this material.
  57624. */
  57625. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57626. /**
  57627. * Sets the Default image processing configuration used either in the this material.
  57628. *
  57629. * If sets to null, the scene one is in use.
  57630. */
  57631. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57632. /**
  57633. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57634. */
  57635. attachedBlocks: NodeMaterialBlock[];
  57636. /**
  57637. * Create a new node based material
  57638. * @param name defines the material name
  57639. * @param scene defines the hosting scene
  57640. * @param options defines creation option
  57641. */
  57642. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57643. /**
  57644. * Gets the current class name of the material e.g. "NodeMaterial"
  57645. * @returns the class name
  57646. */
  57647. getClassName(): string;
  57648. /**
  57649. * Keep track of the image processing observer to allow dispose and replace.
  57650. */
  57651. private _imageProcessingObserver;
  57652. /**
  57653. * Attaches a new image processing configuration to the Standard Material.
  57654. * @param configuration
  57655. */
  57656. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57657. /**
  57658. * Get a block by its name
  57659. * @param name defines the name of the block to retrieve
  57660. * @returns the required block or null if not found
  57661. */
  57662. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57663. /**
  57664. * Get a block by its name
  57665. * @param predicate defines the predicate used to find the good candidate
  57666. * @returns the required block or null if not found
  57667. */
  57668. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57669. /**
  57670. * Get an input block by its name
  57671. * @param predicate defines the predicate used to find the good candidate
  57672. * @returns the required input block or null if not found
  57673. */
  57674. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57675. /**
  57676. * Gets the list of input blocks attached to this material
  57677. * @returns an array of InputBlocks
  57678. */
  57679. getInputBlocks(): InputBlock[];
  57680. /**
  57681. * Adds a new optimizer to the list of optimizers
  57682. * @param optimizer defines the optimizers to add
  57683. * @returns the current material
  57684. */
  57685. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57686. /**
  57687. * Remove an optimizer from the list of optimizers
  57688. * @param optimizer defines the optimizers to remove
  57689. * @returns the current material
  57690. */
  57691. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57692. /**
  57693. * Add a new block to the list of output nodes
  57694. * @param node defines the node to add
  57695. * @returns the current material
  57696. */
  57697. addOutputNode(node: NodeMaterialBlock): this;
  57698. /**
  57699. * Remove a block from the list of root nodes
  57700. * @param node defines the node to remove
  57701. * @returns the current material
  57702. */
  57703. removeOutputNode(node: NodeMaterialBlock): this;
  57704. private _addVertexOutputNode;
  57705. private _removeVertexOutputNode;
  57706. private _addFragmentOutputNode;
  57707. private _removeFragmentOutputNode;
  57708. /**
  57709. * Specifies if the material will require alpha blending
  57710. * @returns a boolean specifying if alpha blending is needed
  57711. */
  57712. needAlphaBlending(): boolean;
  57713. /**
  57714. * Specifies if this material should be rendered in alpha test mode
  57715. * @returns a boolean specifying if an alpha test is needed.
  57716. */
  57717. needAlphaTesting(): boolean;
  57718. private _initializeBlock;
  57719. private _resetDualBlocks;
  57720. /**
  57721. * Remove a block from the current node material
  57722. * @param block defines the block to remove
  57723. */
  57724. removeBlock(block: NodeMaterialBlock): void;
  57725. /**
  57726. * Build the material and generates the inner effect
  57727. * @param verbose defines if the build should log activity
  57728. */
  57729. build(verbose?: boolean): void;
  57730. /**
  57731. * Runs an otpimization phase to try to improve the shader code
  57732. */
  57733. optimize(): void;
  57734. private _prepareDefinesForAttributes;
  57735. /**
  57736. * Get if the submesh is ready to be used and all its information available.
  57737. * Child classes can use it to update shaders
  57738. * @param mesh defines the mesh to check
  57739. * @param subMesh defines which submesh to check
  57740. * @param useInstances specifies that instances should be used
  57741. * @returns a boolean indicating that the submesh is ready or not
  57742. */
  57743. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57744. /**
  57745. * Get a string representing the shaders built by the current node graph
  57746. */
  57747. get compiledShaders(): string;
  57748. /**
  57749. * Binds the world matrix to the material
  57750. * @param world defines the world transformation matrix
  57751. */
  57752. bindOnlyWorldMatrix(world: Matrix): void;
  57753. /**
  57754. * Binds the submesh to this material by preparing the effect and shader to draw
  57755. * @param world defines the world transformation matrix
  57756. * @param mesh defines the mesh containing the submesh
  57757. * @param subMesh defines the submesh to bind the material to
  57758. */
  57759. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57760. /**
  57761. * Gets the active textures from the material
  57762. * @returns an array of textures
  57763. */
  57764. getActiveTextures(): BaseTexture[];
  57765. /**
  57766. * Gets the list of texture blocks
  57767. * @returns an array of texture blocks
  57768. */
  57769. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57770. /**
  57771. * Specifies if the material uses a texture
  57772. * @param texture defines the texture to check against the material
  57773. * @returns a boolean specifying if the material uses the texture
  57774. */
  57775. hasTexture(texture: BaseTexture): boolean;
  57776. /**
  57777. * Disposes the material
  57778. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57779. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57780. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57781. */
  57782. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57783. /** Creates the node editor window. */
  57784. private _createNodeEditor;
  57785. /**
  57786. * Launch the node material editor
  57787. * @param config Define the configuration of the editor
  57788. * @return a promise fulfilled when the node editor is visible
  57789. */
  57790. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57791. /**
  57792. * Clear the current material
  57793. */
  57794. clear(): void;
  57795. /**
  57796. * Clear the current material and set it to a default state
  57797. */
  57798. setToDefault(): void;
  57799. /**
  57800. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57801. * @param url defines the url to load from
  57802. * @returns a promise that will fullfil when the material is fully loaded
  57803. */
  57804. loadAsync(url: string): Promise<void>;
  57805. private _gatherBlocks;
  57806. /**
  57807. * Generate a string containing the code declaration required to create an equivalent of this material
  57808. * @returns a string
  57809. */
  57810. generateCode(): string;
  57811. /**
  57812. * Serializes this material in a JSON representation
  57813. * @returns the serialized material object
  57814. */
  57815. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57816. private _restoreConnections;
  57817. /**
  57818. * Clear the current graph and load a new one from a serialization object
  57819. * @param source defines the JSON representation of the material
  57820. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57821. */
  57822. loadFromSerialization(source: any, rootUrl?: string): void;
  57823. /**
  57824. * Makes a duplicate of the current material.
  57825. * @param name - name to use for the new material.
  57826. */
  57827. clone(name: string): NodeMaterial;
  57828. /**
  57829. * Creates a node material from parsed material data
  57830. * @param source defines the JSON representation of the material
  57831. * @param scene defines the hosting scene
  57832. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57833. * @returns a new node material
  57834. */
  57835. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57836. /**
  57837. * Creates a node material from a snippet saved in a remote file
  57838. * @param name defines the name of the material to create
  57839. * @param url defines the url to load from
  57840. * @param scene defines the hosting scene
  57841. * @returns a promise that will resolve to the new node material
  57842. */
  57843. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57844. /**
  57845. * Creates a node material from a snippet saved by the node material editor
  57846. * @param snippetId defines the snippet to load
  57847. * @param scene defines the hosting scene
  57848. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57849. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  57850. * @returns a promise that will resolve to the new node material
  57851. */
  57852. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  57853. /**
  57854. * Creates a new node material set to default basic configuration
  57855. * @param name defines the name of the material
  57856. * @param scene defines the hosting scene
  57857. * @returns a new NodeMaterial
  57858. */
  57859. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57860. }
  57861. }
  57862. declare module BABYLON {
  57863. /**
  57864. * Block used to read a texture from a sampler
  57865. */
  57866. export class TextureBlock extends NodeMaterialBlock {
  57867. private _defineName;
  57868. private _linearDefineName;
  57869. private _tempTextureRead;
  57870. private _samplerName;
  57871. private _transformedUVName;
  57872. private _textureTransformName;
  57873. private _textureInfoName;
  57874. private _mainUVName;
  57875. private _mainUVDefineName;
  57876. /**
  57877. * Gets or sets the texture associated with the node
  57878. */
  57879. texture: Nullable<Texture>;
  57880. /**
  57881. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  57882. */
  57883. convertToGammaSpace: boolean;
  57884. /**
  57885. * Create a new TextureBlock
  57886. * @param name defines the block name
  57887. */
  57888. constructor(name: string);
  57889. /**
  57890. * Gets the current class name
  57891. * @returns the class name
  57892. */
  57893. getClassName(): string;
  57894. /**
  57895. * Gets the uv input component
  57896. */
  57897. get uv(): NodeMaterialConnectionPoint;
  57898. /**
  57899. * Gets the rgba output component
  57900. */
  57901. get rgba(): NodeMaterialConnectionPoint;
  57902. /**
  57903. * Gets the rgb output component
  57904. */
  57905. get rgb(): NodeMaterialConnectionPoint;
  57906. /**
  57907. * Gets the r output component
  57908. */
  57909. get r(): NodeMaterialConnectionPoint;
  57910. /**
  57911. * Gets the g output component
  57912. */
  57913. get g(): NodeMaterialConnectionPoint;
  57914. /**
  57915. * Gets the b output component
  57916. */
  57917. get b(): NodeMaterialConnectionPoint;
  57918. /**
  57919. * Gets the a output component
  57920. */
  57921. get a(): NodeMaterialConnectionPoint;
  57922. get target(): NodeMaterialBlockTargets;
  57923. autoConfigure(material: NodeMaterial): void;
  57924. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57925. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57926. isReady(): boolean;
  57927. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57928. private get _isMixed();
  57929. private _injectVertexCode;
  57930. private _writeTextureRead;
  57931. private _writeOutput;
  57932. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57933. protected _dumpPropertiesCode(): string;
  57934. serialize(): any;
  57935. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57936. }
  57937. }
  57938. declare module BABYLON {
  57939. /**
  57940. * Class used to store shared data between 2 NodeMaterialBuildState
  57941. */
  57942. export class NodeMaterialBuildStateSharedData {
  57943. /**
  57944. * Gets the list of emitted varyings
  57945. */
  57946. temps: string[];
  57947. /**
  57948. * Gets the list of emitted varyings
  57949. */
  57950. varyings: string[];
  57951. /**
  57952. * Gets the varying declaration string
  57953. */
  57954. varyingDeclaration: string;
  57955. /**
  57956. * Input blocks
  57957. */
  57958. inputBlocks: InputBlock[];
  57959. /**
  57960. * Input blocks
  57961. */
  57962. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57963. /**
  57964. * Bindable blocks (Blocks that need to set data to the effect)
  57965. */
  57966. bindableBlocks: NodeMaterialBlock[];
  57967. /**
  57968. * List of blocks that can provide a compilation fallback
  57969. */
  57970. blocksWithFallbacks: NodeMaterialBlock[];
  57971. /**
  57972. * List of blocks that can provide a define update
  57973. */
  57974. blocksWithDefines: NodeMaterialBlock[];
  57975. /**
  57976. * List of blocks that can provide a repeatable content
  57977. */
  57978. repeatableContentBlocks: NodeMaterialBlock[];
  57979. /**
  57980. * List of blocks that can provide a dynamic list of uniforms
  57981. */
  57982. dynamicUniformBlocks: NodeMaterialBlock[];
  57983. /**
  57984. * List of blocks that can block the isReady function for the material
  57985. */
  57986. blockingBlocks: NodeMaterialBlock[];
  57987. /**
  57988. * Gets the list of animated inputs
  57989. */
  57990. animatedInputs: InputBlock[];
  57991. /**
  57992. * Build Id used to avoid multiple recompilations
  57993. */
  57994. buildId: number;
  57995. /** List of emitted variables */
  57996. variableNames: {
  57997. [key: string]: number;
  57998. };
  57999. /** List of emitted defines */
  58000. defineNames: {
  58001. [key: string]: number;
  58002. };
  58003. /** Should emit comments? */
  58004. emitComments: boolean;
  58005. /** Emit build activity */
  58006. verbose: boolean;
  58007. /** Gets or sets the hosting scene */
  58008. scene: Scene;
  58009. /**
  58010. * Gets the compilation hints emitted at compilation time
  58011. */
  58012. hints: {
  58013. needWorldViewMatrix: boolean;
  58014. needWorldViewProjectionMatrix: boolean;
  58015. needAlphaBlending: boolean;
  58016. needAlphaTesting: boolean;
  58017. };
  58018. /**
  58019. * List of compilation checks
  58020. */
  58021. checks: {
  58022. emitVertex: boolean;
  58023. emitFragment: boolean;
  58024. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58025. };
  58026. /** Creates a new shared data */
  58027. constructor();
  58028. /**
  58029. * Emits console errors and exceptions if there is a failing check
  58030. */
  58031. emitErrors(): void;
  58032. }
  58033. }
  58034. declare module BABYLON {
  58035. /**
  58036. * Class used to store node based material build state
  58037. */
  58038. export class NodeMaterialBuildState {
  58039. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58040. supportUniformBuffers: boolean;
  58041. /**
  58042. * Gets the list of emitted attributes
  58043. */
  58044. attributes: string[];
  58045. /**
  58046. * Gets the list of emitted uniforms
  58047. */
  58048. uniforms: string[];
  58049. /**
  58050. * Gets the list of emitted constants
  58051. */
  58052. constants: string[];
  58053. /**
  58054. * Gets the list of emitted samplers
  58055. */
  58056. samplers: string[];
  58057. /**
  58058. * Gets the list of emitted functions
  58059. */
  58060. functions: {
  58061. [key: string]: string;
  58062. };
  58063. /**
  58064. * Gets the list of emitted extensions
  58065. */
  58066. extensions: {
  58067. [key: string]: string;
  58068. };
  58069. /**
  58070. * Gets the target of the compilation state
  58071. */
  58072. target: NodeMaterialBlockTargets;
  58073. /**
  58074. * Gets the list of emitted counters
  58075. */
  58076. counters: {
  58077. [key: string]: number;
  58078. };
  58079. /**
  58080. * Shared data between multiple NodeMaterialBuildState instances
  58081. */
  58082. sharedData: NodeMaterialBuildStateSharedData;
  58083. /** @hidden */
  58084. _vertexState: NodeMaterialBuildState;
  58085. /** @hidden */
  58086. _attributeDeclaration: string;
  58087. /** @hidden */
  58088. _uniformDeclaration: string;
  58089. /** @hidden */
  58090. _constantDeclaration: string;
  58091. /** @hidden */
  58092. _samplerDeclaration: string;
  58093. /** @hidden */
  58094. _varyingTransfer: string;
  58095. private _repeatableContentAnchorIndex;
  58096. /** @hidden */
  58097. _builtCompilationString: string;
  58098. /**
  58099. * Gets the emitted compilation strings
  58100. */
  58101. compilationString: string;
  58102. /**
  58103. * Finalize the compilation strings
  58104. * @param state defines the current compilation state
  58105. */
  58106. finalize(state: NodeMaterialBuildState): void;
  58107. /** @hidden */
  58108. get _repeatableContentAnchor(): string;
  58109. /** @hidden */
  58110. _getFreeVariableName(prefix: string): string;
  58111. /** @hidden */
  58112. _getFreeDefineName(prefix: string): string;
  58113. /** @hidden */
  58114. _excludeVariableName(name: string): void;
  58115. /** @hidden */
  58116. _emit2DSampler(name: string): void;
  58117. /** @hidden */
  58118. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58119. /** @hidden */
  58120. _emitExtension(name: string, extension: string): void;
  58121. /** @hidden */
  58122. _emitFunction(name: string, code: string, comments: string): void;
  58123. /** @hidden */
  58124. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58125. replaceStrings?: {
  58126. search: RegExp;
  58127. replace: string;
  58128. }[];
  58129. repeatKey?: string;
  58130. }): string;
  58131. /** @hidden */
  58132. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58133. repeatKey?: string;
  58134. removeAttributes?: boolean;
  58135. removeUniforms?: boolean;
  58136. removeVaryings?: boolean;
  58137. removeIfDef?: boolean;
  58138. replaceStrings?: {
  58139. search: RegExp;
  58140. replace: string;
  58141. }[];
  58142. }, storeKey?: string): void;
  58143. /** @hidden */
  58144. _registerTempVariable(name: string): boolean;
  58145. /** @hidden */
  58146. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58147. /** @hidden */
  58148. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58149. /** @hidden */
  58150. _emitFloat(value: number): string;
  58151. }
  58152. }
  58153. declare module BABYLON {
  58154. /**
  58155. * Defines a block that can be used inside a node based material
  58156. */
  58157. export class NodeMaterialBlock {
  58158. private _buildId;
  58159. private _buildTarget;
  58160. private _target;
  58161. private _isFinalMerger;
  58162. private _isInput;
  58163. protected _isUnique: boolean;
  58164. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  58165. inputsAreExclusive: boolean;
  58166. /** @hidden */
  58167. _codeVariableName: string;
  58168. /** @hidden */
  58169. _inputs: NodeMaterialConnectionPoint[];
  58170. /** @hidden */
  58171. _outputs: NodeMaterialConnectionPoint[];
  58172. /** @hidden */
  58173. _preparationId: number;
  58174. /**
  58175. * Gets or sets the name of the block
  58176. */
  58177. name: string;
  58178. /**
  58179. * Gets or sets the unique id of the node
  58180. */
  58181. uniqueId: number;
  58182. /**
  58183. * Gets or sets the comments associated with this block
  58184. */
  58185. comments: string;
  58186. /**
  58187. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58188. */
  58189. get isUnique(): boolean;
  58190. /**
  58191. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58192. */
  58193. get isFinalMerger(): boolean;
  58194. /**
  58195. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58196. */
  58197. get isInput(): boolean;
  58198. /**
  58199. * Gets or sets the build Id
  58200. */
  58201. get buildId(): number;
  58202. set buildId(value: number);
  58203. /**
  58204. * Gets or sets the target of the block
  58205. */
  58206. get target(): NodeMaterialBlockTargets;
  58207. set target(value: NodeMaterialBlockTargets);
  58208. /**
  58209. * Gets the list of input points
  58210. */
  58211. get inputs(): NodeMaterialConnectionPoint[];
  58212. /** Gets the list of output points */
  58213. get outputs(): NodeMaterialConnectionPoint[];
  58214. /**
  58215. * Find an input by its name
  58216. * @param name defines the name of the input to look for
  58217. * @returns the input or null if not found
  58218. */
  58219. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58220. /**
  58221. * Find an output by its name
  58222. * @param name defines the name of the outputto look for
  58223. * @returns the output or null if not found
  58224. */
  58225. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58226. /**
  58227. * Creates a new NodeMaterialBlock
  58228. * @param name defines the block name
  58229. * @param target defines the target of that block (Vertex by default)
  58230. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58231. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58232. */
  58233. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58234. /**
  58235. * Initialize the block and prepare the context for build
  58236. * @param state defines the state that will be used for the build
  58237. */
  58238. initialize(state: NodeMaterialBuildState): void;
  58239. /**
  58240. * Bind data to effect. Will only be called for blocks with isBindable === true
  58241. * @param effect defines the effect to bind data to
  58242. * @param nodeMaterial defines the hosting NodeMaterial
  58243. * @param mesh defines the mesh that will be rendered
  58244. */
  58245. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58246. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58247. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58248. protected _writeFloat(value: number): string;
  58249. /**
  58250. * Gets the current class name e.g. "NodeMaterialBlock"
  58251. * @returns the class name
  58252. */
  58253. getClassName(): string;
  58254. /**
  58255. * Register a new input. Must be called inside a block constructor
  58256. * @param name defines the connection point name
  58257. * @param type defines the connection point type
  58258. * @param isOptional defines a boolean indicating that this input can be omitted
  58259. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58260. * @returns the current block
  58261. */
  58262. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58263. /**
  58264. * Register a new output. Must be called inside a block constructor
  58265. * @param name defines the connection point name
  58266. * @param type defines the connection point type
  58267. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58268. * @returns the current block
  58269. */
  58270. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58271. /**
  58272. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58273. * @param forOutput defines an optional connection point to check compatibility with
  58274. * @returns the first available input or null
  58275. */
  58276. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58277. /**
  58278. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58279. * @param forBlock defines an optional block to check compatibility with
  58280. * @returns the first available input or null
  58281. */
  58282. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58283. /**
  58284. * Gets the sibling of the given output
  58285. * @param current defines the current output
  58286. * @returns the next output in the list or null
  58287. */
  58288. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58289. /**
  58290. * Connect current block with another block
  58291. * @param other defines the block to connect with
  58292. * @param options define the various options to help pick the right connections
  58293. * @returns the current block
  58294. */
  58295. connectTo(other: NodeMaterialBlock, options?: {
  58296. input?: string;
  58297. output?: string;
  58298. outputSwizzle?: string;
  58299. }): this | undefined;
  58300. protected _buildBlock(state: NodeMaterialBuildState): void;
  58301. /**
  58302. * Add uniforms, samplers and uniform buffers at compilation time
  58303. * @param state defines the state to update
  58304. * @param nodeMaterial defines the node material requesting the update
  58305. * @param defines defines the material defines to update
  58306. * @param uniformBuffers defines the list of uniform buffer names
  58307. */
  58308. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58309. /**
  58310. * Add potential fallbacks if shader compilation fails
  58311. * @param mesh defines the mesh to be rendered
  58312. * @param fallbacks defines the current prioritized list of fallbacks
  58313. */
  58314. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58315. /**
  58316. * Initialize defines for shader compilation
  58317. * @param mesh defines the mesh to be rendered
  58318. * @param nodeMaterial defines the node material requesting the update
  58319. * @param defines defines the material defines to update
  58320. * @param useInstances specifies that instances should be used
  58321. */
  58322. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58323. /**
  58324. * Update defines for shader compilation
  58325. * @param mesh defines the mesh to be rendered
  58326. * @param nodeMaterial defines the node material requesting the update
  58327. * @param defines defines the material defines to update
  58328. * @param useInstances specifies that instances should be used
  58329. */
  58330. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58331. /**
  58332. * Lets the block try to connect some inputs automatically
  58333. * @param material defines the hosting NodeMaterial
  58334. */
  58335. autoConfigure(material: NodeMaterial): void;
  58336. /**
  58337. * Function called when a block is declared as repeatable content generator
  58338. * @param vertexShaderState defines the current compilation state for the vertex shader
  58339. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58340. * @param mesh defines the mesh to be rendered
  58341. * @param defines defines the material defines to update
  58342. */
  58343. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58344. /**
  58345. * Checks if the block is ready
  58346. * @param mesh defines the mesh to be rendered
  58347. * @param nodeMaterial defines the node material requesting the update
  58348. * @param defines defines the material defines to update
  58349. * @param useInstances specifies that instances should be used
  58350. * @returns true if the block is ready
  58351. */
  58352. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58353. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58354. private _processBuild;
  58355. /**
  58356. * Compile the current node and generate the shader code
  58357. * @param state defines the current compilation state (uniforms, samplers, current string)
  58358. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58359. * @returns true if already built
  58360. */
  58361. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58362. protected _inputRename(name: string): string;
  58363. protected _outputRename(name: string): string;
  58364. protected _dumpPropertiesCode(): string;
  58365. /** @hidden */
  58366. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58367. /** @hidden */
  58368. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58369. /**
  58370. * Clone the current block to a new identical block
  58371. * @param scene defines the hosting scene
  58372. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58373. * @returns a copy of the current block
  58374. */
  58375. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58376. /**
  58377. * Serializes this block in a JSON representation
  58378. * @returns the serialized block object
  58379. */
  58380. serialize(): any;
  58381. /** @hidden */
  58382. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58383. /**
  58384. * Release resources
  58385. */
  58386. dispose(): void;
  58387. }
  58388. }
  58389. declare module BABYLON {
  58390. /**
  58391. * Enum defining the type of animations supported by InputBlock
  58392. */
  58393. export enum AnimatedInputBlockTypes {
  58394. /** No animation */
  58395. None = 0,
  58396. /** Time based animation. Will only work for floats */
  58397. Time = 1
  58398. }
  58399. }
  58400. declare module BABYLON {
  58401. /**
  58402. * Block used to expose an input value
  58403. */
  58404. export class InputBlock extends NodeMaterialBlock {
  58405. private _mode;
  58406. private _associatedVariableName;
  58407. private _storedValue;
  58408. private _valueCallback;
  58409. private _type;
  58410. private _animationType;
  58411. /** Gets or set a value used to limit the range of float values */
  58412. min: number;
  58413. /** Gets or set a value used to limit the range of float values */
  58414. max: number;
  58415. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  58416. isBoolean: boolean;
  58417. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58418. matrixMode: number;
  58419. /** @hidden */
  58420. _systemValue: Nullable<NodeMaterialSystemValues>;
  58421. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58422. visibleInInspector: boolean;
  58423. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58424. isConstant: boolean;
  58425. /** Gets or sets the group to use to display this block in the Inspector */
  58426. groupInInspector: string;
  58427. /** Gets an observable raised when the value is changed */
  58428. onValueChangedObservable: Observable<InputBlock>;
  58429. /**
  58430. * Gets or sets the connection point type (default is float)
  58431. */
  58432. get type(): NodeMaterialBlockConnectionPointTypes;
  58433. /**
  58434. * Creates a new InputBlock
  58435. * @param name defines the block name
  58436. * @param target defines the target of that block (Vertex by default)
  58437. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58438. */
  58439. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58440. /**
  58441. * Gets the output component
  58442. */
  58443. get output(): NodeMaterialConnectionPoint;
  58444. /**
  58445. * Set the source of this connection point to a vertex attribute
  58446. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58447. * @returns the current connection point
  58448. */
  58449. setAsAttribute(attributeName?: string): InputBlock;
  58450. /**
  58451. * Set the source of this connection point to a system value
  58452. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58453. * @returns the current connection point
  58454. */
  58455. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58456. /**
  58457. * Gets or sets the value of that point.
  58458. * Please note that this value will be ignored if valueCallback is defined
  58459. */
  58460. get value(): any;
  58461. set value(value: any);
  58462. /**
  58463. * Gets or sets a callback used to get the value of that point.
  58464. * Please note that setting this value will force the connection point to ignore the value property
  58465. */
  58466. get valueCallback(): () => any;
  58467. set valueCallback(value: () => any);
  58468. /**
  58469. * Gets or sets the associated variable name in the shader
  58470. */
  58471. get associatedVariableName(): string;
  58472. set associatedVariableName(value: string);
  58473. /** Gets or sets the type of animation applied to the input */
  58474. get animationType(): AnimatedInputBlockTypes;
  58475. set animationType(value: AnimatedInputBlockTypes);
  58476. /**
  58477. * Gets a boolean indicating that this connection point not defined yet
  58478. */
  58479. get isUndefined(): boolean;
  58480. /**
  58481. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58482. * In this case the connection point name must be the name of the uniform to use.
  58483. * Can only be set on inputs
  58484. */
  58485. get isUniform(): boolean;
  58486. set isUniform(value: boolean);
  58487. /**
  58488. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58489. * In this case the connection point name must be the name of the attribute to use
  58490. * Can only be set on inputs
  58491. */
  58492. get isAttribute(): boolean;
  58493. set isAttribute(value: boolean);
  58494. /**
  58495. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58496. * Can only be set on exit points
  58497. */
  58498. get isVarying(): boolean;
  58499. set isVarying(value: boolean);
  58500. /**
  58501. * Gets a boolean indicating that the current connection point is a system value
  58502. */
  58503. get isSystemValue(): boolean;
  58504. /**
  58505. * Gets or sets the current well known value or null if not defined as a system value
  58506. */
  58507. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58508. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58509. /**
  58510. * Gets the current class name
  58511. * @returns the class name
  58512. */
  58513. getClassName(): string;
  58514. /**
  58515. * Animate the input if animationType !== None
  58516. * @param scene defines the rendering scene
  58517. */
  58518. animate(scene: Scene): void;
  58519. private _emitDefine;
  58520. initialize(state: NodeMaterialBuildState): void;
  58521. /**
  58522. * Set the input block to its default value (based on its type)
  58523. */
  58524. setDefaultValue(): void;
  58525. private _emitConstant;
  58526. private _emit;
  58527. /** @hidden */
  58528. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58529. /** @hidden */
  58530. _transmit(effect: Effect, scene: Scene): void;
  58531. protected _buildBlock(state: NodeMaterialBuildState): void;
  58532. protected _dumpPropertiesCode(): string;
  58533. dispose(): void;
  58534. serialize(): any;
  58535. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58536. }
  58537. }
  58538. declare module BABYLON {
  58539. /**
  58540. * Enum used to define the compatibility state between two connection points
  58541. */
  58542. export enum NodeMaterialConnectionPointCompatibilityStates {
  58543. /** Points are compatibles */
  58544. Compatible = 0,
  58545. /** Points are incompatible because of their types */
  58546. TypeIncompatible = 1,
  58547. /** Points are incompatible because of their targets (vertex vs fragment) */
  58548. TargetIncompatible = 2
  58549. }
  58550. /**
  58551. * Defines the direction of a connection point
  58552. */
  58553. export enum NodeMaterialConnectionPointDirection {
  58554. /** Input */
  58555. Input = 0,
  58556. /** Output */
  58557. Output = 1
  58558. }
  58559. /**
  58560. * Defines a connection point for a block
  58561. */
  58562. export class NodeMaterialConnectionPoint {
  58563. /** @hidden */
  58564. _ownerBlock: NodeMaterialBlock;
  58565. /** @hidden */
  58566. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58567. private _endpoints;
  58568. private _associatedVariableName;
  58569. private _direction;
  58570. /** @hidden */
  58571. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58572. /** @hidden */
  58573. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58574. private _type;
  58575. /** @hidden */
  58576. _enforceAssociatedVariableName: boolean;
  58577. /** Gets the direction of the point */
  58578. get direction(): NodeMaterialConnectionPointDirection;
  58579. /**
  58580. * Gets or sets the additional types supported by this connection point
  58581. */
  58582. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58583. /**
  58584. * Gets or sets the additional types excluded by this connection point
  58585. */
  58586. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58587. /**
  58588. * Observable triggered when this point is connected
  58589. */
  58590. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58591. /**
  58592. * Gets or sets the associated variable name in the shader
  58593. */
  58594. get associatedVariableName(): string;
  58595. set associatedVariableName(value: string);
  58596. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58597. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58598. /**
  58599. * Gets or sets the connection point type (default is float)
  58600. */
  58601. get type(): NodeMaterialBlockConnectionPointTypes;
  58602. set type(value: NodeMaterialBlockConnectionPointTypes);
  58603. /**
  58604. * Gets or sets the connection point name
  58605. */
  58606. name: string;
  58607. /**
  58608. * Gets or sets a boolean indicating that this connection point can be omitted
  58609. */
  58610. isOptional: boolean;
  58611. /**
  58612. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58613. */
  58614. define: string;
  58615. /** @hidden */
  58616. _prioritizeVertex: boolean;
  58617. private _target;
  58618. /** Gets or sets the target of that connection point */
  58619. get target(): NodeMaterialBlockTargets;
  58620. set target(value: NodeMaterialBlockTargets);
  58621. /**
  58622. * Gets a boolean indicating that the current point is connected
  58623. */
  58624. get isConnected(): boolean;
  58625. /**
  58626. * Gets a boolean indicating that the current point is connected to an input block
  58627. */
  58628. get isConnectedToInputBlock(): boolean;
  58629. /**
  58630. * Gets a the connected input block (if any)
  58631. */
  58632. get connectInputBlock(): Nullable<InputBlock>;
  58633. /** Get the other side of the connection (if any) */
  58634. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58635. /** Get the block that owns this connection point */
  58636. get ownerBlock(): NodeMaterialBlock;
  58637. /** Get the block connected on the other side of this connection (if any) */
  58638. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58639. /** Get the block connected on the endpoints of this connection (if any) */
  58640. get connectedBlocks(): Array<NodeMaterialBlock>;
  58641. /** Gets the list of connected endpoints */
  58642. get endpoints(): NodeMaterialConnectionPoint[];
  58643. /** Gets a boolean indicating if that output point is connected to at least one input */
  58644. get hasEndpoints(): boolean;
  58645. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58646. get isConnectedInVertexShader(): boolean;
  58647. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58648. get isConnectedInFragmentShader(): boolean;
  58649. /**
  58650. * Creates a new connection point
  58651. * @param name defines the connection point name
  58652. * @param ownerBlock defines the block hosting this connection point
  58653. * @param direction defines the direction of the connection point
  58654. */
  58655. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58656. /**
  58657. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58658. * @returns the class name
  58659. */
  58660. getClassName(): string;
  58661. /**
  58662. * Gets a boolean indicating if the current point can be connected to another point
  58663. * @param connectionPoint defines the other connection point
  58664. * @returns a boolean
  58665. */
  58666. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58667. /**
  58668. * Gets a number indicating if the current point can be connected to another point
  58669. * @param connectionPoint defines the other connection point
  58670. * @returns a number defining the compatibility state
  58671. */
  58672. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58673. /**
  58674. * Connect this point to another connection point
  58675. * @param connectionPoint defines the other connection point
  58676. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58677. * @returns the current connection point
  58678. */
  58679. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58680. /**
  58681. * Disconnect this point from one of his endpoint
  58682. * @param endpoint defines the other connection point
  58683. * @returns the current connection point
  58684. */
  58685. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58686. /**
  58687. * Serializes this point in a JSON representation
  58688. * @returns the serialized point object
  58689. */
  58690. serialize(): any;
  58691. /**
  58692. * Release resources
  58693. */
  58694. dispose(): void;
  58695. }
  58696. }
  58697. declare module BABYLON {
  58698. /**
  58699. * Block used to add support for vertex skinning (bones)
  58700. */
  58701. export class BonesBlock extends NodeMaterialBlock {
  58702. /**
  58703. * Creates a new BonesBlock
  58704. * @param name defines the block name
  58705. */
  58706. constructor(name: string);
  58707. /**
  58708. * Initialize the block and prepare the context for build
  58709. * @param state defines the state that will be used for the build
  58710. */
  58711. initialize(state: NodeMaterialBuildState): void;
  58712. /**
  58713. * Gets the current class name
  58714. * @returns the class name
  58715. */
  58716. getClassName(): string;
  58717. /**
  58718. * Gets the matrix indices input component
  58719. */
  58720. get matricesIndices(): NodeMaterialConnectionPoint;
  58721. /**
  58722. * Gets the matrix weights input component
  58723. */
  58724. get matricesWeights(): NodeMaterialConnectionPoint;
  58725. /**
  58726. * Gets the extra matrix indices input component
  58727. */
  58728. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58729. /**
  58730. * Gets the extra matrix weights input component
  58731. */
  58732. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58733. /**
  58734. * Gets the world input component
  58735. */
  58736. get world(): NodeMaterialConnectionPoint;
  58737. /**
  58738. * Gets the output component
  58739. */
  58740. get output(): NodeMaterialConnectionPoint;
  58741. autoConfigure(material: NodeMaterial): void;
  58742. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58743. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58744. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58745. protected _buildBlock(state: NodeMaterialBuildState): this;
  58746. }
  58747. }
  58748. declare module BABYLON {
  58749. /**
  58750. * Block used to add support for instances
  58751. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58752. */
  58753. export class InstancesBlock extends NodeMaterialBlock {
  58754. /**
  58755. * Creates a new InstancesBlock
  58756. * @param name defines the block name
  58757. */
  58758. constructor(name: string);
  58759. /**
  58760. * Gets the current class name
  58761. * @returns the class name
  58762. */
  58763. getClassName(): string;
  58764. /**
  58765. * Gets the first world row input component
  58766. */
  58767. get world0(): NodeMaterialConnectionPoint;
  58768. /**
  58769. * Gets the second world row input component
  58770. */
  58771. get world1(): NodeMaterialConnectionPoint;
  58772. /**
  58773. * Gets the third world row input component
  58774. */
  58775. get world2(): NodeMaterialConnectionPoint;
  58776. /**
  58777. * Gets the forth world row input component
  58778. */
  58779. get world3(): NodeMaterialConnectionPoint;
  58780. /**
  58781. * Gets the world input component
  58782. */
  58783. get world(): NodeMaterialConnectionPoint;
  58784. /**
  58785. * Gets the output component
  58786. */
  58787. get output(): NodeMaterialConnectionPoint;
  58788. /**
  58789. * Gets the isntanceID component
  58790. */
  58791. get instanceID(): NodeMaterialConnectionPoint;
  58792. autoConfigure(material: NodeMaterial): void;
  58793. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58794. protected _buildBlock(state: NodeMaterialBuildState): this;
  58795. }
  58796. }
  58797. declare module BABYLON {
  58798. /**
  58799. * Block used to add morph targets support to vertex shader
  58800. */
  58801. export class MorphTargetsBlock extends NodeMaterialBlock {
  58802. private _repeatableContentAnchor;
  58803. /**
  58804. * Create a new MorphTargetsBlock
  58805. * @param name defines the block name
  58806. */
  58807. constructor(name: string);
  58808. /**
  58809. * Gets the current class name
  58810. * @returns the class name
  58811. */
  58812. getClassName(): string;
  58813. /**
  58814. * Gets the position input component
  58815. */
  58816. get position(): NodeMaterialConnectionPoint;
  58817. /**
  58818. * Gets the normal input component
  58819. */
  58820. get normal(): NodeMaterialConnectionPoint;
  58821. /**
  58822. * Gets the tangent input component
  58823. */
  58824. get tangent(): NodeMaterialConnectionPoint;
  58825. /**
  58826. * Gets the tangent input component
  58827. */
  58828. get uv(): NodeMaterialConnectionPoint;
  58829. /**
  58830. * Gets the position output component
  58831. */
  58832. get positionOutput(): NodeMaterialConnectionPoint;
  58833. /**
  58834. * Gets the normal output component
  58835. */
  58836. get normalOutput(): NodeMaterialConnectionPoint;
  58837. /**
  58838. * Gets the tangent output component
  58839. */
  58840. get tangentOutput(): NodeMaterialConnectionPoint;
  58841. /**
  58842. * Gets the tangent output component
  58843. */
  58844. get uvOutput(): NodeMaterialConnectionPoint;
  58845. initialize(state: NodeMaterialBuildState): void;
  58846. autoConfigure(material: NodeMaterial): void;
  58847. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58848. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58849. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58850. protected _buildBlock(state: NodeMaterialBuildState): this;
  58851. }
  58852. }
  58853. declare module BABYLON {
  58854. /**
  58855. * Block used to get data information from a light
  58856. */
  58857. export class LightInformationBlock extends NodeMaterialBlock {
  58858. private _lightDataUniformName;
  58859. private _lightColorUniformName;
  58860. private _lightTypeDefineName;
  58861. /**
  58862. * Gets or sets the light associated with this block
  58863. */
  58864. light: Nullable<Light>;
  58865. /**
  58866. * Creates a new LightInformationBlock
  58867. * @param name defines the block name
  58868. */
  58869. constructor(name: string);
  58870. /**
  58871. * Gets the current class name
  58872. * @returns the class name
  58873. */
  58874. getClassName(): string;
  58875. /**
  58876. * Gets the world position input component
  58877. */
  58878. get worldPosition(): NodeMaterialConnectionPoint;
  58879. /**
  58880. * Gets the direction output component
  58881. */
  58882. get direction(): NodeMaterialConnectionPoint;
  58883. /**
  58884. * Gets the direction output component
  58885. */
  58886. get color(): NodeMaterialConnectionPoint;
  58887. /**
  58888. * Gets the direction output component
  58889. */
  58890. get intensity(): NodeMaterialConnectionPoint;
  58891. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58892. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58893. protected _buildBlock(state: NodeMaterialBuildState): this;
  58894. serialize(): any;
  58895. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58896. }
  58897. }
  58898. declare module BABYLON {
  58899. /**
  58900. * Block used to add image processing support to fragment shader
  58901. */
  58902. export class ImageProcessingBlock extends NodeMaterialBlock {
  58903. /**
  58904. * Create a new ImageProcessingBlock
  58905. * @param name defines the block name
  58906. */
  58907. constructor(name: string);
  58908. /**
  58909. * Gets the current class name
  58910. * @returns the class name
  58911. */
  58912. getClassName(): string;
  58913. /**
  58914. * Gets the color input component
  58915. */
  58916. get color(): NodeMaterialConnectionPoint;
  58917. /**
  58918. * Gets the output component
  58919. */
  58920. get output(): NodeMaterialConnectionPoint;
  58921. /**
  58922. * Initialize the block and prepare the context for build
  58923. * @param state defines the state that will be used for the build
  58924. */
  58925. initialize(state: NodeMaterialBuildState): void;
  58926. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58927. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58928. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58929. protected _buildBlock(state: NodeMaterialBuildState): this;
  58930. }
  58931. }
  58932. declare module BABYLON {
  58933. /**
  58934. * Block used to pertub normals based on a normal map
  58935. */
  58936. export class PerturbNormalBlock extends NodeMaterialBlock {
  58937. private _tangentSpaceParameterName;
  58938. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58939. invertX: boolean;
  58940. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58941. invertY: boolean;
  58942. /**
  58943. * Create a new PerturbNormalBlock
  58944. * @param name defines the block name
  58945. */
  58946. constructor(name: string);
  58947. /**
  58948. * Gets the current class name
  58949. * @returns the class name
  58950. */
  58951. getClassName(): string;
  58952. /**
  58953. * Gets the world position input component
  58954. */
  58955. get worldPosition(): NodeMaterialConnectionPoint;
  58956. /**
  58957. * Gets the world normal input component
  58958. */
  58959. get worldNormal(): NodeMaterialConnectionPoint;
  58960. /**
  58961. * Gets the world tangent input component
  58962. */
  58963. get worldTangent(): NodeMaterialConnectionPoint;
  58964. /**
  58965. * Gets the uv input component
  58966. */
  58967. get uv(): NodeMaterialConnectionPoint;
  58968. /**
  58969. * Gets the normal map color input component
  58970. */
  58971. get normalMapColor(): NodeMaterialConnectionPoint;
  58972. /**
  58973. * Gets the strength input component
  58974. */
  58975. get strength(): NodeMaterialConnectionPoint;
  58976. /**
  58977. * Gets the output component
  58978. */
  58979. get output(): NodeMaterialConnectionPoint;
  58980. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58981. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58982. autoConfigure(material: NodeMaterial): void;
  58983. protected _buildBlock(state: NodeMaterialBuildState): this;
  58984. protected _dumpPropertiesCode(): string;
  58985. serialize(): any;
  58986. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58987. }
  58988. }
  58989. declare module BABYLON {
  58990. /**
  58991. * Block used to discard a pixel if a value is smaller than a cutoff
  58992. */
  58993. export class DiscardBlock extends NodeMaterialBlock {
  58994. /**
  58995. * Create a new DiscardBlock
  58996. * @param name defines the block name
  58997. */
  58998. constructor(name: string);
  58999. /**
  59000. * Gets the current class name
  59001. * @returns the class name
  59002. */
  59003. getClassName(): string;
  59004. /**
  59005. * Gets the color input component
  59006. */
  59007. get value(): NodeMaterialConnectionPoint;
  59008. /**
  59009. * Gets the cutoff input component
  59010. */
  59011. get cutoff(): NodeMaterialConnectionPoint;
  59012. protected _buildBlock(state: NodeMaterialBuildState): this;
  59013. }
  59014. }
  59015. declare module BABYLON {
  59016. /**
  59017. * Block used to test if the fragment shader is front facing
  59018. */
  59019. export class FrontFacingBlock extends NodeMaterialBlock {
  59020. /**
  59021. * Creates a new FrontFacingBlock
  59022. * @param name defines the block name
  59023. */
  59024. constructor(name: string);
  59025. /**
  59026. * Gets the current class name
  59027. * @returns the class name
  59028. */
  59029. getClassName(): string;
  59030. /**
  59031. * Gets the output component
  59032. */
  59033. get output(): NodeMaterialConnectionPoint;
  59034. protected _buildBlock(state: NodeMaterialBuildState): this;
  59035. }
  59036. }
  59037. declare module BABYLON {
  59038. /**
  59039. * Block used to get the derivative value on x and y of a given input
  59040. */
  59041. export class DerivativeBlock extends NodeMaterialBlock {
  59042. /**
  59043. * Create a new DerivativeBlock
  59044. * @param name defines the block name
  59045. */
  59046. constructor(name: string);
  59047. /**
  59048. * Gets the current class name
  59049. * @returns the class name
  59050. */
  59051. getClassName(): string;
  59052. /**
  59053. * Gets the input component
  59054. */
  59055. get input(): NodeMaterialConnectionPoint;
  59056. /**
  59057. * Gets the derivative output on x
  59058. */
  59059. get dx(): NodeMaterialConnectionPoint;
  59060. /**
  59061. * Gets the derivative output on y
  59062. */
  59063. get dy(): NodeMaterialConnectionPoint;
  59064. protected _buildBlock(state: NodeMaterialBuildState): this;
  59065. }
  59066. }
  59067. declare module BABYLON {
  59068. /**
  59069. * Block used to add support for scene fog
  59070. */
  59071. export class FogBlock extends NodeMaterialBlock {
  59072. private _fogDistanceName;
  59073. private _fogParameters;
  59074. /**
  59075. * Create a new FogBlock
  59076. * @param name defines the block name
  59077. */
  59078. constructor(name: string);
  59079. /**
  59080. * Gets the current class name
  59081. * @returns the class name
  59082. */
  59083. getClassName(): string;
  59084. /**
  59085. * Gets the world position input component
  59086. */
  59087. get worldPosition(): NodeMaterialConnectionPoint;
  59088. /**
  59089. * Gets the view input component
  59090. */
  59091. get view(): NodeMaterialConnectionPoint;
  59092. /**
  59093. * Gets the color input component
  59094. */
  59095. get input(): NodeMaterialConnectionPoint;
  59096. /**
  59097. * Gets the fog color input component
  59098. */
  59099. get fogColor(): NodeMaterialConnectionPoint;
  59100. /**
  59101. * Gets the output component
  59102. */
  59103. get output(): NodeMaterialConnectionPoint;
  59104. autoConfigure(material: NodeMaterial): void;
  59105. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59106. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59107. protected _buildBlock(state: NodeMaterialBuildState): this;
  59108. }
  59109. }
  59110. declare module BABYLON {
  59111. /**
  59112. * Block used to add light in the fragment shader
  59113. */
  59114. export class LightBlock extends NodeMaterialBlock {
  59115. private _lightId;
  59116. /**
  59117. * Gets or sets the light associated with this block
  59118. */
  59119. light: Nullable<Light>;
  59120. /**
  59121. * Create a new LightBlock
  59122. * @param name defines the block name
  59123. */
  59124. constructor(name: string);
  59125. /**
  59126. * Gets the current class name
  59127. * @returns the class name
  59128. */
  59129. getClassName(): string;
  59130. /**
  59131. * Gets the world position input component
  59132. */
  59133. get worldPosition(): NodeMaterialConnectionPoint;
  59134. /**
  59135. * Gets the world normal input component
  59136. */
  59137. get worldNormal(): NodeMaterialConnectionPoint;
  59138. /**
  59139. * Gets the camera (or eye) position component
  59140. */
  59141. get cameraPosition(): NodeMaterialConnectionPoint;
  59142. /**
  59143. * Gets the glossiness component
  59144. */
  59145. get glossiness(): NodeMaterialConnectionPoint;
  59146. /**
  59147. * Gets the glossinness power component
  59148. */
  59149. get glossPower(): NodeMaterialConnectionPoint;
  59150. /**
  59151. * Gets the diffuse color component
  59152. */
  59153. get diffuseColor(): NodeMaterialConnectionPoint;
  59154. /**
  59155. * Gets the specular color component
  59156. */
  59157. get specularColor(): NodeMaterialConnectionPoint;
  59158. /**
  59159. * Gets the diffuse output component
  59160. */
  59161. get diffuseOutput(): NodeMaterialConnectionPoint;
  59162. /**
  59163. * Gets the specular output component
  59164. */
  59165. get specularOutput(): NodeMaterialConnectionPoint;
  59166. /**
  59167. * Gets the shadow output component
  59168. */
  59169. get shadow(): NodeMaterialConnectionPoint;
  59170. autoConfigure(material: NodeMaterial): void;
  59171. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59172. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59173. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59174. private _injectVertexCode;
  59175. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59176. serialize(): any;
  59177. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59178. }
  59179. }
  59180. declare module BABYLON {
  59181. /**
  59182. * Block used to multiply 2 values
  59183. */
  59184. export class MultiplyBlock extends NodeMaterialBlock {
  59185. /**
  59186. * Creates a new MultiplyBlock
  59187. * @param name defines the block name
  59188. */
  59189. constructor(name: string);
  59190. /**
  59191. * Gets the current class name
  59192. * @returns the class name
  59193. */
  59194. getClassName(): string;
  59195. /**
  59196. * Gets the left operand input component
  59197. */
  59198. get left(): NodeMaterialConnectionPoint;
  59199. /**
  59200. * Gets the right operand input component
  59201. */
  59202. get right(): NodeMaterialConnectionPoint;
  59203. /**
  59204. * Gets the output component
  59205. */
  59206. get output(): NodeMaterialConnectionPoint;
  59207. protected _buildBlock(state: NodeMaterialBuildState): this;
  59208. }
  59209. }
  59210. declare module BABYLON {
  59211. /**
  59212. * Block used to add 2 vectors
  59213. */
  59214. export class AddBlock extends NodeMaterialBlock {
  59215. /**
  59216. * Creates a new AddBlock
  59217. * @param name defines the block name
  59218. */
  59219. constructor(name: string);
  59220. /**
  59221. * Gets the current class name
  59222. * @returns the class name
  59223. */
  59224. getClassName(): string;
  59225. /**
  59226. * Gets the left operand input component
  59227. */
  59228. get left(): NodeMaterialConnectionPoint;
  59229. /**
  59230. * Gets the right operand input component
  59231. */
  59232. get right(): NodeMaterialConnectionPoint;
  59233. /**
  59234. * Gets the output component
  59235. */
  59236. get output(): NodeMaterialConnectionPoint;
  59237. protected _buildBlock(state: NodeMaterialBuildState): this;
  59238. }
  59239. }
  59240. declare module BABYLON {
  59241. /**
  59242. * Block used to scale a vector by a float
  59243. */
  59244. export class ScaleBlock extends NodeMaterialBlock {
  59245. /**
  59246. * Creates a new ScaleBlock
  59247. * @param name defines the block name
  59248. */
  59249. constructor(name: string);
  59250. /**
  59251. * Gets the current class name
  59252. * @returns the class name
  59253. */
  59254. getClassName(): string;
  59255. /**
  59256. * Gets the input component
  59257. */
  59258. get input(): NodeMaterialConnectionPoint;
  59259. /**
  59260. * Gets the factor input component
  59261. */
  59262. get factor(): NodeMaterialConnectionPoint;
  59263. /**
  59264. * Gets the output component
  59265. */
  59266. get output(): NodeMaterialConnectionPoint;
  59267. protected _buildBlock(state: NodeMaterialBuildState): this;
  59268. }
  59269. }
  59270. declare module BABYLON {
  59271. /**
  59272. * Block used to clamp a float
  59273. */
  59274. export class ClampBlock extends NodeMaterialBlock {
  59275. /** Gets or sets the minimum range */
  59276. minimum: number;
  59277. /** Gets or sets the maximum range */
  59278. maximum: number;
  59279. /**
  59280. * Creates a new ClampBlock
  59281. * @param name defines the block name
  59282. */
  59283. constructor(name: string);
  59284. /**
  59285. * Gets the current class name
  59286. * @returns the class name
  59287. */
  59288. getClassName(): string;
  59289. /**
  59290. * Gets the value input component
  59291. */
  59292. get value(): NodeMaterialConnectionPoint;
  59293. /**
  59294. * Gets the output component
  59295. */
  59296. get output(): NodeMaterialConnectionPoint;
  59297. protected _buildBlock(state: NodeMaterialBuildState): this;
  59298. protected _dumpPropertiesCode(): string;
  59299. serialize(): any;
  59300. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59301. }
  59302. }
  59303. declare module BABYLON {
  59304. /**
  59305. * Block used to apply a cross product between 2 vectors
  59306. */
  59307. export class CrossBlock extends NodeMaterialBlock {
  59308. /**
  59309. * Creates a new CrossBlock
  59310. * @param name defines the block name
  59311. */
  59312. constructor(name: string);
  59313. /**
  59314. * Gets the current class name
  59315. * @returns the class name
  59316. */
  59317. getClassName(): string;
  59318. /**
  59319. * Gets the left operand input component
  59320. */
  59321. get left(): NodeMaterialConnectionPoint;
  59322. /**
  59323. * Gets the right operand input component
  59324. */
  59325. get right(): NodeMaterialConnectionPoint;
  59326. /**
  59327. * Gets the output component
  59328. */
  59329. get output(): NodeMaterialConnectionPoint;
  59330. protected _buildBlock(state: NodeMaterialBuildState): this;
  59331. }
  59332. }
  59333. declare module BABYLON {
  59334. /**
  59335. * Block used to apply a dot product between 2 vectors
  59336. */
  59337. export class DotBlock extends NodeMaterialBlock {
  59338. /**
  59339. * Creates a new DotBlock
  59340. * @param name defines the block name
  59341. */
  59342. constructor(name: string);
  59343. /**
  59344. * Gets the current class name
  59345. * @returns the class name
  59346. */
  59347. getClassName(): string;
  59348. /**
  59349. * Gets the left operand input component
  59350. */
  59351. get left(): NodeMaterialConnectionPoint;
  59352. /**
  59353. * Gets the right operand input component
  59354. */
  59355. get right(): NodeMaterialConnectionPoint;
  59356. /**
  59357. * Gets the output component
  59358. */
  59359. get output(): NodeMaterialConnectionPoint;
  59360. protected _buildBlock(state: NodeMaterialBuildState): this;
  59361. }
  59362. }
  59363. declare module BABYLON {
  59364. /**
  59365. * Block used to remap a float from a range to a new one
  59366. */
  59367. export class RemapBlock extends NodeMaterialBlock {
  59368. /**
  59369. * Gets or sets the source range
  59370. */
  59371. sourceRange: Vector2;
  59372. /**
  59373. * Gets or sets the target range
  59374. */
  59375. targetRange: Vector2;
  59376. /**
  59377. * Creates a new RemapBlock
  59378. * @param name defines the block name
  59379. */
  59380. constructor(name: string);
  59381. /**
  59382. * Gets the current class name
  59383. * @returns the class name
  59384. */
  59385. getClassName(): string;
  59386. /**
  59387. * Gets the input component
  59388. */
  59389. get input(): NodeMaterialConnectionPoint;
  59390. /**
  59391. * Gets the source min input component
  59392. */
  59393. get sourceMin(): NodeMaterialConnectionPoint;
  59394. /**
  59395. * Gets the source max input component
  59396. */
  59397. get sourceMax(): NodeMaterialConnectionPoint;
  59398. /**
  59399. * Gets the target min input component
  59400. */
  59401. get targetMin(): NodeMaterialConnectionPoint;
  59402. /**
  59403. * Gets the target max input component
  59404. */
  59405. get targetMax(): NodeMaterialConnectionPoint;
  59406. /**
  59407. * Gets the output component
  59408. */
  59409. get output(): NodeMaterialConnectionPoint;
  59410. protected _buildBlock(state: NodeMaterialBuildState): this;
  59411. protected _dumpPropertiesCode(): string;
  59412. serialize(): any;
  59413. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59414. }
  59415. }
  59416. declare module BABYLON {
  59417. /**
  59418. * Block used to normalize a vector
  59419. */
  59420. export class NormalizeBlock extends NodeMaterialBlock {
  59421. /**
  59422. * Creates a new NormalizeBlock
  59423. * @param name defines the block name
  59424. */
  59425. constructor(name: string);
  59426. /**
  59427. * Gets the current class name
  59428. * @returns the class name
  59429. */
  59430. getClassName(): string;
  59431. /**
  59432. * Gets the input component
  59433. */
  59434. get input(): NodeMaterialConnectionPoint;
  59435. /**
  59436. * Gets the output component
  59437. */
  59438. get output(): NodeMaterialConnectionPoint;
  59439. protected _buildBlock(state: NodeMaterialBuildState): this;
  59440. }
  59441. }
  59442. declare module BABYLON {
  59443. /**
  59444. * Operations supported by the Trigonometry block
  59445. */
  59446. export enum TrigonometryBlockOperations {
  59447. /** Cos */
  59448. Cos = 0,
  59449. /** Sin */
  59450. Sin = 1,
  59451. /** Abs */
  59452. Abs = 2,
  59453. /** Exp */
  59454. Exp = 3,
  59455. /** Exp2 */
  59456. Exp2 = 4,
  59457. /** Round */
  59458. Round = 5,
  59459. /** Floor */
  59460. Floor = 6,
  59461. /** Ceiling */
  59462. Ceiling = 7,
  59463. /** Square root */
  59464. Sqrt = 8,
  59465. /** Log */
  59466. Log = 9,
  59467. /** Tangent */
  59468. Tan = 10,
  59469. /** Arc tangent */
  59470. ArcTan = 11,
  59471. /** Arc cosinus */
  59472. ArcCos = 12,
  59473. /** Arc sinus */
  59474. ArcSin = 13,
  59475. /** Fraction */
  59476. Fract = 14,
  59477. /** Sign */
  59478. Sign = 15,
  59479. /** To radians (from degrees) */
  59480. Radians = 16,
  59481. /** To degrees (from radians) */
  59482. Degrees = 17
  59483. }
  59484. /**
  59485. * Block used to apply trigonometry operation to floats
  59486. */
  59487. export class TrigonometryBlock extends NodeMaterialBlock {
  59488. /**
  59489. * Gets or sets the operation applied by the block
  59490. */
  59491. operation: TrigonometryBlockOperations;
  59492. /**
  59493. * Creates a new TrigonometryBlock
  59494. * @param name defines the block name
  59495. */
  59496. constructor(name: string);
  59497. /**
  59498. * Gets the current class name
  59499. * @returns the class name
  59500. */
  59501. getClassName(): string;
  59502. /**
  59503. * Gets the input component
  59504. */
  59505. get input(): NodeMaterialConnectionPoint;
  59506. /**
  59507. * Gets the output component
  59508. */
  59509. get output(): NodeMaterialConnectionPoint;
  59510. protected _buildBlock(state: NodeMaterialBuildState): this;
  59511. serialize(): any;
  59512. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59513. protected _dumpPropertiesCode(): string;
  59514. }
  59515. }
  59516. declare module BABYLON {
  59517. /**
  59518. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59519. */
  59520. export class ColorMergerBlock extends NodeMaterialBlock {
  59521. /**
  59522. * Create a new ColorMergerBlock
  59523. * @param name defines the block name
  59524. */
  59525. constructor(name: string);
  59526. /**
  59527. * Gets the current class name
  59528. * @returns the class name
  59529. */
  59530. getClassName(): string;
  59531. /**
  59532. * Gets the rgb component (input)
  59533. */
  59534. get rgbIn(): NodeMaterialConnectionPoint;
  59535. /**
  59536. * Gets the r component (input)
  59537. */
  59538. get r(): NodeMaterialConnectionPoint;
  59539. /**
  59540. * Gets the g component (input)
  59541. */
  59542. get g(): NodeMaterialConnectionPoint;
  59543. /**
  59544. * Gets the b component (input)
  59545. */
  59546. get b(): NodeMaterialConnectionPoint;
  59547. /**
  59548. * Gets the a component (input)
  59549. */
  59550. get a(): NodeMaterialConnectionPoint;
  59551. /**
  59552. * Gets the rgba component (output)
  59553. */
  59554. get rgba(): NodeMaterialConnectionPoint;
  59555. /**
  59556. * Gets the rgb component (output)
  59557. */
  59558. get rgbOut(): NodeMaterialConnectionPoint;
  59559. /**
  59560. * Gets the rgb component (output)
  59561. * @deprecated Please use rgbOut instead.
  59562. */
  59563. get rgb(): NodeMaterialConnectionPoint;
  59564. protected _buildBlock(state: NodeMaterialBuildState): this;
  59565. }
  59566. }
  59567. declare module BABYLON {
  59568. /**
  59569. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59570. */
  59571. export class VectorMergerBlock extends NodeMaterialBlock {
  59572. /**
  59573. * Create a new VectorMergerBlock
  59574. * @param name defines the block name
  59575. */
  59576. constructor(name: string);
  59577. /**
  59578. * Gets the current class name
  59579. * @returns the class name
  59580. */
  59581. getClassName(): string;
  59582. /**
  59583. * Gets the xyz component (input)
  59584. */
  59585. get xyzIn(): NodeMaterialConnectionPoint;
  59586. /**
  59587. * Gets the xy component (input)
  59588. */
  59589. get xyIn(): NodeMaterialConnectionPoint;
  59590. /**
  59591. * Gets the x component (input)
  59592. */
  59593. get x(): NodeMaterialConnectionPoint;
  59594. /**
  59595. * Gets the y component (input)
  59596. */
  59597. get y(): NodeMaterialConnectionPoint;
  59598. /**
  59599. * Gets the z component (input)
  59600. */
  59601. get z(): NodeMaterialConnectionPoint;
  59602. /**
  59603. * Gets the w component (input)
  59604. */
  59605. get w(): NodeMaterialConnectionPoint;
  59606. /**
  59607. * Gets the xyzw component (output)
  59608. */
  59609. get xyzw(): NodeMaterialConnectionPoint;
  59610. /**
  59611. * Gets the xyz component (output)
  59612. */
  59613. get xyzOut(): NodeMaterialConnectionPoint;
  59614. /**
  59615. * Gets the xy component (output)
  59616. */
  59617. get xyOut(): NodeMaterialConnectionPoint;
  59618. /**
  59619. * Gets the xy component (output)
  59620. * @deprecated Please use xyOut instead.
  59621. */
  59622. get xy(): NodeMaterialConnectionPoint;
  59623. /**
  59624. * Gets the xyz component (output)
  59625. * @deprecated Please use xyzOut instead.
  59626. */
  59627. get xyz(): NodeMaterialConnectionPoint;
  59628. protected _buildBlock(state: NodeMaterialBuildState): this;
  59629. }
  59630. }
  59631. declare module BABYLON {
  59632. /**
  59633. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59634. */
  59635. export class ColorSplitterBlock extends NodeMaterialBlock {
  59636. /**
  59637. * Create a new ColorSplitterBlock
  59638. * @param name defines the block name
  59639. */
  59640. constructor(name: string);
  59641. /**
  59642. * Gets the current class name
  59643. * @returns the class name
  59644. */
  59645. getClassName(): string;
  59646. /**
  59647. * Gets the rgba component (input)
  59648. */
  59649. get rgba(): NodeMaterialConnectionPoint;
  59650. /**
  59651. * Gets the rgb component (input)
  59652. */
  59653. get rgbIn(): NodeMaterialConnectionPoint;
  59654. /**
  59655. * Gets the rgb component (output)
  59656. */
  59657. get rgbOut(): NodeMaterialConnectionPoint;
  59658. /**
  59659. * Gets the r component (output)
  59660. */
  59661. get r(): NodeMaterialConnectionPoint;
  59662. /**
  59663. * Gets the g component (output)
  59664. */
  59665. get g(): NodeMaterialConnectionPoint;
  59666. /**
  59667. * Gets the b component (output)
  59668. */
  59669. get b(): NodeMaterialConnectionPoint;
  59670. /**
  59671. * Gets the a component (output)
  59672. */
  59673. get a(): NodeMaterialConnectionPoint;
  59674. protected _inputRename(name: string): string;
  59675. protected _outputRename(name: string): string;
  59676. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59677. }
  59678. }
  59679. declare module BABYLON {
  59680. /**
  59681. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59682. */
  59683. export class VectorSplitterBlock extends NodeMaterialBlock {
  59684. /**
  59685. * Create a new VectorSplitterBlock
  59686. * @param name defines the block name
  59687. */
  59688. constructor(name: string);
  59689. /**
  59690. * Gets the current class name
  59691. * @returns the class name
  59692. */
  59693. getClassName(): string;
  59694. /**
  59695. * Gets the xyzw component (input)
  59696. */
  59697. get xyzw(): NodeMaterialConnectionPoint;
  59698. /**
  59699. * Gets the xyz component (input)
  59700. */
  59701. get xyzIn(): NodeMaterialConnectionPoint;
  59702. /**
  59703. * Gets the xy component (input)
  59704. */
  59705. get xyIn(): NodeMaterialConnectionPoint;
  59706. /**
  59707. * Gets the xyz component (output)
  59708. */
  59709. get xyzOut(): NodeMaterialConnectionPoint;
  59710. /**
  59711. * Gets the xy component (output)
  59712. */
  59713. get xyOut(): NodeMaterialConnectionPoint;
  59714. /**
  59715. * Gets the x component (output)
  59716. */
  59717. get x(): NodeMaterialConnectionPoint;
  59718. /**
  59719. * Gets the y component (output)
  59720. */
  59721. get y(): NodeMaterialConnectionPoint;
  59722. /**
  59723. * Gets the z component (output)
  59724. */
  59725. get z(): NodeMaterialConnectionPoint;
  59726. /**
  59727. * Gets the w component (output)
  59728. */
  59729. get w(): NodeMaterialConnectionPoint;
  59730. protected _inputRename(name: string): string;
  59731. protected _outputRename(name: string): string;
  59732. protected _buildBlock(state: NodeMaterialBuildState): this;
  59733. }
  59734. }
  59735. declare module BABYLON {
  59736. /**
  59737. * Block used to lerp between 2 values
  59738. */
  59739. export class LerpBlock extends NodeMaterialBlock {
  59740. /**
  59741. * Creates a new LerpBlock
  59742. * @param name defines the block name
  59743. */
  59744. constructor(name: string);
  59745. /**
  59746. * Gets the current class name
  59747. * @returns the class name
  59748. */
  59749. getClassName(): string;
  59750. /**
  59751. * Gets the left operand input component
  59752. */
  59753. get left(): NodeMaterialConnectionPoint;
  59754. /**
  59755. * Gets the right operand input component
  59756. */
  59757. get right(): NodeMaterialConnectionPoint;
  59758. /**
  59759. * Gets the gradient operand input component
  59760. */
  59761. get gradient(): NodeMaterialConnectionPoint;
  59762. /**
  59763. * Gets the output component
  59764. */
  59765. get output(): NodeMaterialConnectionPoint;
  59766. protected _buildBlock(state: NodeMaterialBuildState): this;
  59767. }
  59768. }
  59769. declare module BABYLON {
  59770. /**
  59771. * Block used to divide 2 vectors
  59772. */
  59773. export class DivideBlock extends NodeMaterialBlock {
  59774. /**
  59775. * Creates a new DivideBlock
  59776. * @param name defines the block name
  59777. */
  59778. constructor(name: string);
  59779. /**
  59780. * Gets the current class name
  59781. * @returns the class name
  59782. */
  59783. getClassName(): string;
  59784. /**
  59785. * Gets the left operand input component
  59786. */
  59787. get left(): NodeMaterialConnectionPoint;
  59788. /**
  59789. * Gets the right operand input component
  59790. */
  59791. get right(): NodeMaterialConnectionPoint;
  59792. /**
  59793. * Gets the output component
  59794. */
  59795. get output(): NodeMaterialConnectionPoint;
  59796. protected _buildBlock(state: NodeMaterialBuildState): this;
  59797. }
  59798. }
  59799. declare module BABYLON {
  59800. /**
  59801. * Block used to subtract 2 vectors
  59802. */
  59803. export class SubtractBlock extends NodeMaterialBlock {
  59804. /**
  59805. * Creates a new SubtractBlock
  59806. * @param name defines the block name
  59807. */
  59808. constructor(name: string);
  59809. /**
  59810. * Gets the current class name
  59811. * @returns the class name
  59812. */
  59813. getClassName(): string;
  59814. /**
  59815. * Gets the left operand input component
  59816. */
  59817. get left(): NodeMaterialConnectionPoint;
  59818. /**
  59819. * Gets the right operand input component
  59820. */
  59821. get right(): NodeMaterialConnectionPoint;
  59822. /**
  59823. * Gets the output component
  59824. */
  59825. get output(): NodeMaterialConnectionPoint;
  59826. protected _buildBlock(state: NodeMaterialBuildState): this;
  59827. }
  59828. }
  59829. declare module BABYLON {
  59830. /**
  59831. * Block used to step a value
  59832. */
  59833. export class StepBlock extends NodeMaterialBlock {
  59834. /**
  59835. * Creates a new StepBlock
  59836. * @param name defines the block name
  59837. */
  59838. constructor(name: string);
  59839. /**
  59840. * Gets the current class name
  59841. * @returns the class name
  59842. */
  59843. getClassName(): string;
  59844. /**
  59845. * Gets the value operand input component
  59846. */
  59847. get value(): NodeMaterialConnectionPoint;
  59848. /**
  59849. * Gets the edge operand input component
  59850. */
  59851. get edge(): NodeMaterialConnectionPoint;
  59852. /**
  59853. * Gets the output component
  59854. */
  59855. get output(): NodeMaterialConnectionPoint;
  59856. protected _buildBlock(state: NodeMaterialBuildState): this;
  59857. }
  59858. }
  59859. declare module BABYLON {
  59860. /**
  59861. * Block used to get the opposite (1 - x) of a value
  59862. */
  59863. export class OneMinusBlock extends NodeMaterialBlock {
  59864. /**
  59865. * Creates a new OneMinusBlock
  59866. * @param name defines the block name
  59867. */
  59868. constructor(name: string);
  59869. /**
  59870. * Gets the current class name
  59871. * @returns the class name
  59872. */
  59873. getClassName(): string;
  59874. /**
  59875. * Gets the input component
  59876. */
  59877. get input(): NodeMaterialConnectionPoint;
  59878. /**
  59879. * Gets the output component
  59880. */
  59881. get output(): NodeMaterialConnectionPoint;
  59882. protected _buildBlock(state: NodeMaterialBuildState): this;
  59883. }
  59884. }
  59885. declare module BABYLON {
  59886. /**
  59887. * Block used to get the view direction
  59888. */
  59889. export class ViewDirectionBlock extends NodeMaterialBlock {
  59890. /**
  59891. * Creates a new ViewDirectionBlock
  59892. * @param name defines the block name
  59893. */
  59894. constructor(name: string);
  59895. /**
  59896. * Gets the current class name
  59897. * @returns the class name
  59898. */
  59899. getClassName(): string;
  59900. /**
  59901. * Gets the world position component
  59902. */
  59903. get worldPosition(): NodeMaterialConnectionPoint;
  59904. /**
  59905. * Gets the camera position component
  59906. */
  59907. get cameraPosition(): NodeMaterialConnectionPoint;
  59908. /**
  59909. * Gets the output component
  59910. */
  59911. get output(): NodeMaterialConnectionPoint;
  59912. autoConfigure(material: NodeMaterial): void;
  59913. protected _buildBlock(state: NodeMaterialBuildState): this;
  59914. }
  59915. }
  59916. declare module BABYLON {
  59917. /**
  59918. * Block used to compute fresnel value
  59919. */
  59920. export class FresnelBlock extends NodeMaterialBlock {
  59921. /**
  59922. * Create a new FresnelBlock
  59923. * @param name defines the block name
  59924. */
  59925. constructor(name: string);
  59926. /**
  59927. * Gets the current class name
  59928. * @returns the class name
  59929. */
  59930. getClassName(): string;
  59931. /**
  59932. * Gets the world normal input component
  59933. */
  59934. get worldNormal(): NodeMaterialConnectionPoint;
  59935. /**
  59936. * Gets the view direction input component
  59937. */
  59938. get viewDirection(): NodeMaterialConnectionPoint;
  59939. /**
  59940. * Gets the bias input component
  59941. */
  59942. get bias(): NodeMaterialConnectionPoint;
  59943. /**
  59944. * Gets the camera (or eye) position component
  59945. */
  59946. get power(): NodeMaterialConnectionPoint;
  59947. /**
  59948. * Gets the fresnel output component
  59949. */
  59950. get fresnel(): NodeMaterialConnectionPoint;
  59951. autoConfigure(material: NodeMaterial): void;
  59952. protected _buildBlock(state: NodeMaterialBuildState): this;
  59953. }
  59954. }
  59955. declare module BABYLON {
  59956. /**
  59957. * Block used to get the max of 2 values
  59958. */
  59959. export class MaxBlock extends NodeMaterialBlock {
  59960. /**
  59961. * Creates a new MaxBlock
  59962. * @param name defines the block name
  59963. */
  59964. constructor(name: string);
  59965. /**
  59966. * Gets the current class name
  59967. * @returns the class name
  59968. */
  59969. getClassName(): string;
  59970. /**
  59971. * Gets the left operand input component
  59972. */
  59973. get left(): NodeMaterialConnectionPoint;
  59974. /**
  59975. * Gets the right operand input component
  59976. */
  59977. get right(): NodeMaterialConnectionPoint;
  59978. /**
  59979. * Gets the output component
  59980. */
  59981. get output(): NodeMaterialConnectionPoint;
  59982. protected _buildBlock(state: NodeMaterialBuildState): this;
  59983. }
  59984. }
  59985. declare module BABYLON {
  59986. /**
  59987. * Block used to get the min of 2 values
  59988. */
  59989. export class MinBlock extends NodeMaterialBlock {
  59990. /**
  59991. * Creates a new MinBlock
  59992. * @param name defines the block name
  59993. */
  59994. constructor(name: string);
  59995. /**
  59996. * Gets the current class name
  59997. * @returns the class name
  59998. */
  59999. getClassName(): string;
  60000. /**
  60001. * Gets the left operand input component
  60002. */
  60003. get left(): NodeMaterialConnectionPoint;
  60004. /**
  60005. * Gets the right operand input component
  60006. */
  60007. get right(): NodeMaterialConnectionPoint;
  60008. /**
  60009. * Gets the output component
  60010. */
  60011. get output(): NodeMaterialConnectionPoint;
  60012. protected _buildBlock(state: NodeMaterialBuildState): this;
  60013. }
  60014. }
  60015. declare module BABYLON {
  60016. /**
  60017. * Block used to get the distance between 2 values
  60018. */
  60019. export class DistanceBlock extends NodeMaterialBlock {
  60020. /**
  60021. * Creates a new DistanceBlock
  60022. * @param name defines the block name
  60023. */
  60024. constructor(name: string);
  60025. /**
  60026. * Gets the current class name
  60027. * @returns the class name
  60028. */
  60029. getClassName(): string;
  60030. /**
  60031. * Gets the left operand input component
  60032. */
  60033. get left(): NodeMaterialConnectionPoint;
  60034. /**
  60035. * Gets the right operand input component
  60036. */
  60037. get right(): NodeMaterialConnectionPoint;
  60038. /**
  60039. * Gets the output component
  60040. */
  60041. get output(): NodeMaterialConnectionPoint;
  60042. protected _buildBlock(state: NodeMaterialBuildState): this;
  60043. }
  60044. }
  60045. declare module BABYLON {
  60046. /**
  60047. * Block used to get the length of a vector
  60048. */
  60049. export class LengthBlock extends NodeMaterialBlock {
  60050. /**
  60051. * Creates a new LengthBlock
  60052. * @param name defines the block name
  60053. */
  60054. constructor(name: string);
  60055. /**
  60056. * Gets the current class name
  60057. * @returns the class name
  60058. */
  60059. getClassName(): string;
  60060. /**
  60061. * Gets the value input component
  60062. */
  60063. get value(): NodeMaterialConnectionPoint;
  60064. /**
  60065. * Gets the output component
  60066. */
  60067. get output(): NodeMaterialConnectionPoint;
  60068. protected _buildBlock(state: NodeMaterialBuildState): this;
  60069. }
  60070. }
  60071. declare module BABYLON {
  60072. /**
  60073. * Block used to get negative version of a value (i.e. x * -1)
  60074. */
  60075. export class NegateBlock extends NodeMaterialBlock {
  60076. /**
  60077. * Creates a new NegateBlock
  60078. * @param name defines the block name
  60079. */
  60080. constructor(name: string);
  60081. /**
  60082. * Gets the current class name
  60083. * @returns the class name
  60084. */
  60085. getClassName(): string;
  60086. /**
  60087. * Gets the value input component
  60088. */
  60089. get value(): NodeMaterialConnectionPoint;
  60090. /**
  60091. * Gets the output component
  60092. */
  60093. get output(): NodeMaterialConnectionPoint;
  60094. protected _buildBlock(state: NodeMaterialBuildState): this;
  60095. }
  60096. }
  60097. declare module BABYLON {
  60098. /**
  60099. * Block used to get the value of the first parameter raised to the power of the second
  60100. */
  60101. export class PowBlock extends NodeMaterialBlock {
  60102. /**
  60103. * Creates a new PowBlock
  60104. * @param name defines the block name
  60105. */
  60106. constructor(name: string);
  60107. /**
  60108. * Gets the current class name
  60109. * @returns the class name
  60110. */
  60111. getClassName(): string;
  60112. /**
  60113. * Gets the value operand input component
  60114. */
  60115. get value(): NodeMaterialConnectionPoint;
  60116. /**
  60117. * Gets the power operand input component
  60118. */
  60119. get power(): NodeMaterialConnectionPoint;
  60120. /**
  60121. * Gets the output component
  60122. */
  60123. get output(): NodeMaterialConnectionPoint;
  60124. protected _buildBlock(state: NodeMaterialBuildState): this;
  60125. }
  60126. }
  60127. declare module BABYLON {
  60128. /**
  60129. * Block used to get a random number
  60130. */
  60131. export class RandomNumberBlock extends NodeMaterialBlock {
  60132. /**
  60133. * Creates a new RandomNumberBlock
  60134. * @param name defines the block name
  60135. */
  60136. constructor(name: string);
  60137. /**
  60138. * Gets the current class name
  60139. * @returns the class name
  60140. */
  60141. getClassName(): string;
  60142. /**
  60143. * Gets the seed input component
  60144. */
  60145. get seed(): NodeMaterialConnectionPoint;
  60146. /**
  60147. * Gets the output component
  60148. */
  60149. get output(): NodeMaterialConnectionPoint;
  60150. protected _buildBlock(state: NodeMaterialBuildState): this;
  60151. }
  60152. }
  60153. declare module BABYLON {
  60154. /**
  60155. * Block used to compute arc tangent of 2 values
  60156. */
  60157. export class ArcTan2Block extends NodeMaterialBlock {
  60158. /**
  60159. * Creates a new ArcTan2Block
  60160. * @param name defines the block name
  60161. */
  60162. constructor(name: string);
  60163. /**
  60164. * Gets the current class name
  60165. * @returns the class name
  60166. */
  60167. getClassName(): string;
  60168. /**
  60169. * Gets the x operand input component
  60170. */
  60171. get x(): NodeMaterialConnectionPoint;
  60172. /**
  60173. * Gets the y operand input component
  60174. */
  60175. get y(): NodeMaterialConnectionPoint;
  60176. /**
  60177. * Gets the output component
  60178. */
  60179. get output(): NodeMaterialConnectionPoint;
  60180. protected _buildBlock(state: NodeMaterialBuildState): this;
  60181. }
  60182. }
  60183. declare module BABYLON {
  60184. /**
  60185. * Block used to smooth step a value
  60186. */
  60187. export class SmoothStepBlock extends NodeMaterialBlock {
  60188. /**
  60189. * Creates a new SmoothStepBlock
  60190. * @param name defines the block name
  60191. */
  60192. constructor(name: string);
  60193. /**
  60194. * Gets the current class name
  60195. * @returns the class name
  60196. */
  60197. getClassName(): string;
  60198. /**
  60199. * Gets the value operand input component
  60200. */
  60201. get value(): NodeMaterialConnectionPoint;
  60202. /**
  60203. * Gets the first edge operand input component
  60204. */
  60205. get edge0(): NodeMaterialConnectionPoint;
  60206. /**
  60207. * Gets the second edge operand input component
  60208. */
  60209. get edge1(): NodeMaterialConnectionPoint;
  60210. /**
  60211. * Gets the output component
  60212. */
  60213. get output(): NodeMaterialConnectionPoint;
  60214. protected _buildBlock(state: NodeMaterialBuildState): this;
  60215. }
  60216. }
  60217. declare module BABYLON {
  60218. /**
  60219. * Block used to get the reciprocal (1 / x) of a value
  60220. */
  60221. export class ReciprocalBlock extends NodeMaterialBlock {
  60222. /**
  60223. * Creates a new ReciprocalBlock
  60224. * @param name defines the block name
  60225. */
  60226. constructor(name: string);
  60227. /**
  60228. * Gets the current class name
  60229. * @returns the class name
  60230. */
  60231. getClassName(): string;
  60232. /**
  60233. * Gets the input component
  60234. */
  60235. get input(): NodeMaterialConnectionPoint;
  60236. /**
  60237. * Gets the output component
  60238. */
  60239. get output(): NodeMaterialConnectionPoint;
  60240. protected _buildBlock(state: NodeMaterialBuildState): this;
  60241. }
  60242. }
  60243. declare module BABYLON {
  60244. /**
  60245. * Block used to replace a color by another one
  60246. */
  60247. export class ReplaceColorBlock extends NodeMaterialBlock {
  60248. /**
  60249. * Creates a new ReplaceColorBlock
  60250. * @param name defines the block name
  60251. */
  60252. constructor(name: string);
  60253. /**
  60254. * Gets the current class name
  60255. * @returns the class name
  60256. */
  60257. getClassName(): string;
  60258. /**
  60259. * Gets the value input component
  60260. */
  60261. get value(): NodeMaterialConnectionPoint;
  60262. /**
  60263. * Gets the reference input component
  60264. */
  60265. get reference(): NodeMaterialConnectionPoint;
  60266. /**
  60267. * Gets the distance input component
  60268. */
  60269. get distance(): NodeMaterialConnectionPoint;
  60270. /**
  60271. * Gets the replacement input component
  60272. */
  60273. get replacement(): NodeMaterialConnectionPoint;
  60274. /**
  60275. * Gets the output component
  60276. */
  60277. get output(): NodeMaterialConnectionPoint;
  60278. protected _buildBlock(state: NodeMaterialBuildState): this;
  60279. }
  60280. }
  60281. declare module BABYLON {
  60282. /**
  60283. * Block used to posterize a value
  60284. * @see https://en.wikipedia.org/wiki/Posterization
  60285. */
  60286. export class PosterizeBlock extends NodeMaterialBlock {
  60287. /**
  60288. * Creates a new PosterizeBlock
  60289. * @param name defines the block name
  60290. */
  60291. constructor(name: string);
  60292. /**
  60293. * Gets the current class name
  60294. * @returns the class name
  60295. */
  60296. getClassName(): string;
  60297. /**
  60298. * Gets the value input component
  60299. */
  60300. get value(): NodeMaterialConnectionPoint;
  60301. /**
  60302. * Gets the steps input component
  60303. */
  60304. get steps(): NodeMaterialConnectionPoint;
  60305. /**
  60306. * Gets the output component
  60307. */
  60308. get output(): NodeMaterialConnectionPoint;
  60309. protected _buildBlock(state: NodeMaterialBuildState): this;
  60310. }
  60311. }
  60312. declare module BABYLON {
  60313. /**
  60314. * Operations supported by the Wave block
  60315. */
  60316. export enum WaveBlockKind {
  60317. /** SawTooth */
  60318. SawTooth = 0,
  60319. /** Square */
  60320. Square = 1,
  60321. /** Triangle */
  60322. Triangle = 2
  60323. }
  60324. /**
  60325. * Block used to apply wave operation to floats
  60326. */
  60327. export class WaveBlock extends NodeMaterialBlock {
  60328. /**
  60329. * Gets or sets the kibnd of wave to be applied by the block
  60330. */
  60331. kind: WaveBlockKind;
  60332. /**
  60333. * Creates a new WaveBlock
  60334. * @param name defines the block name
  60335. */
  60336. constructor(name: string);
  60337. /**
  60338. * Gets the current class name
  60339. * @returns the class name
  60340. */
  60341. getClassName(): string;
  60342. /**
  60343. * Gets the input component
  60344. */
  60345. get input(): NodeMaterialConnectionPoint;
  60346. /**
  60347. * Gets the output component
  60348. */
  60349. get output(): NodeMaterialConnectionPoint;
  60350. protected _buildBlock(state: NodeMaterialBuildState): this;
  60351. serialize(): any;
  60352. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60353. }
  60354. }
  60355. declare module BABYLON {
  60356. /**
  60357. * Class used to store a color step for the GradientBlock
  60358. */
  60359. export class GradientBlockColorStep {
  60360. /**
  60361. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60362. */
  60363. step: number;
  60364. /**
  60365. * Gets or sets the color associated with this step
  60366. */
  60367. color: Color3;
  60368. /**
  60369. * Creates a new GradientBlockColorStep
  60370. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60371. * @param color defines the color associated with this step
  60372. */
  60373. constructor(
  60374. /**
  60375. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60376. */
  60377. step: number,
  60378. /**
  60379. * Gets or sets the color associated with this step
  60380. */
  60381. color: Color3);
  60382. }
  60383. /**
  60384. * Block used to return a color from a gradient based on an input value between 0 and 1
  60385. */
  60386. export class GradientBlock extends NodeMaterialBlock {
  60387. /**
  60388. * Gets or sets the list of color steps
  60389. */
  60390. colorSteps: GradientBlockColorStep[];
  60391. /**
  60392. * Creates a new GradientBlock
  60393. * @param name defines the block name
  60394. */
  60395. constructor(name: string);
  60396. /**
  60397. * Gets the current class name
  60398. * @returns the class name
  60399. */
  60400. getClassName(): string;
  60401. /**
  60402. * Gets the gradient input component
  60403. */
  60404. get gradient(): NodeMaterialConnectionPoint;
  60405. /**
  60406. * Gets the output component
  60407. */
  60408. get output(): NodeMaterialConnectionPoint;
  60409. private _writeColorConstant;
  60410. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60411. serialize(): any;
  60412. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60413. protected _dumpPropertiesCode(): string;
  60414. }
  60415. }
  60416. declare module BABYLON {
  60417. /**
  60418. * Block used to normalize lerp between 2 values
  60419. */
  60420. export class NLerpBlock extends NodeMaterialBlock {
  60421. /**
  60422. * Creates a new NLerpBlock
  60423. * @param name defines the block name
  60424. */
  60425. constructor(name: string);
  60426. /**
  60427. * Gets the current class name
  60428. * @returns the class name
  60429. */
  60430. getClassName(): string;
  60431. /**
  60432. * Gets the left operand input component
  60433. */
  60434. get left(): NodeMaterialConnectionPoint;
  60435. /**
  60436. * Gets the right operand input component
  60437. */
  60438. get right(): NodeMaterialConnectionPoint;
  60439. /**
  60440. * Gets the gradient operand input component
  60441. */
  60442. get gradient(): NodeMaterialConnectionPoint;
  60443. /**
  60444. * Gets the output component
  60445. */
  60446. get output(): NodeMaterialConnectionPoint;
  60447. protected _buildBlock(state: NodeMaterialBuildState): this;
  60448. }
  60449. }
  60450. declare module BABYLON {
  60451. /**
  60452. * block used to Generate a Worley Noise 3D Noise Pattern
  60453. */
  60454. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60455. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60456. manhattanDistance: boolean;
  60457. /**
  60458. * Creates a new WorleyNoise3DBlock
  60459. * @param name defines the block name
  60460. */
  60461. constructor(name: string);
  60462. /**
  60463. * Gets the current class name
  60464. * @returns the class name
  60465. */
  60466. getClassName(): string;
  60467. /**
  60468. * Gets the seed input component
  60469. */
  60470. get seed(): NodeMaterialConnectionPoint;
  60471. /**
  60472. * Gets the jitter input component
  60473. */
  60474. get jitter(): NodeMaterialConnectionPoint;
  60475. /**
  60476. * Gets the output component
  60477. */
  60478. get output(): NodeMaterialConnectionPoint;
  60479. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60480. /**
  60481. * Exposes the properties to the UI?
  60482. */
  60483. protected _dumpPropertiesCode(): string;
  60484. /**
  60485. * Exposes the properties to the Seralize?
  60486. */
  60487. serialize(): any;
  60488. /**
  60489. * Exposes the properties to the deseralize?
  60490. */
  60491. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60492. }
  60493. }
  60494. declare module BABYLON {
  60495. /**
  60496. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60497. */
  60498. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60499. /**
  60500. * Creates a new SimplexPerlin3DBlock
  60501. * @param name defines the block name
  60502. */
  60503. constructor(name: string);
  60504. /**
  60505. * Gets the current class name
  60506. * @returns the class name
  60507. */
  60508. getClassName(): string;
  60509. /**
  60510. * Gets the seed operand input component
  60511. */
  60512. get seed(): NodeMaterialConnectionPoint;
  60513. /**
  60514. * Gets the output component
  60515. */
  60516. get output(): NodeMaterialConnectionPoint;
  60517. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60518. }
  60519. }
  60520. declare module BABYLON {
  60521. /**
  60522. * Block used to blend normals
  60523. */
  60524. export class NormalBlendBlock extends NodeMaterialBlock {
  60525. /**
  60526. * Creates a new NormalBlendBlock
  60527. * @param name defines the block name
  60528. */
  60529. constructor(name: string);
  60530. /**
  60531. * Gets the current class name
  60532. * @returns the class name
  60533. */
  60534. getClassName(): string;
  60535. /**
  60536. * Gets the first input component
  60537. */
  60538. get normalMap0(): NodeMaterialConnectionPoint;
  60539. /**
  60540. * Gets the second input component
  60541. */
  60542. get normalMap1(): NodeMaterialConnectionPoint;
  60543. /**
  60544. * Gets the output component
  60545. */
  60546. get output(): NodeMaterialConnectionPoint;
  60547. protected _buildBlock(state: NodeMaterialBuildState): this;
  60548. }
  60549. }
  60550. declare module BABYLON {
  60551. /**
  60552. * Block used to rotate a 2d vector by a given angle
  60553. */
  60554. export class Rotate2dBlock extends NodeMaterialBlock {
  60555. /**
  60556. * Creates a new Rotate2dBlock
  60557. * @param name defines the block name
  60558. */
  60559. constructor(name: string);
  60560. /**
  60561. * Gets the current class name
  60562. * @returns the class name
  60563. */
  60564. getClassName(): string;
  60565. /**
  60566. * Gets the input vector
  60567. */
  60568. get input(): NodeMaterialConnectionPoint;
  60569. /**
  60570. * Gets the input angle
  60571. */
  60572. get angle(): NodeMaterialConnectionPoint;
  60573. /**
  60574. * Gets the output component
  60575. */
  60576. get output(): NodeMaterialConnectionPoint;
  60577. autoConfigure(material: NodeMaterial): void;
  60578. protected _buildBlock(state: NodeMaterialBuildState): this;
  60579. }
  60580. }
  60581. declare module BABYLON {
  60582. /**
  60583. * Block used to get the reflected vector from a direction and a normal
  60584. */
  60585. export class ReflectBlock extends NodeMaterialBlock {
  60586. /**
  60587. * Creates a new ReflectBlock
  60588. * @param name defines the block name
  60589. */
  60590. constructor(name: string);
  60591. /**
  60592. * Gets the current class name
  60593. * @returns the class name
  60594. */
  60595. getClassName(): string;
  60596. /**
  60597. * Gets the incident component
  60598. */
  60599. get incident(): NodeMaterialConnectionPoint;
  60600. /**
  60601. * Gets the normal component
  60602. */
  60603. get normal(): NodeMaterialConnectionPoint;
  60604. /**
  60605. * Gets the output component
  60606. */
  60607. get output(): NodeMaterialConnectionPoint;
  60608. protected _buildBlock(state: NodeMaterialBuildState): this;
  60609. }
  60610. }
  60611. declare module BABYLON {
  60612. /**
  60613. * Block used to get the refracted vector from a direction and a normal
  60614. */
  60615. export class RefractBlock extends NodeMaterialBlock {
  60616. /**
  60617. * Creates a new RefractBlock
  60618. * @param name defines the block name
  60619. */
  60620. constructor(name: string);
  60621. /**
  60622. * Gets the current class name
  60623. * @returns the class name
  60624. */
  60625. getClassName(): string;
  60626. /**
  60627. * Gets the incident component
  60628. */
  60629. get incident(): NodeMaterialConnectionPoint;
  60630. /**
  60631. * Gets the normal component
  60632. */
  60633. get normal(): NodeMaterialConnectionPoint;
  60634. /**
  60635. * Gets the index of refraction component
  60636. */
  60637. get ior(): NodeMaterialConnectionPoint;
  60638. /**
  60639. * Gets the output component
  60640. */
  60641. get output(): NodeMaterialConnectionPoint;
  60642. protected _buildBlock(state: NodeMaterialBuildState): this;
  60643. }
  60644. }
  60645. declare module BABYLON {
  60646. /**
  60647. * Block used to desaturate a color
  60648. */
  60649. export class DesaturateBlock extends NodeMaterialBlock {
  60650. /**
  60651. * Creates a new DesaturateBlock
  60652. * @param name defines the block name
  60653. */
  60654. constructor(name: string);
  60655. /**
  60656. * Gets the current class name
  60657. * @returns the class name
  60658. */
  60659. getClassName(): string;
  60660. /**
  60661. * Gets the color operand input component
  60662. */
  60663. get color(): NodeMaterialConnectionPoint;
  60664. /**
  60665. * Gets the level operand input component
  60666. */
  60667. get level(): NodeMaterialConnectionPoint;
  60668. /**
  60669. * Gets the output component
  60670. */
  60671. get output(): NodeMaterialConnectionPoint;
  60672. protected _buildBlock(state: NodeMaterialBuildState): this;
  60673. }
  60674. }
  60675. declare module BABYLON {
  60676. /**
  60677. * Effect Render Options
  60678. */
  60679. export interface IEffectRendererOptions {
  60680. /**
  60681. * Defines the vertices positions.
  60682. */
  60683. positions?: number[];
  60684. /**
  60685. * Defines the indices.
  60686. */
  60687. indices?: number[];
  60688. }
  60689. /**
  60690. * Helper class to render one or more effects
  60691. */
  60692. export class EffectRenderer {
  60693. private engine;
  60694. private static _DefaultOptions;
  60695. private _vertexBuffers;
  60696. private _indexBuffer;
  60697. private _ringBufferIndex;
  60698. private _ringScreenBuffer;
  60699. private _fullscreenViewport;
  60700. private _getNextFrameBuffer;
  60701. /**
  60702. * Creates an effect renderer
  60703. * @param engine the engine to use for rendering
  60704. * @param options defines the options of the effect renderer
  60705. */
  60706. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60707. /**
  60708. * Sets the current viewport in normalized coordinates 0-1
  60709. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60710. */
  60711. setViewport(viewport?: Viewport): void;
  60712. /**
  60713. * Binds the embedded attributes buffer to the effect.
  60714. * @param effect Defines the effect to bind the attributes for
  60715. */
  60716. bindBuffers(effect: Effect): void;
  60717. /**
  60718. * Sets the current effect wrapper to use during draw.
  60719. * The effect needs to be ready before calling this api.
  60720. * This also sets the default full screen position attribute.
  60721. * @param effectWrapper Defines the effect to draw with
  60722. */
  60723. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60724. /**
  60725. * Draws a full screen quad.
  60726. */
  60727. draw(): void;
  60728. /**
  60729. * renders one or more effects to a specified texture
  60730. * @param effectWrappers list of effects to renderer
  60731. * @param outputTexture texture to draw to, if null it will render to the screen
  60732. */
  60733. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60734. /**
  60735. * Disposes of the effect renderer
  60736. */
  60737. dispose(): void;
  60738. }
  60739. /**
  60740. * Options to create an EffectWrapper
  60741. */
  60742. interface EffectWrapperCreationOptions {
  60743. /**
  60744. * Engine to use to create the effect
  60745. */
  60746. engine: ThinEngine;
  60747. /**
  60748. * Fragment shader for the effect
  60749. */
  60750. fragmentShader: string;
  60751. /**
  60752. * Vertex shader for the effect
  60753. */
  60754. vertexShader?: string;
  60755. /**
  60756. * Attributes to use in the shader
  60757. */
  60758. attributeNames?: Array<string>;
  60759. /**
  60760. * Uniforms to use in the shader
  60761. */
  60762. uniformNames?: Array<string>;
  60763. /**
  60764. * Texture sampler names to use in the shader
  60765. */
  60766. samplerNames?: Array<string>;
  60767. /**
  60768. * The friendly name of the effect displayed in Spector.
  60769. */
  60770. name?: string;
  60771. }
  60772. /**
  60773. * Wraps an effect to be used for rendering
  60774. */
  60775. export class EffectWrapper {
  60776. /**
  60777. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60778. */
  60779. onApplyObservable: Observable<{}>;
  60780. /**
  60781. * The underlying effect
  60782. */
  60783. effect: Effect;
  60784. /**
  60785. * Creates an effect to be renderer
  60786. * @param creationOptions options to create the effect
  60787. */
  60788. constructor(creationOptions: EffectWrapperCreationOptions);
  60789. /**
  60790. * Disposes of the effect wrapper
  60791. */
  60792. dispose(): void;
  60793. }
  60794. }
  60795. declare module BABYLON {
  60796. /**
  60797. * Helper class to push actions to a pool of workers.
  60798. */
  60799. export class WorkerPool implements IDisposable {
  60800. private _workerInfos;
  60801. private _pendingActions;
  60802. /**
  60803. * Constructor
  60804. * @param workers Array of workers to use for actions
  60805. */
  60806. constructor(workers: Array<Worker>);
  60807. /**
  60808. * Terminates all workers and clears any pending actions.
  60809. */
  60810. dispose(): void;
  60811. /**
  60812. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60813. * pended until a worker has completed its action.
  60814. * @param action The action to perform. Call onComplete when the action is complete.
  60815. */
  60816. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60817. private _execute;
  60818. }
  60819. }
  60820. declare module BABYLON {
  60821. /**
  60822. * Configuration for Draco compression
  60823. */
  60824. export interface IDracoCompressionConfiguration {
  60825. /**
  60826. * Configuration for the decoder.
  60827. */
  60828. decoder: {
  60829. /**
  60830. * The url to the WebAssembly module.
  60831. */
  60832. wasmUrl?: string;
  60833. /**
  60834. * The url to the WebAssembly binary.
  60835. */
  60836. wasmBinaryUrl?: string;
  60837. /**
  60838. * The url to the fallback JavaScript module.
  60839. */
  60840. fallbackUrl?: string;
  60841. };
  60842. }
  60843. /**
  60844. * Draco compression (https://google.github.io/draco/)
  60845. *
  60846. * This class wraps the Draco module.
  60847. *
  60848. * **Encoder**
  60849. *
  60850. * The encoder is not currently implemented.
  60851. *
  60852. * **Decoder**
  60853. *
  60854. * 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.
  60855. *
  60856. * To update the configuration, use the following code:
  60857. * ```javascript
  60858. * DracoCompression.Configuration = {
  60859. * decoder: {
  60860. * wasmUrl: "<url to the WebAssembly library>",
  60861. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60862. * fallbackUrl: "<url to the fallback JavaScript library>",
  60863. * }
  60864. * };
  60865. * ```
  60866. *
  60867. * 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.
  60868. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60869. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60870. *
  60871. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60872. * ```javascript
  60873. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60874. * ```
  60875. *
  60876. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60877. */
  60878. export class DracoCompression implements IDisposable {
  60879. private _workerPoolPromise?;
  60880. private _decoderModulePromise?;
  60881. /**
  60882. * The configuration. Defaults to the following urls:
  60883. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60884. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60885. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60886. */
  60887. static Configuration: IDracoCompressionConfiguration;
  60888. /**
  60889. * Returns true if the decoder configuration is available.
  60890. */
  60891. static get DecoderAvailable(): boolean;
  60892. /**
  60893. * Default number of workers to create when creating the draco compression object.
  60894. */
  60895. static DefaultNumWorkers: number;
  60896. private static GetDefaultNumWorkers;
  60897. private static _Default;
  60898. /**
  60899. * Default instance for the draco compression object.
  60900. */
  60901. static get Default(): DracoCompression;
  60902. /**
  60903. * Constructor
  60904. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60905. */
  60906. constructor(numWorkers?: number);
  60907. /**
  60908. * Stop all async operations and release resources.
  60909. */
  60910. dispose(): void;
  60911. /**
  60912. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60913. * @returns a promise that resolves when ready
  60914. */
  60915. whenReadyAsync(): Promise<void>;
  60916. /**
  60917. * Decode Draco compressed mesh data to vertex data.
  60918. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60919. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60920. * @returns A promise that resolves with the decoded vertex data
  60921. */
  60922. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60923. [kind: string]: number;
  60924. }): Promise<VertexData>;
  60925. }
  60926. }
  60927. declare module BABYLON {
  60928. /**
  60929. * Class for building Constructive Solid Geometry
  60930. */
  60931. export class CSG {
  60932. private polygons;
  60933. /**
  60934. * The world matrix
  60935. */
  60936. matrix: Matrix;
  60937. /**
  60938. * Stores the position
  60939. */
  60940. position: Vector3;
  60941. /**
  60942. * Stores the rotation
  60943. */
  60944. rotation: Vector3;
  60945. /**
  60946. * Stores the rotation quaternion
  60947. */
  60948. rotationQuaternion: Nullable<Quaternion>;
  60949. /**
  60950. * Stores the scaling vector
  60951. */
  60952. scaling: Vector3;
  60953. /**
  60954. * Convert the Mesh to CSG
  60955. * @param mesh The Mesh to convert to CSG
  60956. * @returns A new CSG from the Mesh
  60957. */
  60958. static FromMesh(mesh: Mesh): CSG;
  60959. /**
  60960. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60961. * @param polygons Polygons used to construct a CSG solid
  60962. */
  60963. private static FromPolygons;
  60964. /**
  60965. * Clones, or makes a deep copy, of the CSG
  60966. * @returns A new CSG
  60967. */
  60968. clone(): CSG;
  60969. /**
  60970. * Unions this CSG with another CSG
  60971. * @param csg The CSG to union against this CSG
  60972. * @returns The unioned CSG
  60973. */
  60974. union(csg: CSG): CSG;
  60975. /**
  60976. * Unions this CSG with another CSG in place
  60977. * @param csg The CSG to union against this CSG
  60978. */
  60979. unionInPlace(csg: CSG): void;
  60980. /**
  60981. * Subtracts this CSG with another CSG
  60982. * @param csg The CSG to subtract against this CSG
  60983. * @returns A new CSG
  60984. */
  60985. subtract(csg: CSG): CSG;
  60986. /**
  60987. * Subtracts this CSG with another CSG in place
  60988. * @param csg The CSG to subtact against this CSG
  60989. */
  60990. subtractInPlace(csg: CSG): void;
  60991. /**
  60992. * Intersect this CSG with another CSG
  60993. * @param csg The CSG to intersect against this CSG
  60994. * @returns A new CSG
  60995. */
  60996. intersect(csg: CSG): CSG;
  60997. /**
  60998. * Intersects this CSG with another CSG in place
  60999. * @param csg The CSG to intersect against this CSG
  61000. */
  61001. intersectInPlace(csg: CSG): void;
  61002. /**
  61003. * Return a new CSG solid with solid and empty space switched. This solid is
  61004. * not modified.
  61005. * @returns A new CSG solid with solid and empty space switched
  61006. */
  61007. inverse(): CSG;
  61008. /**
  61009. * Inverses the CSG in place
  61010. */
  61011. inverseInPlace(): void;
  61012. /**
  61013. * This is used to keep meshes transformations so they can be restored
  61014. * when we build back a Babylon Mesh
  61015. * NB : All CSG operations are performed in world coordinates
  61016. * @param csg The CSG to copy the transform attributes from
  61017. * @returns This CSG
  61018. */
  61019. copyTransformAttributes(csg: CSG): CSG;
  61020. /**
  61021. * Build Raw mesh from CSG
  61022. * Coordinates here are in world space
  61023. * @param name The name of the mesh geometry
  61024. * @param scene The Scene
  61025. * @param keepSubMeshes Specifies if the submeshes should be kept
  61026. * @returns A new Mesh
  61027. */
  61028. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61029. /**
  61030. * Build Mesh from CSG taking material and transforms into account
  61031. * @param name The name of the Mesh
  61032. * @param material The material of the Mesh
  61033. * @param scene The Scene
  61034. * @param keepSubMeshes Specifies if submeshes should be kept
  61035. * @returns The new Mesh
  61036. */
  61037. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61038. }
  61039. }
  61040. declare module BABYLON {
  61041. /**
  61042. * Class used to create a trail following a mesh
  61043. */
  61044. export class TrailMesh extends Mesh {
  61045. private _generator;
  61046. private _autoStart;
  61047. private _running;
  61048. private _diameter;
  61049. private _length;
  61050. private _sectionPolygonPointsCount;
  61051. private _sectionVectors;
  61052. private _sectionNormalVectors;
  61053. private _beforeRenderObserver;
  61054. /**
  61055. * @constructor
  61056. * @param name The value used by scene.getMeshByName() to do a lookup.
  61057. * @param generator The mesh or transform node to generate a trail.
  61058. * @param scene The scene to add this mesh to.
  61059. * @param diameter Diameter of trailing mesh. Default is 1.
  61060. * @param length Length of trailing mesh. Default is 60.
  61061. * @param autoStart Automatically start trailing mesh. Default true.
  61062. */
  61063. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  61064. /**
  61065. * "TrailMesh"
  61066. * @returns "TrailMesh"
  61067. */
  61068. getClassName(): string;
  61069. private _createMesh;
  61070. /**
  61071. * Start trailing mesh.
  61072. */
  61073. start(): void;
  61074. /**
  61075. * Stop trailing mesh.
  61076. */
  61077. stop(): void;
  61078. /**
  61079. * Update trailing mesh geometry.
  61080. */
  61081. update(): void;
  61082. /**
  61083. * Returns a new TrailMesh object.
  61084. * @param name is a string, the name given to the new mesh
  61085. * @param newGenerator use new generator object for cloned trail mesh
  61086. * @returns a new mesh
  61087. */
  61088. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  61089. /**
  61090. * Serializes this trail mesh
  61091. * @param serializationObject object to write serialization to
  61092. */
  61093. serialize(serializationObject: any): void;
  61094. /**
  61095. * Parses a serialized trail mesh
  61096. * @param parsedMesh the serialized mesh
  61097. * @param scene the scene to create the trail mesh in
  61098. * @returns the created trail mesh
  61099. */
  61100. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  61101. }
  61102. }
  61103. declare module BABYLON {
  61104. /**
  61105. * Class containing static functions to help procedurally build meshes
  61106. */
  61107. export class TiledBoxBuilder {
  61108. /**
  61109. * Creates a box mesh
  61110. * 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)
  61111. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61113. * * 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
  61114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61115. * @param name defines the name of the mesh
  61116. * @param options defines the options used to create the mesh
  61117. * @param scene defines the hosting scene
  61118. * @returns the box mesh
  61119. */
  61120. static CreateTiledBox(name: string, options: {
  61121. pattern?: number;
  61122. width?: number;
  61123. height?: number;
  61124. depth?: number;
  61125. tileSize?: number;
  61126. tileWidth?: number;
  61127. tileHeight?: number;
  61128. alignHorizontal?: number;
  61129. alignVertical?: number;
  61130. faceUV?: Vector4[];
  61131. faceColors?: Color4[];
  61132. sideOrientation?: number;
  61133. updatable?: boolean;
  61134. }, scene?: Nullable<Scene>): Mesh;
  61135. }
  61136. }
  61137. declare module BABYLON {
  61138. /**
  61139. * Class containing static functions to help procedurally build meshes
  61140. */
  61141. export class TorusKnotBuilder {
  61142. /**
  61143. * Creates a torus knot mesh
  61144. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61145. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61146. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61147. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61148. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61149. * * 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
  61150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61151. * @param name defines the name of the mesh
  61152. * @param options defines the options used to create the mesh
  61153. * @param scene defines the hosting scene
  61154. * @returns the torus knot mesh
  61155. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61156. */
  61157. static CreateTorusKnot(name: string, options: {
  61158. radius?: number;
  61159. tube?: number;
  61160. radialSegments?: number;
  61161. tubularSegments?: number;
  61162. p?: number;
  61163. q?: number;
  61164. updatable?: boolean;
  61165. sideOrientation?: number;
  61166. frontUVs?: Vector4;
  61167. backUVs?: Vector4;
  61168. }, scene: any): Mesh;
  61169. }
  61170. }
  61171. declare module BABYLON {
  61172. /**
  61173. * Polygon
  61174. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  61175. */
  61176. export class Polygon {
  61177. /**
  61178. * Creates a rectangle
  61179. * @param xmin bottom X coord
  61180. * @param ymin bottom Y coord
  61181. * @param xmax top X coord
  61182. * @param ymax top Y coord
  61183. * @returns points that make the resulting rectation
  61184. */
  61185. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61186. /**
  61187. * Creates a circle
  61188. * @param radius radius of circle
  61189. * @param cx scale in x
  61190. * @param cy scale in y
  61191. * @param numberOfSides number of sides that make up the circle
  61192. * @returns points that make the resulting circle
  61193. */
  61194. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61195. /**
  61196. * Creates a polygon from input string
  61197. * @param input Input polygon data
  61198. * @returns the parsed points
  61199. */
  61200. static Parse(input: string): Vector2[];
  61201. /**
  61202. * Starts building a polygon from x and y coordinates
  61203. * @param x x coordinate
  61204. * @param y y coordinate
  61205. * @returns the started path2
  61206. */
  61207. static StartingAt(x: number, y: number): Path2;
  61208. }
  61209. /**
  61210. * Builds a polygon
  61211. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61212. */
  61213. export class PolygonMeshBuilder {
  61214. private _points;
  61215. private _outlinepoints;
  61216. private _holes;
  61217. private _name;
  61218. private _scene;
  61219. private _epoints;
  61220. private _eholes;
  61221. private _addToepoint;
  61222. /**
  61223. * Babylon reference to the earcut plugin.
  61224. */
  61225. bjsEarcut: any;
  61226. /**
  61227. * Creates a PolygonMeshBuilder
  61228. * @param name name of the builder
  61229. * @param contours Path of the polygon
  61230. * @param scene scene to add to when creating the mesh
  61231. * @param earcutInjection can be used to inject your own earcut reference
  61232. */
  61233. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61234. /**
  61235. * Adds a whole within the polygon
  61236. * @param hole Array of points defining the hole
  61237. * @returns this
  61238. */
  61239. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61240. /**
  61241. * Creates the polygon
  61242. * @param updatable If the mesh should be updatable
  61243. * @param depth The depth of the mesh created
  61244. * @returns the created mesh
  61245. */
  61246. build(updatable?: boolean, depth?: number): Mesh;
  61247. /**
  61248. * Creates the polygon
  61249. * @param depth The depth of the mesh created
  61250. * @returns the created VertexData
  61251. */
  61252. buildVertexData(depth?: number): VertexData;
  61253. /**
  61254. * Adds a side to the polygon
  61255. * @param positions points that make the polygon
  61256. * @param normals normals of the polygon
  61257. * @param uvs uvs of the polygon
  61258. * @param indices indices of the polygon
  61259. * @param bounds bounds of the polygon
  61260. * @param points points of the polygon
  61261. * @param depth depth of the polygon
  61262. * @param flip flip of the polygon
  61263. */
  61264. private addSide;
  61265. }
  61266. }
  61267. declare module BABYLON {
  61268. /**
  61269. * Class containing static functions to help procedurally build meshes
  61270. */
  61271. export class PolygonBuilder {
  61272. /**
  61273. * Creates a polygon mesh
  61274. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61275. * * 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
  61276. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61278. * * 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)
  61279. * * Remember you can only change the shape positions, not their number when updating a polygon
  61280. * @param name defines the name of the mesh
  61281. * @param options defines the options used to create the mesh
  61282. * @param scene defines the hosting scene
  61283. * @param earcutInjection can be used to inject your own earcut reference
  61284. * @returns the polygon mesh
  61285. */
  61286. static CreatePolygon(name: string, options: {
  61287. shape: Vector3[];
  61288. holes?: Vector3[][];
  61289. depth?: number;
  61290. faceUV?: Vector4[];
  61291. faceColors?: Color4[];
  61292. updatable?: boolean;
  61293. sideOrientation?: number;
  61294. frontUVs?: Vector4;
  61295. backUVs?: Vector4;
  61296. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61297. /**
  61298. * Creates an extruded polygon mesh, with depth in the Y direction.
  61299. * * 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)
  61300. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61301. * @param name defines the name of the mesh
  61302. * @param options defines the options used to create the mesh
  61303. * @param scene defines the hosting scene
  61304. * @param earcutInjection can be used to inject your own earcut reference
  61305. * @returns the polygon mesh
  61306. */
  61307. static ExtrudePolygon(name: string, options: {
  61308. shape: Vector3[];
  61309. holes?: Vector3[][];
  61310. depth?: number;
  61311. faceUV?: Vector4[];
  61312. faceColors?: Color4[];
  61313. updatable?: boolean;
  61314. sideOrientation?: number;
  61315. frontUVs?: Vector4;
  61316. backUVs?: Vector4;
  61317. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61318. }
  61319. }
  61320. declare module BABYLON {
  61321. /**
  61322. * Class containing static functions to help procedurally build meshes
  61323. */
  61324. export class LatheBuilder {
  61325. /**
  61326. * Creates lathe mesh.
  61327. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61328. * * 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
  61329. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61330. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61331. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61332. * * 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
  61333. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61334. * * 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
  61335. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61336. * * 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
  61337. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61339. * @param name defines the name of the mesh
  61340. * @param options defines the options used to create the mesh
  61341. * @param scene defines the hosting scene
  61342. * @returns the lathe mesh
  61343. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61344. */
  61345. static CreateLathe(name: string, options: {
  61346. shape: Vector3[];
  61347. radius?: number;
  61348. tessellation?: number;
  61349. clip?: number;
  61350. arc?: number;
  61351. closed?: boolean;
  61352. updatable?: boolean;
  61353. sideOrientation?: number;
  61354. frontUVs?: Vector4;
  61355. backUVs?: Vector4;
  61356. cap?: number;
  61357. invertUV?: boolean;
  61358. }, scene?: Nullable<Scene>): Mesh;
  61359. }
  61360. }
  61361. declare module BABYLON {
  61362. /**
  61363. * Class containing static functions to help procedurally build meshes
  61364. */
  61365. export class TiledPlaneBuilder {
  61366. /**
  61367. * Creates a tiled plane mesh
  61368. * * The parameter `pattern` will, depending on value, do nothing or
  61369. * * * flip (reflect about central vertical) alternate tiles across and up
  61370. * * * flip every tile on alternate rows
  61371. * * * rotate (180 degs) alternate tiles across and up
  61372. * * * rotate every tile on alternate rows
  61373. * * * flip and rotate alternate tiles across and up
  61374. * * * flip and rotate every tile on alternate rows
  61375. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  61376. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  61377. * * 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
  61378. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61379. * * 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)
  61380. * * 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)
  61381. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61382. * @param name defines the name of the mesh
  61383. * @param options defines the options used to create the mesh
  61384. * @param scene defines the hosting scene
  61385. * @returns the box mesh
  61386. */
  61387. static CreateTiledPlane(name: string, options: {
  61388. pattern?: number;
  61389. tileSize?: number;
  61390. tileWidth?: number;
  61391. tileHeight?: number;
  61392. size?: number;
  61393. width?: number;
  61394. height?: number;
  61395. alignHorizontal?: number;
  61396. alignVertical?: number;
  61397. sideOrientation?: number;
  61398. frontUVs?: Vector4;
  61399. backUVs?: Vector4;
  61400. updatable?: boolean;
  61401. }, scene?: Nullable<Scene>): Mesh;
  61402. }
  61403. }
  61404. declare module BABYLON {
  61405. /**
  61406. * Class containing static functions to help procedurally build meshes
  61407. */
  61408. export class TubeBuilder {
  61409. /**
  61410. * Creates a tube mesh.
  61411. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61412. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61413. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61414. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61415. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61416. * * 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)
  61417. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61418. * * 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
  61419. * * 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
  61420. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61421. * * 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
  61422. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61424. * @param name defines the name of the mesh
  61425. * @param options defines the options used to create the mesh
  61426. * @param scene defines the hosting scene
  61427. * @returns the tube mesh
  61428. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61429. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61430. */
  61431. static CreateTube(name: string, options: {
  61432. path: Vector3[];
  61433. radius?: number;
  61434. tessellation?: number;
  61435. radiusFunction?: {
  61436. (i: number, distance: number): number;
  61437. };
  61438. cap?: number;
  61439. arc?: number;
  61440. updatable?: boolean;
  61441. sideOrientation?: number;
  61442. frontUVs?: Vector4;
  61443. backUVs?: Vector4;
  61444. instance?: Mesh;
  61445. invertUV?: boolean;
  61446. }, scene?: Nullable<Scene>): Mesh;
  61447. }
  61448. }
  61449. declare module BABYLON {
  61450. /**
  61451. * Class containing static functions to help procedurally build meshes
  61452. */
  61453. export class IcoSphereBuilder {
  61454. /**
  61455. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61456. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61457. * * 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`)
  61458. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61459. * * 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
  61460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61461. * * 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
  61462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61463. * @param name defines the name of the mesh
  61464. * @param options defines the options used to create the mesh
  61465. * @param scene defines the hosting scene
  61466. * @returns the icosahedron mesh
  61467. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61468. */
  61469. static CreateIcoSphere(name: string, options: {
  61470. radius?: number;
  61471. radiusX?: number;
  61472. radiusY?: number;
  61473. radiusZ?: number;
  61474. flat?: boolean;
  61475. subdivisions?: number;
  61476. sideOrientation?: number;
  61477. frontUVs?: Vector4;
  61478. backUVs?: Vector4;
  61479. updatable?: boolean;
  61480. }, scene?: Nullable<Scene>): Mesh;
  61481. }
  61482. }
  61483. declare module BABYLON {
  61484. /**
  61485. * Class containing static functions to help procedurally build meshes
  61486. */
  61487. export class DecalBuilder {
  61488. /**
  61489. * Creates a decal mesh.
  61490. * 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
  61491. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61492. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61493. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61494. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61495. * @param name defines the name of the mesh
  61496. * @param sourceMesh defines the mesh where the decal must be applied
  61497. * @param options defines the options used to create the mesh
  61498. * @param scene defines the hosting scene
  61499. * @returns the decal mesh
  61500. * @see https://doc.babylonjs.com/how_to/decals
  61501. */
  61502. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61503. position?: Vector3;
  61504. normal?: Vector3;
  61505. size?: Vector3;
  61506. angle?: number;
  61507. }): Mesh;
  61508. }
  61509. }
  61510. declare module BABYLON {
  61511. /**
  61512. * Class containing static functions to help procedurally build meshes
  61513. */
  61514. export class MeshBuilder {
  61515. /**
  61516. * Creates a box mesh
  61517. * * The parameter `size` sets the size (float) of each box side (default 1)
  61518. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61519. * * 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)
  61520. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61521. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61522. * * 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
  61523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61524. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61525. * @param name defines the name of the mesh
  61526. * @param options defines the options used to create the mesh
  61527. * @param scene defines the hosting scene
  61528. * @returns the box mesh
  61529. */
  61530. static CreateBox(name: string, options: {
  61531. size?: number;
  61532. width?: number;
  61533. height?: number;
  61534. depth?: number;
  61535. faceUV?: Vector4[];
  61536. faceColors?: Color4[];
  61537. sideOrientation?: number;
  61538. frontUVs?: Vector4;
  61539. backUVs?: Vector4;
  61540. wrap?: boolean;
  61541. topBaseAt?: number;
  61542. bottomBaseAt?: number;
  61543. updatable?: boolean;
  61544. }, scene?: Nullable<Scene>): Mesh;
  61545. /**
  61546. * Creates a tiled box mesh
  61547. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61549. * @param name defines the name of the mesh
  61550. * @param options defines the options used to create the mesh
  61551. * @param scene defines the hosting scene
  61552. * @returns the tiled box mesh
  61553. */
  61554. static CreateTiledBox(name: string, options: {
  61555. pattern?: number;
  61556. size?: number;
  61557. width?: number;
  61558. height?: number;
  61559. depth: number;
  61560. tileSize?: number;
  61561. tileWidth?: number;
  61562. tileHeight?: number;
  61563. faceUV?: Vector4[];
  61564. faceColors?: Color4[];
  61565. alignHorizontal?: number;
  61566. alignVertical?: number;
  61567. sideOrientation?: number;
  61568. updatable?: boolean;
  61569. }, scene?: Nullable<Scene>): Mesh;
  61570. /**
  61571. * Creates a sphere mesh
  61572. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61573. * * 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`)
  61574. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61575. * * 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
  61576. * * 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)
  61577. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61578. * * 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
  61579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61580. * @param name defines the name of the mesh
  61581. * @param options defines the options used to create the mesh
  61582. * @param scene defines the hosting scene
  61583. * @returns the sphere mesh
  61584. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61585. */
  61586. static CreateSphere(name: string, options: {
  61587. segments?: number;
  61588. diameter?: number;
  61589. diameterX?: number;
  61590. diameterY?: number;
  61591. diameterZ?: number;
  61592. arc?: number;
  61593. slice?: number;
  61594. sideOrientation?: number;
  61595. frontUVs?: Vector4;
  61596. backUVs?: Vector4;
  61597. updatable?: boolean;
  61598. }, scene?: Nullable<Scene>): Mesh;
  61599. /**
  61600. * Creates a plane polygonal mesh. By default, this is a disc
  61601. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61602. * * 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
  61603. * * 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
  61604. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61605. * * 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
  61606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61607. * @param name defines the name of the mesh
  61608. * @param options defines the options used to create the mesh
  61609. * @param scene defines the hosting scene
  61610. * @returns the plane polygonal mesh
  61611. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61612. */
  61613. static CreateDisc(name: string, options: {
  61614. radius?: number;
  61615. tessellation?: number;
  61616. arc?: number;
  61617. updatable?: boolean;
  61618. sideOrientation?: number;
  61619. frontUVs?: Vector4;
  61620. backUVs?: Vector4;
  61621. }, scene?: Nullable<Scene>): Mesh;
  61622. /**
  61623. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61624. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61625. * * 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`)
  61626. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61627. * * 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
  61628. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61629. * * 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
  61630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61631. * @param name defines the name of the mesh
  61632. * @param options defines the options used to create the mesh
  61633. * @param scene defines the hosting scene
  61634. * @returns the icosahedron mesh
  61635. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61636. */
  61637. static CreateIcoSphere(name: string, options: {
  61638. radius?: number;
  61639. radiusX?: number;
  61640. radiusY?: number;
  61641. radiusZ?: number;
  61642. flat?: boolean;
  61643. subdivisions?: number;
  61644. sideOrientation?: number;
  61645. frontUVs?: Vector4;
  61646. backUVs?: Vector4;
  61647. updatable?: boolean;
  61648. }, scene?: Nullable<Scene>): Mesh;
  61649. /**
  61650. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61651. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61652. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61653. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61654. * * 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
  61655. * * 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
  61656. * * 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
  61657. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61658. * * 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
  61659. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61660. * * 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
  61661. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61662. * * 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
  61663. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61665. * @param name defines the name of the mesh
  61666. * @param options defines the options used to create the mesh
  61667. * @param scene defines the hosting scene
  61668. * @returns the ribbon mesh
  61669. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61670. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61671. */
  61672. static CreateRibbon(name: string, options: {
  61673. pathArray: Vector3[][];
  61674. closeArray?: boolean;
  61675. closePath?: boolean;
  61676. offset?: number;
  61677. updatable?: boolean;
  61678. sideOrientation?: number;
  61679. frontUVs?: Vector4;
  61680. backUVs?: Vector4;
  61681. instance?: Mesh;
  61682. invertUV?: boolean;
  61683. uvs?: Vector2[];
  61684. colors?: Color4[];
  61685. }, scene?: Nullable<Scene>): Mesh;
  61686. /**
  61687. * Creates a cylinder or a cone mesh
  61688. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61689. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61690. * * 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.
  61691. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61692. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61693. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61694. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61695. * * 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).
  61696. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61697. * * 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).
  61698. * * 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
  61699. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61700. * * 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
  61701. * * 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.
  61702. * * If `enclose` is false, a ring surface is one element.
  61703. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61704. * * 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
  61705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61706. * * 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
  61707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61708. * @param name defines the name of the mesh
  61709. * @param options defines the options used to create the mesh
  61710. * @param scene defines the hosting scene
  61711. * @returns the cylinder mesh
  61712. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61713. */
  61714. static CreateCylinder(name: string, options: {
  61715. height?: number;
  61716. diameterTop?: number;
  61717. diameterBottom?: number;
  61718. diameter?: number;
  61719. tessellation?: number;
  61720. subdivisions?: number;
  61721. arc?: number;
  61722. faceColors?: Color4[];
  61723. faceUV?: Vector4[];
  61724. updatable?: boolean;
  61725. hasRings?: boolean;
  61726. enclose?: boolean;
  61727. cap?: number;
  61728. sideOrientation?: number;
  61729. frontUVs?: Vector4;
  61730. backUVs?: Vector4;
  61731. }, scene?: Nullable<Scene>): Mesh;
  61732. /**
  61733. * Creates a torus mesh
  61734. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61735. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61736. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61737. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61738. * * 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
  61739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61740. * @param name defines the name of the mesh
  61741. * @param options defines the options used to create the mesh
  61742. * @param scene defines the hosting scene
  61743. * @returns the torus mesh
  61744. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61745. */
  61746. static CreateTorus(name: string, options: {
  61747. diameter?: number;
  61748. thickness?: number;
  61749. tessellation?: number;
  61750. updatable?: boolean;
  61751. sideOrientation?: number;
  61752. frontUVs?: Vector4;
  61753. backUVs?: Vector4;
  61754. }, scene?: Nullable<Scene>): Mesh;
  61755. /**
  61756. * Creates a torus knot mesh
  61757. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61758. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61759. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61760. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61761. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61762. * * 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
  61763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61764. * @param name defines the name of the mesh
  61765. * @param options defines the options used to create the mesh
  61766. * @param scene defines the hosting scene
  61767. * @returns the torus knot mesh
  61768. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61769. */
  61770. static CreateTorusKnot(name: string, options: {
  61771. radius?: number;
  61772. tube?: number;
  61773. radialSegments?: number;
  61774. tubularSegments?: number;
  61775. p?: number;
  61776. q?: number;
  61777. updatable?: boolean;
  61778. sideOrientation?: number;
  61779. frontUVs?: Vector4;
  61780. backUVs?: Vector4;
  61781. }, scene?: Nullable<Scene>): Mesh;
  61782. /**
  61783. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61784. * * 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
  61785. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61786. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61787. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61788. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61789. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61790. * * 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
  61791. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61793. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61794. * @param name defines the name of the new line system
  61795. * @param options defines the options used to create the line system
  61796. * @param scene defines the hosting scene
  61797. * @returns a new line system mesh
  61798. */
  61799. static CreateLineSystem(name: string, options: {
  61800. lines: Vector3[][];
  61801. updatable?: boolean;
  61802. instance?: Nullable<LinesMesh>;
  61803. colors?: Nullable<Color4[][]>;
  61804. useVertexAlpha?: boolean;
  61805. }, scene: Nullable<Scene>): LinesMesh;
  61806. /**
  61807. * Creates a line mesh
  61808. * 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
  61809. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61810. * * The parameter `points` is an array successive Vector3
  61811. * * 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
  61812. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61813. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61814. * * When updating an instance, remember that only point positions can change, not the number of points
  61815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61816. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61817. * @param name defines the name of the new line system
  61818. * @param options defines the options used to create the line system
  61819. * @param scene defines the hosting scene
  61820. * @returns a new line mesh
  61821. */
  61822. static CreateLines(name: string, options: {
  61823. points: Vector3[];
  61824. updatable?: boolean;
  61825. instance?: Nullable<LinesMesh>;
  61826. colors?: Color4[];
  61827. useVertexAlpha?: boolean;
  61828. }, scene?: Nullable<Scene>): LinesMesh;
  61829. /**
  61830. * Creates a dashed line mesh
  61831. * * 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
  61832. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61833. * * The parameter `points` is an array successive Vector3
  61834. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61835. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61836. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61837. * * 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
  61838. * * When updating an instance, remember that only point positions can change, not the number of points
  61839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61840. * @param name defines the name of the mesh
  61841. * @param options defines the options used to create the mesh
  61842. * @param scene defines the hosting scene
  61843. * @returns the dashed line mesh
  61844. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61845. */
  61846. static CreateDashedLines(name: string, options: {
  61847. points: Vector3[];
  61848. dashSize?: number;
  61849. gapSize?: number;
  61850. dashNb?: number;
  61851. updatable?: boolean;
  61852. instance?: LinesMesh;
  61853. }, scene?: Nullable<Scene>): LinesMesh;
  61854. /**
  61855. * 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.
  61856. * * 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.
  61857. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61858. * * 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.
  61859. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61860. * * 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
  61861. * * 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
  61862. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61863. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61864. * * 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
  61865. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61867. * @param name defines the name of the mesh
  61868. * @param options defines the options used to create the mesh
  61869. * @param scene defines the hosting scene
  61870. * @returns the extruded shape mesh
  61871. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61872. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61873. */
  61874. static ExtrudeShape(name: string, options: {
  61875. shape: Vector3[];
  61876. path: Vector3[];
  61877. scale?: number;
  61878. rotation?: number;
  61879. cap?: number;
  61880. updatable?: boolean;
  61881. sideOrientation?: number;
  61882. frontUVs?: Vector4;
  61883. backUVs?: Vector4;
  61884. instance?: Mesh;
  61885. invertUV?: boolean;
  61886. }, scene?: Nullable<Scene>): Mesh;
  61887. /**
  61888. * Creates an custom extruded shape mesh.
  61889. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61890. * * 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.
  61891. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61892. * * 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
  61893. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61894. * * 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
  61895. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61896. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61897. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61898. * * 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
  61899. * * 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
  61900. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61902. * * 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
  61903. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61905. * @param name defines the name of the mesh
  61906. * @param options defines the options used to create the mesh
  61907. * @param scene defines the hosting scene
  61908. * @returns the custom extruded shape mesh
  61909. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61910. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61911. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61912. */
  61913. static ExtrudeShapeCustom(name: string, options: {
  61914. shape: Vector3[];
  61915. path: Vector3[];
  61916. scaleFunction?: any;
  61917. rotationFunction?: any;
  61918. ribbonCloseArray?: boolean;
  61919. ribbonClosePath?: boolean;
  61920. cap?: number;
  61921. updatable?: boolean;
  61922. sideOrientation?: number;
  61923. frontUVs?: Vector4;
  61924. backUVs?: Vector4;
  61925. instance?: Mesh;
  61926. invertUV?: boolean;
  61927. }, scene?: Nullable<Scene>): Mesh;
  61928. /**
  61929. * Creates lathe mesh.
  61930. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61931. * * 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
  61932. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61933. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61934. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61935. * * 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
  61936. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61937. * * 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
  61938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61939. * * 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
  61940. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61942. * @param name defines the name of the mesh
  61943. * @param options defines the options used to create the mesh
  61944. * @param scene defines the hosting scene
  61945. * @returns the lathe mesh
  61946. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61947. */
  61948. static CreateLathe(name: string, options: {
  61949. shape: Vector3[];
  61950. radius?: number;
  61951. tessellation?: number;
  61952. clip?: number;
  61953. arc?: number;
  61954. closed?: boolean;
  61955. updatable?: boolean;
  61956. sideOrientation?: number;
  61957. frontUVs?: Vector4;
  61958. backUVs?: Vector4;
  61959. cap?: number;
  61960. invertUV?: boolean;
  61961. }, scene?: Nullable<Scene>): Mesh;
  61962. /**
  61963. * Creates a tiled plane mesh
  61964. * * You can set a limited pattern arrangement with the tiles
  61965. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61966. * * 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
  61967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61968. * @param name defines the name of the mesh
  61969. * @param options defines the options used to create the mesh
  61970. * @param scene defines the hosting scene
  61971. * @returns the plane mesh
  61972. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61973. */
  61974. static CreateTiledPlane(name: string, options: {
  61975. pattern?: number;
  61976. tileSize?: number;
  61977. tileWidth?: number;
  61978. tileHeight?: number;
  61979. size?: number;
  61980. width?: number;
  61981. height?: number;
  61982. alignHorizontal?: number;
  61983. alignVertical?: number;
  61984. sideOrientation?: number;
  61985. frontUVs?: Vector4;
  61986. backUVs?: Vector4;
  61987. updatable?: boolean;
  61988. }, scene?: Nullable<Scene>): Mesh;
  61989. /**
  61990. * Creates a plane mesh
  61991. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61992. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61993. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61994. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61995. * * 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
  61996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61997. * @param name defines the name of the mesh
  61998. * @param options defines the options used to create the mesh
  61999. * @param scene defines the hosting scene
  62000. * @returns the plane mesh
  62001. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62002. */
  62003. static CreatePlane(name: string, options: {
  62004. size?: number;
  62005. width?: number;
  62006. height?: number;
  62007. sideOrientation?: number;
  62008. frontUVs?: Vector4;
  62009. backUVs?: Vector4;
  62010. updatable?: boolean;
  62011. sourcePlane?: Plane;
  62012. }, scene?: Nullable<Scene>): Mesh;
  62013. /**
  62014. * Creates a ground mesh
  62015. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  62016. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  62017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62018. * @param name defines the name of the mesh
  62019. * @param options defines the options used to create the mesh
  62020. * @param scene defines the hosting scene
  62021. * @returns the ground mesh
  62022. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  62023. */
  62024. static CreateGround(name: string, options: {
  62025. width?: number;
  62026. height?: number;
  62027. subdivisions?: number;
  62028. subdivisionsX?: number;
  62029. subdivisionsY?: number;
  62030. updatable?: boolean;
  62031. }, scene?: Nullable<Scene>): Mesh;
  62032. /**
  62033. * Creates a tiled ground mesh
  62034. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  62035. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  62036. * * 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
  62037. * * 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
  62038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62039. * @param name defines the name of the mesh
  62040. * @param options defines the options used to create the mesh
  62041. * @param scene defines the hosting scene
  62042. * @returns the tiled ground mesh
  62043. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  62044. */
  62045. static CreateTiledGround(name: string, options: {
  62046. xmin: number;
  62047. zmin: number;
  62048. xmax: number;
  62049. zmax: number;
  62050. subdivisions?: {
  62051. w: number;
  62052. h: number;
  62053. };
  62054. precision?: {
  62055. w: number;
  62056. h: number;
  62057. };
  62058. updatable?: boolean;
  62059. }, scene?: Nullable<Scene>): Mesh;
  62060. /**
  62061. * Creates a ground mesh from a height map
  62062. * * The parameter `url` sets the URL of the height map image resource.
  62063. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  62064. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  62065. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  62066. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  62067. * * 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.
  62068. * * 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).
  62069. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  62070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62071. * @param name defines the name of the mesh
  62072. * @param url defines the url to the height map
  62073. * @param options defines the options used to create the mesh
  62074. * @param scene defines the hosting scene
  62075. * @returns the ground mesh
  62076. * @see https://doc.babylonjs.com/babylon101/height_map
  62077. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  62078. */
  62079. static CreateGroundFromHeightMap(name: string, url: string, options: {
  62080. width?: number;
  62081. height?: number;
  62082. subdivisions?: number;
  62083. minHeight?: number;
  62084. maxHeight?: number;
  62085. colorFilter?: Color3;
  62086. alphaFilter?: number;
  62087. updatable?: boolean;
  62088. onReady?: (mesh: GroundMesh) => void;
  62089. }, scene?: Nullable<Scene>): GroundMesh;
  62090. /**
  62091. * Creates a polygon mesh
  62092. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62093. * * 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
  62094. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62096. * * 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)
  62097. * * Remember you can only change the shape positions, not their number when updating a polygon
  62098. * @param name defines the name of the mesh
  62099. * @param options defines the options used to create the mesh
  62100. * @param scene defines the hosting scene
  62101. * @param earcutInjection can be used to inject your own earcut reference
  62102. * @returns the polygon mesh
  62103. */
  62104. static CreatePolygon(name: string, options: {
  62105. shape: Vector3[];
  62106. holes?: Vector3[][];
  62107. depth?: number;
  62108. faceUV?: Vector4[];
  62109. faceColors?: Color4[];
  62110. updatable?: boolean;
  62111. sideOrientation?: number;
  62112. frontUVs?: Vector4;
  62113. backUVs?: Vector4;
  62114. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62115. /**
  62116. * Creates an extruded polygon mesh, with depth in the Y direction.
  62117. * * 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)
  62118. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62119. * @param name defines the name of the mesh
  62120. * @param options defines the options used to create the mesh
  62121. * @param scene defines the hosting scene
  62122. * @param earcutInjection can be used to inject your own earcut reference
  62123. * @returns the polygon mesh
  62124. */
  62125. static ExtrudePolygon(name: string, options: {
  62126. shape: Vector3[];
  62127. holes?: Vector3[][];
  62128. depth?: number;
  62129. faceUV?: Vector4[];
  62130. faceColors?: Color4[];
  62131. updatable?: boolean;
  62132. sideOrientation?: number;
  62133. frontUVs?: Vector4;
  62134. backUVs?: Vector4;
  62135. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62136. /**
  62137. * Creates a tube mesh.
  62138. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62139. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62140. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62141. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62142. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62143. * * 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)
  62144. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62145. * * 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
  62146. * * 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
  62147. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62148. * * 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
  62149. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62151. * @param name defines the name of the mesh
  62152. * @param options defines the options used to create the mesh
  62153. * @param scene defines the hosting scene
  62154. * @returns the tube mesh
  62155. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62156. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62157. */
  62158. static CreateTube(name: string, options: {
  62159. path: Vector3[];
  62160. radius?: number;
  62161. tessellation?: number;
  62162. radiusFunction?: {
  62163. (i: number, distance: number): number;
  62164. };
  62165. cap?: number;
  62166. arc?: number;
  62167. updatable?: boolean;
  62168. sideOrientation?: number;
  62169. frontUVs?: Vector4;
  62170. backUVs?: Vector4;
  62171. instance?: Mesh;
  62172. invertUV?: boolean;
  62173. }, scene?: Nullable<Scene>): Mesh;
  62174. /**
  62175. * Creates a polyhedron mesh
  62176. * * 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
  62177. * * The parameter `size` (positive float, default 1) sets the polygon size
  62178. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  62179. * * 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`
  62180. * * 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
  62181. * * 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)`)
  62182. * * 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
  62183. * * 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
  62184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62185. * * 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
  62186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62187. * @param name defines the name of the mesh
  62188. * @param options defines the options used to create the mesh
  62189. * @param scene defines the hosting scene
  62190. * @returns the polyhedron mesh
  62191. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62192. */
  62193. static CreatePolyhedron(name: string, options: {
  62194. type?: number;
  62195. size?: number;
  62196. sizeX?: number;
  62197. sizeY?: number;
  62198. sizeZ?: number;
  62199. custom?: any;
  62200. faceUV?: Vector4[];
  62201. faceColors?: Color4[];
  62202. flat?: boolean;
  62203. updatable?: boolean;
  62204. sideOrientation?: number;
  62205. frontUVs?: Vector4;
  62206. backUVs?: Vector4;
  62207. }, scene?: Nullable<Scene>): Mesh;
  62208. /**
  62209. * Creates a decal mesh.
  62210. * 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
  62211. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62212. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62213. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62214. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62215. * @param name defines the name of the mesh
  62216. * @param sourceMesh defines the mesh where the decal must be applied
  62217. * @param options defines the options used to create the mesh
  62218. * @param scene defines the hosting scene
  62219. * @returns the decal mesh
  62220. * @see https://doc.babylonjs.com/how_to/decals
  62221. */
  62222. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62223. position?: Vector3;
  62224. normal?: Vector3;
  62225. size?: Vector3;
  62226. angle?: number;
  62227. }): Mesh;
  62228. }
  62229. }
  62230. declare module BABYLON {
  62231. /**
  62232. * A simplifier interface for future simplification implementations
  62233. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62234. */
  62235. export interface ISimplifier {
  62236. /**
  62237. * Simplification of a given mesh according to the given settings.
  62238. * Since this requires computation, it is assumed that the function runs async.
  62239. * @param settings The settings of the simplification, including quality and distance
  62240. * @param successCallback A callback that will be called after the mesh was simplified.
  62241. * @param errorCallback in case of an error, this callback will be called. optional.
  62242. */
  62243. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  62244. }
  62245. /**
  62246. * Expected simplification settings.
  62247. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  62248. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62249. */
  62250. export interface ISimplificationSettings {
  62251. /**
  62252. * Gets or sets the expected quality
  62253. */
  62254. quality: number;
  62255. /**
  62256. * Gets or sets the distance when this optimized version should be used
  62257. */
  62258. distance: number;
  62259. /**
  62260. * Gets an already optimized mesh
  62261. */
  62262. optimizeMesh?: boolean;
  62263. }
  62264. /**
  62265. * Class used to specify simplification options
  62266. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62267. */
  62268. export class SimplificationSettings implements ISimplificationSettings {
  62269. /** expected quality */
  62270. quality: number;
  62271. /** distance when this optimized version should be used */
  62272. distance: number;
  62273. /** already optimized mesh */
  62274. optimizeMesh?: boolean | undefined;
  62275. /**
  62276. * Creates a SimplificationSettings
  62277. * @param quality expected quality
  62278. * @param distance distance when this optimized version should be used
  62279. * @param optimizeMesh already optimized mesh
  62280. */
  62281. constructor(
  62282. /** expected quality */
  62283. quality: number,
  62284. /** distance when this optimized version should be used */
  62285. distance: number,
  62286. /** already optimized mesh */
  62287. optimizeMesh?: boolean | undefined);
  62288. }
  62289. /**
  62290. * Interface used to define a simplification task
  62291. */
  62292. export interface ISimplificationTask {
  62293. /**
  62294. * Array of settings
  62295. */
  62296. settings: Array<ISimplificationSettings>;
  62297. /**
  62298. * Simplification type
  62299. */
  62300. simplificationType: SimplificationType;
  62301. /**
  62302. * Mesh to simplify
  62303. */
  62304. mesh: Mesh;
  62305. /**
  62306. * Callback called on success
  62307. */
  62308. successCallback?: () => void;
  62309. /**
  62310. * Defines if parallel processing can be used
  62311. */
  62312. parallelProcessing: boolean;
  62313. }
  62314. /**
  62315. * Queue used to order the simplification tasks
  62316. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62317. */
  62318. export class SimplificationQueue {
  62319. private _simplificationArray;
  62320. /**
  62321. * Gets a boolean indicating that the process is still running
  62322. */
  62323. running: boolean;
  62324. /**
  62325. * Creates a new queue
  62326. */
  62327. constructor();
  62328. /**
  62329. * Adds a new simplification task
  62330. * @param task defines a task to add
  62331. */
  62332. addTask(task: ISimplificationTask): void;
  62333. /**
  62334. * Execute next task
  62335. */
  62336. executeNext(): void;
  62337. /**
  62338. * Execute a simplification task
  62339. * @param task defines the task to run
  62340. */
  62341. runSimplification(task: ISimplificationTask): void;
  62342. private getSimplifier;
  62343. }
  62344. /**
  62345. * The implemented types of simplification
  62346. * At the moment only Quadratic Error Decimation is implemented
  62347. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62348. */
  62349. export enum SimplificationType {
  62350. /** Quadratic error decimation */
  62351. QUADRATIC = 0
  62352. }
  62353. /**
  62354. * An implementation of the Quadratic Error simplification algorithm.
  62355. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  62356. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  62357. * @author RaananW
  62358. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62359. */
  62360. export class QuadraticErrorSimplification implements ISimplifier {
  62361. private _mesh;
  62362. private triangles;
  62363. private vertices;
  62364. private references;
  62365. private _reconstructedMesh;
  62366. /** Gets or sets the number pf sync interations */
  62367. syncIterations: number;
  62368. /** Gets or sets the aggressiveness of the simplifier */
  62369. aggressiveness: number;
  62370. /** Gets or sets the number of allowed iterations for decimation */
  62371. decimationIterations: number;
  62372. /** Gets or sets the espilon to use for bounding box computation */
  62373. boundingBoxEpsilon: number;
  62374. /**
  62375. * Creates a new QuadraticErrorSimplification
  62376. * @param _mesh defines the target mesh
  62377. */
  62378. constructor(_mesh: Mesh);
  62379. /**
  62380. * Simplification of a given mesh according to the given settings.
  62381. * Since this requires computation, it is assumed that the function runs async.
  62382. * @param settings The settings of the simplification, including quality and distance
  62383. * @param successCallback A callback that will be called after the mesh was simplified.
  62384. */
  62385. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  62386. private runDecimation;
  62387. private initWithMesh;
  62388. private init;
  62389. private reconstructMesh;
  62390. private initDecimatedMesh;
  62391. private isFlipped;
  62392. private updateTriangles;
  62393. private identifyBorder;
  62394. private updateMesh;
  62395. private vertexError;
  62396. private calculateError;
  62397. }
  62398. }
  62399. declare module BABYLON {
  62400. interface Scene {
  62401. /** @hidden (Backing field) */
  62402. _simplificationQueue: SimplificationQueue;
  62403. /**
  62404. * Gets or sets the simplification queue attached to the scene
  62405. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62406. */
  62407. simplificationQueue: SimplificationQueue;
  62408. }
  62409. interface Mesh {
  62410. /**
  62411. * Simplify the mesh according to the given array of settings.
  62412. * Function will return immediately and will simplify async
  62413. * @param settings a collection of simplification settings
  62414. * @param parallelProcessing should all levels calculate parallel or one after the other
  62415. * @param simplificationType the type of simplification to run
  62416. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  62417. * @returns the current mesh
  62418. */
  62419. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  62420. }
  62421. /**
  62422. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  62423. * created in a scene
  62424. */
  62425. export class SimplicationQueueSceneComponent implements ISceneComponent {
  62426. /**
  62427. * The component name helpfull to identify the component in the list of scene components.
  62428. */
  62429. readonly name: string;
  62430. /**
  62431. * The scene the component belongs to.
  62432. */
  62433. scene: Scene;
  62434. /**
  62435. * Creates a new instance of the component for the given scene
  62436. * @param scene Defines the scene to register the component in
  62437. */
  62438. constructor(scene: Scene);
  62439. /**
  62440. * Registers the component in a given scene
  62441. */
  62442. register(): void;
  62443. /**
  62444. * Rebuilds the elements related to this component in case of
  62445. * context lost for instance.
  62446. */
  62447. rebuild(): void;
  62448. /**
  62449. * Disposes the component and the associated ressources
  62450. */
  62451. dispose(): void;
  62452. private _beforeCameraUpdate;
  62453. }
  62454. }
  62455. declare module BABYLON {
  62456. /**
  62457. * Navigation plugin interface to add navigation constrained by a navigation mesh
  62458. */
  62459. export interface INavigationEnginePlugin {
  62460. /**
  62461. * plugin name
  62462. */
  62463. name: string;
  62464. /**
  62465. * Creates a navigation mesh
  62466. * @param meshes array of all the geometry used to compute the navigatio mesh
  62467. * @param parameters bunch of parameters used to filter geometry
  62468. */
  62469. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62470. /**
  62471. * Create a navigation mesh debug mesh
  62472. * @param scene is where the mesh will be added
  62473. * @returns debug display mesh
  62474. */
  62475. createDebugNavMesh(scene: Scene): Mesh;
  62476. /**
  62477. * Get a navigation mesh constrained position, closest to the parameter position
  62478. * @param position world position
  62479. * @returns the closest point to position constrained by the navigation mesh
  62480. */
  62481. getClosestPoint(position: Vector3): Vector3;
  62482. /**
  62483. * Get a navigation mesh constrained position, closest to the parameter position
  62484. * @param position world position
  62485. * @param result output the closest point to position constrained by the navigation mesh
  62486. */
  62487. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62488. /**
  62489. * Get a navigation mesh constrained position, within a particular radius
  62490. * @param position world position
  62491. * @param maxRadius the maximum distance to the constrained world position
  62492. * @returns the closest point to position constrained by the navigation mesh
  62493. */
  62494. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62495. /**
  62496. * Get a navigation mesh constrained position, within a particular radius
  62497. * @param position world position
  62498. * @param maxRadius the maximum distance to the constrained world position
  62499. * @param result output the closest point to position constrained by the navigation mesh
  62500. */
  62501. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62502. /**
  62503. * Compute the final position from a segment made of destination-position
  62504. * @param position world position
  62505. * @param destination world position
  62506. * @returns the resulting point along the navmesh
  62507. */
  62508. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62509. /**
  62510. * Compute the final position from a segment made of destination-position
  62511. * @param position world position
  62512. * @param destination world position
  62513. * @param result output the resulting point along the navmesh
  62514. */
  62515. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62516. /**
  62517. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62518. * @param start world position
  62519. * @param end world position
  62520. * @returns array containing world position composing the path
  62521. */
  62522. computePath(start: Vector3, end: Vector3): Vector3[];
  62523. /**
  62524. * If this plugin is supported
  62525. * @returns true if plugin is supported
  62526. */
  62527. isSupported(): boolean;
  62528. /**
  62529. * Create a new Crowd so you can add agents
  62530. * @param maxAgents the maximum agent count in the crowd
  62531. * @param maxAgentRadius the maximum radius an agent can have
  62532. * @param scene to attach the crowd to
  62533. * @returns the crowd you can add agents to
  62534. */
  62535. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62536. /**
  62537. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62538. * The queries will try to find a solution within those bounds
  62539. * default is (1,1,1)
  62540. * @param extent x,y,z value that define the extent around the queries point of reference
  62541. */
  62542. setDefaultQueryExtent(extent: Vector3): void;
  62543. /**
  62544. * Get the Bounding box extent specified by setDefaultQueryExtent
  62545. * @returns the box extent values
  62546. */
  62547. getDefaultQueryExtent(): Vector3;
  62548. /**
  62549. * build the navmesh from a previously saved state using getNavmeshData
  62550. * @param data the Uint8Array returned by getNavmeshData
  62551. */
  62552. buildFromNavmeshData(data: Uint8Array): void;
  62553. /**
  62554. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62555. * @returns data the Uint8Array that can be saved and reused
  62556. */
  62557. getNavmeshData(): Uint8Array;
  62558. /**
  62559. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62560. * @param result output the box extent values
  62561. */
  62562. getDefaultQueryExtentToRef(result: Vector3): void;
  62563. /**
  62564. * Release all resources
  62565. */
  62566. dispose(): void;
  62567. }
  62568. /**
  62569. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62570. */
  62571. export interface ICrowd {
  62572. /**
  62573. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62574. * You can attach anything to that node. The node position is updated in the scene update tick.
  62575. * @param pos world position that will be constrained by the navigation mesh
  62576. * @param parameters agent parameters
  62577. * @param transform hooked to the agent that will be update by the scene
  62578. * @returns agent index
  62579. */
  62580. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62581. /**
  62582. * Returns the agent position in world space
  62583. * @param index agent index returned by addAgent
  62584. * @returns world space position
  62585. */
  62586. getAgentPosition(index: number): Vector3;
  62587. /**
  62588. * Gets the agent position result in world space
  62589. * @param index agent index returned by addAgent
  62590. * @param result output world space position
  62591. */
  62592. getAgentPositionToRef(index: number, result: Vector3): void;
  62593. /**
  62594. * Gets the agent velocity in world space
  62595. * @param index agent index returned by addAgent
  62596. * @returns world space velocity
  62597. */
  62598. getAgentVelocity(index: number): Vector3;
  62599. /**
  62600. * Gets the agent velocity result in world space
  62601. * @param index agent index returned by addAgent
  62602. * @param result output world space velocity
  62603. */
  62604. getAgentVelocityToRef(index: number, result: Vector3): void;
  62605. /**
  62606. * remove a particular agent previously created
  62607. * @param index agent index returned by addAgent
  62608. */
  62609. removeAgent(index: number): void;
  62610. /**
  62611. * get the list of all agents attached to this crowd
  62612. * @returns list of agent indices
  62613. */
  62614. getAgents(): number[];
  62615. /**
  62616. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62617. * @param deltaTime in seconds
  62618. */
  62619. update(deltaTime: number): void;
  62620. /**
  62621. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62622. * @param index agent index returned by addAgent
  62623. * @param destination targeted world position
  62624. */
  62625. agentGoto(index: number, destination: Vector3): void;
  62626. /**
  62627. * Teleport the agent to a new position
  62628. * @param index agent index returned by addAgent
  62629. * @param destination targeted world position
  62630. */
  62631. agentTeleport(index: number, destination: Vector3): void;
  62632. /**
  62633. * Update agent parameters
  62634. * @param index agent index returned by addAgent
  62635. * @param parameters agent parameters
  62636. */
  62637. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62638. /**
  62639. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62640. * The queries will try to find a solution within those bounds
  62641. * default is (1,1,1)
  62642. * @param extent x,y,z value that define the extent around the queries point of reference
  62643. */
  62644. setDefaultQueryExtent(extent: Vector3): void;
  62645. /**
  62646. * Get the Bounding box extent specified by setDefaultQueryExtent
  62647. * @returns the box extent values
  62648. */
  62649. getDefaultQueryExtent(): Vector3;
  62650. /**
  62651. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62652. * @param result output the box extent values
  62653. */
  62654. getDefaultQueryExtentToRef(result: Vector3): void;
  62655. /**
  62656. * Release all resources
  62657. */
  62658. dispose(): void;
  62659. }
  62660. /**
  62661. * Configures an agent
  62662. */
  62663. export interface IAgentParameters {
  62664. /**
  62665. * Agent radius. [Limit: >= 0]
  62666. */
  62667. radius: number;
  62668. /**
  62669. * Agent height. [Limit: > 0]
  62670. */
  62671. height: number;
  62672. /**
  62673. * Maximum allowed acceleration. [Limit: >= 0]
  62674. */
  62675. maxAcceleration: number;
  62676. /**
  62677. * Maximum allowed speed. [Limit: >= 0]
  62678. */
  62679. maxSpeed: number;
  62680. /**
  62681. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62682. */
  62683. collisionQueryRange: number;
  62684. /**
  62685. * The path visibility optimization range. [Limit: > 0]
  62686. */
  62687. pathOptimizationRange: number;
  62688. /**
  62689. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62690. */
  62691. separationWeight: number;
  62692. }
  62693. /**
  62694. * Configures the navigation mesh creation
  62695. */
  62696. export interface INavMeshParameters {
  62697. /**
  62698. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62699. */
  62700. cs: number;
  62701. /**
  62702. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62703. */
  62704. ch: number;
  62705. /**
  62706. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62707. */
  62708. walkableSlopeAngle: number;
  62709. /**
  62710. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62711. * be considered walkable. [Limit: >= 3] [Units: vx]
  62712. */
  62713. walkableHeight: number;
  62714. /**
  62715. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62716. */
  62717. walkableClimb: number;
  62718. /**
  62719. * The distance to erode/shrink the walkable area of the heightfield away from
  62720. * obstructions. [Limit: >=0] [Units: vx]
  62721. */
  62722. walkableRadius: number;
  62723. /**
  62724. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62725. */
  62726. maxEdgeLen: number;
  62727. /**
  62728. * The maximum distance a simplfied contour's border edges should deviate
  62729. * the original raw contour. [Limit: >=0] [Units: vx]
  62730. */
  62731. maxSimplificationError: number;
  62732. /**
  62733. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62734. */
  62735. minRegionArea: number;
  62736. /**
  62737. * Any regions with a span count smaller than this value will, if possible,
  62738. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62739. */
  62740. mergeRegionArea: number;
  62741. /**
  62742. * The maximum number of vertices allowed for polygons generated during the
  62743. * contour to polygon conversion process. [Limit: >= 3]
  62744. */
  62745. maxVertsPerPoly: number;
  62746. /**
  62747. * Sets the sampling distance to use when generating the detail mesh.
  62748. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62749. */
  62750. detailSampleDist: number;
  62751. /**
  62752. * The maximum distance the detail mesh surface should deviate from heightfield
  62753. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62754. */
  62755. detailSampleMaxError: number;
  62756. }
  62757. }
  62758. declare module BABYLON {
  62759. /**
  62760. * RecastJS navigation plugin
  62761. */
  62762. export class RecastJSPlugin implements INavigationEnginePlugin {
  62763. /**
  62764. * Reference to the Recast library
  62765. */
  62766. bjsRECAST: any;
  62767. /**
  62768. * plugin name
  62769. */
  62770. name: string;
  62771. /**
  62772. * the first navmesh created. We might extend this to support multiple navmeshes
  62773. */
  62774. navMesh: any;
  62775. /**
  62776. * Initializes the recastJS plugin
  62777. * @param recastInjection can be used to inject your own recast reference
  62778. */
  62779. constructor(recastInjection?: any);
  62780. /**
  62781. * Creates a navigation mesh
  62782. * @param meshes array of all the geometry used to compute the navigatio mesh
  62783. * @param parameters bunch of parameters used to filter geometry
  62784. */
  62785. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62786. /**
  62787. * Create a navigation mesh debug mesh
  62788. * @param scene is where the mesh will be added
  62789. * @returns debug display mesh
  62790. */
  62791. createDebugNavMesh(scene: Scene): Mesh;
  62792. /**
  62793. * Get a navigation mesh constrained position, closest to the parameter position
  62794. * @param position world position
  62795. * @returns the closest point to position constrained by the navigation mesh
  62796. */
  62797. getClosestPoint(position: Vector3): Vector3;
  62798. /**
  62799. * Get a navigation mesh constrained position, closest to the parameter position
  62800. * @param position world position
  62801. * @param result output the closest point to position constrained by the navigation mesh
  62802. */
  62803. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62804. /**
  62805. * Get a navigation mesh constrained position, within a particular radius
  62806. * @param position world position
  62807. * @param maxRadius the maximum distance to the constrained world position
  62808. * @returns the closest point to position constrained by the navigation mesh
  62809. */
  62810. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62811. /**
  62812. * Get a navigation mesh constrained position, within a particular radius
  62813. * @param position world position
  62814. * @param maxRadius the maximum distance to the constrained world position
  62815. * @param result output the closest point to position constrained by the navigation mesh
  62816. */
  62817. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62818. /**
  62819. * Compute the final position from a segment made of destination-position
  62820. * @param position world position
  62821. * @param destination world position
  62822. * @returns the resulting point along the navmesh
  62823. */
  62824. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62825. /**
  62826. * Compute the final position from a segment made of destination-position
  62827. * @param position world position
  62828. * @param destination world position
  62829. * @param result output the resulting point along the navmesh
  62830. */
  62831. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62832. /**
  62833. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62834. * @param start world position
  62835. * @param end world position
  62836. * @returns array containing world position composing the path
  62837. */
  62838. computePath(start: Vector3, end: Vector3): Vector3[];
  62839. /**
  62840. * Create a new Crowd so you can add agents
  62841. * @param maxAgents the maximum agent count in the crowd
  62842. * @param maxAgentRadius the maximum radius an agent can have
  62843. * @param scene to attach the crowd to
  62844. * @returns the crowd you can add agents to
  62845. */
  62846. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62847. /**
  62848. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62849. * The queries will try to find a solution within those bounds
  62850. * default is (1,1,1)
  62851. * @param extent x,y,z value that define the extent around the queries point of reference
  62852. */
  62853. setDefaultQueryExtent(extent: Vector3): void;
  62854. /**
  62855. * Get the Bounding box extent specified by setDefaultQueryExtent
  62856. * @returns the box extent values
  62857. */
  62858. getDefaultQueryExtent(): Vector3;
  62859. /**
  62860. * build the navmesh from a previously saved state using getNavmeshData
  62861. * @param data the Uint8Array returned by getNavmeshData
  62862. */
  62863. buildFromNavmeshData(data: Uint8Array): void;
  62864. /**
  62865. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62866. * @returns data the Uint8Array that can be saved and reused
  62867. */
  62868. getNavmeshData(): Uint8Array;
  62869. /**
  62870. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62871. * @param result output the box extent values
  62872. */
  62873. getDefaultQueryExtentToRef(result: Vector3): void;
  62874. /**
  62875. * Disposes
  62876. */
  62877. dispose(): void;
  62878. /**
  62879. * If this plugin is supported
  62880. * @returns true if plugin is supported
  62881. */
  62882. isSupported(): boolean;
  62883. }
  62884. /**
  62885. * Recast detour crowd implementation
  62886. */
  62887. export class RecastJSCrowd implements ICrowd {
  62888. /**
  62889. * Recast/detour plugin
  62890. */
  62891. bjsRECASTPlugin: RecastJSPlugin;
  62892. /**
  62893. * Link to the detour crowd
  62894. */
  62895. recastCrowd: any;
  62896. /**
  62897. * One transform per agent
  62898. */
  62899. transforms: TransformNode[];
  62900. /**
  62901. * All agents created
  62902. */
  62903. agents: number[];
  62904. /**
  62905. * Link to the scene is kept to unregister the crowd from the scene
  62906. */
  62907. private _scene;
  62908. /**
  62909. * Observer for crowd updates
  62910. */
  62911. private _onBeforeAnimationsObserver;
  62912. /**
  62913. * Constructor
  62914. * @param plugin recastJS plugin
  62915. * @param maxAgents the maximum agent count in the crowd
  62916. * @param maxAgentRadius the maximum radius an agent can have
  62917. * @param scene to attach the crowd to
  62918. * @returns the crowd you can add agents to
  62919. */
  62920. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62921. /**
  62922. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62923. * You can attach anything to that node. The node position is updated in the scene update tick.
  62924. * @param pos world position that will be constrained by the navigation mesh
  62925. * @param parameters agent parameters
  62926. * @param transform hooked to the agent that will be update by the scene
  62927. * @returns agent index
  62928. */
  62929. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62930. /**
  62931. * Returns the agent position in world space
  62932. * @param index agent index returned by addAgent
  62933. * @returns world space position
  62934. */
  62935. getAgentPosition(index: number): Vector3;
  62936. /**
  62937. * Returns the agent position result in world space
  62938. * @param index agent index returned by addAgent
  62939. * @param result output world space position
  62940. */
  62941. getAgentPositionToRef(index: number, result: Vector3): void;
  62942. /**
  62943. * Returns the agent velocity in world space
  62944. * @param index agent index returned by addAgent
  62945. * @returns world space velocity
  62946. */
  62947. getAgentVelocity(index: number): Vector3;
  62948. /**
  62949. * Returns the agent velocity result in world space
  62950. * @param index agent index returned by addAgent
  62951. * @param result output world space velocity
  62952. */
  62953. getAgentVelocityToRef(index: number, result: Vector3): void;
  62954. /**
  62955. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62956. * @param index agent index returned by addAgent
  62957. * @param destination targeted world position
  62958. */
  62959. agentGoto(index: number, destination: Vector3): void;
  62960. /**
  62961. * Teleport the agent to a new position
  62962. * @param index agent index returned by addAgent
  62963. * @param destination targeted world position
  62964. */
  62965. agentTeleport(index: number, destination: Vector3): void;
  62966. /**
  62967. * Update agent parameters
  62968. * @param index agent index returned by addAgent
  62969. * @param parameters agent parameters
  62970. */
  62971. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62972. /**
  62973. * remove a particular agent previously created
  62974. * @param index agent index returned by addAgent
  62975. */
  62976. removeAgent(index: number): void;
  62977. /**
  62978. * get the list of all agents attached to this crowd
  62979. * @returns list of agent indices
  62980. */
  62981. getAgents(): number[];
  62982. /**
  62983. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62984. * @param deltaTime in seconds
  62985. */
  62986. update(deltaTime: number): void;
  62987. /**
  62988. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62989. * The queries will try to find a solution within those bounds
  62990. * default is (1,1,1)
  62991. * @param extent x,y,z value that define the extent around the queries point of reference
  62992. */
  62993. setDefaultQueryExtent(extent: Vector3): void;
  62994. /**
  62995. * Get the Bounding box extent specified by setDefaultQueryExtent
  62996. * @returns the box extent values
  62997. */
  62998. getDefaultQueryExtent(): Vector3;
  62999. /**
  63000. * Get the Bounding box extent result specified by setDefaultQueryExtent
  63001. * @param result output the box extent values
  63002. */
  63003. getDefaultQueryExtentToRef(result: Vector3): void;
  63004. /**
  63005. * Release all resources
  63006. */
  63007. dispose(): void;
  63008. }
  63009. }
  63010. declare module BABYLON {
  63011. /**
  63012. * Class used to enable access to IndexedDB
  63013. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63014. */
  63015. export class Database implements IOfflineProvider {
  63016. private _callbackManifestChecked;
  63017. private _currentSceneUrl;
  63018. private _db;
  63019. private _enableSceneOffline;
  63020. private _enableTexturesOffline;
  63021. private _manifestVersionFound;
  63022. private _mustUpdateRessources;
  63023. private _hasReachedQuota;
  63024. private _isSupported;
  63025. private _idbFactory;
  63026. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  63027. private static IsUASupportingBlobStorage;
  63028. /**
  63029. * Gets a boolean indicating if Database storate is enabled (off by default)
  63030. */
  63031. static IDBStorageEnabled: boolean;
  63032. /**
  63033. * Gets a boolean indicating if scene must be saved in the database
  63034. */
  63035. get enableSceneOffline(): boolean;
  63036. /**
  63037. * Gets a boolean indicating if textures must be saved in the database
  63038. */
  63039. get enableTexturesOffline(): boolean;
  63040. /**
  63041. * Creates a new Database
  63042. * @param urlToScene defines the url to load the scene
  63043. * @param callbackManifestChecked defines the callback to use when manifest is checked
  63044. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  63045. */
  63046. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  63047. private static _ParseURL;
  63048. private static _ReturnFullUrlLocation;
  63049. private _checkManifestFile;
  63050. /**
  63051. * Open the database and make it available
  63052. * @param successCallback defines the callback to call on success
  63053. * @param errorCallback defines the callback to call on error
  63054. */
  63055. open(successCallback: () => void, errorCallback: () => void): void;
  63056. /**
  63057. * Loads an image from the database
  63058. * @param url defines the url to load from
  63059. * @param image defines the target DOM image
  63060. */
  63061. loadImage(url: string, image: HTMLImageElement): void;
  63062. private _loadImageFromDBAsync;
  63063. private _saveImageIntoDBAsync;
  63064. private _checkVersionFromDB;
  63065. private _loadVersionFromDBAsync;
  63066. private _saveVersionIntoDBAsync;
  63067. /**
  63068. * Loads a file from database
  63069. * @param url defines the URL to load from
  63070. * @param sceneLoaded defines a callback to call on success
  63071. * @param progressCallBack defines a callback to call when progress changed
  63072. * @param errorCallback defines a callback to call on error
  63073. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63074. */
  63075. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63076. private _loadFileAsync;
  63077. private _saveFileAsync;
  63078. /**
  63079. * Validates if xhr data is correct
  63080. * @param xhr defines the request to validate
  63081. * @param dataType defines the expected data type
  63082. * @returns true if data is correct
  63083. */
  63084. private static _ValidateXHRData;
  63085. }
  63086. }
  63087. declare module BABYLON {
  63088. /** @hidden */
  63089. export var gpuUpdateParticlesPixelShader: {
  63090. name: string;
  63091. shader: string;
  63092. };
  63093. }
  63094. declare module BABYLON {
  63095. /** @hidden */
  63096. export var gpuUpdateParticlesVertexShader: {
  63097. name: string;
  63098. shader: string;
  63099. };
  63100. }
  63101. declare module BABYLON {
  63102. /** @hidden */
  63103. export var clipPlaneFragmentDeclaration2: {
  63104. name: string;
  63105. shader: string;
  63106. };
  63107. }
  63108. declare module BABYLON {
  63109. /** @hidden */
  63110. export var gpuRenderParticlesPixelShader: {
  63111. name: string;
  63112. shader: string;
  63113. };
  63114. }
  63115. declare module BABYLON {
  63116. /** @hidden */
  63117. export var clipPlaneVertexDeclaration2: {
  63118. name: string;
  63119. shader: string;
  63120. };
  63121. }
  63122. declare module BABYLON {
  63123. /** @hidden */
  63124. export var gpuRenderParticlesVertexShader: {
  63125. name: string;
  63126. shader: string;
  63127. };
  63128. }
  63129. declare module BABYLON {
  63130. /**
  63131. * This represents a GPU particle system in Babylon
  63132. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  63133. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  63134. */
  63135. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  63136. /**
  63137. * The layer mask we are rendering the particles through.
  63138. */
  63139. layerMask: number;
  63140. private _capacity;
  63141. private _activeCount;
  63142. private _currentActiveCount;
  63143. private _accumulatedCount;
  63144. private _renderEffect;
  63145. private _updateEffect;
  63146. private _buffer0;
  63147. private _buffer1;
  63148. private _spriteBuffer;
  63149. private _updateVAO;
  63150. private _renderVAO;
  63151. private _targetIndex;
  63152. private _sourceBuffer;
  63153. private _targetBuffer;
  63154. private _engine;
  63155. private _currentRenderId;
  63156. private _started;
  63157. private _stopped;
  63158. private _timeDelta;
  63159. private _randomTexture;
  63160. private _randomTexture2;
  63161. private _attributesStrideSize;
  63162. private _updateEffectOptions;
  63163. private _randomTextureSize;
  63164. private _actualFrame;
  63165. private readonly _rawTextureWidth;
  63166. /**
  63167. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  63168. */
  63169. static get IsSupported(): boolean;
  63170. /**
  63171. * An event triggered when the system is disposed.
  63172. */
  63173. onDisposeObservable: Observable<GPUParticleSystem>;
  63174. /**
  63175. * Gets the maximum number of particles active at the same time.
  63176. * @returns The max number of active particles.
  63177. */
  63178. getCapacity(): number;
  63179. /**
  63180. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63181. * to override the particles.
  63182. */
  63183. forceDepthWrite: boolean;
  63184. /**
  63185. * Gets or set the number of active particles
  63186. */
  63187. get activeParticleCount(): number;
  63188. set activeParticleCount(value: number);
  63189. private _preWarmDone;
  63190. /**
  63191. * Specifies if the particles are updated in emitter local space or world space.
  63192. * This is always false for GPU particles
  63193. */
  63194. get isLocal(): boolean;
  63195. set isLocal(value: boolean);
  63196. /**
  63197. * Is this system ready to be used/rendered
  63198. * @return true if the system is ready
  63199. */
  63200. isReady(): boolean;
  63201. /**
  63202. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63203. * @returns True if it has been started, otherwise false.
  63204. */
  63205. isStarted(): boolean;
  63206. /**
  63207. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  63208. * @returns True if it has been stopped, otherwise false.
  63209. */
  63210. isStopped(): boolean;
  63211. /**
  63212. * Gets a boolean indicating that the system is stopping
  63213. * @returns true if the system is currently stopping
  63214. */
  63215. isStopping(): boolean;
  63216. /**
  63217. * Gets the number of particles active at the same time.
  63218. * @returns The number of active particles.
  63219. */
  63220. getActiveCount(): number;
  63221. /**
  63222. * Starts the particle system and begins to emit
  63223. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63224. */
  63225. start(delay?: number): void;
  63226. /**
  63227. * Stops the particle system.
  63228. */
  63229. stop(): void;
  63230. /**
  63231. * Remove all active particles
  63232. */
  63233. reset(): void;
  63234. /**
  63235. * Returns the string "GPUParticleSystem"
  63236. * @returns a string containing the class name
  63237. */
  63238. getClassName(): string;
  63239. private _colorGradientsTexture;
  63240. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63241. /**
  63242. * Adds a new color gradient
  63243. * @param gradient defines the gradient to use (between 0 and 1)
  63244. * @param color1 defines the color to affect to the specified gradient
  63245. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63246. * @returns the current particle system
  63247. */
  63248. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63249. private _refreshColorGradient;
  63250. /** Force the system to rebuild all gradients */
  63251. forceRefreshGradients(): void;
  63252. /**
  63253. * Remove a specific color gradient
  63254. * @param gradient defines the gradient to remove
  63255. * @returns the current particle system
  63256. */
  63257. removeColorGradient(gradient: number): GPUParticleSystem;
  63258. private _angularSpeedGradientsTexture;
  63259. private _sizeGradientsTexture;
  63260. private _velocityGradientsTexture;
  63261. private _limitVelocityGradientsTexture;
  63262. private _dragGradientsTexture;
  63263. private _addFactorGradient;
  63264. /**
  63265. * Adds a new size gradient
  63266. * @param gradient defines the gradient to use (between 0 and 1)
  63267. * @param factor defines the size factor to affect to the specified gradient
  63268. * @returns the current particle system
  63269. */
  63270. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63271. /**
  63272. * Remove a specific size gradient
  63273. * @param gradient defines the gradient to remove
  63274. * @returns the current particle system
  63275. */
  63276. removeSizeGradient(gradient: number): GPUParticleSystem;
  63277. private _refreshFactorGradient;
  63278. /**
  63279. * Adds a new angular speed gradient
  63280. * @param gradient defines the gradient to use (between 0 and 1)
  63281. * @param factor defines the angular speed to affect to the specified gradient
  63282. * @returns the current particle system
  63283. */
  63284. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63285. /**
  63286. * Remove a specific angular speed gradient
  63287. * @param gradient defines the gradient to remove
  63288. * @returns the current particle system
  63289. */
  63290. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63291. /**
  63292. * Adds a new velocity gradient
  63293. * @param gradient defines the gradient to use (between 0 and 1)
  63294. * @param factor defines the velocity to affect to the specified gradient
  63295. * @returns the current particle system
  63296. */
  63297. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63298. /**
  63299. * Remove a specific velocity gradient
  63300. * @param gradient defines the gradient to remove
  63301. * @returns the current particle system
  63302. */
  63303. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63304. /**
  63305. * Adds a new limit velocity gradient
  63306. * @param gradient defines the gradient to use (between 0 and 1)
  63307. * @param factor defines the limit velocity value to affect to the specified gradient
  63308. * @returns the current particle system
  63309. */
  63310. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63311. /**
  63312. * Remove a specific limit velocity gradient
  63313. * @param gradient defines the gradient to remove
  63314. * @returns the current particle system
  63315. */
  63316. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63317. /**
  63318. * Adds a new drag gradient
  63319. * @param gradient defines the gradient to use (between 0 and 1)
  63320. * @param factor defines the drag value to affect to the specified gradient
  63321. * @returns the current particle system
  63322. */
  63323. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63324. /**
  63325. * Remove a specific drag gradient
  63326. * @param gradient defines the gradient to remove
  63327. * @returns the current particle system
  63328. */
  63329. removeDragGradient(gradient: number): GPUParticleSystem;
  63330. /**
  63331. * Not supported by GPUParticleSystem
  63332. * @param gradient defines the gradient to use (between 0 and 1)
  63333. * @param factor defines the emit rate value to affect to the specified gradient
  63334. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63335. * @returns the current particle system
  63336. */
  63337. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63338. /**
  63339. * Not supported by GPUParticleSystem
  63340. * @param gradient defines the gradient to remove
  63341. * @returns the current particle system
  63342. */
  63343. removeEmitRateGradient(gradient: number): IParticleSystem;
  63344. /**
  63345. * Not supported by GPUParticleSystem
  63346. * @param gradient defines the gradient to use (between 0 and 1)
  63347. * @param factor defines the start size value to affect to the specified gradient
  63348. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63349. * @returns the current particle system
  63350. */
  63351. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63352. /**
  63353. * Not supported by GPUParticleSystem
  63354. * @param gradient defines the gradient to remove
  63355. * @returns the current particle system
  63356. */
  63357. removeStartSizeGradient(gradient: number): IParticleSystem;
  63358. /**
  63359. * Not supported by GPUParticleSystem
  63360. * @param gradient defines the gradient to use (between 0 and 1)
  63361. * @param min defines the color remap minimal range
  63362. * @param max defines the color remap maximal range
  63363. * @returns the current particle system
  63364. */
  63365. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63366. /**
  63367. * Not supported by GPUParticleSystem
  63368. * @param gradient defines the gradient to remove
  63369. * @returns the current particle system
  63370. */
  63371. removeColorRemapGradient(): IParticleSystem;
  63372. /**
  63373. * Not supported by GPUParticleSystem
  63374. * @param gradient defines the gradient to use (between 0 and 1)
  63375. * @param min defines the alpha remap minimal range
  63376. * @param max defines the alpha remap maximal range
  63377. * @returns the current particle system
  63378. */
  63379. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63380. /**
  63381. * Not supported by GPUParticleSystem
  63382. * @param gradient defines the gradient to remove
  63383. * @returns the current particle system
  63384. */
  63385. removeAlphaRemapGradient(): IParticleSystem;
  63386. /**
  63387. * Not supported by GPUParticleSystem
  63388. * @param gradient defines the gradient to use (between 0 and 1)
  63389. * @param color defines the color to affect to the specified gradient
  63390. * @returns the current particle system
  63391. */
  63392. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  63393. /**
  63394. * Not supported by GPUParticleSystem
  63395. * @param gradient defines the gradient to remove
  63396. * @returns the current particle system
  63397. */
  63398. removeRampGradient(): IParticleSystem;
  63399. /**
  63400. * Not supported by GPUParticleSystem
  63401. * @returns the list of ramp gradients
  63402. */
  63403. getRampGradients(): Nullable<Array<Color3Gradient>>;
  63404. /**
  63405. * Not supported by GPUParticleSystem
  63406. * Gets or sets a boolean indicating that ramp gradients must be used
  63407. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  63408. */
  63409. get useRampGradients(): boolean;
  63410. set useRampGradients(value: boolean);
  63411. /**
  63412. * Not supported by GPUParticleSystem
  63413. * @param gradient defines the gradient to use (between 0 and 1)
  63414. * @param factor defines the life time factor to affect to the specified gradient
  63415. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63416. * @returns the current particle system
  63417. */
  63418. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63419. /**
  63420. * Not supported by GPUParticleSystem
  63421. * @param gradient defines the gradient to remove
  63422. * @returns the current particle system
  63423. */
  63424. removeLifeTimeGradient(gradient: number): IParticleSystem;
  63425. /**
  63426. * Instantiates a GPU particle system.
  63427. * 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.
  63428. * @param name The name of the particle system
  63429. * @param options The options used to create the system
  63430. * @param scene The scene the particle system belongs to
  63431. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  63432. */
  63433. constructor(name: string, options: Partial<{
  63434. capacity: number;
  63435. randomTextureSize: number;
  63436. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  63437. protected _reset(): void;
  63438. private _createUpdateVAO;
  63439. private _createRenderVAO;
  63440. private _initialize;
  63441. /** @hidden */
  63442. _recreateUpdateEffect(): void;
  63443. /** @hidden */
  63444. _recreateRenderEffect(): void;
  63445. /**
  63446. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  63447. * @param preWarm defines if we are in the pre-warmimg phase
  63448. */
  63449. animate(preWarm?: boolean): void;
  63450. private _createFactorGradientTexture;
  63451. private _createSizeGradientTexture;
  63452. private _createAngularSpeedGradientTexture;
  63453. private _createVelocityGradientTexture;
  63454. private _createLimitVelocityGradientTexture;
  63455. private _createDragGradientTexture;
  63456. private _createColorGradientTexture;
  63457. /**
  63458. * Renders the particle system in its current state
  63459. * @param preWarm defines if the system should only update the particles but not render them
  63460. * @returns the current number of particles
  63461. */
  63462. render(preWarm?: boolean): number;
  63463. /**
  63464. * Rebuilds the particle system
  63465. */
  63466. rebuild(): void;
  63467. private _releaseBuffers;
  63468. private _releaseVAOs;
  63469. /**
  63470. * Disposes the particle system and free the associated resources
  63471. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  63472. */
  63473. dispose(disposeTexture?: boolean): void;
  63474. /**
  63475. * Clones the particle system.
  63476. * @param name The name of the cloned object
  63477. * @param newEmitter The new emitter to use
  63478. * @returns the cloned particle system
  63479. */
  63480. clone(name: string, newEmitter: any): GPUParticleSystem;
  63481. /**
  63482. * Serializes the particle system to a JSON object
  63483. * @param serializeTexture defines if the texture must be serialized as well
  63484. * @returns the JSON object
  63485. */
  63486. serialize(serializeTexture?: boolean): any;
  63487. /**
  63488. * Parses a JSON object to create a GPU particle system.
  63489. * @param parsedParticleSystem The JSON object to parse
  63490. * @param scene The scene to create the particle system in
  63491. * @param rootUrl The root url to use to load external dependencies like texture
  63492. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  63493. * @returns the parsed GPU particle system
  63494. */
  63495. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  63496. }
  63497. }
  63498. declare module BABYLON {
  63499. /**
  63500. * Represents a set of particle systems working together to create a specific effect
  63501. */
  63502. export class ParticleSystemSet implements IDisposable {
  63503. /**
  63504. * Gets or sets base Assets URL
  63505. */
  63506. static BaseAssetsUrl: string;
  63507. private _emitterCreationOptions;
  63508. private _emitterNode;
  63509. /**
  63510. * Gets the particle system list
  63511. */
  63512. systems: IParticleSystem[];
  63513. /**
  63514. * Gets the emitter node used with this set
  63515. */
  63516. get emitterNode(): Nullable<TransformNode>;
  63517. /**
  63518. * Creates a new emitter mesh as a sphere
  63519. * @param options defines the options used to create the sphere
  63520. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  63521. * @param scene defines the hosting scene
  63522. */
  63523. setEmitterAsSphere(options: {
  63524. diameter: number;
  63525. segments: number;
  63526. color: Color3;
  63527. }, renderingGroupId: number, scene: Scene): void;
  63528. /**
  63529. * Starts all particle systems of the set
  63530. * @param emitter defines an optional mesh to use as emitter for the particle systems
  63531. */
  63532. start(emitter?: AbstractMesh): void;
  63533. /**
  63534. * Release all associated resources
  63535. */
  63536. dispose(): void;
  63537. /**
  63538. * Serialize the set into a JSON compatible object
  63539. * @param serializeTexture defines if the texture must be serialized as well
  63540. * @returns a JSON compatible representation of the set
  63541. */
  63542. serialize(serializeTexture?: boolean): any;
  63543. /**
  63544. * Parse a new ParticleSystemSet from a serialized source
  63545. * @param data defines a JSON compatible representation of the set
  63546. * @param scene defines the hosting scene
  63547. * @param gpu defines if we want GPU particles or CPU particles
  63548. * @returns a new ParticleSystemSet
  63549. */
  63550. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  63551. }
  63552. }
  63553. declare module BABYLON {
  63554. /**
  63555. * This class is made for on one-liner static method to help creating particle system set.
  63556. */
  63557. export class ParticleHelper {
  63558. /**
  63559. * Gets or sets base Assets URL
  63560. */
  63561. static BaseAssetsUrl: string;
  63562. /** Define the Url to load snippets */
  63563. static SnippetUrl: string;
  63564. /**
  63565. * Create a default particle system that you can tweak
  63566. * @param emitter defines the emitter to use
  63567. * @param capacity defines the system capacity (default is 500 particles)
  63568. * @param scene defines the hosting scene
  63569. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  63570. * @returns the new Particle system
  63571. */
  63572. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  63573. /**
  63574. * This is the main static method (one-liner) of this helper to create different particle systems
  63575. * @param type This string represents the type to the particle system to create
  63576. * @param scene The scene where the particle system should live
  63577. * @param gpu If the system will use gpu
  63578. * @returns the ParticleSystemSet created
  63579. */
  63580. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  63581. /**
  63582. * Static function used to export a particle system to a ParticleSystemSet variable.
  63583. * Please note that the emitter shape is not exported
  63584. * @param systems defines the particle systems to export
  63585. * @returns the created particle system set
  63586. */
  63587. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  63588. /**
  63589. * Creates a particle system from a snippet saved in a remote file
  63590. * @param name defines the name of the particle system to create
  63591. * @param url defines the url to load from
  63592. * @param scene defines the hosting scene
  63593. * @param gpu If the system will use gpu
  63594. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63595. * @returns a promise that will resolve to the new particle system
  63596. */
  63597. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63598. /**
  63599. * Creates a particle system from a snippet saved by the particle system editor
  63600. * @param snippetId defines the snippet to load
  63601. * @param scene defines the hosting scene
  63602. * @param gpu If the system will use gpu
  63603. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63604. * @returns a promise that will resolve to the new particle system
  63605. */
  63606. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63607. }
  63608. }
  63609. declare module BABYLON {
  63610. interface Engine {
  63611. /**
  63612. * Create an effect to use with particle systems.
  63613. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  63614. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  63615. * @param uniformsNames defines a list of attribute names
  63616. * @param samplers defines an array of string used to represent textures
  63617. * @param defines defines the string containing the defines to use to compile the shaders
  63618. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  63619. * @param onCompiled defines a function to call when the effect creation is successful
  63620. * @param onError defines a function to call when the effect creation has failed
  63621. * @returns the new Effect
  63622. */
  63623. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63624. }
  63625. interface Mesh {
  63626. /**
  63627. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63628. * @returns an array of IParticleSystem
  63629. */
  63630. getEmittedParticleSystems(): IParticleSystem[];
  63631. /**
  63632. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63633. * @returns an array of IParticleSystem
  63634. */
  63635. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63636. }
  63637. /**
  63638. * @hidden
  63639. */
  63640. export var _IDoNeedToBeInTheBuild: number;
  63641. }
  63642. declare module BABYLON {
  63643. /** Defines the 4 color options */
  63644. export enum PointColor {
  63645. /** color value */
  63646. Color = 2,
  63647. /** uv value */
  63648. UV = 1,
  63649. /** random value */
  63650. Random = 0,
  63651. /** stated value */
  63652. Stated = 3
  63653. }
  63654. /**
  63655. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63656. * 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.
  63657. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63658. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63659. *
  63660. * Full documentation here : TO BE ENTERED
  63661. */
  63662. export class PointsCloudSystem implements IDisposable {
  63663. /**
  63664. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63665. * Example : var p = SPS.particles[i];
  63666. */
  63667. particles: CloudPoint[];
  63668. /**
  63669. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63670. */
  63671. nbParticles: number;
  63672. /**
  63673. * This a counter for your own usage. It's not set by any SPS functions.
  63674. */
  63675. counter: number;
  63676. /**
  63677. * The PCS name. This name is also given to the underlying mesh.
  63678. */
  63679. name: string;
  63680. /**
  63681. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63682. */
  63683. mesh: Mesh;
  63684. /**
  63685. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63686. * Please read :
  63687. */
  63688. vars: any;
  63689. /**
  63690. * @hidden
  63691. */
  63692. _size: number;
  63693. private _scene;
  63694. private _promises;
  63695. private _positions;
  63696. private _indices;
  63697. private _normals;
  63698. private _colors;
  63699. private _uvs;
  63700. private _indices32;
  63701. private _positions32;
  63702. private _colors32;
  63703. private _uvs32;
  63704. private _updatable;
  63705. private _isVisibilityBoxLocked;
  63706. private _alwaysVisible;
  63707. private _groups;
  63708. private _groupCounter;
  63709. private _computeParticleColor;
  63710. private _computeParticleTexture;
  63711. private _computeParticleRotation;
  63712. private _computeBoundingBox;
  63713. private _isReady;
  63714. /**
  63715. * Creates a PCS (Points Cloud System) object
  63716. * @param name (String) is the PCS name, this will be the underlying mesh name
  63717. * @param pointSize (number) is the size for each point
  63718. * @param scene (Scene) is the scene in which the PCS is added
  63719. * @param options defines the options of the PCS e.g.
  63720. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63721. */
  63722. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63723. updatable?: boolean;
  63724. });
  63725. /**
  63726. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63727. * If no points were added to the PCS, the returned mesh is just a single point.
  63728. * @returns a promise for the created mesh
  63729. */
  63730. buildMeshAsync(): Promise<Mesh>;
  63731. /**
  63732. * @hidden
  63733. */
  63734. private _buildMesh;
  63735. private _addParticle;
  63736. private _randomUnitVector;
  63737. private _getColorIndicesForCoord;
  63738. private _setPointsColorOrUV;
  63739. private _colorFromTexture;
  63740. private _calculateDensity;
  63741. /**
  63742. * Adds points to the PCS in random positions within a unit sphere
  63743. * @param nb (positive integer) the number of particles to be created from this model
  63744. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63745. * @returns the number of groups in the system
  63746. */
  63747. addPoints(nb: number, pointFunction?: any): number;
  63748. /**
  63749. * Adds points to the PCS from the surface of the model shape
  63750. * @param mesh is any Mesh object that will be used as a surface model for the points
  63751. * @param nb (positive integer) the number of particles to be created from this model
  63752. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63753. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63754. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63755. * @returns the number of groups in the system
  63756. */
  63757. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63758. /**
  63759. * Adds points to the PCS inside the model shape
  63760. * @param mesh is any Mesh object that will be used as a surface model for the points
  63761. * @param nb (positive integer) the number of particles to be created from this model
  63762. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63763. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63764. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63765. * @returns the number of groups in the system
  63766. */
  63767. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63768. /**
  63769. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63770. * This method calls `updateParticle()` for each particle of the SPS.
  63771. * For an animated SPS, it is usually called within the render loop.
  63772. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63773. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63774. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63775. * @returns the PCS.
  63776. */
  63777. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63778. /**
  63779. * Disposes the PCS.
  63780. */
  63781. dispose(): void;
  63782. /**
  63783. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63784. * doc :
  63785. * @returns the PCS.
  63786. */
  63787. refreshVisibleSize(): PointsCloudSystem;
  63788. /**
  63789. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63790. * @param size the size (float) of the visibility box
  63791. * note : this doesn't lock the PCS mesh bounding box.
  63792. * doc :
  63793. */
  63794. setVisibilityBox(size: number): void;
  63795. /**
  63796. * Gets whether the PCS is always visible or not
  63797. * doc :
  63798. */
  63799. get isAlwaysVisible(): boolean;
  63800. /**
  63801. * Sets the PCS as always visible or not
  63802. * doc :
  63803. */
  63804. set isAlwaysVisible(val: boolean);
  63805. /**
  63806. * Tells to `setParticles()` to compute the particle rotations or not
  63807. * Default value : false. The PCS is faster when it's set to false
  63808. * Note : particle rotations are only applied to parent particles
  63809. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63810. */
  63811. set computeParticleRotation(val: boolean);
  63812. /**
  63813. * Tells to `setParticles()` to compute the particle colors or not.
  63814. * Default value : true. The PCS is faster when it's set to false.
  63815. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63816. */
  63817. set computeParticleColor(val: boolean);
  63818. set computeParticleTexture(val: boolean);
  63819. /**
  63820. * Gets if `setParticles()` computes the particle colors or not.
  63821. * Default value : false. The PCS is faster when it's set to false.
  63822. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63823. */
  63824. get computeParticleColor(): boolean;
  63825. /**
  63826. * Gets if `setParticles()` computes the particle textures or not.
  63827. * Default value : false. The PCS is faster when it's set to false.
  63828. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63829. */
  63830. get computeParticleTexture(): boolean;
  63831. /**
  63832. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63833. */
  63834. set computeBoundingBox(val: boolean);
  63835. /**
  63836. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63837. */
  63838. get computeBoundingBox(): boolean;
  63839. /**
  63840. * This function does nothing. It may be overwritten to set all the particle first values.
  63841. * The PCS doesn't call this function, you may have to call it by your own.
  63842. * doc :
  63843. */
  63844. initParticles(): void;
  63845. /**
  63846. * This function does nothing. It may be overwritten to recycle a particle
  63847. * The PCS doesn't call this function, you can to call it
  63848. * doc :
  63849. * @param particle The particle to recycle
  63850. * @returns the recycled particle
  63851. */
  63852. recycleParticle(particle: CloudPoint): CloudPoint;
  63853. /**
  63854. * Updates a particle : this function should be overwritten by the user.
  63855. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63856. * doc :
  63857. * @example : just set a particle position or velocity and recycle conditions
  63858. * @param particle The particle to update
  63859. * @returns the updated particle
  63860. */
  63861. updateParticle(particle: CloudPoint): CloudPoint;
  63862. /**
  63863. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63864. * This does nothing and may be overwritten by the user.
  63865. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63866. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63867. * @param update the boolean update value actually passed to setParticles()
  63868. */
  63869. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63870. /**
  63871. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63872. * This will be passed three parameters.
  63873. * This does nothing and may be overwritten by the user.
  63874. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63875. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63876. * @param update the boolean update value actually passed to setParticles()
  63877. */
  63878. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63879. }
  63880. }
  63881. declare module BABYLON {
  63882. /**
  63883. * Represents one particle of a points cloud system.
  63884. */
  63885. export class CloudPoint {
  63886. /**
  63887. * particle global index
  63888. */
  63889. idx: number;
  63890. /**
  63891. * The color of the particle
  63892. */
  63893. color: Nullable<Color4>;
  63894. /**
  63895. * The world space position of the particle.
  63896. */
  63897. position: Vector3;
  63898. /**
  63899. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63900. */
  63901. rotation: Vector3;
  63902. /**
  63903. * The world space rotation quaternion of the particle.
  63904. */
  63905. rotationQuaternion: Nullable<Quaternion>;
  63906. /**
  63907. * The uv of the particle.
  63908. */
  63909. uv: Nullable<Vector2>;
  63910. /**
  63911. * The current speed of the particle.
  63912. */
  63913. velocity: Vector3;
  63914. /**
  63915. * The pivot point in the particle local space.
  63916. */
  63917. pivot: Vector3;
  63918. /**
  63919. * Must the particle be translated from its pivot point in its local space ?
  63920. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63921. * Default : false
  63922. */
  63923. translateFromPivot: boolean;
  63924. /**
  63925. * Index of this particle in the global "positions" array (Internal use)
  63926. * @hidden
  63927. */
  63928. _pos: number;
  63929. /**
  63930. * @hidden Index of this particle in the global "indices" array (Internal use)
  63931. */
  63932. _ind: number;
  63933. /**
  63934. * Group this particle belongs to
  63935. */
  63936. _group: PointsGroup;
  63937. /**
  63938. * Group id of this particle
  63939. */
  63940. groupId: number;
  63941. /**
  63942. * Index of the particle in its group id (Internal use)
  63943. */
  63944. idxInGroup: number;
  63945. /**
  63946. * @hidden Particle BoundingInfo object (Internal use)
  63947. */
  63948. _boundingInfo: BoundingInfo;
  63949. /**
  63950. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63951. */
  63952. _pcs: PointsCloudSystem;
  63953. /**
  63954. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63955. */
  63956. _stillInvisible: boolean;
  63957. /**
  63958. * @hidden Last computed particle rotation matrix
  63959. */
  63960. _rotationMatrix: number[];
  63961. /**
  63962. * Parent particle Id, if any.
  63963. * Default null.
  63964. */
  63965. parentId: Nullable<number>;
  63966. /**
  63967. * @hidden Internal global position in the PCS.
  63968. */
  63969. _globalPosition: Vector3;
  63970. /**
  63971. * Creates a Point Cloud object.
  63972. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63973. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63974. * @param group (PointsGroup) is the group the particle belongs to
  63975. * @param groupId (integer) is the group identifier in the PCS.
  63976. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63977. * @param pcs defines the PCS it is associated to
  63978. */
  63979. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63980. /**
  63981. * get point size
  63982. */
  63983. get size(): Vector3;
  63984. /**
  63985. * Set point size
  63986. */
  63987. set size(scale: Vector3);
  63988. /**
  63989. * Legacy support, changed quaternion to rotationQuaternion
  63990. */
  63991. get quaternion(): Nullable<Quaternion>;
  63992. /**
  63993. * Legacy support, changed quaternion to rotationQuaternion
  63994. */
  63995. set quaternion(q: Nullable<Quaternion>);
  63996. /**
  63997. * Returns a boolean. True if the particle intersects a mesh, else false
  63998. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63999. * @param target is the object (point or mesh) what the intersection is computed against
  64000. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  64001. * @returns true if it intersects
  64002. */
  64003. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  64004. /**
  64005. * get the rotation matrix of the particle
  64006. * @hidden
  64007. */
  64008. getRotationMatrix(m: Matrix): void;
  64009. }
  64010. /**
  64011. * Represents a group of points in a points cloud system
  64012. * * PCS internal tool, don't use it manually.
  64013. */
  64014. export class PointsGroup {
  64015. /**
  64016. * The group id
  64017. * @hidden
  64018. */
  64019. groupID: number;
  64020. /**
  64021. * image data for group (internal use)
  64022. * @hidden
  64023. */
  64024. _groupImageData: Nullable<ArrayBufferView>;
  64025. /**
  64026. * Image Width (internal use)
  64027. * @hidden
  64028. */
  64029. _groupImgWidth: number;
  64030. /**
  64031. * Image Height (internal use)
  64032. * @hidden
  64033. */
  64034. _groupImgHeight: number;
  64035. /**
  64036. * Custom position function (internal use)
  64037. * @hidden
  64038. */
  64039. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  64040. /**
  64041. * density per facet for surface points
  64042. * @hidden
  64043. */
  64044. _groupDensity: number[];
  64045. /**
  64046. * Only when points are colored by texture carries pointer to texture list array
  64047. * @hidden
  64048. */
  64049. _textureNb: number;
  64050. /**
  64051. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  64052. * PCS internal tool, don't use it manually.
  64053. * @hidden
  64054. */
  64055. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  64056. }
  64057. }
  64058. declare module BABYLON {
  64059. /**
  64060. * Represents a set of particle systems working together to create a specific effect
  64061. */
  64062. export class ParticleSystemDebugger implements IDisposable {
  64063. /**
  64064. * Defines the particle system to debug
  64065. */
  64066. system: IParticleSystem;
  64067. /**
  64068. * Creates a new particle system debugger
  64069. * @param system defines the particle system to debug
  64070. */
  64071. constructor(
  64072. /**
  64073. * Defines the particle system to debug
  64074. */
  64075. system: IParticleSystem);
  64076. /** Clear all the resources */
  64077. dispose(): void;
  64078. }
  64079. }
  64080. declare module BABYLON {
  64081. interface Scene {
  64082. /** @hidden (Backing field) */
  64083. _physicsEngine: Nullable<IPhysicsEngine>;
  64084. /** @hidden */
  64085. _physicsTimeAccumulator: number;
  64086. /**
  64087. * Gets the current physics engine
  64088. * @returns a IPhysicsEngine or null if none attached
  64089. */
  64090. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  64091. /**
  64092. * Enables physics to the current scene
  64093. * @param gravity defines the scene's gravity for the physics engine
  64094. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  64095. * @return a boolean indicating if the physics engine was initialized
  64096. */
  64097. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  64098. /**
  64099. * Disables and disposes the physics engine associated with the scene
  64100. */
  64101. disablePhysicsEngine(): void;
  64102. /**
  64103. * Gets a boolean indicating if there is an active physics engine
  64104. * @returns a boolean indicating if there is an active physics engine
  64105. */
  64106. isPhysicsEnabled(): boolean;
  64107. /**
  64108. * Deletes a physics compound impostor
  64109. * @param compound defines the compound to delete
  64110. */
  64111. deleteCompoundImpostor(compound: any): void;
  64112. /**
  64113. * An event triggered when physic simulation is about to be run
  64114. */
  64115. onBeforePhysicsObservable: Observable<Scene>;
  64116. /**
  64117. * An event triggered when physic simulation has been done
  64118. */
  64119. onAfterPhysicsObservable: Observable<Scene>;
  64120. }
  64121. interface AbstractMesh {
  64122. /** @hidden */
  64123. _physicsImpostor: Nullable<PhysicsImpostor>;
  64124. /**
  64125. * Gets or sets impostor used for physic simulation
  64126. * @see http://doc.babylonjs.com/features/physics_engine
  64127. */
  64128. physicsImpostor: Nullable<PhysicsImpostor>;
  64129. /**
  64130. * Gets the current physics impostor
  64131. * @see http://doc.babylonjs.com/features/physics_engine
  64132. * @returns a physics impostor or null
  64133. */
  64134. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  64135. /** Apply a physic impulse to the mesh
  64136. * @param force defines the force to apply
  64137. * @param contactPoint defines where to apply the force
  64138. * @returns the current mesh
  64139. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  64140. */
  64141. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  64142. /**
  64143. * Creates a physic joint between two meshes
  64144. * @param otherMesh defines the other mesh to use
  64145. * @param pivot1 defines the pivot to use on this mesh
  64146. * @param pivot2 defines the pivot to use on the other mesh
  64147. * @param options defines additional options (can be plugin dependent)
  64148. * @returns the current mesh
  64149. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  64150. */
  64151. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  64152. /** @hidden */
  64153. _disposePhysicsObserver: Nullable<Observer<Node>>;
  64154. }
  64155. /**
  64156. * Defines the physics engine scene component responsible to manage a physics engine
  64157. */
  64158. export class PhysicsEngineSceneComponent implements ISceneComponent {
  64159. /**
  64160. * The component name helpful to identify the component in the list of scene components.
  64161. */
  64162. readonly name: string;
  64163. /**
  64164. * The scene the component belongs to.
  64165. */
  64166. scene: Scene;
  64167. /**
  64168. * Creates a new instance of the component for the given scene
  64169. * @param scene Defines the scene to register the component in
  64170. */
  64171. constructor(scene: Scene);
  64172. /**
  64173. * Registers the component in a given scene
  64174. */
  64175. register(): void;
  64176. /**
  64177. * Rebuilds the elements related to this component in case of
  64178. * context lost for instance.
  64179. */
  64180. rebuild(): void;
  64181. /**
  64182. * Disposes the component and the associated ressources
  64183. */
  64184. dispose(): void;
  64185. }
  64186. }
  64187. declare module BABYLON {
  64188. /**
  64189. * A helper for physics simulations
  64190. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64191. */
  64192. export class PhysicsHelper {
  64193. private _scene;
  64194. private _physicsEngine;
  64195. /**
  64196. * Initializes the Physics helper
  64197. * @param scene Babylon.js scene
  64198. */
  64199. constructor(scene: Scene);
  64200. /**
  64201. * Applies a radial explosion impulse
  64202. * @param origin the origin of the explosion
  64203. * @param radiusOrEventOptions the radius or the options of radial explosion
  64204. * @param strength the explosion strength
  64205. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64206. * @returns A physics radial explosion event, or null
  64207. */
  64208. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64209. /**
  64210. * Applies a radial explosion force
  64211. * @param origin the origin of the explosion
  64212. * @param radiusOrEventOptions the radius or the options of radial explosion
  64213. * @param strength the explosion strength
  64214. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64215. * @returns A physics radial explosion event, or null
  64216. */
  64217. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64218. /**
  64219. * Creates a gravitational field
  64220. * @param origin the origin of the explosion
  64221. * @param radiusOrEventOptions the radius or the options of radial explosion
  64222. * @param strength the explosion strength
  64223. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64224. * @returns A physics gravitational field event, or null
  64225. */
  64226. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  64227. /**
  64228. * Creates a physics updraft event
  64229. * @param origin the origin of the updraft
  64230. * @param radiusOrEventOptions the radius or the options of the updraft
  64231. * @param strength the strength of the updraft
  64232. * @param height the height of the updraft
  64233. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  64234. * @returns A physics updraft event, or null
  64235. */
  64236. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  64237. /**
  64238. * Creates a physics vortex event
  64239. * @param origin the of the vortex
  64240. * @param radiusOrEventOptions the radius or the options of the vortex
  64241. * @param strength the strength of the vortex
  64242. * @param height the height of the vortex
  64243. * @returns a Physics vortex event, or null
  64244. * A physics vortex event or null
  64245. */
  64246. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64247. }
  64248. /**
  64249. * Represents a physics radial explosion event
  64250. */
  64251. class PhysicsRadialExplosionEvent {
  64252. private _scene;
  64253. private _options;
  64254. private _sphere;
  64255. private _dataFetched;
  64256. /**
  64257. * Initializes a radial explosioin event
  64258. * @param _scene BabylonJS scene
  64259. * @param _options The options for the vortex event
  64260. */
  64261. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64262. /**
  64263. * Returns the data related to the radial explosion event (sphere).
  64264. * @returns The radial explosion event data
  64265. */
  64266. getData(): PhysicsRadialExplosionEventData;
  64267. /**
  64268. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64269. * @param impostor A physics imposter
  64270. * @param origin the origin of the explosion
  64271. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64272. */
  64273. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64274. /**
  64275. * Triggers affecterd impostors callbacks
  64276. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64277. */
  64278. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64279. /**
  64280. * Disposes the sphere.
  64281. * @param force Specifies if the sphere should be disposed by force
  64282. */
  64283. dispose(force?: boolean): void;
  64284. /*** Helpers ***/
  64285. private _prepareSphere;
  64286. private _intersectsWithSphere;
  64287. }
  64288. /**
  64289. * Represents a gravitational field event
  64290. */
  64291. class PhysicsGravitationalFieldEvent {
  64292. private _physicsHelper;
  64293. private _scene;
  64294. private _origin;
  64295. private _options;
  64296. private _tickCallback;
  64297. private _sphere;
  64298. private _dataFetched;
  64299. /**
  64300. * Initializes the physics gravitational field event
  64301. * @param _physicsHelper A physics helper
  64302. * @param _scene BabylonJS scene
  64303. * @param _origin The origin position of the gravitational field event
  64304. * @param _options The options for the vortex event
  64305. */
  64306. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  64307. /**
  64308. * Returns the data related to the gravitational field event (sphere).
  64309. * @returns A gravitational field event
  64310. */
  64311. getData(): PhysicsGravitationalFieldEventData;
  64312. /**
  64313. * Enables the gravitational field.
  64314. */
  64315. enable(): void;
  64316. /**
  64317. * Disables the gravitational field.
  64318. */
  64319. disable(): void;
  64320. /**
  64321. * Disposes the sphere.
  64322. * @param force The force to dispose from the gravitational field event
  64323. */
  64324. dispose(force?: boolean): void;
  64325. private _tick;
  64326. }
  64327. /**
  64328. * Represents a physics updraft event
  64329. */
  64330. class PhysicsUpdraftEvent {
  64331. private _scene;
  64332. private _origin;
  64333. private _options;
  64334. private _physicsEngine;
  64335. private _originTop;
  64336. private _originDirection;
  64337. private _tickCallback;
  64338. private _cylinder;
  64339. private _cylinderPosition;
  64340. private _dataFetched;
  64341. /**
  64342. * Initializes the physics updraft event
  64343. * @param _scene BabylonJS scene
  64344. * @param _origin The origin position of the updraft
  64345. * @param _options The options for the updraft event
  64346. */
  64347. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  64348. /**
  64349. * Returns the data related to the updraft event (cylinder).
  64350. * @returns A physics updraft event
  64351. */
  64352. getData(): PhysicsUpdraftEventData;
  64353. /**
  64354. * Enables the updraft.
  64355. */
  64356. enable(): void;
  64357. /**
  64358. * Disables the updraft.
  64359. */
  64360. disable(): void;
  64361. /**
  64362. * Disposes the cylinder.
  64363. * @param force Specifies if the updraft should be disposed by force
  64364. */
  64365. dispose(force?: boolean): void;
  64366. private getImpostorHitData;
  64367. private _tick;
  64368. /*** Helpers ***/
  64369. private _prepareCylinder;
  64370. private _intersectsWithCylinder;
  64371. }
  64372. /**
  64373. * Represents a physics vortex event
  64374. */
  64375. class PhysicsVortexEvent {
  64376. private _scene;
  64377. private _origin;
  64378. private _options;
  64379. private _physicsEngine;
  64380. private _originTop;
  64381. private _tickCallback;
  64382. private _cylinder;
  64383. private _cylinderPosition;
  64384. private _dataFetched;
  64385. /**
  64386. * Initializes the physics vortex event
  64387. * @param _scene The BabylonJS scene
  64388. * @param _origin The origin position of the vortex
  64389. * @param _options The options for the vortex event
  64390. */
  64391. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  64392. /**
  64393. * Returns the data related to the vortex event (cylinder).
  64394. * @returns The physics vortex event data
  64395. */
  64396. getData(): PhysicsVortexEventData;
  64397. /**
  64398. * Enables the vortex.
  64399. */
  64400. enable(): void;
  64401. /**
  64402. * Disables the cortex.
  64403. */
  64404. disable(): void;
  64405. /**
  64406. * Disposes the sphere.
  64407. * @param force
  64408. */
  64409. dispose(force?: boolean): void;
  64410. private getImpostorHitData;
  64411. private _tick;
  64412. /*** Helpers ***/
  64413. private _prepareCylinder;
  64414. private _intersectsWithCylinder;
  64415. }
  64416. /**
  64417. * Options fot the radial explosion event
  64418. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64419. */
  64420. export class PhysicsRadialExplosionEventOptions {
  64421. /**
  64422. * The radius of the sphere for the radial explosion.
  64423. */
  64424. radius: number;
  64425. /**
  64426. * The strenth of the explosion.
  64427. */
  64428. strength: number;
  64429. /**
  64430. * The strenght of the force in correspondence to the distance of the affected object
  64431. */
  64432. falloff: PhysicsRadialImpulseFalloff;
  64433. /**
  64434. * Sphere options for the radial explosion.
  64435. */
  64436. sphere: {
  64437. segments: number;
  64438. diameter: number;
  64439. };
  64440. /**
  64441. * Sphere options for the radial explosion.
  64442. */
  64443. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  64444. }
  64445. /**
  64446. * Options fot the updraft event
  64447. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64448. */
  64449. export class PhysicsUpdraftEventOptions {
  64450. /**
  64451. * The radius of the cylinder for the vortex
  64452. */
  64453. radius: number;
  64454. /**
  64455. * The strenth of the updraft.
  64456. */
  64457. strength: number;
  64458. /**
  64459. * The height of the cylinder for the updraft.
  64460. */
  64461. height: number;
  64462. /**
  64463. * The mode for the the updraft.
  64464. */
  64465. updraftMode: PhysicsUpdraftMode;
  64466. }
  64467. /**
  64468. * Options fot the vortex event
  64469. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64470. */
  64471. export class PhysicsVortexEventOptions {
  64472. /**
  64473. * The radius of the cylinder for the vortex
  64474. */
  64475. radius: number;
  64476. /**
  64477. * The strenth of the vortex.
  64478. */
  64479. strength: number;
  64480. /**
  64481. * The height of the cylinder for the vortex.
  64482. */
  64483. height: number;
  64484. /**
  64485. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  64486. */
  64487. centripetalForceThreshold: number;
  64488. /**
  64489. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  64490. */
  64491. centripetalForceMultiplier: number;
  64492. /**
  64493. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  64494. */
  64495. centrifugalForceMultiplier: number;
  64496. /**
  64497. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  64498. */
  64499. updraftForceMultiplier: number;
  64500. }
  64501. /**
  64502. * The strenght of the force in correspondence to the distance of the affected object
  64503. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64504. */
  64505. export enum PhysicsRadialImpulseFalloff {
  64506. /** Defines that impulse is constant in strength across it's whole radius */
  64507. Constant = 0,
  64508. /** Defines that impulse gets weaker if it's further from the origin */
  64509. Linear = 1
  64510. }
  64511. /**
  64512. * The strength of the force in correspondence to the distance of the affected object
  64513. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64514. */
  64515. export enum PhysicsUpdraftMode {
  64516. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  64517. Center = 0,
  64518. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  64519. Perpendicular = 1
  64520. }
  64521. /**
  64522. * Interface for a physics hit data
  64523. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64524. */
  64525. export interface PhysicsHitData {
  64526. /**
  64527. * The force applied at the contact point
  64528. */
  64529. force: Vector3;
  64530. /**
  64531. * The contact point
  64532. */
  64533. contactPoint: Vector3;
  64534. /**
  64535. * The distance from the origin to the contact point
  64536. */
  64537. distanceFromOrigin: number;
  64538. }
  64539. /**
  64540. * Interface for radial explosion event data
  64541. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64542. */
  64543. export interface PhysicsRadialExplosionEventData {
  64544. /**
  64545. * A sphere used for the radial explosion event
  64546. */
  64547. sphere: Mesh;
  64548. }
  64549. /**
  64550. * Interface for gravitational field event data
  64551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64552. */
  64553. export interface PhysicsGravitationalFieldEventData {
  64554. /**
  64555. * A sphere mesh used for the gravitational field event
  64556. */
  64557. sphere: Mesh;
  64558. }
  64559. /**
  64560. * Interface for updraft event data
  64561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64562. */
  64563. export interface PhysicsUpdraftEventData {
  64564. /**
  64565. * A cylinder used for the updraft event
  64566. */
  64567. cylinder: Mesh;
  64568. }
  64569. /**
  64570. * Interface for vortex event data
  64571. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64572. */
  64573. export interface PhysicsVortexEventData {
  64574. /**
  64575. * A cylinder used for the vortex event
  64576. */
  64577. cylinder: Mesh;
  64578. }
  64579. /**
  64580. * Interface for an affected physics impostor
  64581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64582. */
  64583. export interface PhysicsAffectedImpostorWithData {
  64584. /**
  64585. * The impostor affected by the effect
  64586. */
  64587. impostor: PhysicsImpostor;
  64588. /**
  64589. * The data about the hit/horce from the explosion
  64590. */
  64591. hitData: PhysicsHitData;
  64592. }
  64593. }
  64594. declare module BABYLON {
  64595. /** @hidden */
  64596. export var blackAndWhitePixelShader: {
  64597. name: string;
  64598. shader: string;
  64599. };
  64600. }
  64601. declare module BABYLON {
  64602. /**
  64603. * Post process used to render in black and white
  64604. */
  64605. export class BlackAndWhitePostProcess extends PostProcess {
  64606. /**
  64607. * Linear about to convert he result to black and white (default: 1)
  64608. */
  64609. degree: number;
  64610. /**
  64611. * Creates a black and white post process
  64612. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  64613. * @param name The name of the effect.
  64614. * @param options The required width/height ratio to downsize to before computing the render pass.
  64615. * @param camera The camera to apply the render pass to.
  64616. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64617. * @param engine The engine which the post process will be applied. (default: current engine)
  64618. * @param reusable If the post process can be reused on the same frame. (default: false)
  64619. */
  64620. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64621. }
  64622. }
  64623. declare module BABYLON {
  64624. /**
  64625. * This represents a set of one or more post processes in Babylon.
  64626. * A post process can be used to apply a shader to a texture after it is rendered.
  64627. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64628. */
  64629. export class PostProcessRenderEffect {
  64630. private _postProcesses;
  64631. private _getPostProcesses;
  64632. private _singleInstance;
  64633. private _cameras;
  64634. private _indicesForCamera;
  64635. /**
  64636. * Name of the effect
  64637. * @hidden
  64638. */
  64639. _name: string;
  64640. /**
  64641. * Instantiates a post process render effect.
  64642. * A post process can be used to apply a shader to a texture after it is rendered.
  64643. * @param engine The engine the effect is tied to
  64644. * @param name The name of the effect
  64645. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64646. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64647. */
  64648. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64649. /**
  64650. * Checks if all the post processes in the effect are supported.
  64651. */
  64652. get isSupported(): boolean;
  64653. /**
  64654. * Updates the current state of the effect
  64655. * @hidden
  64656. */
  64657. _update(): void;
  64658. /**
  64659. * Attaches the effect on cameras
  64660. * @param cameras The camera to attach to.
  64661. * @hidden
  64662. */
  64663. _attachCameras(cameras: Camera): void;
  64664. /**
  64665. * Attaches the effect on cameras
  64666. * @param cameras The camera to attach to.
  64667. * @hidden
  64668. */
  64669. _attachCameras(cameras: Camera[]): void;
  64670. /**
  64671. * Detaches the effect on cameras
  64672. * @param cameras The camera to detatch from.
  64673. * @hidden
  64674. */
  64675. _detachCameras(cameras: Camera): void;
  64676. /**
  64677. * Detatches the effect on cameras
  64678. * @param cameras The camera to detatch from.
  64679. * @hidden
  64680. */
  64681. _detachCameras(cameras: Camera[]): void;
  64682. /**
  64683. * Enables the effect on given cameras
  64684. * @param cameras The camera to enable.
  64685. * @hidden
  64686. */
  64687. _enable(cameras: Camera): void;
  64688. /**
  64689. * Enables the effect on given cameras
  64690. * @param cameras The camera to enable.
  64691. * @hidden
  64692. */
  64693. _enable(cameras: Nullable<Camera[]>): void;
  64694. /**
  64695. * Disables the effect on the given cameras
  64696. * @param cameras The camera to disable.
  64697. * @hidden
  64698. */
  64699. _disable(cameras: Camera): void;
  64700. /**
  64701. * Disables the effect on the given cameras
  64702. * @param cameras The camera to disable.
  64703. * @hidden
  64704. */
  64705. _disable(cameras: Nullable<Camera[]>): void;
  64706. /**
  64707. * Gets a list of the post processes contained in the effect.
  64708. * @param camera The camera to get the post processes on.
  64709. * @returns The list of the post processes in the effect.
  64710. */
  64711. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64712. }
  64713. }
  64714. declare module BABYLON {
  64715. /** @hidden */
  64716. export var extractHighlightsPixelShader: {
  64717. name: string;
  64718. shader: string;
  64719. };
  64720. }
  64721. declare module BABYLON {
  64722. /**
  64723. * 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.
  64724. */
  64725. export class ExtractHighlightsPostProcess extends PostProcess {
  64726. /**
  64727. * The luminance threshold, pixels below this value will be set to black.
  64728. */
  64729. threshold: number;
  64730. /** @hidden */
  64731. _exposure: number;
  64732. /**
  64733. * Post process which has the input texture to be used when performing highlight extraction
  64734. * @hidden
  64735. */
  64736. _inputPostProcess: Nullable<PostProcess>;
  64737. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64738. }
  64739. }
  64740. declare module BABYLON {
  64741. /** @hidden */
  64742. export var bloomMergePixelShader: {
  64743. name: string;
  64744. shader: string;
  64745. };
  64746. }
  64747. declare module BABYLON {
  64748. /**
  64749. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64750. */
  64751. export class BloomMergePostProcess extends PostProcess {
  64752. /** Weight of the bloom to be added to the original input. */
  64753. weight: number;
  64754. /**
  64755. * Creates a new instance of @see BloomMergePostProcess
  64756. * @param name The name of the effect.
  64757. * @param originalFromInput Post process which's input will be used for the merge.
  64758. * @param blurred Blurred highlights post process which's output will be used.
  64759. * @param weight Weight of the bloom to be added to the original input.
  64760. * @param options The required width/height ratio to downsize to before computing the render pass.
  64761. * @param camera The camera to apply the render pass to.
  64762. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64763. * @param engine The engine which the post process will be applied. (default: current engine)
  64764. * @param reusable If the post process can be reused on the same frame. (default: false)
  64765. * @param textureType Type of textures used when performing the post process. (default: 0)
  64766. * @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)
  64767. */
  64768. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64769. /** Weight of the bloom to be added to the original input. */
  64770. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64771. }
  64772. }
  64773. declare module BABYLON {
  64774. /**
  64775. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64776. */
  64777. export class BloomEffect extends PostProcessRenderEffect {
  64778. private bloomScale;
  64779. /**
  64780. * @hidden Internal
  64781. */
  64782. _effects: Array<PostProcess>;
  64783. /**
  64784. * @hidden Internal
  64785. */
  64786. _downscale: ExtractHighlightsPostProcess;
  64787. private _blurX;
  64788. private _blurY;
  64789. private _merge;
  64790. /**
  64791. * The luminance threshold to find bright areas of the image to bloom.
  64792. */
  64793. get threshold(): number;
  64794. set threshold(value: number);
  64795. /**
  64796. * The strength of the bloom.
  64797. */
  64798. get weight(): number;
  64799. set weight(value: number);
  64800. /**
  64801. * Specifies the size of the bloom blur kernel, relative to the final output size
  64802. */
  64803. get kernel(): number;
  64804. set kernel(value: number);
  64805. /**
  64806. * Creates a new instance of @see BloomEffect
  64807. * @param scene The scene the effect belongs to.
  64808. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64809. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64810. * @param bloomWeight The the strength of bloom.
  64811. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64812. * @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)
  64813. */
  64814. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64815. /**
  64816. * Disposes each of the internal effects for a given camera.
  64817. * @param camera The camera to dispose the effect on.
  64818. */
  64819. disposeEffects(camera: Camera): void;
  64820. /**
  64821. * @hidden Internal
  64822. */
  64823. _updateEffects(): void;
  64824. /**
  64825. * Internal
  64826. * @returns if all the contained post processes are ready.
  64827. * @hidden
  64828. */
  64829. _isReady(): boolean;
  64830. }
  64831. }
  64832. declare module BABYLON {
  64833. /** @hidden */
  64834. export var chromaticAberrationPixelShader: {
  64835. name: string;
  64836. shader: string;
  64837. };
  64838. }
  64839. declare module BABYLON {
  64840. /**
  64841. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64842. */
  64843. export class ChromaticAberrationPostProcess extends PostProcess {
  64844. /**
  64845. * The amount of seperation of rgb channels (default: 30)
  64846. */
  64847. aberrationAmount: number;
  64848. /**
  64849. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64850. */
  64851. radialIntensity: number;
  64852. /**
  64853. * 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))
  64854. */
  64855. direction: Vector2;
  64856. /**
  64857. * 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))
  64858. */
  64859. centerPosition: Vector2;
  64860. /**
  64861. * Creates a new instance ChromaticAberrationPostProcess
  64862. * @param name The name of the effect.
  64863. * @param screenWidth The width of the screen to apply the effect on.
  64864. * @param screenHeight The height of the screen to apply the effect on.
  64865. * @param options The required width/height ratio to downsize to before computing the render pass.
  64866. * @param camera The camera to apply the render pass to.
  64867. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64868. * @param engine The engine which the post process will be applied. (default: current engine)
  64869. * @param reusable If the post process can be reused on the same frame. (default: false)
  64870. * @param textureType Type of textures used when performing the post process. (default: 0)
  64871. * @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)
  64872. */
  64873. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64874. }
  64875. }
  64876. declare module BABYLON {
  64877. /** @hidden */
  64878. export var circleOfConfusionPixelShader: {
  64879. name: string;
  64880. shader: string;
  64881. };
  64882. }
  64883. declare module BABYLON {
  64884. /**
  64885. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64886. */
  64887. export class CircleOfConfusionPostProcess extends PostProcess {
  64888. /**
  64889. * 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.
  64890. */
  64891. lensSize: number;
  64892. /**
  64893. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64894. */
  64895. fStop: number;
  64896. /**
  64897. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64898. */
  64899. focusDistance: number;
  64900. /**
  64901. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64902. */
  64903. focalLength: number;
  64904. private _depthTexture;
  64905. /**
  64906. * Creates a new instance CircleOfConfusionPostProcess
  64907. * @param name The name of the effect.
  64908. * @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.
  64909. * @param options The required width/height ratio to downsize to before computing the render pass.
  64910. * @param camera The camera to apply the render pass to.
  64911. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64912. * @param engine The engine which the post process will be applied. (default: current engine)
  64913. * @param reusable If the post process can be reused on the same frame. (default: false)
  64914. * @param textureType Type of textures used when performing the post process. (default: 0)
  64915. * @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)
  64916. */
  64917. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64918. /**
  64919. * 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.
  64920. */
  64921. set depthTexture(value: RenderTargetTexture);
  64922. }
  64923. }
  64924. declare module BABYLON {
  64925. /** @hidden */
  64926. export var colorCorrectionPixelShader: {
  64927. name: string;
  64928. shader: string;
  64929. };
  64930. }
  64931. declare module BABYLON {
  64932. /**
  64933. *
  64934. * This post-process allows the modification of rendered colors by using
  64935. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64936. *
  64937. * The object needs to be provided an url to a texture containing the color
  64938. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64939. * Use an image editing software to tweak the LUT to match your needs.
  64940. *
  64941. * For an example of a color LUT, see here:
  64942. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64943. * For explanations on color grading, see here:
  64944. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64945. *
  64946. */
  64947. export class ColorCorrectionPostProcess extends PostProcess {
  64948. private _colorTableTexture;
  64949. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64950. }
  64951. }
  64952. declare module BABYLON {
  64953. /** @hidden */
  64954. export var convolutionPixelShader: {
  64955. name: string;
  64956. shader: string;
  64957. };
  64958. }
  64959. declare module BABYLON {
  64960. /**
  64961. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64962. * input texture to perform effects such as edge detection or sharpening
  64963. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64964. */
  64965. export class ConvolutionPostProcess extends PostProcess {
  64966. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64967. kernel: number[];
  64968. /**
  64969. * Creates a new instance ConvolutionPostProcess
  64970. * @param name The name of the effect.
  64971. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64972. * @param options The required width/height ratio to downsize to before computing the render pass.
  64973. * @param camera The camera to apply the render pass to.
  64974. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64975. * @param engine The engine which the post process will be applied. (default: current engine)
  64976. * @param reusable If the post process can be reused on the same frame. (default: false)
  64977. * @param textureType Type of textures used when performing the post process. (default: 0)
  64978. */
  64979. constructor(name: string,
  64980. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64981. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64982. /**
  64983. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64984. */
  64985. static EdgeDetect0Kernel: number[];
  64986. /**
  64987. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64988. */
  64989. static EdgeDetect1Kernel: number[];
  64990. /**
  64991. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64992. */
  64993. static EdgeDetect2Kernel: number[];
  64994. /**
  64995. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64996. */
  64997. static SharpenKernel: number[];
  64998. /**
  64999. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65000. */
  65001. static EmbossKernel: number[];
  65002. /**
  65003. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65004. */
  65005. static GaussianKernel: number[];
  65006. }
  65007. }
  65008. declare module BABYLON {
  65009. /**
  65010. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  65011. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  65012. * based on samples that have a large difference in distance than the center pixel.
  65013. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  65014. */
  65015. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  65016. direction: Vector2;
  65017. /**
  65018. * Creates a new instance CircleOfConfusionPostProcess
  65019. * @param name The name of the effect.
  65020. * @param scene The scene the effect belongs to.
  65021. * @param direction The direction the blur should be applied.
  65022. * @param kernel The size of the kernel used to blur.
  65023. * @param options The required width/height ratio to downsize to before computing the render pass.
  65024. * @param camera The camera to apply the render pass to.
  65025. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  65026. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  65027. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65028. * @param engine The engine which the post process will be applied. (default: current engine)
  65029. * @param reusable If the post process can be reused on the same frame. (default: false)
  65030. * @param textureType Type of textures used when performing the post process. (default: 0)
  65031. * @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)
  65032. */
  65033. 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);
  65034. }
  65035. }
  65036. declare module BABYLON {
  65037. /** @hidden */
  65038. export var depthOfFieldMergePixelShader: {
  65039. name: string;
  65040. shader: string;
  65041. };
  65042. }
  65043. declare module BABYLON {
  65044. /**
  65045. * Options to be set when merging outputs from the default pipeline.
  65046. */
  65047. export class DepthOfFieldMergePostProcessOptions {
  65048. /**
  65049. * The original image to merge on top of
  65050. */
  65051. originalFromInput: PostProcess;
  65052. /**
  65053. * Parameters to perform the merge of the depth of field effect
  65054. */
  65055. depthOfField?: {
  65056. circleOfConfusion: PostProcess;
  65057. blurSteps: Array<PostProcess>;
  65058. };
  65059. /**
  65060. * Parameters to perform the merge of bloom effect
  65061. */
  65062. bloom?: {
  65063. blurred: PostProcess;
  65064. weight: number;
  65065. };
  65066. }
  65067. /**
  65068. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65069. */
  65070. export class DepthOfFieldMergePostProcess extends PostProcess {
  65071. private blurSteps;
  65072. /**
  65073. * Creates a new instance of DepthOfFieldMergePostProcess
  65074. * @param name The name of the effect.
  65075. * @param originalFromInput Post process which's input will be used for the merge.
  65076. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  65077. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  65078. * @param options The required width/height ratio to downsize to before computing the render pass.
  65079. * @param camera The camera to apply the render pass to.
  65080. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65081. * @param engine The engine which the post process will be applied. (default: current engine)
  65082. * @param reusable If the post process can be reused on the same frame. (default: false)
  65083. * @param textureType Type of textures used when performing the post process. (default: 0)
  65084. * @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)
  65085. */
  65086. 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);
  65087. /**
  65088. * Updates the effect with the current post process compile time values and recompiles the shader.
  65089. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65090. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65091. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65092. * @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
  65093. * @param onCompiled Called when the shader has been compiled.
  65094. * @param onError Called if there is an error when compiling a shader.
  65095. */
  65096. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65097. }
  65098. }
  65099. declare module BABYLON {
  65100. /**
  65101. * Specifies the level of max blur that should be applied when using the depth of field effect
  65102. */
  65103. export enum DepthOfFieldEffectBlurLevel {
  65104. /**
  65105. * Subtle blur
  65106. */
  65107. Low = 0,
  65108. /**
  65109. * Medium blur
  65110. */
  65111. Medium = 1,
  65112. /**
  65113. * Large blur
  65114. */
  65115. High = 2
  65116. }
  65117. /**
  65118. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  65119. */
  65120. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  65121. private _circleOfConfusion;
  65122. /**
  65123. * @hidden Internal, blurs from high to low
  65124. */
  65125. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  65126. private _depthOfFieldBlurY;
  65127. private _dofMerge;
  65128. /**
  65129. * @hidden Internal post processes in depth of field effect
  65130. */
  65131. _effects: Array<PostProcess>;
  65132. /**
  65133. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  65134. */
  65135. set focalLength(value: number);
  65136. get focalLength(): number;
  65137. /**
  65138. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65139. */
  65140. set fStop(value: number);
  65141. get fStop(): number;
  65142. /**
  65143. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65144. */
  65145. set focusDistance(value: number);
  65146. get focusDistance(): number;
  65147. /**
  65148. * 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.
  65149. */
  65150. set lensSize(value: number);
  65151. get lensSize(): number;
  65152. /**
  65153. * Creates a new instance DepthOfFieldEffect
  65154. * @param scene The scene the effect belongs to.
  65155. * @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.
  65156. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65157. * @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)
  65158. */
  65159. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  65160. /**
  65161. * Get the current class name of the current effet
  65162. * @returns "DepthOfFieldEffect"
  65163. */
  65164. getClassName(): string;
  65165. /**
  65166. * 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.
  65167. */
  65168. set depthTexture(value: RenderTargetTexture);
  65169. /**
  65170. * Disposes each of the internal effects for a given camera.
  65171. * @param camera The camera to dispose the effect on.
  65172. */
  65173. disposeEffects(camera: Camera): void;
  65174. /**
  65175. * @hidden Internal
  65176. */
  65177. _updateEffects(): void;
  65178. /**
  65179. * Internal
  65180. * @returns if all the contained post processes are ready.
  65181. * @hidden
  65182. */
  65183. _isReady(): boolean;
  65184. }
  65185. }
  65186. declare module BABYLON {
  65187. /** @hidden */
  65188. export var displayPassPixelShader: {
  65189. name: string;
  65190. shader: string;
  65191. };
  65192. }
  65193. declare module BABYLON {
  65194. /**
  65195. * DisplayPassPostProcess which produces an output the same as it's input
  65196. */
  65197. export class DisplayPassPostProcess extends PostProcess {
  65198. /**
  65199. * Creates the DisplayPassPostProcess
  65200. * @param name The name of the effect.
  65201. * @param options The required width/height ratio to downsize to before computing the render pass.
  65202. * @param camera The camera to apply the render pass to.
  65203. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65204. * @param engine The engine which the post process will be applied. (default: current engine)
  65205. * @param reusable If the post process can be reused on the same frame. (default: false)
  65206. */
  65207. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65208. }
  65209. }
  65210. declare module BABYLON {
  65211. /** @hidden */
  65212. export var filterPixelShader: {
  65213. name: string;
  65214. shader: string;
  65215. };
  65216. }
  65217. declare module BABYLON {
  65218. /**
  65219. * Applies a kernel filter to the image
  65220. */
  65221. export class FilterPostProcess extends PostProcess {
  65222. /** The matrix to be applied to the image */
  65223. kernelMatrix: Matrix;
  65224. /**
  65225. *
  65226. * @param name The name of the effect.
  65227. * @param kernelMatrix The matrix to be applied to the image
  65228. * @param options The required width/height ratio to downsize to before computing the render pass.
  65229. * @param camera The camera to apply the render pass to.
  65230. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65231. * @param engine The engine which the post process will be applied. (default: current engine)
  65232. * @param reusable If the post process can be reused on the same frame. (default: false)
  65233. */
  65234. constructor(name: string,
  65235. /** The matrix to be applied to the image */
  65236. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65237. }
  65238. }
  65239. declare module BABYLON {
  65240. /** @hidden */
  65241. export var fxaaPixelShader: {
  65242. name: string;
  65243. shader: string;
  65244. };
  65245. }
  65246. declare module BABYLON {
  65247. /** @hidden */
  65248. export var fxaaVertexShader: {
  65249. name: string;
  65250. shader: string;
  65251. };
  65252. }
  65253. declare module BABYLON {
  65254. /**
  65255. * Fxaa post process
  65256. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  65257. */
  65258. export class FxaaPostProcess extends PostProcess {
  65259. /** @hidden */
  65260. texelWidth: number;
  65261. /** @hidden */
  65262. texelHeight: number;
  65263. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65264. private _getDefines;
  65265. }
  65266. }
  65267. declare module BABYLON {
  65268. /** @hidden */
  65269. export var grainPixelShader: {
  65270. name: string;
  65271. shader: string;
  65272. };
  65273. }
  65274. declare module BABYLON {
  65275. /**
  65276. * The GrainPostProcess adds noise to the image at mid luminance levels
  65277. */
  65278. export class GrainPostProcess extends PostProcess {
  65279. /**
  65280. * The intensity of the grain added (default: 30)
  65281. */
  65282. intensity: number;
  65283. /**
  65284. * If the grain should be randomized on every frame
  65285. */
  65286. animated: boolean;
  65287. /**
  65288. * Creates a new instance of @see GrainPostProcess
  65289. * @param name The name of the effect.
  65290. * @param options The required width/height ratio to downsize to before computing the render pass.
  65291. * @param camera The camera to apply the render pass to.
  65292. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65293. * @param engine The engine which the post process will be applied. (default: current engine)
  65294. * @param reusable If the post process can be reused on the same frame. (default: false)
  65295. * @param textureType Type of textures used when performing the post process. (default: 0)
  65296. * @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)
  65297. */
  65298. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65299. }
  65300. }
  65301. declare module BABYLON {
  65302. /** @hidden */
  65303. export var highlightsPixelShader: {
  65304. name: string;
  65305. shader: string;
  65306. };
  65307. }
  65308. declare module BABYLON {
  65309. /**
  65310. * Extracts highlights from the image
  65311. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65312. */
  65313. export class HighlightsPostProcess extends PostProcess {
  65314. /**
  65315. * Extracts highlights from the image
  65316. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65317. * @param name The name of the effect.
  65318. * @param options The required width/height ratio to downsize to before computing the render pass.
  65319. * @param camera The camera to apply the render pass to.
  65320. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65321. * @param engine The engine which the post process will be applied. (default: current engine)
  65322. * @param reusable If the post process can be reused on the same frame. (default: false)
  65323. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  65324. */
  65325. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65326. }
  65327. }
  65328. declare module BABYLON {
  65329. /** @hidden */
  65330. export var mrtFragmentDeclaration: {
  65331. name: string;
  65332. shader: string;
  65333. };
  65334. }
  65335. declare module BABYLON {
  65336. /** @hidden */
  65337. export var geometryPixelShader: {
  65338. name: string;
  65339. shader: string;
  65340. };
  65341. }
  65342. declare module BABYLON {
  65343. /** @hidden */
  65344. export var geometryVertexShader: {
  65345. name: string;
  65346. shader: string;
  65347. };
  65348. }
  65349. declare module BABYLON {
  65350. /** @hidden */
  65351. interface ISavedTransformationMatrix {
  65352. world: Matrix;
  65353. viewProjection: Matrix;
  65354. }
  65355. /**
  65356. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  65357. */
  65358. export class GeometryBufferRenderer {
  65359. /**
  65360. * Constant used to retrieve the position texture index in the G-Buffer textures array
  65361. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  65362. */
  65363. static readonly POSITION_TEXTURE_TYPE: number;
  65364. /**
  65365. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  65366. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  65367. */
  65368. static readonly VELOCITY_TEXTURE_TYPE: number;
  65369. /**
  65370. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  65371. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  65372. */
  65373. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  65374. /**
  65375. * Dictionary used to store the previous transformation matrices of each rendered mesh
  65376. * in order to compute objects velocities when enableVelocity is set to "true"
  65377. * @hidden
  65378. */
  65379. _previousTransformationMatrices: {
  65380. [index: number]: ISavedTransformationMatrix;
  65381. };
  65382. /**
  65383. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  65384. * in order to compute objects velocities when enableVelocity is set to "true"
  65385. * @hidden
  65386. */
  65387. _previousBonesTransformationMatrices: {
  65388. [index: number]: Float32Array;
  65389. };
  65390. /**
  65391. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  65392. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  65393. */
  65394. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  65395. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  65396. renderTransparentMeshes: boolean;
  65397. private _scene;
  65398. private _multiRenderTarget;
  65399. private _ratio;
  65400. private _enablePosition;
  65401. private _enableVelocity;
  65402. private _enableReflectivity;
  65403. private _positionIndex;
  65404. private _velocityIndex;
  65405. private _reflectivityIndex;
  65406. protected _effect: Effect;
  65407. protected _cachedDefines: string;
  65408. /**
  65409. * Set the render list (meshes to be rendered) used in the G buffer.
  65410. */
  65411. set renderList(meshes: Mesh[]);
  65412. /**
  65413. * Gets wether or not G buffer are supported by the running hardware.
  65414. * This requires draw buffer supports
  65415. */
  65416. get isSupported(): boolean;
  65417. /**
  65418. * Returns the index of the given texture type in the G-Buffer textures array
  65419. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  65420. * @returns the index of the given texture type in the G-Buffer textures array
  65421. */
  65422. getTextureIndex(textureType: number): number;
  65423. /**
  65424. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  65425. */
  65426. get enablePosition(): boolean;
  65427. /**
  65428. * Sets whether or not objects positions are enabled for the G buffer.
  65429. */
  65430. set enablePosition(enable: boolean);
  65431. /**
  65432. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  65433. */
  65434. get enableVelocity(): boolean;
  65435. /**
  65436. * Sets wether or not objects velocities are enabled for the G buffer.
  65437. */
  65438. set enableVelocity(enable: boolean);
  65439. /**
  65440. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  65441. */
  65442. get enableReflectivity(): boolean;
  65443. /**
  65444. * Sets wether or not objects roughness are enabled for the G buffer.
  65445. */
  65446. set enableReflectivity(enable: boolean);
  65447. /**
  65448. * Gets the scene associated with the buffer.
  65449. */
  65450. get scene(): Scene;
  65451. /**
  65452. * Gets the ratio used by the buffer during its creation.
  65453. * How big is the buffer related to the main canvas.
  65454. */
  65455. get ratio(): number;
  65456. /** @hidden */
  65457. static _SceneComponentInitialization: (scene: Scene) => void;
  65458. /**
  65459. * Creates a new G Buffer for the scene
  65460. * @param scene The scene the buffer belongs to
  65461. * @param ratio How big is the buffer related to the main canvas.
  65462. */
  65463. constructor(scene: Scene, ratio?: number);
  65464. /**
  65465. * Checks wether everything is ready to render a submesh to the G buffer.
  65466. * @param subMesh the submesh to check readiness for
  65467. * @param useInstances is the mesh drawn using instance or not
  65468. * @returns true if ready otherwise false
  65469. */
  65470. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65471. /**
  65472. * Gets the current underlying G Buffer.
  65473. * @returns the buffer
  65474. */
  65475. getGBuffer(): MultiRenderTarget;
  65476. /**
  65477. * Gets the number of samples used to render the buffer (anti aliasing).
  65478. */
  65479. get samples(): number;
  65480. /**
  65481. * Sets the number of samples used to render the buffer (anti aliasing).
  65482. */
  65483. set samples(value: number);
  65484. /**
  65485. * Disposes the renderer and frees up associated resources.
  65486. */
  65487. dispose(): void;
  65488. protected _createRenderTargets(): void;
  65489. private _copyBonesTransformationMatrices;
  65490. }
  65491. }
  65492. declare module BABYLON {
  65493. interface Scene {
  65494. /** @hidden (Backing field) */
  65495. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65496. /**
  65497. * Gets or Sets the current geometry buffer associated to the scene.
  65498. */
  65499. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65500. /**
  65501. * Enables a GeometryBufferRender and associates it with the scene
  65502. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  65503. * @returns the GeometryBufferRenderer
  65504. */
  65505. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  65506. /**
  65507. * Disables the GeometryBufferRender associated with the scene
  65508. */
  65509. disableGeometryBufferRenderer(): void;
  65510. }
  65511. /**
  65512. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  65513. * in several rendering techniques.
  65514. */
  65515. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  65516. /**
  65517. * The component name helpful to identify the component in the list of scene components.
  65518. */
  65519. readonly name: string;
  65520. /**
  65521. * The scene the component belongs to.
  65522. */
  65523. scene: Scene;
  65524. /**
  65525. * Creates a new instance of the component for the given scene
  65526. * @param scene Defines the scene to register the component in
  65527. */
  65528. constructor(scene: Scene);
  65529. /**
  65530. * Registers the component in a given scene
  65531. */
  65532. register(): void;
  65533. /**
  65534. * Rebuilds the elements related to this component in case of
  65535. * context lost for instance.
  65536. */
  65537. rebuild(): void;
  65538. /**
  65539. * Disposes the component and the associated ressources
  65540. */
  65541. dispose(): void;
  65542. private _gatherRenderTargets;
  65543. }
  65544. }
  65545. declare module BABYLON {
  65546. /** @hidden */
  65547. export var motionBlurPixelShader: {
  65548. name: string;
  65549. shader: string;
  65550. };
  65551. }
  65552. declare module BABYLON {
  65553. /**
  65554. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  65555. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  65556. * As an example, all you have to do is to create the post-process:
  65557. * var mb = new BABYLON.MotionBlurPostProcess(
  65558. * 'mb', // The name of the effect.
  65559. * scene, // The scene containing the objects to blur according to their velocity.
  65560. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  65561. * camera // The camera to apply the render pass to.
  65562. * );
  65563. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  65564. */
  65565. export class MotionBlurPostProcess extends PostProcess {
  65566. /**
  65567. * Defines how much the image is blurred by the movement. Default value is equal to 1
  65568. */
  65569. motionStrength: number;
  65570. /**
  65571. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65572. */
  65573. get motionBlurSamples(): number;
  65574. /**
  65575. * Sets the number of iterations to be used for motion blur quality
  65576. */
  65577. set motionBlurSamples(samples: number);
  65578. private _motionBlurSamples;
  65579. private _geometryBufferRenderer;
  65580. /**
  65581. * Creates a new instance MotionBlurPostProcess
  65582. * @param name The name of the effect.
  65583. * @param scene The scene containing the objects to blur according to their velocity.
  65584. * @param options The required width/height ratio to downsize to before computing the render pass.
  65585. * @param camera The camera to apply the render pass to.
  65586. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65587. * @param engine The engine which the post process will be applied. (default: current engine)
  65588. * @param reusable If the post process can be reused on the same frame. (default: false)
  65589. * @param textureType Type of textures used when performing the post process. (default: 0)
  65590. * @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)
  65591. */
  65592. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65593. /**
  65594. * Excludes the given skinned mesh from computing bones velocities.
  65595. * 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.
  65596. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65597. */
  65598. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65599. /**
  65600. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65601. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65602. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65603. */
  65604. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65605. /**
  65606. * Disposes the post process.
  65607. * @param camera The camera to dispose the post process on.
  65608. */
  65609. dispose(camera?: Camera): void;
  65610. }
  65611. }
  65612. declare module BABYLON {
  65613. /** @hidden */
  65614. export var refractionPixelShader: {
  65615. name: string;
  65616. shader: string;
  65617. };
  65618. }
  65619. declare module BABYLON {
  65620. /**
  65621. * Post process which applies a refractin texture
  65622. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65623. */
  65624. export class RefractionPostProcess extends PostProcess {
  65625. /** the base color of the refraction (used to taint the rendering) */
  65626. color: Color3;
  65627. /** simulated refraction depth */
  65628. depth: number;
  65629. /** the coefficient of the base color (0 to remove base color tainting) */
  65630. colorLevel: number;
  65631. private _refTexture;
  65632. private _ownRefractionTexture;
  65633. /**
  65634. * Gets or sets the refraction texture
  65635. * Please note that you are responsible for disposing the texture if you set it manually
  65636. */
  65637. get refractionTexture(): Texture;
  65638. set refractionTexture(value: Texture);
  65639. /**
  65640. * Initializes the RefractionPostProcess
  65641. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65642. * @param name The name of the effect.
  65643. * @param refractionTextureUrl Url of the refraction texture to use
  65644. * @param color the base color of the refraction (used to taint the rendering)
  65645. * @param depth simulated refraction depth
  65646. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65647. * @param camera The camera to apply the render pass to.
  65648. * @param options The required width/height ratio to downsize to before computing the render pass.
  65649. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65650. * @param engine The engine which the post process will be applied. (default: current engine)
  65651. * @param reusable If the post process can be reused on the same frame. (default: false)
  65652. */
  65653. constructor(name: string, refractionTextureUrl: string,
  65654. /** the base color of the refraction (used to taint the rendering) */
  65655. color: Color3,
  65656. /** simulated refraction depth */
  65657. depth: number,
  65658. /** the coefficient of the base color (0 to remove base color tainting) */
  65659. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65660. /**
  65661. * Disposes of the post process
  65662. * @param camera Camera to dispose post process on
  65663. */
  65664. dispose(camera: Camera): void;
  65665. }
  65666. }
  65667. declare module BABYLON {
  65668. /** @hidden */
  65669. export var sharpenPixelShader: {
  65670. name: string;
  65671. shader: string;
  65672. };
  65673. }
  65674. declare module BABYLON {
  65675. /**
  65676. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65677. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65678. */
  65679. export class SharpenPostProcess extends PostProcess {
  65680. /**
  65681. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65682. */
  65683. colorAmount: number;
  65684. /**
  65685. * How much sharpness should be applied (default: 0.3)
  65686. */
  65687. edgeAmount: number;
  65688. /**
  65689. * Creates a new instance ConvolutionPostProcess
  65690. * @param name The name of the effect.
  65691. * @param options The required width/height ratio to downsize to before computing the render pass.
  65692. * @param camera The camera to apply the render pass to.
  65693. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65694. * @param engine The engine which the post process will be applied. (default: current engine)
  65695. * @param reusable If the post process can be reused on the same frame. (default: false)
  65696. * @param textureType Type of textures used when performing the post process. (default: 0)
  65697. * @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)
  65698. */
  65699. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65700. }
  65701. }
  65702. declare module BABYLON {
  65703. /**
  65704. * PostProcessRenderPipeline
  65705. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65706. */
  65707. export class PostProcessRenderPipeline {
  65708. private engine;
  65709. private _renderEffects;
  65710. private _renderEffectsForIsolatedPass;
  65711. /**
  65712. * List of inspectable custom properties (used by the Inspector)
  65713. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65714. */
  65715. inspectableCustomProperties: IInspectable[];
  65716. /**
  65717. * @hidden
  65718. */
  65719. protected _cameras: Camera[];
  65720. /** @hidden */
  65721. _name: string;
  65722. /**
  65723. * Gets pipeline name
  65724. */
  65725. get name(): string;
  65726. /** Gets the list of attached cameras */
  65727. get cameras(): Camera[];
  65728. /**
  65729. * Initializes a PostProcessRenderPipeline
  65730. * @param engine engine to add the pipeline to
  65731. * @param name name of the pipeline
  65732. */
  65733. constructor(engine: Engine, name: string);
  65734. /**
  65735. * Gets the class name
  65736. * @returns "PostProcessRenderPipeline"
  65737. */
  65738. getClassName(): string;
  65739. /**
  65740. * If all the render effects in the pipeline are supported
  65741. */
  65742. get isSupported(): boolean;
  65743. /**
  65744. * Adds an effect to the pipeline
  65745. * @param renderEffect the effect to add
  65746. */
  65747. addEffect(renderEffect: PostProcessRenderEffect): void;
  65748. /** @hidden */
  65749. _rebuild(): void;
  65750. /** @hidden */
  65751. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65752. /** @hidden */
  65753. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65754. /** @hidden */
  65755. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65756. /** @hidden */
  65757. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65758. /** @hidden */
  65759. _attachCameras(cameras: Camera, unique: boolean): void;
  65760. /** @hidden */
  65761. _attachCameras(cameras: Camera[], unique: boolean): void;
  65762. /** @hidden */
  65763. _detachCameras(cameras: Camera): void;
  65764. /** @hidden */
  65765. _detachCameras(cameras: Nullable<Camera[]>): void;
  65766. /** @hidden */
  65767. _update(): void;
  65768. /** @hidden */
  65769. _reset(): void;
  65770. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65771. /**
  65772. * Disposes of the pipeline
  65773. */
  65774. dispose(): void;
  65775. }
  65776. }
  65777. declare module BABYLON {
  65778. /**
  65779. * PostProcessRenderPipelineManager class
  65780. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65781. */
  65782. export class PostProcessRenderPipelineManager {
  65783. private _renderPipelines;
  65784. /**
  65785. * Initializes a PostProcessRenderPipelineManager
  65786. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65787. */
  65788. constructor();
  65789. /**
  65790. * Gets the list of supported render pipelines
  65791. */
  65792. get supportedPipelines(): PostProcessRenderPipeline[];
  65793. /**
  65794. * Adds a pipeline to the manager
  65795. * @param renderPipeline The pipeline to add
  65796. */
  65797. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65798. /**
  65799. * Attaches a camera to the pipeline
  65800. * @param renderPipelineName The name of the pipeline to attach to
  65801. * @param cameras the camera to attach
  65802. * @param unique if the camera can be attached multiple times to the pipeline
  65803. */
  65804. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65805. /**
  65806. * Detaches a camera from the pipeline
  65807. * @param renderPipelineName The name of the pipeline to detach from
  65808. * @param cameras the camera to detach
  65809. */
  65810. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65811. /**
  65812. * Enables an effect by name on a pipeline
  65813. * @param renderPipelineName the name of the pipeline to enable the effect in
  65814. * @param renderEffectName the name of the effect to enable
  65815. * @param cameras the cameras that the effect should be enabled on
  65816. */
  65817. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65818. /**
  65819. * Disables an effect by name on a pipeline
  65820. * @param renderPipelineName the name of the pipeline to disable the effect in
  65821. * @param renderEffectName the name of the effect to disable
  65822. * @param cameras the cameras that the effect should be disabled on
  65823. */
  65824. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65825. /**
  65826. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65827. */
  65828. update(): void;
  65829. /** @hidden */
  65830. _rebuild(): void;
  65831. /**
  65832. * Disposes of the manager and pipelines
  65833. */
  65834. dispose(): void;
  65835. }
  65836. }
  65837. declare module BABYLON {
  65838. interface Scene {
  65839. /** @hidden (Backing field) */
  65840. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65841. /**
  65842. * Gets the postprocess render pipeline manager
  65843. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65844. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65845. */
  65846. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65847. }
  65848. /**
  65849. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65850. */
  65851. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65852. /**
  65853. * The component name helpfull to identify the component in the list of scene components.
  65854. */
  65855. readonly name: string;
  65856. /**
  65857. * The scene the component belongs to.
  65858. */
  65859. scene: Scene;
  65860. /**
  65861. * Creates a new instance of the component for the given scene
  65862. * @param scene Defines the scene to register the component in
  65863. */
  65864. constructor(scene: Scene);
  65865. /**
  65866. * Registers the component in a given scene
  65867. */
  65868. register(): void;
  65869. /**
  65870. * Rebuilds the elements related to this component in case of
  65871. * context lost for instance.
  65872. */
  65873. rebuild(): void;
  65874. /**
  65875. * Disposes the component and the associated ressources
  65876. */
  65877. dispose(): void;
  65878. private _gatherRenderTargets;
  65879. }
  65880. }
  65881. declare module BABYLON {
  65882. /**
  65883. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65884. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65885. */
  65886. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65887. private _scene;
  65888. private _camerasToBeAttached;
  65889. /**
  65890. * ID of the sharpen post process,
  65891. */
  65892. private readonly SharpenPostProcessId;
  65893. /**
  65894. * @ignore
  65895. * ID of the image processing post process;
  65896. */
  65897. readonly ImageProcessingPostProcessId: string;
  65898. /**
  65899. * @ignore
  65900. * ID of the Fast Approximate Anti-Aliasing post process;
  65901. */
  65902. readonly FxaaPostProcessId: string;
  65903. /**
  65904. * ID of the chromatic aberration post process,
  65905. */
  65906. private readonly ChromaticAberrationPostProcessId;
  65907. /**
  65908. * ID of the grain post process
  65909. */
  65910. private readonly GrainPostProcessId;
  65911. /**
  65912. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65913. */
  65914. sharpen: SharpenPostProcess;
  65915. private _sharpenEffect;
  65916. private bloom;
  65917. /**
  65918. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65919. */
  65920. depthOfField: DepthOfFieldEffect;
  65921. /**
  65922. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65923. */
  65924. fxaa: FxaaPostProcess;
  65925. /**
  65926. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65927. */
  65928. imageProcessing: ImageProcessingPostProcess;
  65929. /**
  65930. * Chromatic aberration post process which will shift rgb colors in the image
  65931. */
  65932. chromaticAberration: ChromaticAberrationPostProcess;
  65933. private _chromaticAberrationEffect;
  65934. /**
  65935. * Grain post process which add noise to the image
  65936. */
  65937. grain: GrainPostProcess;
  65938. private _grainEffect;
  65939. /**
  65940. * Glow post process which adds a glow to emissive areas of the image
  65941. */
  65942. private _glowLayer;
  65943. /**
  65944. * Animations which can be used to tweak settings over a period of time
  65945. */
  65946. animations: Animation[];
  65947. private _imageProcessingConfigurationObserver;
  65948. private _sharpenEnabled;
  65949. private _bloomEnabled;
  65950. private _depthOfFieldEnabled;
  65951. private _depthOfFieldBlurLevel;
  65952. private _fxaaEnabled;
  65953. private _imageProcessingEnabled;
  65954. private _defaultPipelineTextureType;
  65955. private _bloomScale;
  65956. private _chromaticAberrationEnabled;
  65957. private _grainEnabled;
  65958. private _buildAllowed;
  65959. /**
  65960. * Gets active scene
  65961. */
  65962. get scene(): Scene;
  65963. /**
  65964. * Enable or disable the sharpen process from the pipeline
  65965. */
  65966. set sharpenEnabled(enabled: boolean);
  65967. get sharpenEnabled(): boolean;
  65968. private _resizeObserver;
  65969. private _hardwareScaleLevel;
  65970. private _bloomKernel;
  65971. /**
  65972. * Specifies the size of the bloom blur kernel, relative to the final output size
  65973. */
  65974. get bloomKernel(): number;
  65975. set bloomKernel(value: number);
  65976. /**
  65977. * Specifies the weight of the bloom in the final rendering
  65978. */
  65979. private _bloomWeight;
  65980. /**
  65981. * Specifies the luma threshold for the area that will be blurred by the bloom
  65982. */
  65983. private _bloomThreshold;
  65984. private _hdr;
  65985. /**
  65986. * The strength of the bloom.
  65987. */
  65988. set bloomWeight(value: number);
  65989. get bloomWeight(): number;
  65990. /**
  65991. * The strength of the bloom.
  65992. */
  65993. set bloomThreshold(value: number);
  65994. get bloomThreshold(): number;
  65995. /**
  65996. * The scale of the bloom, lower value will provide better performance.
  65997. */
  65998. set bloomScale(value: number);
  65999. get bloomScale(): number;
  66000. /**
  66001. * Enable or disable the bloom from the pipeline
  66002. */
  66003. set bloomEnabled(enabled: boolean);
  66004. get bloomEnabled(): boolean;
  66005. private _rebuildBloom;
  66006. /**
  66007. * If the depth of field is enabled.
  66008. */
  66009. get depthOfFieldEnabled(): boolean;
  66010. set depthOfFieldEnabled(enabled: boolean);
  66011. /**
  66012. * Blur level of the depth of field effect. (Higher blur will effect performance)
  66013. */
  66014. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  66015. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  66016. /**
  66017. * If the anti aliasing is enabled.
  66018. */
  66019. set fxaaEnabled(enabled: boolean);
  66020. get fxaaEnabled(): boolean;
  66021. private _samples;
  66022. /**
  66023. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66024. */
  66025. set samples(sampleCount: number);
  66026. get samples(): number;
  66027. /**
  66028. * If image processing is enabled.
  66029. */
  66030. set imageProcessingEnabled(enabled: boolean);
  66031. get imageProcessingEnabled(): boolean;
  66032. /**
  66033. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  66034. */
  66035. set glowLayerEnabled(enabled: boolean);
  66036. get glowLayerEnabled(): boolean;
  66037. /**
  66038. * Gets the glow layer (or null if not defined)
  66039. */
  66040. get glowLayer(): Nullable<GlowLayer>;
  66041. /**
  66042. * Enable or disable the chromaticAberration process from the pipeline
  66043. */
  66044. set chromaticAberrationEnabled(enabled: boolean);
  66045. get chromaticAberrationEnabled(): boolean;
  66046. /**
  66047. * Enable or disable the grain process from the pipeline
  66048. */
  66049. set grainEnabled(enabled: boolean);
  66050. get grainEnabled(): boolean;
  66051. /**
  66052. * @constructor
  66053. * @param name - The rendering pipeline name (default: "")
  66054. * @param hdr - If high dynamic range textures should be used (default: true)
  66055. * @param scene - The scene linked to this pipeline (default: the last created scene)
  66056. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  66057. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  66058. */
  66059. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  66060. /**
  66061. * Get the class name
  66062. * @returns "DefaultRenderingPipeline"
  66063. */
  66064. getClassName(): string;
  66065. /**
  66066. * Force the compilation of the entire pipeline.
  66067. */
  66068. prepare(): void;
  66069. private _hasCleared;
  66070. private _prevPostProcess;
  66071. private _prevPrevPostProcess;
  66072. private _setAutoClearAndTextureSharing;
  66073. private _depthOfFieldSceneObserver;
  66074. private _buildPipeline;
  66075. private _disposePostProcesses;
  66076. /**
  66077. * Adds a camera to the pipeline
  66078. * @param camera the camera to be added
  66079. */
  66080. addCamera(camera: Camera): void;
  66081. /**
  66082. * Removes a camera from the pipeline
  66083. * @param camera the camera to remove
  66084. */
  66085. removeCamera(camera: Camera): void;
  66086. /**
  66087. * Dispose of the pipeline and stop all post processes
  66088. */
  66089. dispose(): void;
  66090. /**
  66091. * Serialize the rendering pipeline (Used when exporting)
  66092. * @returns the serialized object
  66093. */
  66094. serialize(): any;
  66095. /**
  66096. * Parse the serialized pipeline
  66097. * @param source Source pipeline.
  66098. * @param scene The scene to load the pipeline to.
  66099. * @param rootUrl The URL of the serialized pipeline.
  66100. * @returns An instantiated pipeline from the serialized object.
  66101. */
  66102. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  66103. }
  66104. }
  66105. declare module BABYLON {
  66106. /** @hidden */
  66107. export var lensHighlightsPixelShader: {
  66108. name: string;
  66109. shader: string;
  66110. };
  66111. }
  66112. declare module BABYLON {
  66113. /** @hidden */
  66114. export var depthOfFieldPixelShader: {
  66115. name: string;
  66116. shader: string;
  66117. };
  66118. }
  66119. declare module BABYLON {
  66120. /**
  66121. * BABYLON.JS Chromatic Aberration GLSL Shader
  66122. * Author: Olivier Guyot
  66123. * Separates very slightly R, G and B colors on the edges of the screen
  66124. * Inspired by Francois Tarlier & Martins Upitis
  66125. */
  66126. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  66127. /**
  66128. * @ignore
  66129. * The chromatic aberration PostProcess id in the pipeline
  66130. */
  66131. LensChromaticAberrationEffect: string;
  66132. /**
  66133. * @ignore
  66134. * The highlights enhancing PostProcess id in the pipeline
  66135. */
  66136. HighlightsEnhancingEffect: string;
  66137. /**
  66138. * @ignore
  66139. * The depth-of-field PostProcess id in the pipeline
  66140. */
  66141. LensDepthOfFieldEffect: string;
  66142. private _scene;
  66143. private _depthTexture;
  66144. private _grainTexture;
  66145. private _chromaticAberrationPostProcess;
  66146. private _highlightsPostProcess;
  66147. private _depthOfFieldPostProcess;
  66148. private _edgeBlur;
  66149. private _grainAmount;
  66150. private _chromaticAberration;
  66151. private _distortion;
  66152. private _highlightsGain;
  66153. private _highlightsThreshold;
  66154. private _dofDistance;
  66155. private _dofAperture;
  66156. private _dofDarken;
  66157. private _dofPentagon;
  66158. private _blurNoise;
  66159. /**
  66160. * @constructor
  66161. *
  66162. * Effect parameters are as follow:
  66163. * {
  66164. * chromatic_aberration: number; // from 0 to x (1 for realism)
  66165. * edge_blur: number; // from 0 to x (1 for realism)
  66166. * distortion: number; // from 0 to x (1 for realism)
  66167. * grain_amount: number; // from 0 to 1
  66168. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  66169. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  66170. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  66171. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  66172. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  66173. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  66174. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  66175. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  66176. * }
  66177. * Note: if an effect parameter is unset, effect is disabled
  66178. *
  66179. * @param name The rendering pipeline name
  66180. * @param parameters - An object containing all parameters (see above)
  66181. * @param scene The scene linked to this pipeline
  66182. * @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)
  66183. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66184. */
  66185. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  66186. /**
  66187. * Get the class name
  66188. * @returns "LensRenderingPipeline"
  66189. */
  66190. getClassName(): string;
  66191. /**
  66192. * Gets associated scene
  66193. */
  66194. get scene(): Scene;
  66195. /**
  66196. * Gets or sets the edge blur
  66197. */
  66198. get edgeBlur(): number;
  66199. set edgeBlur(value: number);
  66200. /**
  66201. * Gets or sets the grain amount
  66202. */
  66203. get grainAmount(): number;
  66204. set grainAmount(value: number);
  66205. /**
  66206. * Gets or sets the chromatic aberration amount
  66207. */
  66208. get chromaticAberration(): number;
  66209. set chromaticAberration(value: number);
  66210. /**
  66211. * Gets or sets the depth of field aperture
  66212. */
  66213. get dofAperture(): number;
  66214. set dofAperture(value: number);
  66215. /**
  66216. * Gets or sets the edge distortion
  66217. */
  66218. get edgeDistortion(): number;
  66219. set edgeDistortion(value: number);
  66220. /**
  66221. * Gets or sets the depth of field distortion
  66222. */
  66223. get dofDistortion(): number;
  66224. set dofDistortion(value: number);
  66225. /**
  66226. * Gets or sets the darken out of focus amount
  66227. */
  66228. get darkenOutOfFocus(): number;
  66229. set darkenOutOfFocus(value: number);
  66230. /**
  66231. * Gets or sets a boolean indicating if blur noise is enabled
  66232. */
  66233. get blurNoise(): boolean;
  66234. set blurNoise(value: boolean);
  66235. /**
  66236. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  66237. */
  66238. get pentagonBokeh(): boolean;
  66239. set pentagonBokeh(value: boolean);
  66240. /**
  66241. * Gets or sets the highlight grain amount
  66242. */
  66243. get highlightsGain(): number;
  66244. set highlightsGain(value: number);
  66245. /**
  66246. * Gets or sets the highlight threshold
  66247. */
  66248. get highlightsThreshold(): number;
  66249. set highlightsThreshold(value: number);
  66250. /**
  66251. * Sets the amount of blur at the edges
  66252. * @param amount blur amount
  66253. */
  66254. setEdgeBlur(amount: number): void;
  66255. /**
  66256. * Sets edge blur to 0
  66257. */
  66258. disableEdgeBlur(): void;
  66259. /**
  66260. * Sets the amout of grain
  66261. * @param amount Amount of grain
  66262. */
  66263. setGrainAmount(amount: number): void;
  66264. /**
  66265. * Set grain amount to 0
  66266. */
  66267. disableGrain(): void;
  66268. /**
  66269. * Sets the chromatic aberration amount
  66270. * @param amount amount of chromatic aberration
  66271. */
  66272. setChromaticAberration(amount: number): void;
  66273. /**
  66274. * Sets chromatic aberration amount to 0
  66275. */
  66276. disableChromaticAberration(): void;
  66277. /**
  66278. * Sets the EdgeDistortion amount
  66279. * @param amount amount of EdgeDistortion
  66280. */
  66281. setEdgeDistortion(amount: number): void;
  66282. /**
  66283. * Sets edge distortion to 0
  66284. */
  66285. disableEdgeDistortion(): void;
  66286. /**
  66287. * Sets the FocusDistance amount
  66288. * @param amount amount of FocusDistance
  66289. */
  66290. setFocusDistance(amount: number): void;
  66291. /**
  66292. * Disables depth of field
  66293. */
  66294. disableDepthOfField(): void;
  66295. /**
  66296. * Sets the Aperture amount
  66297. * @param amount amount of Aperture
  66298. */
  66299. setAperture(amount: number): void;
  66300. /**
  66301. * Sets the DarkenOutOfFocus amount
  66302. * @param amount amount of DarkenOutOfFocus
  66303. */
  66304. setDarkenOutOfFocus(amount: number): void;
  66305. private _pentagonBokehIsEnabled;
  66306. /**
  66307. * Creates a pentagon bokeh effect
  66308. */
  66309. enablePentagonBokeh(): void;
  66310. /**
  66311. * Disables the pentagon bokeh effect
  66312. */
  66313. disablePentagonBokeh(): void;
  66314. /**
  66315. * Enables noise blur
  66316. */
  66317. enableNoiseBlur(): void;
  66318. /**
  66319. * Disables noise blur
  66320. */
  66321. disableNoiseBlur(): void;
  66322. /**
  66323. * Sets the HighlightsGain amount
  66324. * @param amount amount of HighlightsGain
  66325. */
  66326. setHighlightsGain(amount: number): void;
  66327. /**
  66328. * Sets the HighlightsThreshold amount
  66329. * @param amount amount of HighlightsThreshold
  66330. */
  66331. setHighlightsThreshold(amount: number): void;
  66332. /**
  66333. * Disables highlights
  66334. */
  66335. disableHighlights(): void;
  66336. /**
  66337. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  66338. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  66339. */
  66340. dispose(disableDepthRender?: boolean): void;
  66341. private _createChromaticAberrationPostProcess;
  66342. private _createHighlightsPostProcess;
  66343. private _createDepthOfFieldPostProcess;
  66344. private _createGrainTexture;
  66345. }
  66346. }
  66347. declare module BABYLON {
  66348. /** @hidden */
  66349. export var ssao2PixelShader: {
  66350. name: string;
  66351. shader: string;
  66352. };
  66353. }
  66354. declare module BABYLON {
  66355. /** @hidden */
  66356. export var ssaoCombinePixelShader: {
  66357. name: string;
  66358. shader: string;
  66359. };
  66360. }
  66361. declare module BABYLON {
  66362. /**
  66363. * Render pipeline to produce ssao effect
  66364. */
  66365. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  66366. /**
  66367. * @ignore
  66368. * The PassPostProcess id in the pipeline that contains the original scene color
  66369. */
  66370. SSAOOriginalSceneColorEffect: string;
  66371. /**
  66372. * @ignore
  66373. * The SSAO PostProcess id in the pipeline
  66374. */
  66375. SSAORenderEffect: string;
  66376. /**
  66377. * @ignore
  66378. * The horizontal blur PostProcess id in the pipeline
  66379. */
  66380. SSAOBlurHRenderEffect: string;
  66381. /**
  66382. * @ignore
  66383. * The vertical blur PostProcess id in the pipeline
  66384. */
  66385. SSAOBlurVRenderEffect: string;
  66386. /**
  66387. * @ignore
  66388. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66389. */
  66390. SSAOCombineRenderEffect: string;
  66391. /**
  66392. * The output strength of the SSAO post-process. Default value is 1.0.
  66393. */
  66394. totalStrength: number;
  66395. /**
  66396. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  66397. */
  66398. maxZ: number;
  66399. /**
  66400. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  66401. */
  66402. minZAspect: number;
  66403. private _samples;
  66404. /**
  66405. * Number of samples used for the SSAO calculations. Default value is 8
  66406. */
  66407. set samples(n: number);
  66408. get samples(): number;
  66409. private _textureSamples;
  66410. /**
  66411. * Number of samples to use for antialiasing
  66412. */
  66413. set textureSamples(n: number);
  66414. get textureSamples(): number;
  66415. /**
  66416. * Ratio object used for SSAO ratio and blur ratio
  66417. */
  66418. private _ratio;
  66419. /**
  66420. * Dynamically generated sphere sampler.
  66421. */
  66422. private _sampleSphere;
  66423. /**
  66424. * Blur filter offsets
  66425. */
  66426. private _samplerOffsets;
  66427. private _expensiveBlur;
  66428. /**
  66429. * If bilateral blur should be used
  66430. */
  66431. set expensiveBlur(b: boolean);
  66432. get expensiveBlur(): boolean;
  66433. /**
  66434. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  66435. */
  66436. radius: number;
  66437. /**
  66438. * The base color of the SSAO post-process
  66439. * The final result is "base + ssao" between [0, 1]
  66440. */
  66441. base: number;
  66442. /**
  66443. * Support test.
  66444. */
  66445. static get IsSupported(): boolean;
  66446. private _scene;
  66447. private _depthTexture;
  66448. private _normalTexture;
  66449. private _randomTexture;
  66450. private _originalColorPostProcess;
  66451. private _ssaoPostProcess;
  66452. private _blurHPostProcess;
  66453. private _blurVPostProcess;
  66454. private _ssaoCombinePostProcess;
  66455. /**
  66456. * Gets active scene
  66457. */
  66458. get scene(): Scene;
  66459. /**
  66460. * @constructor
  66461. * @param name The rendering pipeline name
  66462. * @param scene The scene linked to this pipeline
  66463. * @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 }
  66464. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66465. */
  66466. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66467. /**
  66468. * Get the class name
  66469. * @returns "SSAO2RenderingPipeline"
  66470. */
  66471. getClassName(): string;
  66472. /**
  66473. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66474. */
  66475. dispose(disableGeometryBufferRenderer?: boolean): void;
  66476. private _createBlurPostProcess;
  66477. /** @hidden */
  66478. _rebuild(): void;
  66479. private _bits;
  66480. private _radicalInverse_VdC;
  66481. private _hammersley;
  66482. private _hemisphereSample_uniform;
  66483. private _generateHemisphere;
  66484. private _createSSAOPostProcess;
  66485. private _createSSAOCombinePostProcess;
  66486. private _createRandomTexture;
  66487. /**
  66488. * Serialize the rendering pipeline (Used when exporting)
  66489. * @returns the serialized object
  66490. */
  66491. serialize(): any;
  66492. /**
  66493. * Parse the serialized pipeline
  66494. * @param source Source pipeline.
  66495. * @param scene The scene to load the pipeline to.
  66496. * @param rootUrl The URL of the serialized pipeline.
  66497. * @returns An instantiated pipeline from the serialized object.
  66498. */
  66499. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  66500. }
  66501. }
  66502. declare module BABYLON {
  66503. /** @hidden */
  66504. export var ssaoPixelShader: {
  66505. name: string;
  66506. shader: string;
  66507. };
  66508. }
  66509. declare module BABYLON {
  66510. /**
  66511. * Render pipeline to produce ssao effect
  66512. */
  66513. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  66514. /**
  66515. * @ignore
  66516. * The PassPostProcess id in the pipeline that contains the original scene color
  66517. */
  66518. SSAOOriginalSceneColorEffect: string;
  66519. /**
  66520. * @ignore
  66521. * The SSAO PostProcess id in the pipeline
  66522. */
  66523. SSAORenderEffect: string;
  66524. /**
  66525. * @ignore
  66526. * The horizontal blur PostProcess id in the pipeline
  66527. */
  66528. SSAOBlurHRenderEffect: string;
  66529. /**
  66530. * @ignore
  66531. * The vertical blur PostProcess id in the pipeline
  66532. */
  66533. SSAOBlurVRenderEffect: string;
  66534. /**
  66535. * @ignore
  66536. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66537. */
  66538. SSAOCombineRenderEffect: string;
  66539. /**
  66540. * The output strength of the SSAO post-process. Default value is 1.0.
  66541. */
  66542. totalStrength: number;
  66543. /**
  66544. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66545. */
  66546. radius: number;
  66547. /**
  66548. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66549. * Must not be equal to fallOff and superior to fallOff.
  66550. * Default value is 0.0075
  66551. */
  66552. area: number;
  66553. /**
  66554. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66555. * Must not be equal to area and inferior to area.
  66556. * Default value is 0.000001
  66557. */
  66558. fallOff: number;
  66559. /**
  66560. * The base color of the SSAO post-process
  66561. * The final result is "base + ssao" between [0, 1]
  66562. */
  66563. base: number;
  66564. private _scene;
  66565. private _depthTexture;
  66566. private _randomTexture;
  66567. private _originalColorPostProcess;
  66568. private _ssaoPostProcess;
  66569. private _blurHPostProcess;
  66570. private _blurVPostProcess;
  66571. private _ssaoCombinePostProcess;
  66572. private _firstUpdate;
  66573. /**
  66574. * Gets active scene
  66575. */
  66576. get scene(): Scene;
  66577. /**
  66578. * @constructor
  66579. * @param name - The rendering pipeline name
  66580. * @param scene - The scene linked to this pipeline
  66581. * @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 }
  66582. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66583. */
  66584. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66585. /**
  66586. * Get the class name
  66587. * @returns "SSAORenderingPipeline"
  66588. */
  66589. getClassName(): string;
  66590. /**
  66591. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66592. */
  66593. dispose(disableDepthRender?: boolean): void;
  66594. private _createBlurPostProcess;
  66595. /** @hidden */
  66596. _rebuild(): void;
  66597. private _createSSAOPostProcess;
  66598. private _createSSAOCombinePostProcess;
  66599. private _createRandomTexture;
  66600. }
  66601. }
  66602. declare module BABYLON {
  66603. /** @hidden */
  66604. export var screenSpaceReflectionPixelShader: {
  66605. name: string;
  66606. shader: string;
  66607. };
  66608. }
  66609. declare module BABYLON {
  66610. /**
  66611. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  66612. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  66613. */
  66614. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  66615. /**
  66616. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  66617. */
  66618. threshold: number;
  66619. /**
  66620. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  66621. */
  66622. strength: number;
  66623. /**
  66624. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  66625. */
  66626. reflectionSpecularFalloffExponent: number;
  66627. /**
  66628. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  66629. */
  66630. step: number;
  66631. /**
  66632. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  66633. */
  66634. roughnessFactor: number;
  66635. private _geometryBufferRenderer;
  66636. private _enableSmoothReflections;
  66637. private _reflectionSamples;
  66638. private _smoothSteps;
  66639. /**
  66640. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  66641. * @param name The name of the effect.
  66642. * @param scene The scene containing the objects to calculate reflections.
  66643. * @param options The required width/height ratio to downsize to before computing the render pass.
  66644. * @param camera The camera to apply the render pass to.
  66645. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66646. * @param engine The engine which the post process will be applied. (default: current engine)
  66647. * @param reusable If the post process can be reused on the same frame. (default: false)
  66648. * @param textureType Type of textures used when performing the post process. (default: 0)
  66649. * @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)
  66650. */
  66651. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66652. /**
  66653. * Gets wether or not smoothing reflections is enabled.
  66654. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66655. */
  66656. get enableSmoothReflections(): boolean;
  66657. /**
  66658. * Sets wether or not smoothing reflections is enabled.
  66659. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66660. */
  66661. set enableSmoothReflections(enabled: boolean);
  66662. /**
  66663. * Gets the number of samples taken while computing reflections. More samples count is high,
  66664. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66665. */
  66666. get reflectionSamples(): number;
  66667. /**
  66668. * Sets the number of samples taken while computing reflections. More samples count is high,
  66669. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66670. */
  66671. set reflectionSamples(samples: number);
  66672. /**
  66673. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  66674. * more the post-process will require GPU power and can generate a drop in FPS.
  66675. * Default value (5.0) work pretty well in all cases but can be adjusted.
  66676. */
  66677. get smoothSteps(): number;
  66678. set smoothSteps(steps: number);
  66679. private _updateEffectDefines;
  66680. }
  66681. }
  66682. declare module BABYLON {
  66683. /** @hidden */
  66684. export var standardPixelShader: {
  66685. name: string;
  66686. shader: string;
  66687. };
  66688. }
  66689. declare module BABYLON {
  66690. /**
  66691. * Standard rendering pipeline
  66692. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66693. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66694. */
  66695. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66696. /**
  66697. * Public members
  66698. */
  66699. /**
  66700. * Post-process which contains the original scene color before the pipeline applies all the effects
  66701. */
  66702. originalPostProcess: Nullable<PostProcess>;
  66703. /**
  66704. * Post-process used to down scale an image x4
  66705. */
  66706. downSampleX4PostProcess: Nullable<PostProcess>;
  66707. /**
  66708. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66709. */
  66710. brightPassPostProcess: Nullable<PostProcess>;
  66711. /**
  66712. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66713. */
  66714. blurHPostProcesses: PostProcess[];
  66715. /**
  66716. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66717. */
  66718. blurVPostProcesses: PostProcess[];
  66719. /**
  66720. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66721. */
  66722. textureAdderPostProcess: Nullable<PostProcess>;
  66723. /**
  66724. * Post-process used to create volumetric lighting effect
  66725. */
  66726. volumetricLightPostProcess: Nullable<PostProcess>;
  66727. /**
  66728. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66729. */
  66730. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66731. /**
  66732. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66733. */
  66734. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66735. /**
  66736. * Post-process used to merge the volumetric light effect and the real scene color
  66737. */
  66738. volumetricLightMergePostProces: Nullable<PostProcess>;
  66739. /**
  66740. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66741. */
  66742. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66743. /**
  66744. * Base post-process used to calculate the average luminance of the final image for HDR
  66745. */
  66746. luminancePostProcess: Nullable<PostProcess>;
  66747. /**
  66748. * Post-processes used to create down sample post-processes in order to get
  66749. * the average luminance of the final image for HDR
  66750. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66751. */
  66752. luminanceDownSamplePostProcesses: PostProcess[];
  66753. /**
  66754. * Post-process used to create a HDR effect (light adaptation)
  66755. */
  66756. hdrPostProcess: Nullable<PostProcess>;
  66757. /**
  66758. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66759. */
  66760. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66761. /**
  66762. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66763. */
  66764. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66765. /**
  66766. * Post-process used to merge the final HDR post-process and the real scene color
  66767. */
  66768. hdrFinalPostProcess: Nullable<PostProcess>;
  66769. /**
  66770. * Post-process used to create a lens flare effect
  66771. */
  66772. lensFlarePostProcess: Nullable<PostProcess>;
  66773. /**
  66774. * Post-process that merges the result of the lens flare post-process and the real scene color
  66775. */
  66776. lensFlareComposePostProcess: Nullable<PostProcess>;
  66777. /**
  66778. * Post-process used to create a motion blur effect
  66779. */
  66780. motionBlurPostProcess: Nullable<PostProcess>;
  66781. /**
  66782. * Post-process used to create a depth of field effect
  66783. */
  66784. depthOfFieldPostProcess: Nullable<PostProcess>;
  66785. /**
  66786. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66787. */
  66788. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66789. /**
  66790. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66791. */
  66792. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66793. /**
  66794. * Represents the brightness threshold in order to configure the illuminated surfaces
  66795. */
  66796. brightThreshold: number;
  66797. /**
  66798. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66799. */
  66800. blurWidth: number;
  66801. /**
  66802. * Sets if the blur for highlighted surfaces must be only horizontal
  66803. */
  66804. horizontalBlur: boolean;
  66805. /**
  66806. * Gets the overall exposure used by the pipeline
  66807. */
  66808. get exposure(): number;
  66809. /**
  66810. * Sets the overall exposure used by the pipeline
  66811. */
  66812. set exposure(value: number);
  66813. /**
  66814. * Texture used typically to simulate "dirty" on camera lens
  66815. */
  66816. lensTexture: Nullable<Texture>;
  66817. /**
  66818. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66819. */
  66820. volumetricLightCoefficient: number;
  66821. /**
  66822. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66823. */
  66824. volumetricLightPower: number;
  66825. /**
  66826. * Used the set the blur intensity to smooth the volumetric lights
  66827. */
  66828. volumetricLightBlurScale: number;
  66829. /**
  66830. * Light (spot or directional) used to generate the volumetric lights rays
  66831. * The source light must have a shadow generate so the pipeline can get its
  66832. * depth map
  66833. */
  66834. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66835. /**
  66836. * For eye adaptation, represents the minimum luminance the eye can see
  66837. */
  66838. hdrMinimumLuminance: number;
  66839. /**
  66840. * For eye adaptation, represents the decrease luminance speed
  66841. */
  66842. hdrDecreaseRate: number;
  66843. /**
  66844. * For eye adaptation, represents the increase luminance speed
  66845. */
  66846. hdrIncreaseRate: number;
  66847. /**
  66848. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66849. */
  66850. get hdrAutoExposure(): boolean;
  66851. /**
  66852. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66853. */
  66854. set hdrAutoExposure(value: boolean);
  66855. /**
  66856. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66857. */
  66858. lensColorTexture: Nullable<Texture>;
  66859. /**
  66860. * The overall strengh for the lens flare effect
  66861. */
  66862. lensFlareStrength: number;
  66863. /**
  66864. * Dispersion coefficient for lens flare ghosts
  66865. */
  66866. lensFlareGhostDispersal: number;
  66867. /**
  66868. * Main lens flare halo width
  66869. */
  66870. lensFlareHaloWidth: number;
  66871. /**
  66872. * Based on the lens distortion effect, defines how much the lens flare result
  66873. * is distorted
  66874. */
  66875. lensFlareDistortionStrength: number;
  66876. /**
  66877. * Configures the blur intensity used for for lens flare (halo)
  66878. */
  66879. lensFlareBlurWidth: number;
  66880. /**
  66881. * Lens star texture must be used to simulate rays on the flares and is available
  66882. * in the documentation
  66883. */
  66884. lensStarTexture: Nullable<Texture>;
  66885. /**
  66886. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66887. * flare effect by taking account of the dirt texture
  66888. */
  66889. lensFlareDirtTexture: Nullable<Texture>;
  66890. /**
  66891. * Represents the focal length for the depth of field effect
  66892. */
  66893. depthOfFieldDistance: number;
  66894. /**
  66895. * Represents the blur intensity for the blurred part of the depth of field effect
  66896. */
  66897. depthOfFieldBlurWidth: number;
  66898. /**
  66899. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66900. */
  66901. get motionStrength(): number;
  66902. /**
  66903. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66904. */
  66905. set motionStrength(strength: number);
  66906. /**
  66907. * Gets wether or not the motion blur post-process is object based or screen based.
  66908. */
  66909. get objectBasedMotionBlur(): boolean;
  66910. /**
  66911. * Sets wether or not the motion blur post-process should be object based or screen based
  66912. */
  66913. set objectBasedMotionBlur(value: boolean);
  66914. /**
  66915. * List of animations for the pipeline (IAnimatable implementation)
  66916. */
  66917. animations: Animation[];
  66918. /**
  66919. * Private members
  66920. */
  66921. private _scene;
  66922. private _currentDepthOfFieldSource;
  66923. private _basePostProcess;
  66924. private _fixedExposure;
  66925. private _currentExposure;
  66926. private _hdrAutoExposure;
  66927. private _hdrCurrentLuminance;
  66928. private _motionStrength;
  66929. private _isObjectBasedMotionBlur;
  66930. private _floatTextureType;
  66931. private _camerasToBeAttached;
  66932. private _ratio;
  66933. private _bloomEnabled;
  66934. private _depthOfFieldEnabled;
  66935. private _vlsEnabled;
  66936. private _lensFlareEnabled;
  66937. private _hdrEnabled;
  66938. private _motionBlurEnabled;
  66939. private _fxaaEnabled;
  66940. private _screenSpaceReflectionsEnabled;
  66941. private _motionBlurSamples;
  66942. private _volumetricLightStepsCount;
  66943. private _samples;
  66944. /**
  66945. * @ignore
  66946. * Specifies if the bloom pipeline is enabled
  66947. */
  66948. get BloomEnabled(): boolean;
  66949. set BloomEnabled(enabled: boolean);
  66950. /**
  66951. * @ignore
  66952. * Specifies if the depth of field pipeline is enabed
  66953. */
  66954. get DepthOfFieldEnabled(): boolean;
  66955. set DepthOfFieldEnabled(enabled: boolean);
  66956. /**
  66957. * @ignore
  66958. * Specifies if the lens flare pipeline is enabed
  66959. */
  66960. get LensFlareEnabled(): boolean;
  66961. set LensFlareEnabled(enabled: boolean);
  66962. /**
  66963. * @ignore
  66964. * Specifies if the HDR pipeline is enabled
  66965. */
  66966. get HDREnabled(): boolean;
  66967. set HDREnabled(enabled: boolean);
  66968. /**
  66969. * @ignore
  66970. * Specifies if the volumetric lights scattering effect is enabled
  66971. */
  66972. get VLSEnabled(): boolean;
  66973. set VLSEnabled(enabled: boolean);
  66974. /**
  66975. * @ignore
  66976. * Specifies if the motion blur effect is enabled
  66977. */
  66978. get MotionBlurEnabled(): boolean;
  66979. set MotionBlurEnabled(enabled: boolean);
  66980. /**
  66981. * Specifies if anti-aliasing is enabled
  66982. */
  66983. get fxaaEnabled(): boolean;
  66984. set fxaaEnabled(enabled: boolean);
  66985. /**
  66986. * Specifies if screen space reflections are enabled.
  66987. */
  66988. get screenSpaceReflectionsEnabled(): boolean;
  66989. set screenSpaceReflectionsEnabled(enabled: boolean);
  66990. /**
  66991. * Specifies the number of steps used to calculate the volumetric lights
  66992. * Typically in interval [50, 200]
  66993. */
  66994. get volumetricLightStepsCount(): number;
  66995. set volumetricLightStepsCount(count: number);
  66996. /**
  66997. * Specifies the number of samples used for the motion blur effect
  66998. * Typically in interval [16, 64]
  66999. */
  67000. get motionBlurSamples(): number;
  67001. set motionBlurSamples(samples: number);
  67002. /**
  67003. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67004. */
  67005. get samples(): number;
  67006. set samples(sampleCount: number);
  67007. /**
  67008. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67009. * @constructor
  67010. * @param name The rendering pipeline name
  67011. * @param scene The scene linked to this pipeline
  67012. * @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)
  67013. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  67014. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67015. */
  67016. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  67017. private _buildPipeline;
  67018. private _createDownSampleX4PostProcess;
  67019. private _createBrightPassPostProcess;
  67020. private _createBlurPostProcesses;
  67021. private _createTextureAdderPostProcess;
  67022. private _createVolumetricLightPostProcess;
  67023. private _createLuminancePostProcesses;
  67024. private _createHdrPostProcess;
  67025. private _createLensFlarePostProcess;
  67026. private _createDepthOfFieldPostProcess;
  67027. private _createMotionBlurPostProcess;
  67028. private _getDepthTexture;
  67029. private _disposePostProcesses;
  67030. /**
  67031. * Dispose of the pipeline and stop all post processes
  67032. */
  67033. dispose(): void;
  67034. /**
  67035. * Serialize the rendering pipeline (Used when exporting)
  67036. * @returns the serialized object
  67037. */
  67038. serialize(): any;
  67039. /**
  67040. * Parse the serialized pipeline
  67041. * @param source Source pipeline.
  67042. * @param scene The scene to load the pipeline to.
  67043. * @param rootUrl The URL of the serialized pipeline.
  67044. * @returns An instantiated pipeline from the serialized object.
  67045. */
  67046. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  67047. /**
  67048. * Luminance steps
  67049. */
  67050. static LuminanceSteps: number;
  67051. }
  67052. }
  67053. declare module BABYLON {
  67054. /** @hidden */
  67055. export var tonemapPixelShader: {
  67056. name: string;
  67057. shader: string;
  67058. };
  67059. }
  67060. declare module BABYLON {
  67061. /** Defines operator used for tonemapping */
  67062. export enum TonemappingOperator {
  67063. /** Hable */
  67064. Hable = 0,
  67065. /** Reinhard */
  67066. Reinhard = 1,
  67067. /** HejiDawson */
  67068. HejiDawson = 2,
  67069. /** Photographic */
  67070. Photographic = 3
  67071. }
  67072. /**
  67073. * Defines a post process to apply tone mapping
  67074. */
  67075. export class TonemapPostProcess extends PostProcess {
  67076. private _operator;
  67077. /** Defines the required exposure adjustement */
  67078. exposureAdjustment: number;
  67079. /**
  67080. * Creates a new TonemapPostProcess
  67081. * @param name defines the name of the postprocess
  67082. * @param _operator defines the operator to use
  67083. * @param exposureAdjustment defines the required exposure adjustement
  67084. * @param camera defines the camera to use (can be null)
  67085. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  67086. * @param engine defines the hosting engine (can be ignore if camera is set)
  67087. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67088. */
  67089. constructor(name: string, _operator: TonemappingOperator,
  67090. /** Defines the required exposure adjustement */
  67091. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  67092. }
  67093. }
  67094. declare module BABYLON {
  67095. /** @hidden */
  67096. export var volumetricLightScatteringPixelShader: {
  67097. name: string;
  67098. shader: string;
  67099. };
  67100. }
  67101. declare module BABYLON {
  67102. /** @hidden */
  67103. export var volumetricLightScatteringPassVertexShader: {
  67104. name: string;
  67105. shader: string;
  67106. };
  67107. }
  67108. declare module BABYLON {
  67109. /** @hidden */
  67110. export var volumetricLightScatteringPassPixelShader: {
  67111. name: string;
  67112. shader: string;
  67113. };
  67114. }
  67115. declare module BABYLON {
  67116. /**
  67117. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  67118. */
  67119. export class VolumetricLightScatteringPostProcess extends PostProcess {
  67120. private _volumetricLightScatteringPass;
  67121. private _volumetricLightScatteringRTT;
  67122. private _viewPort;
  67123. private _screenCoordinates;
  67124. private _cachedDefines;
  67125. /**
  67126. * If not undefined, the mesh position is computed from the attached node position
  67127. */
  67128. attachedNode: {
  67129. position: Vector3;
  67130. };
  67131. /**
  67132. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  67133. */
  67134. customMeshPosition: Vector3;
  67135. /**
  67136. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  67137. */
  67138. useCustomMeshPosition: boolean;
  67139. /**
  67140. * If the post-process should inverse the light scattering direction
  67141. */
  67142. invert: boolean;
  67143. /**
  67144. * The internal mesh used by the post-process
  67145. */
  67146. mesh: Mesh;
  67147. /**
  67148. * @hidden
  67149. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  67150. */
  67151. get useDiffuseColor(): boolean;
  67152. set useDiffuseColor(useDiffuseColor: boolean);
  67153. /**
  67154. * Array containing the excluded meshes not rendered in the internal pass
  67155. */
  67156. excludedMeshes: AbstractMesh[];
  67157. /**
  67158. * Controls the overall intensity of the post-process
  67159. */
  67160. exposure: number;
  67161. /**
  67162. * Dissipates each sample's contribution in range [0, 1]
  67163. */
  67164. decay: number;
  67165. /**
  67166. * Controls the overall intensity of each sample
  67167. */
  67168. weight: number;
  67169. /**
  67170. * Controls the density of each sample
  67171. */
  67172. density: number;
  67173. /**
  67174. * @constructor
  67175. * @param name The post-process name
  67176. * @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)
  67177. * @param camera The camera that the post-process will be attached to
  67178. * @param mesh The mesh used to create the light scattering
  67179. * @param samples The post-process quality, default 100
  67180. * @param samplingModeThe post-process filtering mode
  67181. * @param engine The babylon engine
  67182. * @param reusable If the post-process is reusable
  67183. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  67184. */
  67185. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  67186. /**
  67187. * Returns the string "VolumetricLightScatteringPostProcess"
  67188. * @returns "VolumetricLightScatteringPostProcess"
  67189. */
  67190. getClassName(): string;
  67191. private _isReady;
  67192. /**
  67193. * Sets the new light position for light scattering effect
  67194. * @param position The new custom light position
  67195. */
  67196. setCustomMeshPosition(position: Vector3): void;
  67197. /**
  67198. * Returns the light position for light scattering effect
  67199. * @return Vector3 The custom light position
  67200. */
  67201. getCustomMeshPosition(): Vector3;
  67202. /**
  67203. * Disposes the internal assets and detaches the post-process from the camera
  67204. */
  67205. dispose(camera: Camera): void;
  67206. /**
  67207. * Returns the render target texture used by the post-process
  67208. * @return the render target texture used by the post-process
  67209. */
  67210. getPass(): RenderTargetTexture;
  67211. private _meshExcluded;
  67212. private _createPass;
  67213. private _updateMeshScreenCoordinates;
  67214. /**
  67215. * Creates a default mesh for the Volumeric Light Scattering post-process
  67216. * @param name The mesh name
  67217. * @param scene The scene where to create the mesh
  67218. * @return the default mesh
  67219. */
  67220. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  67221. }
  67222. }
  67223. declare module BABYLON {
  67224. interface Scene {
  67225. /** @hidden (Backing field) */
  67226. _boundingBoxRenderer: BoundingBoxRenderer;
  67227. /** @hidden (Backing field) */
  67228. _forceShowBoundingBoxes: boolean;
  67229. /**
  67230. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  67231. */
  67232. forceShowBoundingBoxes: boolean;
  67233. /**
  67234. * Gets the bounding box renderer associated with the scene
  67235. * @returns a BoundingBoxRenderer
  67236. */
  67237. getBoundingBoxRenderer(): BoundingBoxRenderer;
  67238. }
  67239. interface AbstractMesh {
  67240. /** @hidden (Backing field) */
  67241. _showBoundingBox: boolean;
  67242. /**
  67243. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  67244. */
  67245. showBoundingBox: boolean;
  67246. }
  67247. /**
  67248. * Component responsible of rendering the bounding box of the meshes in a scene.
  67249. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  67250. */
  67251. export class BoundingBoxRenderer implements ISceneComponent {
  67252. /**
  67253. * The component name helpfull to identify the component in the list of scene components.
  67254. */
  67255. readonly name: string;
  67256. /**
  67257. * The scene the component belongs to.
  67258. */
  67259. scene: Scene;
  67260. /**
  67261. * Color of the bounding box lines placed in front of an object
  67262. */
  67263. frontColor: Color3;
  67264. /**
  67265. * Color of the bounding box lines placed behind an object
  67266. */
  67267. backColor: Color3;
  67268. /**
  67269. * Defines if the renderer should show the back lines or not
  67270. */
  67271. showBackLines: boolean;
  67272. /**
  67273. * @hidden
  67274. */
  67275. renderList: SmartArray<BoundingBox>;
  67276. private _colorShader;
  67277. private _vertexBuffers;
  67278. private _indexBuffer;
  67279. private _fillIndexBuffer;
  67280. private _fillIndexData;
  67281. /**
  67282. * Instantiates a new bounding box renderer in a scene.
  67283. * @param scene the scene the renderer renders in
  67284. */
  67285. constructor(scene: Scene);
  67286. /**
  67287. * Registers the component in a given scene
  67288. */
  67289. register(): void;
  67290. private _evaluateSubMesh;
  67291. private _activeMesh;
  67292. private _prepareRessources;
  67293. private _createIndexBuffer;
  67294. /**
  67295. * Rebuilds the elements related to this component in case of
  67296. * context lost for instance.
  67297. */
  67298. rebuild(): void;
  67299. /**
  67300. * @hidden
  67301. */
  67302. reset(): void;
  67303. /**
  67304. * Render the bounding boxes of a specific rendering group
  67305. * @param renderingGroupId defines the rendering group to render
  67306. */
  67307. render(renderingGroupId: number): void;
  67308. /**
  67309. * In case of occlusion queries, we can render the occlusion bounding box through this method
  67310. * @param mesh Define the mesh to render the occlusion bounding box for
  67311. */
  67312. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  67313. /**
  67314. * Dispose and release the resources attached to this renderer.
  67315. */
  67316. dispose(): void;
  67317. }
  67318. }
  67319. declare module BABYLON {
  67320. interface Scene {
  67321. /** @hidden (Backing field) */
  67322. _depthRenderer: {
  67323. [id: string]: DepthRenderer;
  67324. };
  67325. /**
  67326. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  67327. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  67328. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  67329. * @returns the created depth renderer
  67330. */
  67331. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  67332. /**
  67333. * Disables a depth renderer for a given camera
  67334. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  67335. */
  67336. disableDepthRenderer(camera?: Nullable<Camera>): void;
  67337. }
  67338. /**
  67339. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  67340. * in several rendering techniques.
  67341. */
  67342. export class DepthRendererSceneComponent implements ISceneComponent {
  67343. /**
  67344. * The component name helpfull to identify the component in the list of scene components.
  67345. */
  67346. readonly name: string;
  67347. /**
  67348. * The scene the component belongs to.
  67349. */
  67350. scene: Scene;
  67351. /**
  67352. * Creates a new instance of the component for the given scene
  67353. * @param scene Defines the scene to register the component in
  67354. */
  67355. constructor(scene: Scene);
  67356. /**
  67357. * Registers the component in a given scene
  67358. */
  67359. register(): void;
  67360. /**
  67361. * Rebuilds the elements related to this component in case of
  67362. * context lost for instance.
  67363. */
  67364. rebuild(): void;
  67365. /**
  67366. * Disposes the component and the associated ressources
  67367. */
  67368. dispose(): void;
  67369. private _gatherRenderTargets;
  67370. private _gatherActiveCameraRenderTargets;
  67371. }
  67372. }
  67373. declare module BABYLON {
  67374. /** @hidden */
  67375. export var outlinePixelShader: {
  67376. name: string;
  67377. shader: string;
  67378. };
  67379. }
  67380. declare module BABYLON {
  67381. /** @hidden */
  67382. export var outlineVertexShader: {
  67383. name: string;
  67384. shader: string;
  67385. };
  67386. }
  67387. declare module BABYLON {
  67388. interface Scene {
  67389. /** @hidden */
  67390. _outlineRenderer: OutlineRenderer;
  67391. /**
  67392. * Gets the outline renderer associated with the scene
  67393. * @returns a OutlineRenderer
  67394. */
  67395. getOutlineRenderer(): OutlineRenderer;
  67396. }
  67397. interface AbstractMesh {
  67398. /** @hidden (Backing field) */
  67399. _renderOutline: boolean;
  67400. /**
  67401. * Gets or sets a boolean indicating if the outline must be rendered as well
  67402. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  67403. */
  67404. renderOutline: boolean;
  67405. /** @hidden (Backing field) */
  67406. _renderOverlay: boolean;
  67407. /**
  67408. * Gets or sets a boolean indicating if the overlay must be rendered as well
  67409. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  67410. */
  67411. renderOverlay: boolean;
  67412. }
  67413. /**
  67414. * This class is responsible to draw bothe outline/overlay of meshes.
  67415. * It should not be used directly but through the available method on mesh.
  67416. */
  67417. export class OutlineRenderer implements ISceneComponent {
  67418. /**
  67419. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  67420. */
  67421. private static _StencilReference;
  67422. /**
  67423. * The name of the component. Each component must have a unique name.
  67424. */
  67425. name: string;
  67426. /**
  67427. * The scene the component belongs to.
  67428. */
  67429. scene: Scene;
  67430. /**
  67431. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  67432. */
  67433. zOffset: number;
  67434. private _engine;
  67435. private _effect;
  67436. private _cachedDefines;
  67437. private _savedDepthWrite;
  67438. /**
  67439. * Instantiates a new outline renderer. (There could be only one per scene).
  67440. * @param scene Defines the scene it belongs to
  67441. */
  67442. constructor(scene: Scene);
  67443. /**
  67444. * Register the component to one instance of a scene.
  67445. */
  67446. register(): void;
  67447. /**
  67448. * Rebuilds the elements related to this component in case of
  67449. * context lost for instance.
  67450. */
  67451. rebuild(): void;
  67452. /**
  67453. * Disposes the component and the associated ressources.
  67454. */
  67455. dispose(): void;
  67456. /**
  67457. * Renders the outline in the canvas.
  67458. * @param subMesh Defines the sumesh to render
  67459. * @param batch Defines the batch of meshes in case of instances
  67460. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67461. */
  67462. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67463. /**
  67464. * Returns whether or not the outline renderer is ready for a given submesh.
  67465. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67466. * @param subMesh Defines the submesh to check readyness for
  67467. * @param useInstances Defines wheter wee are trying to render instances or not
  67468. * @returns true if ready otherwise false
  67469. */
  67470. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67471. private _beforeRenderingMesh;
  67472. private _afterRenderingMesh;
  67473. }
  67474. }
  67475. declare module BABYLON {
  67476. /**
  67477. * Defines the basic options interface of a Sprite Frame Source Size.
  67478. */
  67479. export interface ISpriteJSONSpriteSourceSize {
  67480. /**
  67481. * number of the original width of the Frame
  67482. */
  67483. w: number;
  67484. /**
  67485. * number of the original height of the Frame
  67486. */
  67487. h: number;
  67488. }
  67489. /**
  67490. * Defines the basic options interface of a Sprite Frame Data.
  67491. */
  67492. export interface ISpriteJSONSpriteFrameData {
  67493. /**
  67494. * number of the x offset of the Frame
  67495. */
  67496. x: number;
  67497. /**
  67498. * number of the y offset of the Frame
  67499. */
  67500. y: number;
  67501. /**
  67502. * number of the width of the Frame
  67503. */
  67504. w: number;
  67505. /**
  67506. * number of the height of the Frame
  67507. */
  67508. h: number;
  67509. }
  67510. /**
  67511. * Defines the basic options interface of a JSON Sprite.
  67512. */
  67513. export interface ISpriteJSONSprite {
  67514. /**
  67515. * string name of the Frame
  67516. */
  67517. filename: string;
  67518. /**
  67519. * ISpriteJSONSpriteFrame basic object of the frame data
  67520. */
  67521. frame: ISpriteJSONSpriteFrameData;
  67522. /**
  67523. * boolean to flag is the frame was rotated.
  67524. */
  67525. rotated: boolean;
  67526. /**
  67527. * boolean to flag is the frame was trimmed.
  67528. */
  67529. trimmed: boolean;
  67530. /**
  67531. * ISpriteJSONSpriteFrame basic object of the source data
  67532. */
  67533. spriteSourceSize: ISpriteJSONSpriteFrameData;
  67534. /**
  67535. * ISpriteJSONSpriteFrame basic object of the source data
  67536. */
  67537. sourceSize: ISpriteJSONSpriteSourceSize;
  67538. }
  67539. /**
  67540. * Defines the basic options interface of a JSON atlas.
  67541. */
  67542. export interface ISpriteJSONAtlas {
  67543. /**
  67544. * Array of objects that contain the frame data.
  67545. */
  67546. frames: Array<ISpriteJSONSprite>;
  67547. /**
  67548. * object basic object containing the sprite meta data.
  67549. */
  67550. meta?: object;
  67551. }
  67552. }
  67553. declare module BABYLON {
  67554. /** @hidden */
  67555. export var spriteMapPixelShader: {
  67556. name: string;
  67557. shader: string;
  67558. };
  67559. }
  67560. declare module BABYLON {
  67561. /** @hidden */
  67562. export var spriteMapVertexShader: {
  67563. name: string;
  67564. shader: string;
  67565. };
  67566. }
  67567. declare module BABYLON {
  67568. /**
  67569. * Defines the basic options interface of a SpriteMap
  67570. */
  67571. export interface ISpriteMapOptions {
  67572. /**
  67573. * Vector2 of the number of cells in the grid.
  67574. */
  67575. stageSize?: Vector2;
  67576. /**
  67577. * Vector2 of the size of the output plane in World Units.
  67578. */
  67579. outputSize?: Vector2;
  67580. /**
  67581. * Vector3 of the position of the output plane in World Units.
  67582. */
  67583. outputPosition?: Vector3;
  67584. /**
  67585. * Vector3 of the rotation of the output plane.
  67586. */
  67587. outputRotation?: Vector3;
  67588. /**
  67589. * number of layers that the system will reserve in resources.
  67590. */
  67591. layerCount?: number;
  67592. /**
  67593. * number of max animation frames a single cell will reserve in resources.
  67594. */
  67595. maxAnimationFrames?: number;
  67596. /**
  67597. * number cell index of the base tile when the system compiles.
  67598. */
  67599. baseTile?: number;
  67600. /**
  67601. * boolean flip the sprite after its been repositioned by the framing data.
  67602. */
  67603. flipU?: boolean;
  67604. /**
  67605. * Vector3 scalar of the global RGB values of the SpriteMap.
  67606. */
  67607. colorMultiply?: Vector3;
  67608. }
  67609. /**
  67610. * Defines the IDisposable interface in order to be cleanable from resources.
  67611. */
  67612. export interface ISpriteMap extends IDisposable {
  67613. /**
  67614. * String name of the SpriteMap.
  67615. */
  67616. name: string;
  67617. /**
  67618. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  67619. */
  67620. atlasJSON: ISpriteJSONAtlas;
  67621. /**
  67622. * Texture of the SpriteMap.
  67623. */
  67624. spriteSheet: Texture;
  67625. /**
  67626. * The parameters to initialize the SpriteMap with.
  67627. */
  67628. options: ISpriteMapOptions;
  67629. }
  67630. /**
  67631. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67632. */
  67633. export class SpriteMap implements ISpriteMap {
  67634. /** The Name of the spriteMap */
  67635. name: string;
  67636. /** The JSON file with the frame and meta data */
  67637. atlasJSON: ISpriteJSONAtlas;
  67638. /** The systems Sprite Sheet Texture */
  67639. spriteSheet: Texture;
  67640. /** Arguments passed with the Constructor */
  67641. options: ISpriteMapOptions;
  67642. /** Public Sprite Storage array, parsed from atlasJSON */
  67643. sprites: Array<ISpriteJSONSprite>;
  67644. /** Returns the Number of Sprites in the System */
  67645. get spriteCount(): number;
  67646. /** Returns the Position of Output Plane*/
  67647. get position(): Vector3;
  67648. /** Returns the Position of Output Plane*/
  67649. set position(v: Vector3);
  67650. /** Returns the Rotation of Output Plane*/
  67651. get rotation(): Vector3;
  67652. /** Returns the Rotation of Output Plane*/
  67653. set rotation(v: Vector3);
  67654. /** Sets the AnimationMap*/
  67655. get animationMap(): RawTexture;
  67656. /** Sets the AnimationMap*/
  67657. set animationMap(v: RawTexture);
  67658. /** Scene that the SpriteMap was created in */
  67659. private _scene;
  67660. /** Texture Buffer of Float32 that holds tile frame data*/
  67661. private _frameMap;
  67662. /** Texture Buffers of Float32 that holds tileMap data*/
  67663. private _tileMaps;
  67664. /** Texture Buffer of Float32 that holds Animation Data*/
  67665. private _animationMap;
  67666. /** Custom ShaderMaterial Central to the System*/
  67667. private _material;
  67668. /** Custom ShaderMaterial Central to the System*/
  67669. private _output;
  67670. /** Systems Time Ticker*/
  67671. private _time;
  67672. /**
  67673. * Creates a new SpriteMap
  67674. * @param name defines the SpriteMaps Name
  67675. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67676. * @param spriteSheet is the Texture that the Sprites are on.
  67677. * @param options a basic deployment configuration
  67678. * @param scene The Scene that the map is deployed on
  67679. */
  67680. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67681. /**
  67682. * Returns tileID location
  67683. * @returns Vector2 the cell position ID
  67684. */
  67685. getTileID(): Vector2;
  67686. /**
  67687. * Gets the UV location of the mouse over the SpriteMap.
  67688. * @returns Vector2 the UV position of the mouse interaction
  67689. */
  67690. getMousePosition(): Vector2;
  67691. /**
  67692. * Creates the "frame" texture Buffer
  67693. * -------------------------------------
  67694. * Structure of frames
  67695. * "filename": "Falling-Water-2.png",
  67696. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67697. * "rotated": true,
  67698. * "trimmed": true,
  67699. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67700. * "sourceSize": {"w":32,"h":32}
  67701. * @returns RawTexture of the frameMap
  67702. */
  67703. private _createFrameBuffer;
  67704. /**
  67705. * Creates the tileMap texture Buffer
  67706. * @param buffer normally and array of numbers, or a false to generate from scratch
  67707. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67708. * @returns RawTexture of the tileMap
  67709. */
  67710. private _createTileBuffer;
  67711. /**
  67712. * Modifies the data of the tileMaps
  67713. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67714. * @param pos is the iVector2 Coordinates of the Tile
  67715. * @param tile The SpriteIndex of the new Tile
  67716. */
  67717. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67718. /**
  67719. * Creates the animationMap texture Buffer
  67720. * @param buffer normally and array of numbers, or a false to generate from scratch
  67721. * @returns RawTexture of the animationMap
  67722. */
  67723. private _createTileAnimationBuffer;
  67724. /**
  67725. * Modifies the data of the animationMap
  67726. * @param cellID is the Index of the Sprite
  67727. * @param _frame is the target Animation frame
  67728. * @param toCell is the Target Index of the next frame of the animation
  67729. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67730. * @param speed is a global scalar of the time variable on the map.
  67731. */
  67732. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67733. /**
  67734. * Exports the .tilemaps file
  67735. */
  67736. saveTileMaps(): void;
  67737. /**
  67738. * Imports the .tilemaps file
  67739. * @param url of the .tilemaps file
  67740. */
  67741. loadTileMaps(url: string): void;
  67742. /**
  67743. * Release associated resources
  67744. */
  67745. dispose(): void;
  67746. }
  67747. }
  67748. declare module BABYLON {
  67749. /**
  67750. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67751. * @see http://doc.babylonjs.com/babylon101/sprites
  67752. */
  67753. export class SpritePackedManager extends SpriteManager {
  67754. /** defines the packed manager's name */
  67755. name: string;
  67756. /**
  67757. * Creates a new sprite manager from a packed sprite sheet
  67758. * @param name defines the manager's name
  67759. * @param imgUrl defines the sprite sheet url
  67760. * @param capacity defines the maximum allowed number of sprites
  67761. * @param scene defines the hosting scene
  67762. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67763. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67764. * @param samplingMode defines the smapling mode to use with spritesheet
  67765. * @param fromPacked set to true; do not alter
  67766. */
  67767. constructor(
  67768. /** defines the packed manager's name */
  67769. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67770. }
  67771. }
  67772. declare module BABYLON {
  67773. /**
  67774. * Defines the list of states available for a task inside a AssetsManager
  67775. */
  67776. export enum AssetTaskState {
  67777. /**
  67778. * Initialization
  67779. */
  67780. INIT = 0,
  67781. /**
  67782. * Running
  67783. */
  67784. RUNNING = 1,
  67785. /**
  67786. * Done
  67787. */
  67788. DONE = 2,
  67789. /**
  67790. * Error
  67791. */
  67792. ERROR = 3
  67793. }
  67794. /**
  67795. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67796. */
  67797. export abstract class AbstractAssetTask {
  67798. /**
  67799. * Task name
  67800. */ name: string;
  67801. /**
  67802. * Callback called when the task is successful
  67803. */
  67804. onSuccess: (task: any) => void;
  67805. /**
  67806. * Callback called when the task is not successful
  67807. */
  67808. onError: (task: any, message?: string, exception?: any) => void;
  67809. /**
  67810. * Creates a new AssetsManager
  67811. * @param name defines the name of the task
  67812. */
  67813. constructor(
  67814. /**
  67815. * Task name
  67816. */ name: string);
  67817. private _isCompleted;
  67818. private _taskState;
  67819. private _errorObject;
  67820. /**
  67821. * Get if the task is completed
  67822. */
  67823. get isCompleted(): boolean;
  67824. /**
  67825. * Gets the current state of the task
  67826. */
  67827. get taskState(): AssetTaskState;
  67828. /**
  67829. * Gets the current error object (if task is in error)
  67830. */
  67831. get errorObject(): {
  67832. message?: string;
  67833. exception?: any;
  67834. };
  67835. /**
  67836. * Internal only
  67837. * @hidden
  67838. */
  67839. _setErrorObject(message?: string, exception?: any): void;
  67840. /**
  67841. * Execute the current task
  67842. * @param scene defines the scene where you want your assets to be loaded
  67843. * @param onSuccess is a callback called when the task is successfully executed
  67844. * @param onError is a callback called if an error occurs
  67845. */
  67846. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67847. /**
  67848. * Execute the current task
  67849. * @param scene defines the scene where you want your assets to be loaded
  67850. * @param onSuccess is a callback called when the task is successfully executed
  67851. * @param onError is a callback called if an error occurs
  67852. */
  67853. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67854. /**
  67855. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67856. * This can be used with failed tasks that have the reason for failure fixed.
  67857. */
  67858. reset(): void;
  67859. private onErrorCallback;
  67860. private onDoneCallback;
  67861. }
  67862. /**
  67863. * Define the interface used by progress events raised during assets loading
  67864. */
  67865. export interface IAssetsProgressEvent {
  67866. /**
  67867. * Defines the number of remaining tasks to process
  67868. */
  67869. remainingCount: number;
  67870. /**
  67871. * Defines the total number of tasks
  67872. */
  67873. totalCount: number;
  67874. /**
  67875. * Defines the task that was just processed
  67876. */
  67877. task: AbstractAssetTask;
  67878. }
  67879. /**
  67880. * Class used to share progress information about assets loading
  67881. */
  67882. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67883. /**
  67884. * Defines the number of remaining tasks to process
  67885. */
  67886. remainingCount: number;
  67887. /**
  67888. * Defines the total number of tasks
  67889. */
  67890. totalCount: number;
  67891. /**
  67892. * Defines the task that was just processed
  67893. */
  67894. task: AbstractAssetTask;
  67895. /**
  67896. * Creates a AssetsProgressEvent
  67897. * @param remainingCount defines the number of remaining tasks to process
  67898. * @param totalCount defines the total number of tasks
  67899. * @param task defines the task that was just processed
  67900. */
  67901. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67902. }
  67903. /**
  67904. * Define a task used by AssetsManager to load meshes
  67905. */
  67906. export class MeshAssetTask extends AbstractAssetTask {
  67907. /**
  67908. * Defines the name of the task
  67909. */
  67910. name: string;
  67911. /**
  67912. * Defines the list of mesh's names you want to load
  67913. */
  67914. meshesNames: any;
  67915. /**
  67916. * Defines the root url to use as a base to load your meshes and associated resources
  67917. */
  67918. rootUrl: string;
  67919. /**
  67920. * Defines the filename of the scene to load from
  67921. */
  67922. sceneFilename: string;
  67923. /**
  67924. * Gets the list of loaded meshes
  67925. */
  67926. loadedMeshes: Array<AbstractMesh>;
  67927. /**
  67928. * Gets the list of loaded particle systems
  67929. */
  67930. loadedParticleSystems: Array<IParticleSystem>;
  67931. /**
  67932. * Gets the list of loaded skeletons
  67933. */
  67934. loadedSkeletons: Array<Skeleton>;
  67935. /**
  67936. * Gets the list of loaded animation groups
  67937. */
  67938. loadedAnimationGroups: Array<AnimationGroup>;
  67939. /**
  67940. * Callback called when the task is successful
  67941. */
  67942. onSuccess: (task: MeshAssetTask) => void;
  67943. /**
  67944. * Callback called when the task is successful
  67945. */
  67946. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67947. /**
  67948. * Creates a new MeshAssetTask
  67949. * @param name defines the name of the task
  67950. * @param meshesNames defines the list of mesh's names you want to load
  67951. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67952. * @param sceneFilename defines the filename of the scene to load from
  67953. */
  67954. constructor(
  67955. /**
  67956. * Defines the name of the task
  67957. */
  67958. name: string,
  67959. /**
  67960. * Defines the list of mesh's names you want to load
  67961. */
  67962. meshesNames: any,
  67963. /**
  67964. * Defines the root url to use as a base to load your meshes and associated resources
  67965. */
  67966. rootUrl: string,
  67967. /**
  67968. * Defines the filename of the scene to load from
  67969. */
  67970. sceneFilename: string);
  67971. /**
  67972. * Execute the current task
  67973. * @param scene defines the scene where you want your assets to be loaded
  67974. * @param onSuccess is a callback called when the task is successfully executed
  67975. * @param onError is a callback called if an error occurs
  67976. */
  67977. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67978. }
  67979. /**
  67980. * Define a task used by AssetsManager to load text content
  67981. */
  67982. export class TextFileAssetTask extends AbstractAssetTask {
  67983. /**
  67984. * Defines the name of the task
  67985. */
  67986. name: string;
  67987. /**
  67988. * Defines the location of the file to load
  67989. */
  67990. url: string;
  67991. /**
  67992. * Gets the loaded text string
  67993. */
  67994. text: string;
  67995. /**
  67996. * Callback called when the task is successful
  67997. */
  67998. onSuccess: (task: TextFileAssetTask) => void;
  67999. /**
  68000. * Callback called when the task is successful
  68001. */
  68002. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  68003. /**
  68004. * Creates a new TextFileAssetTask object
  68005. * @param name defines the name of the task
  68006. * @param url defines the location of the file to load
  68007. */
  68008. constructor(
  68009. /**
  68010. * Defines the name of the task
  68011. */
  68012. name: string,
  68013. /**
  68014. * Defines the location of the file to load
  68015. */
  68016. url: string);
  68017. /**
  68018. * Execute the current task
  68019. * @param scene defines the scene where you want your assets to be loaded
  68020. * @param onSuccess is a callback called when the task is successfully executed
  68021. * @param onError is a callback called if an error occurs
  68022. */
  68023. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68024. }
  68025. /**
  68026. * Define a task used by AssetsManager to load binary data
  68027. */
  68028. export class BinaryFileAssetTask extends AbstractAssetTask {
  68029. /**
  68030. * Defines the name of the task
  68031. */
  68032. name: string;
  68033. /**
  68034. * Defines the location of the file to load
  68035. */
  68036. url: string;
  68037. /**
  68038. * Gets the lodaded data (as an array buffer)
  68039. */
  68040. data: ArrayBuffer;
  68041. /**
  68042. * Callback called when the task is successful
  68043. */
  68044. onSuccess: (task: BinaryFileAssetTask) => void;
  68045. /**
  68046. * Callback called when the task is successful
  68047. */
  68048. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  68049. /**
  68050. * Creates a new BinaryFileAssetTask object
  68051. * @param name defines the name of the new task
  68052. * @param url defines the location of the file to load
  68053. */
  68054. constructor(
  68055. /**
  68056. * Defines the name of the task
  68057. */
  68058. name: string,
  68059. /**
  68060. * Defines the location of the file to load
  68061. */
  68062. url: string);
  68063. /**
  68064. * Execute the current task
  68065. * @param scene defines the scene where you want your assets to be loaded
  68066. * @param onSuccess is a callback called when the task is successfully executed
  68067. * @param onError is a callback called if an error occurs
  68068. */
  68069. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68070. }
  68071. /**
  68072. * Define a task used by AssetsManager to load images
  68073. */
  68074. export class ImageAssetTask extends AbstractAssetTask {
  68075. /**
  68076. * Defines the name of the task
  68077. */
  68078. name: string;
  68079. /**
  68080. * Defines the location of the image to load
  68081. */
  68082. url: string;
  68083. /**
  68084. * Gets the loaded images
  68085. */
  68086. image: HTMLImageElement;
  68087. /**
  68088. * Callback called when the task is successful
  68089. */
  68090. onSuccess: (task: ImageAssetTask) => void;
  68091. /**
  68092. * Callback called when the task is successful
  68093. */
  68094. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  68095. /**
  68096. * Creates a new ImageAssetTask
  68097. * @param name defines the name of the task
  68098. * @param url defines the location of the image to load
  68099. */
  68100. constructor(
  68101. /**
  68102. * Defines the name of the task
  68103. */
  68104. name: string,
  68105. /**
  68106. * Defines the location of the image to load
  68107. */
  68108. url: string);
  68109. /**
  68110. * Execute the current task
  68111. * @param scene defines the scene where you want your assets to be loaded
  68112. * @param onSuccess is a callback called when the task is successfully executed
  68113. * @param onError is a callback called if an error occurs
  68114. */
  68115. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68116. }
  68117. /**
  68118. * Defines the interface used by texture loading tasks
  68119. */
  68120. export interface ITextureAssetTask<TEX extends BaseTexture> {
  68121. /**
  68122. * Gets the loaded texture
  68123. */
  68124. texture: TEX;
  68125. }
  68126. /**
  68127. * Define a task used by AssetsManager to load 2D textures
  68128. */
  68129. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  68130. /**
  68131. * Defines the name of the task
  68132. */
  68133. name: string;
  68134. /**
  68135. * Defines the location of the file to load
  68136. */
  68137. url: string;
  68138. /**
  68139. * Defines if mipmap should not be generated (default is false)
  68140. */
  68141. noMipmap?: boolean | undefined;
  68142. /**
  68143. * Defines if texture must be inverted on Y axis (default is true)
  68144. */
  68145. invertY: boolean;
  68146. /**
  68147. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68148. */
  68149. samplingMode: number;
  68150. /**
  68151. * Gets the loaded texture
  68152. */
  68153. texture: Texture;
  68154. /**
  68155. * Callback called when the task is successful
  68156. */
  68157. onSuccess: (task: TextureAssetTask) => void;
  68158. /**
  68159. * Callback called when the task is successful
  68160. */
  68161. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  68162. /**
  68163. * Creates a new TextureAssetTask object
  68164. * @param name defines the name of the task
  68165. * @param url defines the location of the file to load
  68166. * @param noMipmap defines if mipmap should not be generated (default is false)
  68167. * @param invertY defines if texture must be inverted on Y axis (default is true)
  68168. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68169. */
  68170. constructor(
  68171. /**
  68172. * Defines the name of the task
  68173. */
  68174. name: string,
  68175. /**
  68176. * Defines the location of the file to load
  68177. */
  68178. url: string,
  68179. /**
  68180. * Defines if mipmap should not be generated (default is false)
  68181. */
  68182. noMipmap?: boolean | undefined,
  68183. /**
  68184. * Defines if texture must be inverted on Y axis (default is true)
  68185. */
  68186. invertY?: boolean,
  68187. /**
  68188. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68189. */
  68190. samplingMode?: number);
  68191. /**
  68192. * Execute the current task
  68193. * @param scene defines the scene where you want your assets to be loaded
  68194. * @param onSuccess is a callback called when the task is successfully executed
  68195. * @param onError is a callback called if an error occurs
  68196. */
  68197. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68198. }
  68199. /**
  68200. * Define a task used by AssetsManager to load cube textures
  68201. */
  68202. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  68203. /**
  68204. * Defines the name of the task
  68205. */
  68206. name: string;
  68207. /**
  68208. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68209. */
  68210. url: string;
  68211. /**
  68212. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68213. */
  68214. extensions?: string[] | undefined;
  68215. /**
  68216. * Defines if mipmaps should not be generated (default is false)
  68217. */
  68218. noMipmap?: boolean | undefined;
  68219. /**
  68220. * Defines the explicit list of files (undefined by default)
  68221. */
  68222. files?: string[] | undefined;
  68223. /**
  68224. * Gets the loaded texture
  68225. */
  68226. texture: CubeTexture;
  68227. /**
  68228. * Callback called when the task is successful
  68229. */
  68230. onSuccess: (task: CubeTextureAssetTask) => void;
  68231. /**
  68232. * Callback called when the task is successful
  68233. */
  68234. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  68235. /**
  68236. * Creates a new CubeTextureAssetTask
  68237. * @param name defines the name of the task
  68238. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68239. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68240. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68241. * @param files defines the explicit list of files (undefined by default)
  68242. */
  68243. constructor(
  68244. /**
  68245. * Defines the name of the task
  68246. */
  68247. name: string,
  68248. /**
  68249. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68250. */
  68251. url: string,
  68252. /**
  68253. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68254. */
  68255. extensions?: string[] | undefined,
  68256. /**
  68257. * Defines if mipmaps should not be generated (default is false)
  68258. */
  68259. noMipmap?: boolean | undefined,
  68260. /**
  68261. * Defines the explicit list of files (undefined by default)
  68262. */
  68263. files?: string[] | undefined);
  68264. /**
  68265. * Execute the current task
  68266. * @param scene defines the scene where you want your assets to be loaded
  68267. * @param onSuccess is a callback called when the task is successfully executed
  68268. * @param onError is a callback called if an error occurs
  68269. */
  68270. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68271. }
  68272. /**
  68273. * Define a task used by AssetsManager to load HDR cube textures
  68274. */
  68275. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  68276. /**
  68277. * Defines the name of the task
  68278. */
  68279. name: string;
  68280. /**
  68281. * Defines the location of the file to load
  68282. */
  68283. url: string;
  68284. /**
  68285. * Defines the desired size (the more it increases the longer the generation will be)
  68286. */
  68287. size: number;
  68288. /**
  68289. * Defines if mipmaps should not be generated (default is false)
  68290. */
  68291. noMipmap: boolean;
  68292. /**
  68293. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68294. */
  68295. generateHarmonics: boolean;
  68296. /**
  68297. * 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)
  68298. */
  68299. gammaSpace: boolean;
  68300. /**
  68301. * Internal Use Only
  68302. */
  68303. reserved: boolean;
  68304. /**
  68305. * Gets the loaded texture
  68306. */
  68307. texture: HDRCubeTexture;
  68308. /**
  68309. * Callback called when the task is successful
  68310. */
  68311. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  68312. /**
  68313. * Callback called when the task is successful
  68314. */
  68315. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  68316. /**
  68317. * Creates a new HDRCubeTextureAssetTask object
  68318. * @param name defines the name of the task
  68319. * @param url defines the location of the file to load
  68320. * @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.
  68321. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68322. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68323. * @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)
  68324. * @param reserved Internal use only
  68325. */
  68326. constructor(
  68327. /**
  68328. * Defines the name of the task
  68329. */
  68330. name: string,
  68331. /**
  68332. * Defines the location of the file to load
  68333. */
  68334. url: string,
  68335. /**
  68336. * Defines the desired size (the more it increases the longer the generation will be)
  68337. */
  68338. size: number,
  68339. /**
  68340. * Defines if mipmaps should not be generated (default is false)
  68341. */
  68342. noMipmap?: boolean,
  68343. /**
  68344. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68345. */
  68346. generateHarmonics?: boolean,
  68347. /**
  68348. * 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)
  68349. */
  68350. gammaSpace?: boolean,
  68351. /**
  68352. * Internal Use Only
  68353. */
  68354. reserved?: boolean);
  68355. /**
  68356. * Execute the current task
  68357. * @param scene defines the scene where you want your assets to be loaded
  68358. * @param onSuccess is a callback called when the task is successfully executed
  68359. * @param onError is a callback called if an error occurs
  68360. */
  68361. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68362. }
  68363. /**
  68364. * Define a task used by AssetsManager to load Equirectangular cube textures
  68365. */
  68366. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  68367. /**
  68368. * Defines the name of the task
  68369. */
  68370. name: string;
  68371. /**
  68372. * Defines the location of the file to load
  68373. */
  68374. url: string;
  68375. /**
  68376. * Defines the desired size (the more it increases the longer the generation will be)
  68377. */
  68378. size: number;
  68379. /**
  68380. * Defines if mipmaps should not be generated (default is false)
  68381. */
  68382. noMipmap: boolean;
  68383. /**
  68384. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68385. * but the standard material would require them in Gamma space) (default is true)
  68386. */
  68387. gammaSpace: boolean;
  68388. /**
  68389. * Gets the loaded texture
  68390. */
  68391. texture: EquiRectangularCubeTexture;
  68392. /**
  68393. * Callback called when the task is successful
  68394. */
  68395. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  68396. /**
  68397. * Callback called when the task is successful
  68398. */
  68399. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  68400. /**
  68401. * Creates a new EquiRectangularCubeTextureAssetTask object
  68402. * @param name defines the name of the task
  68403. * @param url defines the location of the file to load
  68404. * @param size defines the desired size (the more it increases the longer the generation will be)
  68405. * If the size is omitted this implies you are using a preprocessed cubemap.
  68406. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68407. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  68408. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  68409. * (default is true)
  68410. */
  68411. constructor(
  68412. /**
  68413. * Defines the name of the task
  68414. */
  68415. name: string,
  68416. /**
  68417. * Defines the location of the file to load
  68418. */
  68419. url: string,
  68420. /**
  68421. * Defines the desired size (the more it increases the longer the generation will be)
  68422. */
  68423. size: number,
  68424. /**
  68425. * Defines if mipmaps should not be generated (default is false)
  68426. */
  68427. noMipmap?: boolean,
  68428. /**
  68429. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68430. * but the standard material would require them in Gamma space) (default is true)
  68431. */
  68432. gammaSpace?: boolean);
  68433. /**
  68434. * Execute the current task
  68435. * @param scene defines the scene where you want your assets to be loaded
  68436. * @param onSuccess is a callback called when the task is successfully executed
  68437. * @param onError is a callback called if an error occurs
  68438. */
  68439. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68440. }
  68441. /**
  68442. * This class can be used to easily import assets into a scene
  68443. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  68444. */
  68445. export class AssetsManager {
  68446. private _scene;
  68447. private _isLoading;
  68448. protected _tasks: AbstractAssetTask[];
  68449. protected _waitingTasksCount: number;
  68450. protected _totalTasksCount: number;
  68451. /**
  68452. * Callback called when all tasks are processed
  68453. */
  68454. onFinish: (tasks: AbstractAssetTask[]) => void;
  68455. /**
  68456. * Callback called when a task is successful
  68457. */
  68458. onTaskSuccess: (task: AbstractAssetTask) => void;
  68459. /**
  68460. * Callback called when a task had an error
  68461. */
  68462. onTaskError: (task: AbstractAssetTask) => void;
  68463. /**
  68464. * Callback called when a task is done (whatever the result is)
  68465. */
  68466. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  68467. /**
  68468. * Observable called when all tasks are processed
  68469. */
  68470. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  68471. /**
  68472. * Observable called when a task had an error
  68473. */
  68474. onTaskErrorObservable: Observable<AbstractAssetTask>;
  68475. /**
  68476. * Observable called when all tasks were executed
  68477. */
  68478. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  68479. /**
  68480. * Observable called when a task is done (whatever the result is)
  68481. */
  68482. onProgressObservable: Observable<IAssetsProgressEvent>;
  68483. /**
  68484. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  68485. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  68486. */
  68487. useDefaultLoadingScreen: boolean;
  68488. /**
  68489. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  68490. * when all assets have been downloaded.
  68491. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  68492. */
  68493. autoHideLoadingUI: boolean;
  68494. /**
  68495. * Creates a new AssetsManager
  68496. * @param scene defines the scene to work on
  68497. */
  68498. constructor(scene: Scene);
  68499. /**
  68500. * Add a MeshAssetTask to the list of active tasks
  68501. * @param taskName defines the name of the new task
  68502. * @param meshesNames defines the name of meshes to load
  68503. * @param rootUrl defines the root url to use to locate files
  68504. * @param sceneFilename defines the filename of the scene file
  68505. * @returns a new MeshAssetTask object
  68506. */
  68507. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  68508. /**
  68509. * Add a TextFileAssetTask to the list of active tasks
  68510. * @param taskName defines the name of the new task
  68511. * @param url defines the url of the file to load
  68512. * @returns a new TextFileAssetTask object
  68513. */
  68514. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  68515. /**
  68516. * Add a BinaryFileAssetTask to the list of active tasks
  68517. * @param taskName defines the name of the new task
  68518. * @param url defines the url of the file to load
  68519. * @returns a new BinaryFileAssetTask object
  68520. */
  68521. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  68522. /**
  68523. * Add a ImageAssetTask to the list of active tasks
  68524. * @param taskName defines the name of the new task
  68525. * @param url defines the url of the file to load
  68526. * @returns a new ImageAssetTask object
  68527. */
  68528. addImageTask(taskName: string, url: string): ImageAssetTask;
  68529. /**
  68530. * Add a TextureAssetTask to the list of active tasks
  68531. * @param taskName defines the name of the new task
  68532. * @param url defines the url of the file to load
  68533. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68534. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  68535. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  68536. * @returns a new TextureAssetTask object
  68537. */
  68538. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  68539. /**
  68540. * Add a CubeTextureAssetTask to the list of active tasks
  68541. * @param taskName defines the name of the new task
  68542. * @param url defines the url of the file to load
  68543. * @param extensions defines the extension to use to load the cube map (can be null)
  68544. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68545. * @param files defines the list of files to load (can be null)
  68546. * @returns a new CubeTextureAssetTask object
  68547. */
  68548. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  68549. /**
  68550. *
  68551. * Add a HDRCubeTextureAssetTask to the list of active tasks
  68552. * @param taskName defines the name of the new task
  68553. * @param url defines the url of the file to load
  68554. * @param size defines the size you want for the cubemap (can be null)
  68555. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68556. * @param generateHarmonics defines if you want to automatically generate (true by default)
  68557. * @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)
  68558. * @param reserved Internal use only
  68559. * @returns a new HDRCubeTextureAssetTask object
  68560. */
  68561. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  68562. /**
  68563. *
  68564. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  68565. * @param taskName defines the name of the new task
  68566. * @param url defines the url of the file to load
  68567. * @param size defines the size you want for the cubemap (can be null)
  68568. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68569. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68570. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68571. * @returns a new EquiRectangularCubeTextureAssetTask object
  68572. */
  68573. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  68574. /**
  68575. * Remove a task from the assets manager.
  68576. * @param task the task to remove
  68577. */
  68578. removeTask(task: AbstractAssetTask): void;
  68579. private _decreaseWaitingTasksCount;
  68580. private _runTask;
  68581. /**
  68582. * Reset the AssetsManager and remove all tasks
  68583. * @return the current instance of the AssetsManager
  68584. */
  68585. reset(): AssetsManager;
  68586. /**
  68587. * Start the loading process
  68588. * @return the current instance of the AssetsManager
  68589. */
  68590. load(): AssetsManager;
  68591. /**
  68592. * Start the loading process as an async operation
  68593. * @return a promise returning the list of failed tasks
  68594. */
  68595. loadAsync(): Promise<void>;
  68596. }
  68597. }
  68598. declare module BABYLON {
  68599. /**
  68600. * Wrapper class for promise with external resolve and reject.
  68601. */
  68602. export class Deferred<T> {
  68603. /**
  68604. * The promise associated with this deferred object.
  68605. */
  68606. readonly promise: Promise<T>;
  68607. private _resolve;
  68608. private _reject;
  68609. /**
  68610. * The resolve method of the promise associated with this deferred object.
  68611. */
  68612. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  68613. /**
  68614. * The reject method of the promise associated with this deferred object.
  68615. */
  68616. get reject(): (reason?: any) => void;
  68617. /**
  68618. * Constructor for this deferred object.
  68619. */
  68620. constructor();
  68621. }
  68622. }
  68623. declare module BABYLON {
  68624. /**
  68625. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  68626. */
  68627. export class MeshExploder {
  68628. private _centerMesh;
  68629. private _meshes;
  68630. private _meshesOrigins;
  68631. private _toCenterVectors;
  68632. private _scaledDirection;
  68633. private _newPosition;
  68634. private _centerPosition;
  68635. /**
  68636. * Explodes meshes from a center mesh.
  68637. * @param meshes The meshes to explode.
  68638. * @param centerMesh The mesh to be center of explosion.
  68639. */
  68640. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68641. private _setCenterMesh;
  68642. /**
  68643. * Get class name
  68644. * @returns "MeshExploder"
  68645. */
  68646. getClassName(): string;
  68647. /**
  68648. * "Exploded meshes"
  68649. * @returns Array of meshes with the centerMesh at index 0.
  68650. */
  68651. getMeshes(): Array<Mesh>;
  68652. /**
  68653. * Explodes meshes giving a specific direction
  68654. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68655. */
  68656. explode(direction?: number): void;
  68657. }
  68658. }
  68659. declare module BABYLON {
  68660. /**
  68661. * Class used to help managing file picking and drag'n'drop
  68662. */
  68663. export class FilesInput {
  68664. /**
  68665. * List of files ready to be loaded
  68666. */
  68667. static get FilesToLoad(): {
  68668. [key: string]: File;
  68669. };
  68670. /**
  68671. * Callback called when a file is processed
  68672. */
  68673. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68674. private _engine;
  68675. private _currentScene;
  68676. private _sceneLoadedCallback;
  68677. private _progressCallback;
  68678. private _additionalRenderLoopLogicCallback;
  68679. private _textureLoadingCallback;
  68680. private _startingProcessingFilesCallback;
  68681. private _onReloadCallback;
  68682. private _errorCallback;
  68683. private _elementToMonitor;
  68684. private _sceneFileToLoad;
  68685. private _filesToLoad;
  68686. /**
  68687. * Creates a new FilesInput
  68688. * @param engine defines the rendering engine
  68689. * @param scene defines the hosting scene
  68690. * @param sceneLoadedCallback callback called when scene is loaded
  68691. * @param progressCallback callback called to track progress
  68692. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68693. * @param textureLoadingCallback callback called when a texture is loading
  68694. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68695. * @param onReloadCallback callback called when a reload is requested
  68696. * @param errorCallback callback call if an error occurs
  68697. */
  68698. 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);
  68699. private _dragEnterHandler;
  68700. private _dragOverHandler;
  68701. private _dropHandler;
  68702. /**
  68703. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68704. * @param elementToMonitor defines the DOM element to track
  68705. */
  68706. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68707. /**
  68708. * Release all associated resources
  68709. */
  68710. dispose(): void;
  68711. private renderFunction;
  68712. private drag;
  68713. private drop;
  68714. private _traverseFolder;
  68715. private _processFiles;
  68716. /**
  68717. * Load files from a drop event
  68718. * @param event defines the drop event to use as source
  68719. */
  68720. loadFiles(event: any): void;
  68721. private _processReload;
  68722. /**
  68723. * Reload the current scene from the loaded files
  68724. */
  68725. reload(): void;
  68726. }
  68727. }
  68728. declare module BABYLON {
  68729. /**
  68730. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68731. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68732. */
  68733. export class SceneOptimization {
  68734. /**
  68735. * Defines the priority of this optimization (0 by default which means first in the list)
  68736. */
  68737. priority: number;
  68738. /**
  68739. * Gets a string describing the action executed by the current optimization
  68740. * @returns description string
  68741. */
  68742. getDescription(): string;
  68743. /**
  68744. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68745. * @param scene defines the current scene where to apply this optimization
  68746. * @param optimizer defines the current optimizer
  68747. * @returns true if everything that can be done was applied
  68748. */
  68749. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68750. /**
  68751. * Creates the SceneOptimization object
  68752. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68753. * @param desc defines the description associated with the optimization
  68754. */
  68755. constructor(
  68756. /**
  68757. * Defines the priority of this optimization (0 by default which means first in the list)
  68758. */
  68759. priority?: number);
  68760. }
  68761. /**
  68762. * Defines an optimization used to reduce the size of render target textures
  68763. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68764. */
  68765. export class TextureOptimization extends SceneOptimization {
  68766. /**
  68767. * Defines the priority of this optimization (0 by default which means first in the list)
  68768. */
  68769. priority: number;
  68770. /**
  68771. * 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
  68772. */
  68773. maximumSize: number;
  68774. /**
  68775. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68776. */
  68777. step: number;
  68778. /**
  68779. * Gets a string describing the action executed by the current optimization
  68780. * @returns description string
  68781. */
  68782. getDescription(): string;
  68783. /**
  68784. * Creates the TextureOptimization object
  68785. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68786. * @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
  68787. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68788. */
  68789. constructor(
  68790. /**
  68791. * Defines the priority of this optimization (0 by default which means first in the list)
  68792. */
  68793. priority?: number,
  68794. /**
  68795. * 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
  68796. */
  68797. maximumSize?: number,
  68798. /**
  68799. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68800. */
  68801. step?: number);
  68802. /**
  68803. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68804. * @param scene defines the current scene where to apply this optimization
  68805. * @param optimizer defines the current optimizer
  68806. * @returns true if everything that can be done was applied
  68807. */
  68808. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68809. }
  68810. /**
  68811. * Defines an optimization used to increase or decrease the rendering resolution
  68812. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68813. */
  68814. export class HardwareScalingOptimization extends SceneOptimization {
  68815. /**
  68816. * Defines the priority of this optimization (0 by default which means first in the list)
  68817. */
  68818. priority: number;
  68819. /**
  68820. * Defines the maximum scale to use (2 by default)
  68821. */
  68822. maximumScale: number;
  68823. /**
  68824. * Defines the step to use between two passes (0.5 by default)
  68825. */
  68826. step: number;
  68827. private _currentScale;
  68828. private _directionOffset;
  68829. /**
  68830. * Gets a string describing the action executed by the current optimization
  68831. * @return description string
  68832. */
  68833. getDescription(): string;
  68834. /**
  68835. * Creates the HardwareScalingOptimization object
  68836. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68837. * @param maximumScale defines the maximum scale to use (2 by default)
  68838. * @param step defines the step to use between two passes (0.5 by default)
  68839. */
  68840. constructor(
  68841. /**
  68842. * Defines the priority of this optimization (0 by default which means first in the list)
  68843. */
  68844. priority?: number,
  68845. /**
  68846. * Defines the maximum scale to use (2 by default)
  68847. */
  68848. maximumScale?: number,
  68849. /**
  68850. * Defines the step to use between two passes (0.5 by default)
  68851. */
  68852. step?: number);
  68853. /**
  68854. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68855. * @param scene defines the current scene where to apply this optimization
  68856. * @param optimizer defines the current optimizer
  68857. * @returns true if everything that can be done was applied
  68858. */
  68859. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68860. }
  68861. /**
  68862. * Defines an optimization used to remove shadows
  68863. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68864. */
  68865. export class ShadowsOptimization extends SceneOptimization {
  68866. /**
  68867. * Gets a string describing the action executed by the current optimization
  68868. * @return description string
  68869. */
  68870. getDescription(): string;
  68871. /**
  68872. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68873. * @param scene defines the current scene where to apply this optimization
  68874. * @param optimizer defines the current optimizer
  68875. * @returns true if everything that can be done was applied
  68876. */
  68877. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68878. }
  68879. /**
  68880. * Defines an optimization used to turn post-processes off
  68881. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68882. */
  68883. export class PostProcessesOptimization extends SceneOptimization {
  68884. /**
  68885. * Gets a string describing the action executed by the current optimization
  68886. * @return description string
  68887. */
  68888. getDescription(): string;
  68889. /**
  68890. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68891. * @param scene defines the current scene where to apply this optimization
  68892. * @param optimizer defines the current optimizer
  68893. * @returns true if everything that can be done was applied
  68894. */
  68895. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68896. }
  68897. /**
  68898. * Defines an optimization used to turn lens flares off
  68899. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68900. */
  68901. export class LensFlaresOptimization extends SceneOptimization {
  68902. /**
  68903. * Gets a string describing the action executed by the current optimization
  68904. * @return description string
  68905. */
  68906. getDescription(): string;
  68907. /**
  68908. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68909. * @param scene defines the current scene where to apply this optimization
  68910. * @param optimizer defines the current optimizer
  68911. * @returns true if everything that can be done was applied
  68912. */
  68913. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68914. }
  68915. /**
  68916. * Defines an optimization based on user defined callback.
  68917. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68918. */
  68919. export class CustomOptimization extends SceneOptimization {
  68920. /**
  68921. * Callback called to apply the custom optimization.
  68922. */
  68923. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68924. /**
  68925. * Callback called to get custom description
  68926. */
  68927. onGetDescription: () => string;
  68928. /**
  68929. * Gets a string describing the action executed by the current optimization
  68930. * @returns description string
  68931. */
  68932. getDescription(): string;
  68933. /**
  68934. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68935. * @param scene defines the current scene where to apply this optimization
  68936. * @param optimizer defines the current optimizer
  68937. * @returns true if everything that can be done was applied
  68938. */
  68939. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68940. }
  68941. /**
  68942. * Defines an optimization used to turn particles off
  68943. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68944. */
  68945. export class ParticlesOptimization extends SceneOptimization {
  68946. /**
  68947. * Gets a string describing the action executed by the current optimization
  68948. * @return description string
  68949. */
  68950. getDescription(): string;
  68951. /**
  68952. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68953. * @param scene defines the current scene where to apply this optimization
  68954. * @param optimizer defines the current optimizer
  68955. * @returns true if everything that can be done was applied
  68956. */
  68957. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68958. }
  68959. /**
  68960. * Defines an optimization used to turn render targets off
  68961. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68962. */
  68963. export class RenderTargetsOptimization extends SceneOptimization {
  68964. /**
  68965. * Gets a string describing the action executed by the current optimization
  68966. * @return description string
  68967. */
  68968. getDescription(): string;
  68969. /**
  68970. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68971. * @param scene defines the current scene where to apply this optimization
  68972. * @param optimizer defines the current optimizer
  68973. * @returns true if everything that can be done was applied
  68974. */
  68975. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68976. }
  68977. /**
  68978. * Defines an optimization used to merge meshes with compatible materials
  68979. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68980. */
  68981. export class MergeMeshesOptimization extends SceneOptimization {
  68982. private static _UpdateSelectionTree;
  68983. /**
  68984. * Gets or sets a boolean which defines if optimization octree has to be updated
  68985. */
  68986. static get UpdateSelectionTree(): boolean;
  68987. /**
  68988. * Gets or sets a boolean which defines if optimization octree has to be updated
  68989. */
  68990. static set UpdateSelectionTree(value: boolean);
  68991. /**
  68992. * Gets a string describing the action executed by the current optimization
  68993. * @return description string
  68994. */
  68995. getDescription(): string;
  68996. private _canBeMerged;
  68997. /**
  68998. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68999. * @param scene defines the current scene where to apply this optimization
  69000. * @param optimizer defines the current optimizer
  69001. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  69002. * @returns true if everything that can be done was applied
  69003. */
  69004. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  69005. }
  69006. /**
  69007. * Defines a list of options used by SceneOptimizer
  69008. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69009. */
  69010. export class SceneOptimizerOptions {
  69011. /**
  69012. * Defines the target frame rate to reach (60 by default)
  69013. */
  69014. targetFrameRate: number;
  69015. /**
  69016. * Defines the interval between two checkes (2000ms by default)
  69017. */
  69018. trackerDuration: number;
  69019. /**
  69020. * Gets the list of optimizations to apply
  69021. */
  69022. optimizations: SceneOptimization[];
  69023. /**
  69024. * Creates a new list of options used by SceneOptimizer
  69025. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  69026. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  69027. */
  69028. constructor(
  69029. /**
  69030. * Defines the target frame rate to reach (60 by default)
  69031. */
  69032. targetFrameRate?: number,
  69033. /**
  69034. * Defines the interval between two checkes (2000ms by default)
  69035. */
  69036. trackerDuration?: number);
  69037. /**
  69038. * Add a new optimization
  69039. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  69040. * @returns the current SceneOptimizerOptions
  69041. */
  69042. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  69043. /**
  69044. * Add a new custom optimization
  69045. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  69046. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  69047. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69048. * @returns the current SceneOptimizerOptions
  69049. */
  69050. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  69051. /**
  69052. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  69053. * @param targetFrameRate defines the target frame rate (60 by default)
  69054. * @returns a SceneOptimizerOptions object
  69055. */
  69056. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69057. /**
  69058. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  69059. * @param targetFrameRate defines the target frame rate (60 by default)
  69060. * @returns a SceneOptimizerOptions object
  69061. */
  69062. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69063. /**
  69064. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  69065. * @param targetFrameRate defines the target frame rate (60 by default)
  69066. * @returns a SceneOptimizerOptions object
  69067. */
  69068. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69069. }
  69070. /**
  69071. * Class used to run optimizations in order to reach a target frame rate
  69072. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69073. */
  69074. export class SceneOptimizer implements IDisposable {
  69075. private _isRunning;
  69076. private _options;
  69077. private _scene;
  69078. private _currentPriorityLevel;
  69079. private _targetFrameRate;
  69080. private _trackerDuration;
  69081. private _currentFrameRate;
  69082. private _sceneDisposeObserver;
  69083. private _improvementMode;
  69084. /**
  69085. * Defines an observable called when the optimizer reaches the target frame rate
  69086. */
  69087. onSuccessObservable: Observable<SceneOptimizer>;
  69088. /**
  69089. * Defines an observable called when the optimizer enables an optimization
  69090. */
  69091. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  69092. /**
  69093. * Defines an observable called when the optimizer is not able to reach the target frame rate
  69094. */
  69095. onFailureObservable: Observable<SceneOptimizer>;
  69096. /**
  69097. * Gets a boolean indicating if the optimizer is in improvement mode
  69098. */
  69099. get isInImprovementMode(): boolean;
  69100. /**
  69101. * Gets the current priority level (0 at start)
  69102. */
  69103. get currentPriorityLevel(): number;
  69104. /**
  69105. * Gets the current frame rate checked by the SceneOptimizer
  69106. */
  69107. get currentFrameRate(): number;
  69108. /**
  69109. * Gets or sets the current target frame rate (60 by default)
  69110. */
  69111. get targetFrameRate(): number;
  69112. /**
  69113. * Gets or sets the current target frame rate (60 by default)
  69114. */
  69115. set targetFrameRate(value: number);
  69116. /**
  69117. * Gets or sets the current interval between two checks (every 2000ms by default)
  69118. */
  69119. get trackerDuration(): number;
  69120. /**
  69121. * Gets or sets the current interval between two checks (every 2000ms by default)
  69122. */
  69123. set trackerDuration(value: number);
  69124. /**
  69125. * Gets the list of active optimizations
  69126. */
  69127. get optimizations(): SceneOptimization[];
  69128. /**
  69129. * Creates a new SceneOptimizer
  69130. * @param scene defines the scene to work on
  69131. * @param options defines the options to use with the SceneOptimizer
  69132. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  69133. * @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)
  69134. */
  69135. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  69136. /**
  69137. * Stops the current optimizer
  69138. */
  69139. stop(): void;
  69140. /**
  69141. * Reset the optimizer to initial step (current priority level = 0)
  69142. */
  69143. reset(): void;
  69144. /**
  69145. * Start the optimizer. By default it will try to reach a specific framerate
  69146. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  69147. */
  69148. start(): void;
  69149. private _checkCurrentState;
  69150. /**
  69151. * Release all resources
  69152. */
  69153. dispose(): void;
  69154. /**
  69155. * Helper function to create a SceneOptimizer with one single line of code
  69156. * @param scene defines the scene to work on
  69157. * @param options defines the options to use with the SceneOptimizer
  69158. * @param onSuccess defines a callback to call on success
  69159. * @param onFailure defines a callback to call on failure
  69160. * @returns the new SceneOptimizer object
  69161. */
  69162. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  69163. }
  69164. }
  69165. declare module BABYLON {
  69166. /**
  69167. * Class used to serialize a scene into a string
  69168. */
  69169. export class SceneSerializer {
  69170. /**
  69171. * Clear cache used by a previous serialization
  69172. */
  69173. static ClearCache(): void;
  69174. /**
  69175. * Serialize a scene into a JSON compatible object
  69176. * @param scene defines the scene to serialize
  69177. * @returns a JSON compatible object
  69178. */
  69179. static Serialize(scene: Scene): any;
  69180. /**
  69181. * Serialize a mesh into a JSON compatible object
  69182. * @param toSerialize defines the mesh to serialize
  69183. * @param withParents defines if parents must be serialized as well
  69184. * @param withChildren defines if children must be serialized as well
  69185. * @returns a JSON compatible object
  69186. */
  69187. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  69188. }
  69189. }
  69190. declare module BABYLON {
  69191. /**
  69192. * Class used to host texture specific utilities
  69193. */
  69194. export class TextureTools {
  69195. /**
  69196. * Uses the GPU to create a copy texture rescaled at a given size
  69197. * @param texture Texture to copy from
  69198. * @param width defines the desired width
  69199. * @param height defines the desired height
  69200. * @param useBilinearMode defines if bilinear mode has to be used
  69201. * @return the generated texture
  69202. */
  69203. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  69204. }
  69205. }
  69206. declare module BABYLON {
  69207. /**
  69208. * This represents the different options available for the video capture.
  69209. */
  69210. export interface VideoRecorderOptions {
  69211. /** Defines the mime type of the video. */
  69212. mimeType: string;
  69213. /** Defines the FPS the video should be recorded at. */
  69214. fps: number;
  69215. /** Defines the chunk size for the recording data. */
  69216. recordChunckSize: number;
  69217. /** The audio tracks to attach to the recording. */
  69218. audioTracks?: MediaStreamTrack[];
  69219. }
  69220. /**
  69221. * This can help with recording videos from BabylonJS.
  69222. * This is based on the available WebRTC functionalities of the browser.
  69223. *
  69224. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  69225. */
  69226. export class VideoRecorder {
  69227. private static readonly _defaultOptions;
  69228. /**
  69229. * Returns whether or not the VideoRecorder is available in your browser.
  69230. * @param engine Defines the Babylon Engine.
  69231. * @returns true if supported otherwise false.
  69232. */
  69233. static IsSupported(engine: Engine): boolean;
  69234. private readonly _options;
  69235. private _canvas;
  69236. private _mediaRecorder;
  69237. private _recordedChunks;
  69238. private _fileName;
  69239. private _resolve;
  69240. private _reject;
  69241. /**
  69242. * True when a recording is already in progress.
  69243. */
  69244. get isRecording(): boolean;
  69245. /**
  69246. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  69247. * @param engine Defines the BabylonJS Engine you wish to record.
  69248. * @param options Defines options that can be used to customize the capture.
  69249. */
  69250. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  69251. /**
  69252. * Stops the current recording before the default capture timeout passed in the startRecording function.
  69253. */
  69254. stopRecording(): void;
  69255. /**
  69256. * Starts recording the canvas for a max duration specified in parameters.
  69257. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  69258. * If null no automatic download will start and you can rely on the promise to get the data back.
  69259. * @param maxDuration Defines the maximum recording time in seconds.
  69260. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  69261. * @return A promise callback at the end of the recording with the video data in Blob.
  69262. */
  69263. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  69264. /**
  69265. * Releases internal resources used during the recording.
  69266. */
  69267. dispose(): void;
  69268. private _handleDataAvailable;
  69269. private _handleError;
  69270. private _handleStop;
  69271. }
  69272. }
  69273. declare module BABYLON {
  69274. /**
  69275. * Class containing a set of static utilities functions for screenshots
  69276. */
  69277. export class ScreenshotTools {
  69278. /**
  69279. * Captures a screenshot of the current rendering
  69280. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69281. * @param engine defines the rendering engine
  69282. * @param camera defines the source camera
  69283. * @param size This parameter can be set to a single number or to an object with the
  69284. * following (optional) properties: precision, width, height. If a single number is passed,
  69285. * it will be used for both width and height. If an object is passed, the screenshot size
  69286. * will be derived from the parameters. The precision property is a multiplier allowing
  69287. * rendering at a higher or lower resolution
  69288. * @param successCallback defines the callback receives a single parameter which contains the
  69289. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69290. * src parameter of an <img> to display it
  69291. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69292. * Check your browser for supported MIME types
  69293. */
  69294. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  69295. /**
  69296. * Captures a screenshot of the current rendering
  69297. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69298. * @param engine defines the rendering engine
  69299. * @param camera defines the source camera
  69300. * @param size This parameter can be set to a single number or to an object with the
  69301. * following (optional) properties: precision, width, height. If a single number is passed,
  69302. * it will be used for both width and height. If an object is passed, the screenshot size
  69303. * will be derived from the parameters. The precision property is a multiplier allowing
  69304. * rendering at a higher or lower resolution
  69305. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69306. * Check your browser for supported MIME types
  69307. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69308. * to the src parameter of an <img> to display it
  69309. */
  69310. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  69311. /**
  69312. * Generates an image screenshot from the specified camera.
  69313. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69314. * @param engine The engine to use for rendering
  69315. * @param camera The camera to use for rendering
  69316. * @param size This parameter can be set to a single number or to an object with the
  69317. * following (optional) properties: precision, width, height. If a single number is passed,
  69318. * it will be used for both width and height. If an object is passed, the screenshot size
  69319. * will be derived from the parameters. The precision property is a multiplier allowing
  69320. * rendering at a higher or lower resolution
  69321. * @param successCallback The callback receives a single parameter which contains the
  69322. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69323. * src parameter of an <img> to display it
  69324. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69325. * Check your browser for supported MIME types
  69326. * @param samples Texture samples (default: 1)
  69327. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69328. * @param fileName A name for for the downloaded file.
  69329. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69330. */
  69331. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  69332. /**
  69333. * Generates an image screenshot from the specified camera.
  69334. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69335. * @param engine The engine to use for rendering
  69336. * @param camera The camera to use for rendering
  69337. * @param size This parameter can be set to a single number or to an object with the
  69338. * following (optional) properties: precision, width, height. If a single number is passed,
  69339. * it will be used for both width and height. If an object is passed, the screenshot size
  69340. * will be derived from the parameters. The precision property is a multiplier allowing
  69341. * rendering at a higher or lower resolution
  69342. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69343. * Check your browser for supported MIME types
  69344. * @param samples Texture samples (default: 1)
  69345. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69346. * @param fileName A name for for the downloaded file.
  69347. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69348. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69349. * to the src parameter of an <img> to display it
  69350. */
  69351. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  69352. /**
  69353. * Gets height and width for screenshot size
  69354. * @private
  69355. */
  69356. private static _getScreenshotSize;
  69357. }
  69358. }
  69359. declare module BABYLON {
  69360. /**
  69361. * Interface for a data buffer
  69362. */
  69363. export interface IDataBuffer {
  69364. /**
  69365. * Reads bytes from the data buffer.
  69366. * @param byteOffset The byte offset to read
  69367. * @param byteLength The byte length to read
  69368. * @returns A promise that resolves when the bytes are read
  69369. */
  69370. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  69371. /**
  69372. * The byte length of the buffer.
  69373. */
  69374. readonly byteLength: number;
  69375. }
  69376. /**
  69377. * Utility class for reading from a data buffer
  69378. */
  69379. export class DataReader {
  69380. /**
  69381. * The data buffer associated with this data reader.
  69382. */
  69383. readonly buffer: IDataBuffer;
  69384. /**
  69385. * The current byte offset from the beginning of the data buffer.
  69386. */
  69387. byteOffset: number;
  69388. private _dataView;
  69389. private _dataByteOffset;
  69390. /**
  69391. * Constructor
  69392. * @param buffer The buffer to read
  69393. */
  69394. constructor(buffer: IDataBuffer);
  69395. /**
  69396. * Loads the given byte length.
  69397. * @param byteLength The byte length to load
  69398. * @returns A promise that resolves when the load is complete
  69399. */
  69400. loadAsync(byteLength: number): Promise<void>;
  69401. /**
  69402. * Read a unsigned 32-bit integer from the currently loaded data range.
  69403. * @returns The 32-bit integer read
  69404. */
  69405. readUint32(): number;
  69406. /**
  69407. * Read a byte array from the currently loaded data range.
  69408. * @param byteLength The byte length to read
  69409. * @returns The byte array read
  69410. */
  69411. readUint8Array(byteLength: number): Uint8Array;
  69412. /**
  69413. * Read a string from the currently loaded data range.
  69414. * @param byteLength The byte length to read
  69415. * @returns The string read
  69416. */
  69417. readString(byteLength: number): string;
  69418. /**
  69419. * Skips the given byte length the currently loaded data range.
  69420. * @param byteLength The byte length to skip
  69421. */
  69422. skipBytes(byteLength: number): void;
  69423. }
  69424. }
  69425. declare module BABYLON {
  69426. /**
  69427. * Class for storing data to local storage if available or in-memory storage otherwise
  69428. */
  69429. export class DataStorage {
  69430. private static _Storage;
  69431. private static _GetStorage;
  69432. /**
  69433. * Reads a string from the data storage
  69434. * @param key The key to read
  69435. * @param defaultValue The value if the key doesn't exist
  69436. * @returns The string value
  69437. */
  69438. static ReadString(key: string, defaultValue: string): string;
  69439. /**
  69440. * Writes a string to the data storage
  69441. * @param key The key to write
  69442. * @param value The value to write
  69443. */
  69444. static WriteString(key: string, value: string): void;
  69445. /**
  69446. * Reads a boolean from the data storage
  69447. * @param key The key to read
  69448. * @param defaultValue The value if the key doesn't exist
  69449. * @returns The boolean value
  69450. */
  69451. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  69452. /**
  69453. * Writes a boolean to the data storage
  69454. * @param key The key to write
  69455. * @param value The value to write
  69456. */
  69457. static WriteBoolean(key: string, value: boolean): void;
  69458. /**
  69459. * Reads a number from the data storage
  69460. * @param key The key to read
  69461. * @param defaultValue The value if the key doesn't exist
  69462. * @returns The number value
  69463. */
  69464. static ReadNumber(key: string, defaultValue: number): number;
  69465. /**
  69466. * Writes a number to the data storage
  69467. * @param key The key to write
  69468. * @param value The value to write
  69469. */
  69470. static WriteNumber(key: string, value: number): void;
  69471. }
  69472. }
  69473. declare module BABYLON {
  69474. /**
  69475. * Options used for hit testing
  69476. */
  69477. export interface IWebXRLegacyHitTestOptions {
  69478. /**
  69479. * Only test when user interacted with the scene. Default - hit test every frame
  69480. */
  69481. testOnPointerDownOnly?: boolean;
  69482. /**
  69483. * The node to use to transform the local results to world coordinates
  69484. */
  69485. worldParentNode?: TransformNode;
  69486. }
  69487. /**
  69488. * Interface defining the babylon result of raycasting/hit-test
  69489. */
  69490. export interface IWebXRLegacyHitResult {
  69491. /**
  69492. * Transformation matrix that can be applied to a node that will put it in the hit point location
  69493. */
  69494. transformationMatrix: Matrix;
  69495. /**
  69496. * The native hit test result
  69497. */
  69498. xrHitResult: XRHitResult | XRHitTestResult;
  69499. }
  69500. /**
  69501. * The currently-working hit-test module.
  69502. * Hit test (or Ray-casting) is used to interact with the real world.
  69503. * For further information read here - https://github.com/immersive-web/hit-test
  69504. */
  69505. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  69506. /**
  69507. * options to use when constructing this feature
  69508. */
  69509. readonly options: IWebXRLegacyHitTestOptions;
  69510. private _direction;
  69511. private _mat;
  69512. private _onSelectEnabled;
  69513. private _origin;
  69514. /**
  69515. * The module's name
  69516. */
  69517. static readonly Name: string;
  69518. /**
  69519. * The (Babylon) version of this module.
  69520. * This is an integer representing the implementation version.
  69521. * This number does not correspond to the WebXR specs version
  69522. */
  69523. static readonly Version: number;
  69524. /**
  69525. * Populated with the last native XR Hit Results
  69526. */
  69527. lastNativeXRHitResults: XRHitResult[];
  69528. /**
  69529. * Triggered when new babylon (transformed) hit test results are available
  69530. */
  69531. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  69532. /**
  69533. * Creates a new instance of the (legacy version) hit test feature
  69534. * @param _xrSessionManager an instance of WebXRSessionManager
  69535. * @param options options to use when constructing this feature
  69536. */
  69537. constructor(_xrSessionManager: WebXRSessionManager,
  69538. /**
  69539. * options to use when constructing this feature
  69540. */
  69541. options?: IWebXRLegacyHitTestOptions);
  69542. /**
  69543. * execute a hit test with an XR Ray
  69544. *
  69545. * @param xrSession a native xrSession that will execute this hit test
  69546. * @param xrRay the ray (position and direction) to use for ray-casting
  69547. * @param referenceSpace native XR reference space to use for the hit-test
  69548. * @param filter filter function that will filter the results
  69549. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69550. */
  69551. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  69552. /**
  69553. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  69554. * @param event the (select) event to use to select with
  69555. * @param referenceSpace the reference space to use for this hit test
  69556. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69557. */
  69558. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69559. /**
  69560. * attach this feature
  69561. * Will usually be called by the features manager
  69562. *
  69563. * @returns true if successful.
  69564. */
  69565. attach(): boolean;
  69566. /**
  69567. * detach this feature.
  69568. * Will usually be called by the features manager
  69569. *
  69570. * @returns true if successful.
  69571. */
  69572. detach(): boolean;
  69573. /**
  69574. * Dispose this feature and all of the resources attached
  69575. */
  69576. dispose(): void;
  69577. protected _onXRFrame(frame: XRFrame): void;
  69578. private _onHitTestResults;
  69579. private _onSelect;
  69580. }
  69581. }
  69582. declare module BABYLON {
  69583. /**
  69584. * Options used in the plane detector module
  69585. */
  69586. export interface IWebXRPlaneDetectorOptions {
  69587. /**
  69588. * The node to use to transform the local results to world coordinates
  69589. */
  69590. worldParentNode?: TransformNode;
  69591. }
  69592. /**
  69593. * A babylon interface for a WebXR plane.
  69594. * A Plane is actually a polygon, built from N points in space
  69595. *
  69596. * Supported in chrome 79, not supported in canary 81 ATM
  69597. */
  69598. export interface IWebXRPlane {
  69599. /**
  69600. * a babylon-assigned ID for this polygon
  69601. */
  69602. id: number;
  69603. /**
  69604. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  69605. */
  69606. polygonDefinition: Array<Vector3>;
  69607. /**
  69608. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  69609. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  69610. */
  69611. transformationMatrix: Matrix;
  69612. /**
  69613. * the native xr-plane object
  69614. */
  69615. xrPlane: XRPlane;
  69616. }
  69617. /**
  69618. * The plane detector is used to detect planes in the real world when in AR
  69619. * For more information see https://github.com/immersive-web/real-world-geometry/
  69620. */
  69621. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  69622. private _options;
  69623. private _detectedPlanes;
  69624. private _enabled;
  69625. private _lastFrameDetected;
  69626. /**
  69627. * The module's name
  69628. */
  69629. static readonly Name: string;
  69630. /**
  69631. * The (Babylon) version of this module.
  69632. * This is an integer representing the implementation version.
  69633. * This number does not correspond to the WebXR specs version
  69634. */
  69635. static readonly Version: number;
  69636. /**
  69637. * Observers registered here will be executed when a new plane was added to the session
  69638. */
  69639. onPlaneAddedObservable: Observable<IWebXRPlane>;
  69640. /**
  69641. * Observers registered here will be executed when a plane is no longer detected in the session
  69642. */
  69643. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  69644. /**
  69645. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  69646. * This can execute N times every frame
  69647. */
  69648. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  69649. /**
  69650. * construct a new Plane Detector
  69651. * @param _xrSessionManager an instance of xr Session manager
  69652. * @param _options configuration to use when constructing this feature
  69653. */
  69654. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  69655. /**
  69656. * Dispose this feature and all of the resources attached
  69657. */
  69658. dispose(): void;
  69659. protected _onXRFrame(frame: XRFrame): void;
  69660. private _init;
  69661. private _updatePlaneWithXRPlane;
  69662. /**
  69663. * avoiding using Array.find for global support.
  69664. * @param xrPlane the plane to find in the array
  69665. */
  69666. private findIndexInPlaneArray;
  69667. }
  69668. }
  69669. declare module BABYLON {
  69670. /**
  69671. * Configuration options of the anchor system
  69672. */
  69673. export interface IWebXRAnchorSystemOptions {
  69674. /**
  69675. * Should a new anchor be added every time a select event is triggered
  69676. */
  69677. addAnchorOnSelect?: boolean;
  69678. /**
  69679. * should the anchor system use plane detection.
  69680. * If set to true, the plane-detection feature should be set using setPlaneDetector
  69681. */
  69682. usePlaneDetection?: boolean;
  69683. /**
  69684. * a node that will be used to convert local to world coordinates
  69685. */
  69686. worldParentNode?: TransformNode;
  69687. }
  69688. /**
  69689. * A babylon container for an XR Anchor
  69690. */
  69691. export interface IWebXRAnchor {
  69692. /**
  69693. * A babylon-assigned ID for this anchor
  69694. */
  69695. id: number;
  69696. /**
  69697. * Transformation matrix to apply to an object attached to this anchor
  69698. */
  69699. transformationMatrix: Matrix;
  69700. /**
  69701. * The native anchor object
  69702. */
  69703. xrAnchor: XRAnchor;
  69704. }
  69705. /**
  69706. * An implementation of the anchor system of WebXR.
  69707. * Note that the current documented implementation is not available in any browser. Future implementations
  69708. * will use the frame to create an anchor and not the session or a detected plane
  69709. * For further information see https://github.com/immersive-web/anchors/
  69710. */
  69711. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  69712. private _options;
  69713. private _enabled;
  69714. private _hitTestModule;
  69715. private _lastFrameDetected;
  69716. private _onSelect;
  69717. private _planeDetector;
  69718. private _trackedAnchors;
  69719. /**
  69720. * The module's name
  69721. */
  69722. static readonly Name: string;
  69723. /**
  69724. * The (Babylon) version of this module.
  69725. * This is an integer representing the implementation version.
  69726. * This number does not correspond to the WebXR specs version
  69727. */
  69728. static readonly Version: number;
  69729. /**
  69730. * Observers registered here will be executed when a new anchor was added to the session
  69731. */
  69732. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  69733. /**
  69734. * Observers registered here will be executed when an anchor was removed from the session
  69735. */
  69736. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  69737. /**
  69738. * Observers registered here will be executed when an existing anchor updates
  69739. * This can execute N times every frame
  69740. */
  69741. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  69742. /**
  69743. * constructs a new anchor system
  69744. * @param _xrSessionManager an instance of WebXRSessionManager
  69745. * @param _options configuration object for this feature
  69746. */
  69747. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  69748. /**
  69749. * Add anchor at a specific XR point.
  69750. *
  69751. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  69752. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  69753. * @returns a promise the fulfills when the anchor was created
  69754. */
  69755. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  69756. /**
  69757. * attach this feature
  69758. * Will usually be called by the features manager
  69759. *
  69760. * @returns true if successful.
  69761. */
  69762. attach(): boolean;
  69763. /**
  69764. * detach this feature.
  69765. * Will usually be called by the features manager
  69766. *
  69767. * @returns true if successful.
  69768. */
  69769. detach(): boolean;
  69770. /**
  69771. * Dispose this feature and all of the resources attached
  69772. */
  69773. dispose(): void;
  69774. /**
  69775. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  69776. * @param hitTestModule the hit-test module to use.
  69777. */
  69778. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  69779. /**
  69780. * set the plane detector to use in order to create anchors from frames
  69781. * @param planeDetector the plane-detector module to use
  69782. * @param enable enable plane-anchors. default is true
  69783. */
  69784. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  69785. protected _onXRFrame(frame: XRFrame): void;
  69786. /**
  69787. * avoiding using Array.find for global support.
  69788. * @param xrAnchor the plane to find in the array
  69789. */
  69790. private _findIndexInAnchorArray;
  69791. private _updateAnchorWithXRFrame;
  69792. }
  69793. }
  69794. declare module BABYLON {
  69795. /**
  69796. * Options interface for the background remover plugin
  69797. */
  69798. export interface IWebXRBackgroundRemoverOptions {
  69799. /**
  69800. * Further background meshes to disable when entering AR
  69801. */
  69802. backgroundMeshes?: AbstractMesh[];
  69803. /**
  69804. * flags to configure the removal of the environment helper.
  69805. * If not set, the entire background will be removed. If set, flags should be set as well.
  69806. */
  69807. environmentHelperRemovalFlags?: {
  69808. /**
  69809. * Should the skybox be removed (default false)
  69810. */
  69811. skyBox?: boolean;
  69812. /**
  69813. * Should the ground be removed (default false)
  69814. */
  69815. ground?: boolean;
  69816. };
  69817. /**
  69818. * don't disable the environment helper
  69819. */
  69820. ignoreEnvironmentHelper?: boolean;
  69821. }
  69822. /**
  69823. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  69824. */
  69825. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  69826. /**
  69827. * read-only options to be used in this module
  69828. */
  69829. readonly options: IWebXRBackgroundRemoverOptions;
  69830. /**
  69831. * The module's name
  69832. */
  69833. static readonly Name: string;
  69834. /**
  69835. * The (Babylon) version of this module.
  69836. * This is an integer representing the implementation version.
  69837. * This number does not correspond to the WebXR specs version
  69838. */
  69839. static readonly Version: number;
  69840. /**
  69841. * registered observers will be triggered when the background state changes
  69842. */
  69843. onBackgroundStateChangedObservable: Observable<boolean>;
  69844. /**
  69845. * constructs a new background remover module
  69846. * @param _xrSessionManager the session manager for this module
  69847. * @param options read-only options to be used in this module
  69848. */
  69849. constructor(_xrSessionManager: WebXRSessionManager,
  69850. /**
  69851. * read-only options to be used in this module
  69852. */
  69853. options?: IWebXRBackgroundRemoverOptions);
  69854. /**
  69855. * attach this feature
  69856. * Will usually be called by the features manager
  69857. *
  69858. * @returns true if successful.
  69859. */
  69860. attach(): boolean;
  69861. /**
  69862. * detach this feature.
  69863. * Will usually be called by the features manager
  69864. *
  69865. * @returns true if successful.
  69866. */
  69867. detach(): boolean;
  69868. /**
  69869. * Dispose this feature and all of the resources attached
  69870. */
  69871. dispose(): void;
  69872. protected _onXRFrame(_xrFrame: XRFrame): void;
  69873. private _setBackgroundState;
  69874. }
  69875. }
  69876. declare module BABYLON {
  69877. /**
  69878. * Options for the controller physics feature
  69879. */
  69880. export class IWebXRControllerPhysicsOptions {
  69881. /**
  69882. * Should the headset get its own impostor
  69883. */
  69884. enableHeadsetImpostor?: boolean;
  69885. /**
  69886. * Optional parameters for the headset impostor
  69887. */
  69888. headsetImpostorParams?: {
  69889. /**
  69890. * The type of impostor to create. Default is sphere
  69891. */
  69892. impostorType: number;
  69893. /**
  69894. * the size of the impostor. Defaults to 10cm
  69895. */
  69896. impostorSize?: number | {
  69897. width: number;
  69898. height: number;
  69899. depth: number;
  69900. };
  69901. /**
  69902. * Friction definitions
  69903. */
  69904. friction?: number;
  69905. /**
  69906. * Restitution
  69907. */
  69908. restitution?: number;
  69909. };
  69910. /**
  69911. * The physics properties of the future impostors
  69912. */
  69913. physicsProperties?: {
  69914. /**
  69915. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  69916. * Note that this requires a physics engine that supports mesh impostors!
  69917. */
  69918. useControllerMesh?: boolean;
  69919. /**
  69920. * The type of impostor to create. Default is sphere
  69921. */
  69922. impostorType?: number;
  69923. /**
  69924. * the size of the impostor. Defaults to 10cm
  69925. */
  69926. impostorSize?: number | {
  69927. width: number;
  69928. height: number;
  69929. depth: number;
  69930. };
  69931. /**
  69932. * Friction definitions
  69933. */
  69934. friction?: number;
  69935. /**
  69936. * Restitution
  69937. */
  69938. restitution?: number;
  69939. };
  69940. /**
  69941. * the xr input to use with this pointer selection
  69942. */
  69943. xrInput: WebXRInput;
  69944. }
  69945. /**
  69946. * Add physics impostor to your webxr controllers,
  69947. * including naive calculation of their linear and angular velocity
  69948. */
  69949. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  69950. private readonly _options;
  69951. private _attachController;
  69952. private _controllers;
  69953. private _debugMode;
  69954. private _delta;
  69955. private _headsetImpostor?;
  69956. private _headsetMesh?;
  69957. private _lastTimestamp;
  69958. private _tmpQuaternion;
  69959. private _tmpVector;
  69960. /**
  69961. * The module's name
  69962. */
  69963. static readonly Name: string;
  69964. /**
  69965. * The (Babylon) version of this module.
  69966. * This is an integer representing the implementation version.
  69967. * This number does not correspond to the webxr specs version
  69968. */
  69969. static readonly Version: number;
  69970. /**
  69971. * Construct a new Controller Physics Feature
  69972. * @param _xrSessionManager the corresponding xr session manager
  69973. * @param _options options to create this feature with
  69974. */
  69975. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  69976. /**
  69977. * @hidden
  69978. * enable debugging - will show console outputs and the impostor mesh
  69979. */
  69980. _enablePhysicsDebug(): void;
  69981. /**
  69982. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  69983. * @param xrController the controller to add
  69984. */
  69985. addController(xrController: WebXRInputSource): void;
  69986. /**
  69987. * attach this feature
  69988. * Will usually be called by the features manager
  69989. *
  69990. * @returns true if successful.
  69991. */
  69992. attach(): boolean;
  69993. /**
  69994. * detach this feature.
  69995. * Will usually be called by the features manager
  69996. *
  69997. * @returns true if successful.
  69998. */
  69999. detach(): boolean;
  70000. /**
  70001. * Get the headset impostor, if enabled
  70002. * @returns the impostor
  70003. */
  70004. getHeadsetImpostor(): PhysicsImpostor | undefined;
  70005. /**
  70006. * Get the physics impostor of a specific controller.
  70007. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  70008. * @param controller the controller or the controller id of which to get the impostor
  70009. * @returns the impostor or null
  70010. */
  70011. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  70012. /**
  70013. * Update the physics properties provided in the constructor
  70014. * @param newProperties the new properties object
  70015. */
  70016. setPhysicsProperties(newProperties: {
  70017. impostorType?: number;
  70018. impostorSize?: number | {
  70019. width: number;
  70020. height: number;
  70021. depth: number;
  70022. };
  70023. friction?: number;
  70024. restitution?: number;
  70025. }): void;
  70026. protected _onXRFrame(_xrFrame: any): void;
  70027. private _detachController;
  70028. }
  70029. }
  70030. declare module BABYLON {
  70031. /**
  70032. * Options used for hit testing (version 2)
  70033. */
  70034. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  70035. /**
  70036. * Do not create a permanent hit test. Will usually be used when only
  70037. * transient inputs are needed.
  70038. */
  70039. disablePermanentHitTest?: boolean;
  70040. /**
  70041. * Enable transient (for example touch-based) hit test inspections
  70042. */
  70043. enableTransientHitTest?: boolean;
  70044. /**
  70045. * Offset ray for the permanent hit test
  70046. */
  70047. offsetRay?: Vector3;
  70048. /**
  70049. * Offset ray for the transient hit test
  70050. */
  70051. transientOffsetRay?: Vector3;
  70052. /**
  70053. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  70054. */
  70055. useReferenceSpace?: boolean;
  70056. }
  70057. /**
  70058. * Interface defining the babylon result of hit-test
  70059. */
  70060. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  70061. /**
  70062. * The input source that generated this hit test (if transient)
  70063. */
  70064. inputSource?: XRInputSource;
  70065. /**
  70066. * Is this a transient hit test
  70067. */
  70068. isTransient?: boolean;
  70069. /**
  70070. * Position of the hit test result
  70071. */
  70072. position: Vector3;
  70073. /**
  70074. * Rotation of the hit test result
  70075. */
  70076. rotationQuaternion: Quaternion;
  70077. }
  70078. /**
  70079. * The currently-working hit-test module.
  70080. * Hit test (or Ray-casting) is used to interact with the real world.
  70081. * For further information read here - https://github.com/immersive-web/hit-test
  70082. *
  70083. * Tested on chrome (mobile) 80.
  70084. */
  70085. export class WebXRHitTest extends WebXRAbstractFeature {
  70086. /**
  70087. * options to use when constructing this feature
  70088. */
  70089. readonly options: IWebXRHitTestOptions;
  70090. private _tmpMat;
  70091. private _tmpPos;
  70092. private _tmpQuat;
  70093. private _transientXrHitTestSource;
  70094. private _xrHitTestSource;
  70095. private initHitTestSource;
  70096. /**
  70097. * The module's name
  70098. */
  70099. static readonly Name: string;
  70100. /**
  70101. * The (Babylon) version of this module.
  70102. * This is an integer representing the implementation version.
  70103. * This number does not correspond to the WebXR specs version
  70104. */
  70105. static readonly Version: number;
  70106. /**
  70107. * When set to true, each hit test will have its own position/rotation objects
  70108. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  70109. * the developers will clone them or copy them as they see fit.
  70110. */
  70111. autoCloneTransformation: boolean;
  70112. /**
  70113. * Populated with the last native XR Hit Results
  70114. */
  70115. lastNativeXRHitResults: XRHitResult[];
  70116. /**
  70117. * Triggered when new babylon (transformed) hit test results are available
  70118. */
  70119. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  70120. /**
  70121. * Use this to temporarily pause hit test checks.
  70122. */
  70123. paused: boolean;
  70124. /**
  70125. * Creates a new instance of the hit test feature
  70126. * @param _xrSessionManager an instance of WebXRSessionManager
  70127. * @param options options to use when constructing this feature
  70128. */
  70129. constructor(_xrSessionManager: WebXRSessionManager,
  70130. /**
  70131. * options to use when constructing this feature
  70132. */
  70133. options?: IWebXRHitTestOptions);
  70134. /**
  70135. * attach this feature
  70136. * Will usually be called by the features manager
  70137. *
  70138. * @returns true if successful.
  70139. */
  70140. attach(): boolean;
  70141. /**
  70142. * detach this feature.
  70143. * Will usually be called by the features manager
  70144. *
  70145. * @returns true if successful.
  70146. */
  70147. detach(): boolean;
  70148. /**
  70149. * Dispose this feature and all of the resources attached
  70150. */
  70151. dispose(): void;
  70152. protected _onXRFrame(frame: XRFrame): void;
  70153. private _processWebXRHitTestResult;
  70154. }
  70155. }
  70156. declare module BABYLON {
  70157. /**
  70158. * The motion controller class for all microsoft mixed reality controllers
  70159. */
  70160. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  70161. protected readonly _mapping: {
  70162. defaultButton: {
  70163. valueNodeName: string;
  70164. unpressedNodeName: string;
  70165. pressedNodeName: string;
  70166. };
  70167. defaultAxis: {
  70168. valueNodeName: string;
  70169. minNodeName: string;
  70170. maxNodeName: string;
  70171. };
  70172. buttons: {
  70173. "xr-standard-trigger": {
  70174. rootNodeName: string;
  70175. componentProperty: string;
  70176. states: string[];
  70177. };
  70178. "xr-standard-squeeze": {
  70179. rootNodeName: string;
  70180. componentProperty: string;
  70181. states: string[];
  70182. };
  70183. "xr-standard-touchpad": {
  70184. rootNodeName: string;
  70185. labelAnchorNodeName: string;
  70186. touchPointNodeName: string;
  70187. };
  70188. "xr-standard-thumbstick": {
  70189. rootNodeName: string;
  70190. componentProperty: string;
  70191. states: string[];
  70192. };
  70193. };
  70194. axes: {
  70195. "xr-standard-touchpad": {
  70196. "x-axis": {
  70197. rootNodeName: string;
  70198. };
  70199. "y-axis": {
  70200. rootNodeName: string;
  70201. };
  70202. };
  70203. "xr-standard-thumbstick": {
  70204. "x-axis": {
  70205. rootNodeName: string;
  70206. };
  70207. "y-axis": {
  70208. rootNodeName: string;
  70209. };
  70210. };
  70211. };
  70212. };
  70213. /**
  70214. * The base url used to load the left and right controller models
  70215. */
  70216. static MODEL_BASE_URL: string;
  70217. /**
  70218. * The name of the left controller model file
  70219. */
  70220. static MODEL_LEFT_FILENAME: string;
  70221. /**
  70222. * The name of the right controller model file
  70223. */
  70224. static MODEL_RIGHT_FILENAME: string;
  70225. profileId: string;
  70226. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70227. protected _getFilenameAndPath(): {
  70228. filename: string;
  70229. path: string;
  70230. };
  70231. protected _getModelLoadingConstraints(): boolean;
  70232. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70233. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70234. protected _updateModel(): void;
  70235. }
  70236. }
  70237. declare module BABYLON {
  70238. /**
  70239. * The motion controller class for oculus touch (quest, rift).
  70240. * This class supports legacy mapping as well the standard xr mapping
  70241. */
  70242. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  70243. private _forceLegacyControllers;
  70244. private _modelRootNode;
  70245. /**
  70246. * The base url used to load the left and right controller models
  70247. */
  70248. static MODEL_BASE_URL: string;
  70249. /**
  70250. * The name of the left controller model file
  70251. */
  70252. static MODEL_LEFT_FILENAME: string;
  70253. /**
  70254. * The name of the right controller model file
  70255. */
  70256. static MODEL_RIGHT_FILENAME: string;
  70257. /**
  70258. * Base Url for the Quest controller model.
  70259. */
  70260. static QUEST_MODEL_BASE_URL: string;
  70261. profileId: string;
  70262. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  70263. protected _getFilenameAndPath(): {
  70264. filename: string;
  70265. path: string;
  70266. };
  70267. protected _getModelLoadingConstraints(): boolean;
  70268. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70269. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70270. protected _updateModel(): void;
  70271. /**
  70272. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  70273. * between the touch and touch 2.
  70274. */
  70275. private _isQuest;
  70276. }
  70277. }
  70278. declare module BABYLON {
  70279. /**
  70280. * The motion controller class for the standard HTC-Vive controllers
  70281. */
  70282. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  70283. private _modelRootNode;
  70284. /**
  70285. * The base url used to load the left and right controller models
  70286. */
  70287. static MODEL_BASE_URL: string;
  70288. /**
  70289. * File name for the controller model.
  70290. */
  70291. static MODEL_FILENAME: string;
  70292. profileId: string;
  70293. /**
  70294. * Create a new Vive motion controller object
  70295. * @param scene the scene to use to create this controller
  70296. * @param gamepadObject the corresponding gamepad object
  70297. * @param handness the handness of the controller
  70298. */
  70299. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70300. protected _getFilenameAndPath(): {
  70301. filename: string;
  70302. path: string;
  70303. };
  70304. protected _getModelLoadingConstraints(): boolean;
  70305. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70306. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70307. protected _updateModel(): void;
  70308. }
  70309. }
  70310. declare module BABYLON {
  70311. /**
  70312. * A cursor which tracks a point on a path
  70313. */
  70314. export class PathCursor {
  70315. private path;
  70316. /**
  70317. * Stores path cursor callbacks for when an onchange event is triggered
  70318. */
  70319. private _onchange;
  70320. /**
  70321. * The value of the path cursor
  70322. */
  70323. value: number;
  70324. /**
  70325. * The animation array of the path cursor
  70326. */
  70327. animations: Animation[];
  70328. /**
  70329. * Initializes the path cursor
  70330. * @param path The path to track
  70331. */
  70332. constructor(path: Path2);
  70333. /**
  70334. * Gets the cursor point on the path
  70335. * @returns A point on the path cursor at the cursor location
  70336. */
  70337. getPoint(): Vector3;
  70338. /**
  70339. * Moves the cursor ahead by the step amount
  70340. * @param step The amount to move the cursor forward
  70341. * @returns This path cursor
  70342. */
  70343. moveAhead(step?: number): PathCursor;
  70344. /**
  70345. * Moves the cursor behind by the step amount
  70346. * @param step The amount to move the cursor back
  70347. * @returns This path cursor
  70348. */
  70349. moveBack(step?: number): PathCursor;
  70350. /**
  70351. * Moves the cursor by the step amount
  70352. * If the step amount is greater than one, an exception is thrown
  70353. * @param step The amount to move the cursor
  70354. * @returns This path cursor
  70355. */
  70356. move(step: number): PathCursor;
  70357. /**
  70358. * Ensures that the value is limited between zero and one
  70359. * @returns This path cursor
  70360. */
  70361. private ensureLimits;
  70362. /**
  70363. * Runs onchange callbacks on change (used by the animation engine)
  70364. * @returns This path cursor
  70365. */
  70366. private raiseOnChange;
  70367. /**
  70368. * Executes a function on change
  70369. * @param f A path cursor onchange callback
  70370. * @returns This path cursor
  70371. */
  70372. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70373. }
  70374. }
  70375. declare module BABYLON {
  70376. /** @hidden */
  70377. export var blurPixelShader: {
  70378. name: string;
  70379. shader: string;
  70380. };
  70381. }
  70382. declare module BABYLON {
  70383. /** @hidden */
  70384. export var pointCloudVertexDeclaration: {
  70385. name: string;
  70386. shader: string;
  70387. };
  70388. }
  70389. // Mixins
  70390. interface Window {
  70391. mozIndexedDB: IDBFactory;
  70392. webkitIndexedDB: IDBFactory;
  70393. msIndexedDB: IDBFactory;
  70394. webkitURL: typeof URL;
  70395. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  70396. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  70397. WebGLRenderingContext: WebGLRenderingContext;
  70398. MSGesture: MSGesture;
  70399. CANNON: any;
  70400. AudioContext: AudioContext;
  70401. webkitAudioContext: AudioContext;
  70402. PointerEvent: any;
  70403. Math: Math;
  70404. Uint8Array: Uint8ArrayConstructor;
  70405. Float32Array: Float32ArrayConstructor;
  70406. mozURL: typeof URL;
  70407. msURL: typeof URL;
  70408. VRFrameData: any; // WebVR, from specs 1.1
  70409. DracoDecoderModule: any;
  70410. setImmediate(handler: (...args: any[]) => void): number;
  70411. }
  70412. interface HTMLCanvasElement {
  70413. requestPointerLock(): void;
  70414. msRequestPointerLock?(): void;
  70415. mozRequestPointerLock?(): void;
  70416. webkitRequestPointerLock?(): void;
  70417. /** Track wether a record is in progress */
  70418. isRecording: boolean;
  70419. /** Capture Stream method defined by some browsers */
  70420. captureStream(fps?: number): MediaStream;
  70421. }
  70422. interface CanvasRenderingContext2D {
  70423. msImageSmoothingEnabled: boolean;
  70424. }
  70425. interface MouseEvent {
  70426. mozMovementX: number;
  70427. mozMovementY: number;
  70428. webkitMovementX: number;
  70429. webkitMovementY: number;
  70430. msMovementX: number;
  70431. msMovementY: number;
  70432. }
  70433. interface Navigator {
  70434. mozGetVRDevices: (any: any) => any;
  70435. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70436. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70437. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70438. webkitGetGamepads(): Gamepad[];
  70439. msGetGamepads(): Gamepad[];
  70440. webkitGamepads(): Gamepad[];
  70441. }
  70442. interface HTMLVideoElement {
  70443. mozSrcObject: any;
  70444. }
  70445. interface Math {
  70446. fround(x: number): number;
  70447. imul(a: number, b: number): number;
  70448. }
  70449. interface WebGLRenderingContext {
  70450. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  70451. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  70452. vertexAttribDivisor(index: number, divisor: number): void;
  70453. createVertexArray(): any;
  70454. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  70455. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  70456. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  70457. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  70458. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  70459. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  70460. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  70461. // Queries
  70462. createQuery(): WebGLQuery;
  70463. deleteQuery(query: WebGLQuery): void;
  70464. beginQuery(target: number, query: WebGLQuery): void;
  70465. endQuery(target: number): void;
  70466. getQueryParameter(query: WebGLQuery, pname: number): any;
  70467. getQuery(target: number, pname: number): any;
  70468. MAX_SAMPLES: number;
  70469. RGBA8: number;
  70470. READ_FRAMEBUFFER: number;
  70471. DRAW_FRAMEBUFFER: number;
  70472. UNIFORM_BUFFER: number;
  70473. HALF_FLOAT_OES: number;
  70474. RGBA16F: number;
  70475. RGBA32F: number;
  70476. R32F: number;
  70477. RG32F: number;
  70478. RGB32F: number;
  70479. R16F: number;
  70480. RG16F: number;
  70481. RGB16F: number;
  70482. RED: number;
  70483. RG: number;
  70484. R8: number;
  70485. RG8: number;
  70486. UNSIGNED_INT_24_8: number;
  70487. DEPTH24_STENCIL8: number;
  70488. MIN: number;
  70489. MAX: number;
  70490. /* Multiple Render Targets */
  70491. drawBuffers(buffers: number[]): void;
  70492. readBuffer(src: number): void;
  70493. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  70494. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  70495. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  70496. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  70497. // Occlusion Query
  70498. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  70499. ANY_SAMPLES_PASSED: number;
  70500. QUERY_RESULT_AVAILABLE: number;
  70501. QUERY_RESULT: number;
  70502. }
  70503. interface WebGLProgram {
  70504. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  70505. }
  70506. interface EXT_disjoint_timer_query {
  70507. QUERY_COUNTER_BITS_EXT: number;
  70508. TIME_ELAPSED_EXT: number;
  70509. TIMESTAMP_EXT: number;
  70510. GPU_DISJOINT_EXT: number;
  70511. QUERY_RESULT_EXT: number;
  70512. QUERY_RESULT_AVAILABLE_EXT: number;
  70513. queryCounterEXT(query: WebGLQuery, target: number): void;
  70514. createQueryEXT(): WebGLQuery;
  70515. beginQueryEXT(target: number, query: WebGLQuery): void;
  70516. endQueryEXT(target: number): void;
  70517. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  70518. deleteQueryEXT(query: WebGLQuery): void;
  70519. }
  70520. interface WebGLUniformLocation {
  70521. _currentState: any;
  70522. }
  70523. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  70524. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  70525. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  70526. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70527. interface WebGLRenderingContext {
  70528. readonly RASTERIZER_DISCARD: number;
  70529. readonly DEPTH_COMPONENT24: number;
  70530. readonly TEXTURE_3D: number;
  70531. readonly TEXTURE_2D_ARRAY: number;
  70532. readonly TEXTURE_COMPARE_FUNC: number;
  70533. readonly TEXTURE_COMPARE_MODE: number;
  70534. readonly COMPARE_REF_TO_TEXTURE: number;
  70535. readonly TEXTURE_WRAP_R: number;
  70536. readonly HALF_FLOAT: number;
  70537. readonly RGB8: number;
  70538. readonly RED_INTEGER: number;
  70539. readonly RG_INTEGER: number;
  70540. readonly RGB_INTEGER: number;
  70541. readonly RGBA_INTEGER: number;
  70542. readonly R8_SNORM: number;
  70543. readonly RG8_SNORM: number;
  70544. readonly RGB8_SNORM: number;
  70545. readonly RGBA8_SNORM: number;
  70546. readonly R8I: number;
  70547. readonly RG8I: number;
  70548. readonly RGB8I: number;
  70549. readonly RGBA8I: number;
  70550. readonly R8UI: number;
  70551. readonly RG8UI: number;
  70552. readonly RGB8UI: number;
  70553. readonly RGBA8UI: number;
  70554. readonly R16I: number;
  70555. readonly RG16I: number;
  70556. readonly RGB16I: number;
  70557. readonly RGBA16I: number;
  70558. readonly R16UI: number;
  70559. readonly RG16UI: number;
  70560. readonly RGB16UI: number;
  70561. readonly RGBA16UI: number;
  70562. readonly R32I: number;
  70563. readonly RG32I: number;
  70564. readonly RGB32I: number;
  70565. readonly RGBA32I: number;
  70566. readonly R32UI: number;
  70567. readonly RG32UI: number;
  70568. readonly RGB32UI: number;
  70569. readonly RGBA32UI: number;
  70570. readonly RGB10_A2UI: number;
  70571. readonly R11F_G11F_B10F: number;
  70572. readonly RGB9_E5: number;
  70573. readonly RGB10_A2: number;
  70574. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  70575. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  70576. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  70577. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70578. readonly DEPTH_COMPONENT32F: number;
  70579. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  70580. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  70581. 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;
  70582. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  70583. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  70584. readonly TRANSFORM_FEEDBACK: number;
  70585. readonly INTERLEAVED_ATTRIBS: number;
  70586. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  70587. createTransformFeedback(): WebGLTransformFeedback;
  70588. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  70589. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  70590. beginTransformFeedback(primitiveMode: number): void;
  70591. endTransformFeedback(): void;
  70592. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  70593. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70594. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70595. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70596. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  70597. }
  70598. interface ImageBitmap {
  70599. readonly width: number;
  70600. readonly height: number;
  70601. close(): void;
  70602. }
  70603. interface WebGLQuery extends WebGLObject {
  70604. }
  70605. declare var WebGLQuery: {
  70606. prototype: WebGLQuery;
  70607. new(): WebGLQuery;
  70608. };
  70609. interface WebGLSampler extends WebGLObject {
  70610. }
  70611. declare var WebGLSampler: {
  70612. prototype: WebGLSampler;
  70613. new(): WebGLSampler;
  70614. };
  70615. interface WebGLSync extends WebGLObject {
  70616. }
  70617. declare var WebGLSync: {
  70618. prototype: WebGLSync;
  70619. new(): WebGLSync;
  70620. };
  70621. interface WebGLTransformFeedback extends WebGLObject {
  70622. }
  70623. declare var WebGLTransformFeedback: {
  70624. prototype: WebGLTransformFeedback;
  70625. new(): WebGLTransformFeedback;
  70626. };
  70627. interface WebGLVertexArrayObject extends WebGLObject {
  70628. }
  70629. declare var WebGLVertexArrayObject: {
  70630. prototype: WebGLVertexArrayObject;
  70631. new(): WebGLVertexArrayObject;
  70632. };
  70633. // Type definitions for WebVR API
  70634. // Project: https://w3c.github.io/webvr/
  70635. // Definitions by: six a <https://github.com/lostfictions>
  70636. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70637. interface VRDisplay extends EventTarget {
  70638. /**
  70639. * Dictionary of capabilities describing the VRDisplay.
  70640. */
  70641. readonly capabilities: VRDisplayCapabilities;
  70642. /**
  70643. * z-depth defining the far plane of the eye view frustum
  70644. * enables mapping of values in the render target depth
  70645. * attachment to scene coordinates. Initially set to 10000.0.
  70646. */
  70647. depthFar: number;
  70648. /**
  70649. * z-depth defining the near plane of the eye view frustum
  70650. * enables mapping of values in the render target depth
  70651. * attachment to scene coordinates. Initially set to 0.01.
  70652. */
  70653. depthNear: number;
  70654. /**
  70655. * An identifier for this distinct VRDisplay. Used as an
  70656. * association point in the Gamepad API.
  70657. */
  70658. readonly displayId: number;
  70659. /**
  70660. * A display name, a user-readable name identifying it.
  70661. */
  70662. readonly displayName: string;
  70663. readonly isConnected: boolean;
  70664. readonly isPresenting: boolean;
  70665. /**
  70666. * If this VRDisplay supports room-scale experiences, the optional
  70667. * stage attribute contains details on the room-scale parameters.
  70668. */
  70669. readonly stageParameters: VRStageParameters | null;
  70670. /**
  70671. * Passing the value returned by `requestAnimationFrame` to
  70672. * `cancelAnimationFrame` will unregister the callback.
  70673. * @param handle Define the hanle of the request to cancel
  70674. */
  70675. cancelAnimationFrame(handle: number): void;
  70676. /**
  70677. * Stops presenting to the VRDisplay.
  70678. * @returns a promise to know when it stopped
  70679. */
  70680. exitPresent(): Promise<void>;
  70681. /**
  70682. * Return the current VREyeParameters for the given eye.
  70683. * @param whichEye Define the eye we want the parameter for
  70684. * @returns the eye parameters
  70685. */
  70686. getEyeParameters(whichEye: string): VREyeParameters;
  70687. /**
  70688. * Populates the passed VRFrameData with the information required to render
  70689. * the current frame.
  70690. * @param frameData Define the data structure to populate
  70691. * @returns true if ok otherwise false
  70692. */
  70693. getFrameData(frameData: VRFrameData): boolean;
  70694. /**
  70695. * Get the layers currently being presented.
  70696. * @returns the list of VR layers
  70697. */
  70698. getLayers(): VRLayer[];
  70699. /**
  70700. * Return a VRPose containing the future predicted pose of the VRDisplay
  70701. * when the current frame will be presented. The value returned will not
  70702. * change until JavaScript has returned control to the browser.
  70703. *
  70704. * The VRPose will contain the position, orientation, velocity,
  70705. * and acceleration of each of these properties.
  70706. * @returns the pose object
  70707. */
  70708. getPose(): VRPose;
  70709. /**
  70710. * Return the current instantaneous pose of the VRDisplay, with no
  70711. * prediction applied.
  70712. * @returns the current instantaneous pose
  70713. */
  70714. getImmediatePose(): VRPose;
  70715. /**
  70716. * The callback passed to `requestAnimationFrame` will be called
  70717. * any time a new frame should be rendered. When the VRDisplay is
  70718. * presenting the callback will be called at the native refresh
  70719. * rate of the HMD. When not presenting this function acts
  70720. * identically to how window.requestAnimationFrame acts. Content should
  70721. * make no assumptions of frame rate or vsync behavior as the HMD runs
  70722. * asynchronously from other displays and at differing refresh rates.
  70723. * @param callback Define the eaction to run next frame
  70724. * @returns the request handle it
  70725. */
  70726. requestAnimationFrame(callback: FrameRequestCallback): number;
  70727. /**
  70728. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  70729. * Repeat calls while already presenting will update the VRLayers being displayed.
  70730. * @param layers Define the list of layer to present
  70731. * @returns a promise to know when the request has been fulfilled
  70732. */
  70733. requestPresent(layers: VRLayer[]): Promise<void>;
  70734. /**
  70735. * Reset the pose for this display, treating its current position and
  70736. * orientation as the "origin/zero" values. VRPose.position,
  70737. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  70738. * updated when calling resetPose(). This should be called in only
  70739. * sitting-space experiences.
  70740. */
  70741. resetPose(): void;
  70742. /**
  70743. * The VRLayer provided to the VRDisplay will be captured and presented
  70744. * in the HMD. Calling this function has the same effect on the source
  70745. * canvas as any other operation that uses its source image, and canvases
  70746. * created without preserveDrawingBuffer set to true will be cleared.
  70747. * @param pose Define the pose to submit
  70748. */
  70749. submitFrame(pose?: VRPose): void;
  70750. }
  70751. declare var VRDisplay: {
  70752. prototype: VRDisplay;
  70753. new(): VRDisplay;
  70754. };
  70755. interface VRLayer {
  70756. leftBounds?: number[] | Float32Array | null;
  70757. rightBounds?: number[] | Float32Array | null;
  70758. source?: HTMLCanvasElement | null;
  70759. }
  70760. interface VRDisplayCapabilities {
  70761. readonly canPresent: boolean;
  70762. readonly hasExternalDisplay: boolean;
  70763. readonly hasOrientation: boolean;
  70764. readonly hasPosition: boolean;
  70765. readonly maxLayers: number;
  70766. }
  70767. interface VREyeParameters {
  70768. /** @deprecated */
  70769. readonly fieldOfView: VRFieldOfView;
  70770. readonly offset: Float32Array;
  70771. readonly renderHeight: number;
  70772. readonly renderWidth: number;
  70773. }
  70774. interface VRFieldOfView {
  70775. readonly downDegrees: number;
  70776. readonly leftDegrees: number;
  70777. readonly rightDegrees: number;
  70778. readonly upDegrees: number;
  70779. }
  70780. interface VRFrameData {
  70781. readonly leftProjectionMatrix: Float32Array;
  70782. readonly leftViewMatrix: Float32Array;
  70783. readonly pose: VRPose;
  70784. readonly rightProjectionMatrix: Float32Array;
  70785. readonly rightViewMatrix: Float32Array;
  70786. readonly timestamp: number;
  70787. }
  70788. interface VRPose {
  70789. readonly angularAcceleration: Float32Array | null;
  70790. readonly angularVelocity: Float32Array | null;
  70791. readonly linearAcceleration: Float32Array | null;
  70792. readonly linearVelocity: Float32Array | null;
  70793. readonly orientation: Float32Array | null;
  70794. readonly position: Float32Array | null;
  70795. readonly timestamp: number;
  70796. }
  70797. interface VRStageParameters {
  70798. sittingToStandingTransform?: Float32Array;
  70799. sizeX?: number;
  70800. sizeY?: number;
  70801. }
  70802. interface Navigator {
  70803. getVRDisplays(): Promise<VRDisplay[]>;
  70804. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  70805. }
  70806. interface Window {
  70807. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  70808. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  70809. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  70810. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70811. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70812. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  70813. }
  70814. interface Gamepad {
  70815. readonly displayId: number;
  70816. }
  70817. type XRSessionMode =
  70818. | "inline"
  70819. | "immersive-vr"
  70820. | "immersive-ar";
  70821. type XRReferenceSpaceType =
  70822. | "viewer"
  70823. | "local"
  70824. | "local-floor"
  70825. | "bounded-floor"
  70826. | "unbounded";
  70827. type XREnvironmentBlendMode =
  70828. | "opaque"
  70829. | "additive"
  70830. | "alpha-blend";
  70831. type XRVisibilityState =
  70832. | "visible"
  70833. | "visible-blurred"
  70834. | "hidden";
  70835. type XRHandedness =
  70836. | "none"
  70837. | "left"
  70838. | "right";
  70839. type XRTargetRayMode =
  70840. | "gaze"
  70841. | "tracked-pointer"
  70842. | "screen";
  70843. type XREye =
  70844. | "none"
  70845. | "left"
  70846. | "right";
  70847. interface XRSpace extends EventTarget {
  70848. }
  70849. interface XRRenderState {
  70850. depthNear?: number;
  70851. depthFar?: number;
  70852. inlineVerticalFieldOfView?: number;
  70853. baseLayer?: XRWebGLLayer;
  70854. }
  70855. interface XRInputSource {
  70856. handedness: XRHandedness;
  70857. targetRayMode: XRTargetRayMode;
  70858. targetRaySpace: XRSpace;
  70859. gripSpace: XRSpace | undefined;
  70860. gamepad: Gamepad | undefined;
  70861. profiles: Array<string>;
  70862. }
  70863. interface XRSessionInit {
  70864. optionalFeatures?: XRReferenceSpaceType[];
  70865. requiredFeatures?: XRReferenceSpaceType[];
  70866. }
  70867. interface XRSession extends XRAnchorCreator {
  70868. addEventListener: Function;
  70869. removeEventListener: Function;
  70870. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  70871. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  70872. requestAnimationFrame: Function;
  70873. end(): Promise<void>;
  70874. renderState: XRRenderState;
  70875. inputSources: Array<XRInputSource>;
  70876. // hit test
  70877. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  70878. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  70879. // legacy AR hit test
  70880. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  70881. // legacy plane detection
  70882. updateWorldTrackingState(options: {
  70883. planeDetectionState?: { enabled: boolean; }
  70884. }): void;
  70885. }
  70886. interface XRReferenceSpace extends XRSpace {
  70887. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  70888. onreset: any;
  70889. }
  70890. type XRPlaneSet = Set<XRPlane>;
  70891. type XRAnchorSet = Set<XRAnchor>;
  70892. interface XRFrame {
  70893. session: XRSession;
  70894. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  70895. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  70896. // AR
  70897. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  70898. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  70899. // Anchors
  70900. trackedAnchors?: XRAnchorSet;
  70901. // Planes
  70902. worldInformation: {
  70903. detectedPlanes?: XRPlaneSet;
  70904. };
  70905. }
  70906. interface XRViewerPose extends XRPose {
  70907. views: Array<XRView>;
  70908. }
  70909. interface XRPose {
  70910. transform: XRRigidTransform;
  70911. emulatedPosition: boolean;
  70912. }
  70913. interface XRWebGLLayerOptions {
  70914. antialias?: boolean;
  70915. depth?: boolean;
  70916. stencil?: boolean;
  70917. alpha?: boolean;
  70918. multiview?: boolean;
  70919. framebufferScaleFactor?: number;
  70920. }
  70921. declare var XRWebGLLayer: {
  70922. prototype: XRWebGLLayer;
  70923. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  70924. };
  70925. interface XRWebGLLayer {
  70926. framebuffer: WebGLFramebuffer;
  70927. framebufferWidth: number;
  70928. framebufferHeight: number;
  70929. getViewport: Function;
  70930. }
  70931. declare class XRRigidTransform {
  70932. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  70933. position: DOMPointReadOnly;
  70934. orientation: DOMPointReadOnly;
  70935. matrix: Float32Array;
  70936. inverse: XRRigidTransform;
  70937. }
  70938. interface XRView {
  70939. eye: XREye;
  70940. projectionMatrix: Float32Array;
  70941. transform: XRRigidTransform;
  70942. }
  70943. interface XRInputSourceChangeEvent {
  70944. session: XRSession;
  70945. removed: Array<XRInputSource>;
  70946. added: Array<XRInputSource>;
  70947. }
  70948. interface XRInputSourceEvent extends Event {
  70949. readonly frame: XRFrame;
  70950. readonly inputSource: XRInputSource;
  70951. }
  70952. // Experimental(er) features
  70953. declare class XRRay {
  70954. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  70955. origin: DOMPointReadOnly;
  70956. direction: DOMPointReadOnly;
  70957. matrix: Float32Array;
  70958. }
  70959. declare enum XRHitTestTrackableType {
  70960. "point",
  70961. "plane"
  70962. }
  70963. interface XRHitResult {
  70964. hitMatrix: Float32Array;
  70965. }
  70966. interface XRTransientInputHitTestResult {
  70967. readonly inputSource: XRInputSource;
  70968. readonly results: Array<XRHitTestResult>;
  70969. }
  70970. interface XRHitTestResult {
  70971. getPose(baseSpace: XRSpace): XRPose | undefined;
  70972. }
  70973. interface XRHitTestSource {
  70974. cancel(): void;
  70975. }
  70976. interface XRTransientInputHitTestSource {
  70977. cancel(): void;
  70978. }
  70979. interface XRHitTestOptionsInit {
  70980. space: XRSpace;
  70981. entityTypes?: Array<XRHitTestTrackableType>;
  70982. offsetRay?: XRRay;
  70983. }
  70984. interface XRTransientInputHitTestOptionsInit {
  70985. profile: string;
  70986. entityTypes?: Array<XRHitTestTrackableType>;
  70987. offsetRay?: XRRay;
  70988. }
  70989. interface XRAnchor {
  70990. // remove?
  70991. id?: string;
  70992. anchorSpace: XRSpace;
  70993. lastChangedTime: number;
  70994. detach(): void;
  70995. }
  70996. interface XRPlane extends XRAnchorCreator {
  70997. orientation: "Horizontal" | "Vertical";
  70998. planeSpace: XRSpace;
  70999. polygon: Array<DOMPointReadOnly>;
  71000. lastChangedTime: number;
  71001. }
  71002. interface XRAnchorCreator {
  71003. // AR Anchors
  71004. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  71005. }
  71006. /**
  71007. * @ignore
  71008. */
  71009. declare module BABYLON.GLTF2.Exporter {
  71010. }
  71011. /**
  71012. * @ignore
  71013. */
  71014. declare module BABYLON.GLTF1 {
  71015. }
  71016. declare module BABYLON.GUI {
  71017. /**
  71018. * Class used to specific a value and its associated unit
  71019. */
  71020. export class ValueAndUnit {
  71021. /** defines the unit to store */
  71022. unit: number;
  71023. /** defines a boolean indicating if the value can be negative */
  71024. negativeValueAllowed: boolean;
  71025. private _value;
  71026. private _originalUnit;
  71027. /**
  71028. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  71029. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71030. */
  71031. ignoreAdaptiveScaling: boolean;
  71032. /**
  71033. * Creates a new ValueAndUnit
  71034. * @param value defines the value to store
  71035. * @param unit defines the unit to store
  71036. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  71037. */
  71038. constructor(value: number,
  71039. /** defines the unit to store */
  71040. unit?: number,
  71041. /** defines a boolean indicating if the value can be negative */
  71042. negativeValueAllowed?: boolean);
  71043. /** Gets a boolean indicating if the value is a percentage */
  71044. get isPercentage(): boolean;
  71045. /** Gets a boolean indicating if the value is store as pixel */
  71046. get isPixel(): boolean;
  71047. /** Gets direct internal value */
  71048. get internalValue(): number;
  71049. /**
  71050. * Gets value as pixel
  71051. * @param host defines the root host
  71052. * @param refValue defines the reference value for percentages
  71053. * @returns the value as pixel
  71054. */
  71055. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  71056. /**
  71057. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  71058. * @param value defines the value to store
  71059. * @param unit defines the unit to store
  71060. * @returns the current ValueAndUnit
  71061. */
  71062. updateInPlace(value: number, unit?: number): ValueAndUnit;
  71063. /**
  71064. * Gets the value accordingly to its unit
  71065. * @param host defines the root host
  71066. * @returns the value
  71067. */
  71068. getValue(host: AdvancedDynamicTexture): number;
  71069. /**
  71070. * Gets a string representation of the value
  71071. * @param host defines the root host
  71072. * @param decimals defines an optional number of decimals to display
  71073. * @returns a string
  71074. */
  71075. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  71076. /**
  71077. * Store a value parsed from a string
  71078. * @param source defines the source string
  71079. * @returns true if the value was successfully parsed
  71080. */
  71081. fromString(source: string | number): boolean;
  71082. private static _Regex;
  71083. private static _UNITMODE_PERCENTAGE;
  71084. private static _UNITMODE_PIXEL;
  71085. /** UNITMODE_PERCENTAGE */
  71086. static get UNITMODE_PERCENTAGE(): number;
  71087. /** UNITMODE_PIXEL */
  71088. static get UNITMODE_PIXEL(): number;
  71089. }
  71090. }
  71091. declare module BABYLON.GUI {
  71092. /**
  71093. * Define a style used by control to automatically setup properties based on a template.
  71094. * Only support font related properties so far
  71095. */
  71096. export class Style implements BABYLON.IDisposable {
  71097. private _fontFamily;
  71098. private _fontStyle;
  71099. private _fontWeight;
  71100. /** @hidden */
  71101. _host: AdvancedDynamicTexture;
  71102. /** @hidden */
  71103. _fontSize: ValueAndUnit;
  71104. /**
  71105. * BABYLON.Observable raised when the style values are changed
  71106. */
  71107. onChangedObservable: BABYLON.Observable<Style>;
  71108. /**
  71109. * Creates a new style object
  71110. * @param host defines the AdvancedDynamicTexture which hosts this style
  71111. */
  71112. constructor(host: AdvancedDynamicTexture);
  71113. /**
  71114. * Gets or sets the font size
  71115. */
  71116. get fontSize(): string | number;
  71117. set fontSize(value: string | number);
  71118. /**
  71119. * Gets or sets the font family
  71120. */
  71121. get fontFamily(): string;
  71122. set fontFamily(value: string);
  71123. /**
  71124. * Gets or sets the font style
  71125. */
  71126. get fontStyle(): string;
  71127. set fontStyle(value: string);
  71128. /** Gets or sets font weight */
  71129. get fontWeight(): string;
  71130. set fontWeight(value: string);
  71131. /** Dispose all associated resources */
  71132. dispose(): void;
  71133. }
  71134. }
  71135. declare module BABYLON.GUI {
  71136. /**
  71137. * Class used to transport BABYLON.Vector2 information for pointer events
  71138. */
  71139. export class Vector2WithInfo extends BABYLON.Vector2 {
  71140. /** defines the current mouse button index */
  71141. buttonIndex: number;
  71142. /**
  71143. * Creates a new Vector2WithInfo
  71144. * @param source defines the vector2 data to transport
  71145. * @param buttonIndex defines the current mouse button index
  71146. */
  71147. constructor(source: BABYLON.Vector2,
  71148. /** defines the current mouse button index */
  71149. buttonIndex?: number);
  71150. }
  71151. /** Class used to provide 2D matrix features */
  71152. export class Matrix2D {
  71153. /** Gets the internal array of 6 floats used to store matrix data */
  71154. m: Float32Array;
  71155. /**
  71156. * Creates a new matrix
  71157. * @param m00 defines value for (0, 0)
  71158. * @param m01 defines value for (0, 1)
  71159. * @param m10 defines value for (1, 0)
  71160. * @param m11 defines value for (1, 1)
  71161. * @param m20 defines value for (2, 0)
  71162. * @param m21 defines value for (2, 1)
  71163. */
  71164. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  71165. /**
  71166. * Fills the matrix from direct values
  71167. * @param m00 defines value for (0, 0)
  71168. * @param m01 defines value for (0, 1)
  71169. * @param m10 defines value for (1, 0)
  71170. * @param m11 defines value for (1, 1)
  71171. * @param m20 defines value for (2, 0)
  71172. * @param m21 defines value for (2, 1)
  71173. * @returns the current modified matrix
  71174. */
  71175. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  71176. /**
  71177. * Gets matrix determinant
  71178. * @returns the determinant
  71179. */
  71180. determinant(): number;
  71181. /**
  71182. * Inverses the matrix and stores it in a target matrix
  71183. * @param result defines the target matrix
  71184. * @returns the current matrix
  71185. */
  71186. invertToRef(result: Matrix2D): Matrix2D;
  71187. /**
  71188. * Multiplies the current matrix with another one
  71189. * @param other defines the second operand
  71190. * @param result defines the target matrix
  71191. * @returns the current matrix
  71192. */
  71193. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  71194. /**
  71195. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  71196. * @param x defines the x coordinate to transform
  71197. * @param y defines the x coordinate to transform
  71198. * @param result defines the target vector2
  71199. * @returns the current matrix
  71200. */
  71201. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  71202. /**
  71203. * Creates an identity matrix
  71204. * @returns a new matrix
  71205. */
  71206. static Identity(): Matrix2D;
  71207. /**
  71208. * Creates a translation matrix and stores it in a target matrix
  71209. * @param x defines the x coordinate of the translation
  71210. * @param y defines the y coordinate of the translation
  71211. * @param result defines the target matrix
  71212. */
  71213. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  71214. /**
  71215. * Creates a scaling matrix and stores it in a target matrix
  71216. * @param x defines the x coordinate of the scaling
  71217. * @param y defines the y coordinate of the scaling
  71218. * @param result defines the target matrix
  71219. */
  71220. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  71221. /**
  71222. * Creates a rotation matrix and stores it in a target matrix
  71223. * @param angle defines the rotation angle
  71224. * @param result defines the target matrix
  71225. */
  71226. static RotationToRef(angle: number, result: Matrix2D): void;
  71227. private static _TempPreTranslationMatrix;
  71228. private static _TempPostTranslationMatrix;
  71229. private static _TempRotationMatrix;
  71230. private static _TempScalingMatrix;
  71231. private static _TempCompose0;
  71232. private static _TempCompose1;
  71233. private static _TempCompose2;
  71234. /**
  71235. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  71236. * @param tx defines the x coordinate of the translation
  71237. * @param ty defines the y coordinate of the translation
  71238. * @param angle defines the rotation angle
  71239. * @param scaleX defines the x coordinate of the scaling
  71240. * @param scaleY defines the y coordinate of the scaling
  71241. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  71242. * @param result defines the target matrix
  71243. */
  71244. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  71245. }
  71246. }
  71247. declare module BABYLON.GUI {
  71248. /**
  71249. * Class used to store 2D control sizes
  71250. */
  71251. export class Measure {
  71252. /** defines left coordinate */
  71253. left: number;
  71254. /** defines top coordinate */
  71255. top: number;
  71256. /** defines width dimension */
  71257. width: number;
  71258. /** defines height dimension */
  71259. height: number;
  71260. /**
  71261. * Creates a new measure
  71262. * @param left defines left coordinate
  71263. * @param top defines top coordinate
  71264. * @param width defines width dimension
  71265. * @param height defines height dimension
  71266. */
  71267. constructor(
  71268. /** defines left coordinate */
  71269. left: number,
  71270. /** defines top coordinate */
  71271. top: number,
  71272. /** defines width dimension */
  71273. width: number,
  71274. /** defines height dimension */
  71275. height: number);
  71276. /**
  71277. * Copy from another measure
  71278. * @param other defines the other measure to copy from
  71279. */
  71280. copyFrom(other: Measure): void;
  71281. /**
  71282. * Copy from a group of 4 floats
  71283. * @param left defines left coordinate
  71284. * @param top defines top coordinate
  71285. * @param width defines width dimension
  71286. * @param height defines height dimension
  71287. */
  71288. copyFromFloats(left: number, top: number, width: number, height: number): void;
  71289. /**
  71290. * Computes the axis aligned bounding box measure for two given measures
  71291. * @param a Input measure
  71292. * @param b Input measure
  71293. * @param result the resulting bounding measure
  71294. */
  71295. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  71296. /**
  71297. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  71298. * @param transform the matrix to transform the measure before computing the AABB
  71299. * @param result the resulting AABB
  71300. */
  71301. transformToRef(transform: Matrix2D, result: Measure): void;
  71302. /**
  71303. * Check equality between this measure and another one
  71304. * @param other defines the other measures
  71305. * @returns true if both measures are equals
  71306. */
  71307. isEqualsTo(other: Measure): boolean;
  71308. /**
  71309. * Creates an empty measure
  71310. * @returns a new measure
  71311. */
  71312. static Empty(): Measure;
  71313. }
  71314. }
  71315. declare module BABYLON.GUI {
  71316. /**
  71317. * Interface used to define a control that can receive focus
  71318. */
  71319. export interface IFocusableControl {
  71320. /**
  71321. * Function called when the control receives the focus
  71322. */
  71323. onFocus(): void;
  71324. /**
  71325. * Function called when the control loses the focus
  71326. */
  71327. onBlur(): void;
  71328. /**
  71329. * Function called to let the control handle keyboard events
  71330. * @param evt defines the current keyboard event
  71331. */
  71332. processKeyboard(evt: KeyboardEvent): void;
  71333. /**
  71334. * Function called to get the list of controls that should not steal the focus from this control
  71335. * @returns an array of controls
  71336. */
  71337. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  71338. }
  71339. /**
  71340. * Class used to create texture to support 2D GUI elements
  71341. * @see http://doc.babylonjs.com/how_to/gui
  71342. */
  71343. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  71344. private _isDirty;
  71345. private _renderObserver;
  71346. private _resizeObserver;
  71347. private _preKeyboardObserver;
  71348. private _pointerMoveObserver;
  71349. private _pointerObserver;
  71350. private _canvasPointerOutObserver;
  71351. private _background;
  71352. /** @hidden */
  71353. _rootContainer: Container;
  71354. /** @hidden */
  71355. _lastPickedControl: Control;
  71356. /** @hidden */
  71357. _lastControlOver: {
  71358. [pointerId: number]: Control;
  71359. };
  71360. /** @hidden */
  71361. _lastControlDown: {
  71362. [pointerId: number]: Control;
  71363. };
  71364. /** @hidden */
  71365. _capturingControl: {
  71366. [pointerId: number]: Control;
  71367. };
  71368. /** @hidden */
  71369. _shouldBlockPointer: boolean;
  71370. /** @hidden */
  71371. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  71372. /** @hidden */
  71373. _linkedControls: Control[];
  71374. private _isFullscreen;
  71375. private _fullscreenViewport;
  71376. private _idealWidth;
  71377. private _idealHeight;
  71378. private _useSmallestIdeal;
  71379. private _renderAtIdealSize;
  71380. private _focusedControl;
  71381. private _blockNextFocusCheck;
  71382. private _renderScale;
  71383. private _rootElement;
  71384. private _cursorChanged;
  71385. private _defaultMousePointerId;
  71386. /** @hidden */
  71387. _numLayoutCalls: number;
  71388. /** Gets the number of layout calls made the last time the ADT has been rendered */
  71389. get numLayoutCalls(): number;
  71390. /** @hidden */
  71391. _numRenderCalls: number;
  71392. /** Gets the number of render calls made the last time the ADT has been rendered */
  71393. get numRenderCalls(): number;
  71394. /**
  71395. * Define type to string to ensure compatibility across browsers
  71396. * Safari doesn't support DataTransfer constructor
  71397. */
  71398. private _clipboardData;
  71399. /**
  71400. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  71401. */
  71402. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  71403. /**
  71404. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  71405. */
  71406. onControlPickedObservable: BABYLON.Observable<Control>;
  71407. /**
  71408. * BABYLON.Observable event triggered before layout is evaluated
  71409. */
  71410. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71411. /**
  71412. * BABYLON.Observable event triggered after the layout was evaluated
  71413. */
  71414. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71415. /**
  71416. * BABYLON.Observable event triggered before the texture is rendered
  71417. */
  71418. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71419. /**
  71420. * BABYLON.Observable event triggered after the texture was rendered
  71421. */
  71422. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71423. /**
  71424. * Gets or sets a boolean defining if alpha is stored as premultiplied
  71425. */
  71426. premulAlpha: boolean;
  71427. /**
  71428. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  71429. * Useful when you want more antialiasing
  71430. */
  71431. get renderScale(): number;
  71432. set renderScale(value: number);
  71433. /** Gets or sets the background color */
  71434. get background(): string;
  71435. set background(value: string);
  71436. /**
  71437. * Gets or sets the ideal width used to design controls.
  71438. * The GUI will then rescale everything accordingly
  71439. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71440. */
  71441. get idealWidth(): number;
  71442. set idealWidth(value: number);
  71443. /**
  71444. * Gets or sets the ideal height used to design controls.
  71445. * The GUI will then rescale everything accordingly
  71446. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71447. */
  71448. get idealHeight(): number;
  71449. set idealHeight(value: number);
  71450. /**
  71451. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  71452. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71453. */
  71454. get useSmallestIdeal(): boolean;
  71455. set useSmallestIdeal(value: boolean);
  71456. /**
  71457. * Gets or sets a boolean indicating if adaptive scaling must be used
  71458. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71459. */
  71460. get renderAtIdealSize(): boolean;
  71461. set renderAtIdealSize(value: boolean);
  71462. /**
  71463. * Gets the ratio used when in "ideal mode"
  71464. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71465. * */
  71466. get idealRatio(): number;
  71467. /**
  71468. * Gets the underlying layer used to render the texture when in fullscreen mode
  71469. */
  71470. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  71471. /**
  71472. * Gets the root container control
  71473. */
  71474. get rootContainer(): Container;
  71475. /**
  71476. * Returns an array containing the root container.
  71477. * This is mostly used to let the Inspector introspects the ADT
  71478. * @returns an array containing the rootContainer
  71479. */
  71480. getChildren(): Array<Container>;
  71481. /**
  71482. * Will return all controls that are inside this texture
  71483. * @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
  71484. * @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
  71485. * @return all child controls
  71486. */
  71487. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71488. /**
  71489. * Gets or sets the current focused control
  71490. */
  71491. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  71492. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  71493. /**
  71494. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  71495. */
  71496. get isForeground(): boolean;
  71497. set isForeground(value: boolean);
  71498. /**
  71499. * Gets or set information about clipboardData
  71500. */
  71501. get clipboardData(): string;
  71502. set clipboardData(value: string);
  71503. /**
  71504. * Creates a new AdvancedDynamicTexture
  71505. * @param name defines the name of the texture
  71506. * @param width defines the width of the texture
  71507. * @param height defines the height of the texture
  71508. * @param scene defines the hosting scene
  71509. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  71510. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71511. */
  71512. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  71513. /**
  71514. * Get the current class name of the texture useful for serialization or dynamic coding.
  71515. * @returns "AdvancedDynamicTexture"
  71516. */
  71517. getClassName(): string;
  71518. /**
  71519. * Function used to execute a function on all controls
  71520. * @param func defines the function to execute
  71521. * @param container defines the container where controls belong. If null the root container will be used
  71522. */
  71523. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  71524. private _useInvalidateRectOptimization;
  71525. /**
  71526. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  71527. */
  71528. get useInvalidateRectOptimization(): boolean;
  71529. set useInvalidateRectOptimization(value: boolean);
  71530. private _invalidatedRectangle;
  71531. /**
  71532. * Invalidates a rectangle area on the gui texture
  71533. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  71534. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  71535. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  71536. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  71537. */
  71538. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  71539. /**
  71540. * Marks the texture as dirty forcing a complete update
  71541. */
  71542. markAsDirty(): void;
  71543. /**
  71544. * Helper function used to create a new style
  71545. * @returns a new style
  71546. * @see http://doc.babylonjs.com/how_to/gui#styles
  71547. */
  71548. createStyle(): Style;
  71549. /**
  71550. * Adds a new control to the root container
  71551. * @param control defines the control to add
  71552. * @returns the current texture
  71553. */
  71554. addControl(control: Control): AdvancedDynamicTexture;
  71555. /**
  71556. * Removes a control from the root container
  71557. * @param control defines the control to remove
  71558. * @returns the current texture
  71559. */
  71560. removeControl(control: Control): AdvancedDynamicTexture;
  71561. /**
  71562. * Release all resources
  71563. */
  71564. dispose(): void;
  71565. private _onResize;
  71566. /** @hidden */
  71567. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  71568. /**
  71569. * Get screen coordinates for a vector3
  71570. * @param position defines the position to project
  71571. * @param worldMatrix defines the world matrix to use
  71572. * @returns the projected position
  71573. */
  71574. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  71575. private _checkUpdate;
  71576. private _clearMeasure;
  71577. private _render;
  71578. /** @hidden */
  71579. _changeCursor(cursor: string): void;
  71580. /** @hidden */
  71581. _registerLastControlDown(control: Control, pointerId: number): void;
  71582. private _doPicking;
  71583. /** @hidden */
  71584. _cleanControlAfterRemovalFromList(list: {
  71585. [pointerId: number]: Control;
  71586. }, control: Control): void;
  71587. /** @hidden */
  71588. _cleanControlAfterRemoval(control: Control): void;
  71589. /** Attach to all scene events required to support pointer events */
  71590. attach(): void;
  71591. /** @hidden */
  71592. private onClipboardCopy;
  71593. /** @hidden */
  71594. private onClipboardCut;
  71595. /** @hidden */
  71596. private onClipboardPaste;
  71597. /**
  71598. * Register the clipboard Events onto the canvas
  71599. */
  71600. registerClipboardEvents(): void;
  71601. /**
  71602. * Unregister the clipboard Events from the canvas
  71603. */
  71604. unRegisterClipboardEvents(): void;
  71605. /**
  71606. * Connect the texture to a hosting mesh to enable interactions
  71607. * @param mesh defines the mesh to attach to
  71608. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  71609. */
  71610. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  71611. /**
  71612. * Move the focus to a specific control
  71613. * @param control defines the control which will receive the focus
  71614. */
  71615. moveFocusToControl(control: IFocusableControl): void;
  71616. private _manageFocus;
  71617. private _attachToOnPointerOut;
  71618. /**
  71619. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  71620. * @param mesh defines the mesh which will receive the texture
  71621. * @param width defines the texture width (1024 by default)
  71622. * @param height defines the texture height (1024 by default)
  71623. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  71624. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  71625. * @returns a new AdvancedDynamicTexture
  71626. */
  71627. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  71628. /**
  71629. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  71630. * In this mode the texture will rely on a layer for its rendering.
  71631. * This allows it to be treated like any other layer.
  71632. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  71633. * LayerMask is set through advancedTexture.layer.layerMask
  71634. * @param name defines name for the texture
  71635. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  71636. * @param scene defines the hsoting scene
  71637. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  71638. * @returns a new AdvancedDynamicTexture
  71639. */
  71640. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  71641. }
  71642. }
  71643. declare module BABYLON.GUI {
  71644. /**
  71645. * Root class used for all 2D controls
  71646. * @see http://doc.babylonjs.com/how_to/gui#controls
  71647. */
  71648. export class Control {
  71649. /** defines the name of the control */
  71650. name?: string | undefined;
  71651. /**
  71652. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  71653. */
  71654. static AllowAlphaInheritance: boolean;
  71655. private _alpha;
  71656. private _alphaSet;
  71657. private _zIndex;
  71658. /** @hidden */
  71659. _host: AdvancedDynamicTexture;
  71660. /** Gets or sets the control parent */
  71661. parent: BABYLON.Nullable<Container>;
  71662. /** @hidden */
  71663. _currentMeasure: Measure;
  71664. private _fontFamily;
  71665. private _fontStyle;
  71666. private _fontWeight;
  71667. private _fontSize;
  71668. private _font;
  71669. /** @hidden */
  71670. _width: ValueAndUnit;
  71671. /** @hidden */
  71672. _height: ValueAndUnit;
  71673. /** @hidden */
  71674. protected _fontOffset: {
  71675. ascent: number;
  71676. height: number;
  71677. descent: number;
  71678. };
  71679. private _color;
  71680. private _style;
  71681. private _styleObserver;
  71682. /** @hidden */
  71683. protected _horizontalAlignment: number;
  71684. /** @hidden */
  71685. protected _verticalAlignment: number;
  71686. /** @hidden */
  71687. protected _isDirty: boolean;
  71688. /** @hidden */
  71689. protected _wasDirty: boolean;
  71690. /** @hidden */
  71691. _tempParentMeasure: Measure;
  71692. /** @hidden */
  71693. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  71694. /** @hidden */
  71695. protected _cachedParentMeasure: Measure;
  71696. private _paddingLeft;
  71697. private _paddingRight;
  71698. private _paddingTop;
  71699. private _paddingBottom;
  71700. /** @hidden */
  71701. _left: ValueAndUnit;
  71702. /** @hidden */
  71703. _top: ValueAndUnit;
  71704. private _scaleX;
  71705. private _scaleY;
  71706. private _rotation;
  71707. private _transformCenterX;
  71708. private _transformCenterY;
  71709. /** @hidden */
  71710. _transformMatrix: Matrix2D;
  71711. /** @hidden */
  71712. protected _invertTransformMatrix: Matrix2D;
  71713. /** @hidden */
  71714. protected _transformedPosition: BABYLON.Vector2;
  71715. private _isMatrixDirty;
  71716. private _cachedOffsetX;
  71717. private _cachedOffsetY;
  71718. private _isVisible;
  71719. private _isHighlighted;
  71720. /** @hidden */
  71721. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  71722. private _fontSet;
  71723. private _dummyVector2;
  71724. private _downCount;
  71725. private _enterCount;
  71726. private _doNotRender;
  71727. private _downPointerIds;
  71728. protected _isEnabled: boolean;
  71729. protected _disabledColor: string;
  71730. protected _disabledColorItem: string;
  71731. /** @hidden */
  71732. protected _rebuildLayout: boolean;
  71733. /** @hidden */
  71734. _customData: any;
  71735. /** @hidden */
  71736. _isClipped: boolean;
  71737. /** @hidden */
  71738. _automaticSize: boolean;
  71739. /** @hidden */
  71740. _tag: any;
  71741. /**
  71742. * 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
  71743. */
  71744. uniqueId: number;
  71745. /**
  71746. * Gets or sets an object used to store user defined information for the node
  71747. */
  71748. metadata: any;
  71749. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  71750. isHitTestVisible: boolean;
  71751. /** Gets or sets a boolean indicating if the control can block pointer events */
  71752. isPointerBlocker: boolean;
  71753. /** Gets or sets a boolean indicating if the control can be focusable */
  71754. isFocusInvisible: boolean;
  71755. /**
  71756. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  71757. * 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
  71758. */
  71759. clipChildren: boolean;
  71760. /**
  71761. * Gets or sets a boolean indicating that control content must be clipped
  71762. * 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
  71763. */
  71764. clipContent: boolean;
  71765. /**
  71766. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  71767. */
  71768. useBitmapCache: boolean;
  71769. private _cacheData;
  71770. private _shadowOffsetX;
  71771. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  71772. get shadowOffsetX(): number;
  71773. set shadowOffsetX(value: number);
  71774. private _shadowOffsetY;
  71775. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  71776. get shadowOffsetY(): number;
  71777. set shadowOffsetY(value: number);
  71778. private _shadowBlur;
  71779. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  71780. get shadowBlur(): number;
  71781. set shadowBlur(value: number);
  71782. private _shadowColor;
  71783. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  71784. get shadowColor(): string;
  71785. set shadowColor(value: string);
  71786. /** Gets or sets the cursor to use when the control is hovered */
  71787. hoverCursor: string;
  71788. /** @hidden */
  71789. protected _linkOffsetX: ValueAndUnit;
  71790. /** @hidden */
  71791. protected _linkOffsetY: ValueAndUnit;
  71792. /** Gets the control type name */
  71793. get typeName(): string;
  71794. /**
  71795. * Get the current class name of the control.
  71796. * @returns current class name
  71797. */
  71798. getClassName(): string;
  71799. /**
  71800. * An event triggered when pointer wheel is scrolled
  71801. */
  71802. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  71803. /**
  71804. * An event triggered when the pointer move over the control.
  71805. */
  71806. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  71807. /**
  71808. * An event triggered when the pointer move out of the control.
  71809. */
  71810. onPointerOutObservable: BABYLON.Observable<Control>;
  71811. /**
  71812. * An event triggered when the pointer taps the control
  71813. */
  71814. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  71815. /**
  71816. * An event triggered when pointer up
  71817. */
  71818. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  71819. /**
  71820. * An event triggered when a control is clicked on
  71821. */
  71822. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  71823. /**
  71824. * An event triggered when pointer enters the control
  71825. */
  71826. onPointerEnterObservable: BABYLON.Observable<Control>;
  71827. /**
  71828. * An event triggered when the control is marked as dirty
  71829. */
  71830. onDirtyObservable: BABYLON.Observable<Control>;
  71831. /**
  71832. * An event triggered before drawing the control
  71833. */
  71834. onBeforeDrawObservable: BABYLON.Observable<Control>;
  71835. /**
  71836. * An event triggered after the control was drawn
  71837. */
  71838. onAfterDrawObservable: BABYLON.Observable<Control>;
  71839. /**
  71840. * Get the hosting AdvancedDynamicTexture
  71841. */
  71842. get host(): AdvancedDynamicTexture;
  71843. /** Gets or set information about font offsets (used to render and align text) */
  71844. get fontOffset(): {
  71845. ascent: number;
  71846. height: number;
  71847. descent: number;
  71848. };
  71849. set fontOffset(offset: {
  71850. ascent: number;
  71851. height: number;
  71852. descent: number;
  71853. });
  71854. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  71855. get alpha(): number;
  71856. set alpha(value: number);
  71857. /**
  71858. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  71859. */
  71860. get isHighlighted(): boolean;
  71861. set isHighlighted(value: boolean);
  71862. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  71863. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71864. */
  71865. get scaleX(): number;
  71866. set scaleX(value: number);
  71867. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  71868. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71869. */
  71870. get scaleY(): number;
  71871. set scaleY(value: number);
  71872. /** Gets or sets the rotation angle (0 by default)
  71873. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71874. */
  71875. get rotation(): number;
  71876. set rotation(value: number);
  71877. /** Gets or sets the transformation center on Y axis (0 by default)
  71878. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71879. */
  71880. get transformCenterY(): number;
  71881. set transformCenterY(value: number);
  71882. /** Gets or sets the transformation center on X axis (0 by default)
  71883. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71884. */
  71885. get transformCenterX(): number;
  71886. set transformCenterX(value: number);
  71887. /**
  71888. * Gets or sets the horizontal alignment
  71889. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71890. */
  71891. get horizontalAlignment(): number;
  71892. set horizontalAlignment(value: number);
  71893. /**
  71894. * Gets or sets the vertical alignment
  71895. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71896. */
  71897. get verticalAlignment(): number;
  71898. set verticalAlignment(value: number);
  71899. /**
  71900. * Gets or sets control width
  71901. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71902. */
  71903. get width(): string | number;
  71904. set width(value: string | number);
  71905. /**
  71906. * Gets or sets the control width in pixel
  71907. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71908. */
  71909. get widthInPixels(): number;
  71910. set widthInPixels(value: number);
  71911. /**
  71912. * Gets or sets control height
  71913. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71914. */
  71915. get height(): string | number;
  71916. set height(value: string | number);
  71917. /**
  71918. * Gets or sets control height in pixel
  71919. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71920. */
  71921. get heightInPixels(): number;
  71922. set heightInPixels(value: number);
  71923. /** Gets or set font family */
  71924. get fontFamily(): string;
  71925. set fontFamily(value: string);
  71926. /** Gets or sets font style */
  71927. get fontStyle(): string;
  71928. set fontStyle(value: string);
  71929. /** Gets or sets font weight */
  71930. get fontWeight(): string;
  71931. set fontWeight(value: string);
  71932. /**
  71933. * Gets or sets style
  71934. * @see http://doc.babylonjs.com/how_to/gui#styles
  71935. */
  71936. get style(): BABYLON.Nullable<Style>;
  71937. set style(value: BABYLON.Nullable<Style>);
  71938. /** @hidden */
  71939. get _isFontSizeInPercentage(): boolean;
  71940. /** Gets or sets font size in pixels */
  71941. get fontSizeInPixels(): number;
  71942. set fontSizeInPixels(value: number);
  71943. /** Gets or sets font size */
  71944. get fontSize(): string | number;
  71945. set fontSize(value: string | number);
  71946. /** Gets or sets foreground color */
  71947. get color(): string;
  71948. set color(value: string);
  71949. /** Gets or sets z index which is used to reorder controls on the z axis */
  71950. get zIndex(): number;
  71951. set zIndex(value: number);
  71952. /** Gets or sets a boolean indicating if the control can be rendered */
  71953. get notRenderable(): boolean;
  71954. set notRenderable(value: boolean);
  71955. /** Gets or sets a boolean indicating if the control is visible */
  71956. get isVisible(): boolean;
  71957. set isVisible(value: boolean);
  71958. /** Gets a boolean indicating that the control needs to update its rendering */
  71959. get isDirty(): boolean;
  71960. /**
  71961. * Gets the current linked mesh (or null if none)
  71962. */
  71963. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  71964. /**
  71965. * Gets or sets a value indicating the padding to use on the left of the control
  71966. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71967. */
  71968. get paddingLeft(): string | number;
  71969. set paddingLeft(value: string | number);
  71970. /**
  71971. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  71972. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71973. */
  71974. get paddingLeftInPixels(): number;
  71975. set paddingLeftInPixels(value: number);
  71976. /**
  71977. * Gets or sets a value indicating the padding to use on the right of the control
  71978. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71979. */
  71980. get paddingRight(): string | number;
  71981. set paddingRight(value: string | number);
  71982. /**
  71983. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  71984. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71985. */
  71986. get paddingRightInPixels(): number;
  71987. set paddingRightInPixels(value: number);
  71988. /**
  71989. * Gets or sets a value indicating the padding to use on the top of the control
  71990. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71991. */
  71992. get paddingTop(): string | number;
  71993. set paddingTop(value: string | number);
  71994. /**
  71995. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  71996. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71997. */
  71998. get paddingTopInPixels(): number;
  71999. set paddingTopInPixels(value: number);
  72000. /**
  72001. * Gets or sets a value indicating the padding to use on the bottom of the control
  72002. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72003. */
  72004. get paddingBottom(): string | number;
  72005. set paddingBottom(value: string | number);
  72006. /**
  72007. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  72008. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72009. */
  72010. get paddingBottomInPixels(): number;
  72011. set paddingBottomInPixels(value: number);
  72012. /**
  72013. * Gets or sets a value indicating the left coordinate of the control
  72014. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72015. */
  72016. get left(): string | number;
  72017. set left(value: string | number);
  72018. /**
  72019. * Gets or sets a value indicating the left coordinate in pixels of the control
  72020. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72021. */
  72022. get leftInPixels(): number;
  72023. set leftInPixels(value: number);
  72024. /**
  72025. * Gets or sets a value indicating the top coordinate of the control
  72026. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72027. */
  72028. get top(): string | number;
  72029. set top(value: string | number);
  72030. /**
  72031. * Gets or sets a value indicating the top coordinate in pixels of the control
  72032. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72033. */
  72034. get topInPixels(): number;
  72035. set topInPixels(value: number);
  72036. /**
  72037. * Gets or sets a value indicating the offset on X axis to the linked mesh
  72038. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72039. */
  72040. get linkOffsetX(): string | number;
  72041. set linkOffsetX(value: string | number);
  72042. /**
  72043. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  72044. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72045. */
  72046. get linkOffsetXInPixels(): number;
  72047. set linkOffsetXInPixels(value: number);
  72048. /**
  72049. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  72050. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72051. */
  72052. get linkOffsetY(): string | number;
  72053. set linkOffsetY(value: string | number);
  72054. /**
  72055. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  72056. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72057. */
  72058. get linkOffsetYInPixels(): number;
  72059. set linkOffsetYInPixels(value: number);
  72060. /** Gets the center coordinate on X axis */
  72061. get centerX(): number;
  72062. /** Gets the center coordinate on Y axis */
  72063. get centerY(): number;
  72064. /** Gets or sets if control is Enabled*/
  72065. get isEnabled(): boolean;
  72066. set isEnabled(value: boolean);
  72067. /** Gets or sets background color of control if it's disabled*/
  72068. get disabledColor(): string;
  72069. set disabledColor(value: string);
  72070. /** Gets or sets front color of control if it's disabled*/
  72071. get disabledColorItem(): string;
  72072. set disabledColorItem(value: string);
  72073. /**
  72074. * Creates a new control
  72075. * @param name defines the name of the control
  72076. */
  72077. constructor(
  72078. /** defines the name of the control */
  72079. name?: string | undefined);
  72080. /** @hidden */
  72081. protected _getTypeName(): string;
  72082. /**
  72083. * Gets the first ascendant in the hierarchy of the given type
  72084. * @param className defines the required type
  72085. * @returns the ascendant or null if not found
  72086. */
  72087. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  72088. /** @hidden */
  72089. _resetFontCache(): void;
  72090. /**
  72091. * Determines if a container is an ascendant of the current control
  72092. * @param container defines the container to look for
  72093. * @returns true if the container is one of the ascendant of the control
  72094. */
  72095. isAscendant(container: Control): boolean;
  72096. /**
  72097. * Gets coordinates in local control space
  72098. * @param globalCoordinates defines the coordinates to transform
  72099. * @returns the new coordinates in local space
  72100. */
  72101. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72102. /**
  72103. * Gets coordinates in local control space
  72104. * @param globalCoordinates defines the coordinates to transform
  72105. * @param result defines the target vector2 where to store the result
  72106. * @returns the current control
  72107. */
  72108. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  72109. /**
  72110. * Gets coordinates in parent local control space
  72111. * @param globalCoordinates defines the coordinates to transform
  72112. * @returns the new coordinates in parent local space
  72113. */
  72114. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72115. /**
  72116. * Move the current control to a vector3 position projected onto the screen.
  72117. * @param position defines the target position
  72118. * @param scene defines the hosting scene
  72119. */
  72120. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  72121. /**
  72122. * Will store all controls that have this control as ascendant in a given array
  72123. * @param results defines the array where to store the descendants
  72124. * @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
  72125. * @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
  72126. */
  72127. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72128. /**
  72129. * Will return all controls that have this control as ascendant
  72130. * @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
  72131. * @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
  72132. * @return all child controls
  72133. */
  72134. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  72135. /**
  72136. * Link current control with a target mesh
  72137. * @param mesh defines the mesh to link with
  72138. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72139. */
  72140. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  72141. /** @hidden */
  72142. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  72143. /** @hidden */
  72144. _offsetLeft(offset: number): void;
  72145. /** @hidden */
  72146. _offsetTop(offset: number): void;
  72147. /** @hidden */
  72148. _markMatrixAsDirty(): void;
  72149. /** @hidden */
  72150. _flagDescendantsAsMatrixDirty(): void;
  72151. /** @hidden */
  72152. _intersectsRect(rect: Measure): boolean;
  72153. /** @hidden */
  72154. protected invalidateRect(): void;
  72155. /** @hidden */
  72156. _markAsDirty(force?: boolean): void;
  72157. /** @hidden */
  72158. _markAllAsDirty(): void;
  72159. /** @hidden */
  72160. _link(host: AdvancedDynamicTexture): void;
  72161. /** @hidden */
  72162. protected _transform(context?: CanvasRenderingContext2D): void;
  72163. /** @hidden */
  72164. _renderHighlight(context: CanvasRenderingContext2D): void;
  72165. /** @hidden */
  72166. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72167. /** @hidden */
  72168. protected _applyStates(context: CanvasRenderingContext2D): void;
  72169. /** @hidden */
  72170. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72171. /** @hidden */
  72172. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72173. protected _evaluateClippingState(parentMeasure: Measure): void;
  72174. /** @hidden */
  72175. _measure(): void;
  72176. /** @hidden */
  72177. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72178. /** @hidden */
  72179. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72180. /** @hidden */
  72181. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72182. /** @hidden */
  72183. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72184. private static _ClipMeasure;
  72185. private _tmpMeasureA;
  72186. private _clip;
  72187. /** @hidden */
  72188. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  72189. /** @hidden */
  72190. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72191. /**
  72192. * Tests if a given coordinates belong to the current control
  72193. * @param x defines x coordinate to test
  72194. * @param y defines y coordinate to test
  72195. * @returns true if the coordinates are inside the control
  72196. */
  72197. contains(x: number, y: number): boolean;
  72198. /** @hidden */
  72199. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72200. /** @hidden */
  72201. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72202. /** @hidden */
  72203. _onPointerEnter(target: Control): boolean;
  72204. /** @hidden */
  72205. _onPointerOut(target: Control, force?: boolean): void;
  72206. /** @hidden */
  72207. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72208. /** @hidden */
  72209. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72210. /** @hidden */
  72211. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  72212. /** @hidden */
  72213. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  72214. /** @hidden */
  72215. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72216. private _prepareFont;
  72217. /** Releases associated resources */
  72218. dispose(): void;
  72219. private static _HORIZONTAL_ALIGNMENT_LEFT;
  72220. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  72221. private static _HORIZONTAL_ALIGNMENT_CENTER;
  72222. private static _VERTICAL_ALIGNMENT_TOP;
  72223. private static _VERTICAL_ALIGNMENT_BOTTOM;
  72224. private static _VERTICAL_ALIGNMENT_CENTER;
  72225. /** HORIZONTAL_ALIGNMENT_LEFT */
  72226. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  72227. /** HORIZONTAL_ALIGNMENT_RIGHT */
  72228. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  72229. /** HORIZONTAL_ALIGNMENT_CENTER */
  72230. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  72231. /** VERTICAL_ALIGNMENT_TOP */
  72232. static get VERTICAL_ALIGNMENT_TOP(): number;
  72233. /** VERTICAL_ALIGNMENT_BOTTOM */
  72234. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  72235. /** VERTICAL_ALIGNMENT_CENTER */
  72236. static get VERTICAL_ALIGNMENT_CENTER(): number;
  72237. private static _FontHeightSizes;
  72238. /** @hidden */
  72239. static _GetFontOffset(font: string): {
  72240. ascent: number;
  72241. height: number;
  72242. descent: number;
  72243. };
  72244. /**
  72245. * Creates a stack panel that can be used to render headers
  72246. * @param control defines the control to associate with the header
  72247. * @param text defines the text of the header
  72248. * @param size defines the size of the header
  72249. * @param options defines options used to configure the header
  72250. * @returns a new StackPanel
  72251. * @ignore
  72252. * @hidden
  72253. */
  72254. static AddHeader: (control: Control, text: string, size: string | number, options: {
  72255. isHorizontal: boolean;
  72256. controlFirst: boolean;
  72257. }) => any;
  72258. /** @hidden */
  72259. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  72260. }
  72261. }
  72262. declare module BABYLON.GUI {
  72263. /**
  72264. * Root class for 2D containers
  72265. * @see http://doc.babylonjs.com/how_to/gui#containers
  72266. */
  72267. export class Container extends Control {
  72268. name?: string | undefined;
  72269. /** @hidden */
  72270. _children: Control[];
  72271. /** @hidden */
  72272. protected _measureForChildren: Measure;
  72273. /** @hidden */
  72274. protected _background: string;
  72275. /** @hidden */
  72276. protected _adaptWidthToChildren: boolean;
  72277. /** @hidden */
  72278. protected _adaptHeightToChildren: boolean;
  72279. /**
  72280. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  72281. */
  72282. logLayoutCycleErrors: boolean;
  72283. /**
  72284. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  72285. */
  72286. maxLayoutCycle: number;
  72287. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  72288. get adaptHeightToChildren(): boolean;
  72289. set adaptHeightToChildren(value: boolean);
  72290. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  72291. get adaptWidthToChildren(): boolean;
  72292. set adaptWidthToChildren(value: boolean);
  72293. /** Gets or sets background color */
  72294. get background(): string;
  72295. set background(value: string);
  72296. /** Gets the list of children */
  72297. get children(): Control[];
  72298. /**
  72299. * Creates a new Container
  72300. * @param name defines the name of the container
  72301. */
  72302. constructor(name?: string | undefined);
  72303. protected _getTypeName(): string;
  72304. _flagDescendantsAsMatrixDirty(): void;
  72305. /**
  72306. * Gets a child using its name
  72307. * @param name defines the child name to look for
  72308. * @returns the child control if found
  72309. */
  72310. getChildByName(name: string): BABYLON.Nullable<Control>;
  72311. /**
  72312. * Gets a child using its type and its name
  72313. * @param name defines the child name to look for
  72314. * @param type defines the child type to look for
  72315. * @returns the child control if found
  72316. */
  72317. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  72318. /**
  72319. * Search for a specific control in children
  72320. * @param control defines the control to look for
  72321. * @returns true if the control is in child list
  72322. */
  72323. containsControl(control: Control): boolean;
  72324. /**
  72325. * Adds a new control to the current container
  72326. * @param control defines the control to add
  72327. * @returns the current container
  72328. */
  72329. addControl(control: BABYLON.Nullable<Control>): Container;
  72330. /**
  72331. * Removes all controls from the current container
  72332. * @returns the current container
  72333. */
  72334. clearControls(): Container;
  72335. /**
  72336. * Removes a control from the current container
  72337. * @param control defines the control to remove
  72338. * @returns the current container
  72339. */
  72340. removeControl(control: Control): Container;
  72341. /** @hidden */
  72342. _reOrderControl(control: Control): void;
  72343. /** @hidden */
  72344. _offsetLeft(offset: number): void;
  72345. /** @hidden */
  72346. _offsetTop(offset: number): void;
  72347. /** @hidden */
  72348. _markAllAsDirty(): void;
  72349. /** @hidden */
  72350. protected _localDraw(context: CanvasRenderingContext2D): void;
  72351. /** @hidden */
  72352. _link(host: AdvancedDynamicTexture): void;
  72353. /** @hidden */
  72354. protected _beforeLayout(): void;
  72355. /** @hidden */
  72356. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72357. /** @hidden */
  72358. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72359. protected _postMeasure(): void;
  72360. /** @hidden */
  72361. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  72362. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72363. /** @hidden */
  72364. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72365. /** @hidden */
  72366. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72367. /** Releases associated resources */
  72368. dispose(): void;
  72369. }
  72370. }
  72371. declare module BABYLON.GUI {
  72372. /** Class used to create rectangle container */
  72373. export class Rectangle extends Container {
  72374. name?: string | undefined;
  72375. private _thickness;
  72376. private _cornerRadius;
  72377. /** Gets or sets border thickness */
  72378. get thickness(): number;
  72379. set thickness(value: number);
  72380. /** Gets or sets the corner radius angle */
  72381. get cornerRadius(): number;
  72382. set cornerRadius(value: number);
  72383. /**
  72384. * Creates a new Rectangle
  72385. * @param name defines the control name
  72386. */
  72387. constructor(name?: string | undefined);
  72388. protected _getTypeName(): string;
  72389. protected _localDraw(context: CanvasRenderingContext2D): void;
  72390. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72391. private _drawRoundedRect;
  72392. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72393. }
  72394. }
  72395. declare module BABYLON.GUI {
  72396. /**
  72397. * Enum that determines the text-wrapping mode to use.
  72398. */
  72399. export enum TextWrapping {
  72400. /**
  72401. * Clip the text when it's larger than Control.width; this is the default mode.
  72402. */
  72403. Clip = 0,
  72404. /**
  72405. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  72406. */
  72407. WordWrap = 1,
  72408. /**
  72409. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  72410. */
  72411. Ellipsis = 2
  72412. }
  72413. /**
  72414. * Class used to create text block control
  72415. */
  72416. export class TextBlock extends Control {
  72417. /**
  72418. * Defines the name of the control
  72419. */
  72420. name?: string | undefined;
  72421. private _text;
  72422. private _textWrapping;
  72423. private _textHorizontalAlignment;
  72424. private _textVerticalAlignment;
  72425. private _lines;
  72426. private _resizeToFit;
  72427. private _lineSpacing;
  72428. private _outlineWidth;
  72429. private _outlineColor;
  72430. /**
  72431. * An event triggered after the text is changed
  72432. */
  72433. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  72434. /**
  72435. * An event triggered after the text was broken up into lines
  72436. */
  72437. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  72438. /**
  72439. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  72440. */
  72441. get lines(): any[];
  72442. /**
  72443. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72444. */
  72445. get resizeToFit(): boolean;
  72446. /**
  72447. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72448. */
  72449. set resizeToFit(value: boolean);
  72450. /**
  72451. * Gets or sets a boolean indicating if text must be wrapped
  72452. */
  72453. get textWrapping(): TextWrapping | boolean;
  72454. /**
  72455. * Gets or sets a boolean indicating if text must be wrapped
  72456. */
  72457. set textWrapping(value: TextWrapping | boolean);
  72458. /**
  72459. * Gets or sets text to display
  72460. */
  72461. get text(): string;
  72462. /**
  72463. * Gets or sets text to display
  72464. */
  72465. set text(value: string);
  72466. /**
  72467. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72468. */
  72469. get textHorizontalAlignment(): number;
  72470. /**
  72471. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72472. */
  72473. set textHorizontalAlignment(value: number);
  72474. /**
  72475. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72476. */
  72477. get textVerticalAlignment(): number;
  72478. /**
  72479. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72480. */
  72481. set textVerticalAlignment(value: number);
  72482. /**
  72483. * Gets or sets line spacing value
  72484. */
  72485. set lineSpacing(value: string | number);
  72486. /**
  72487. * Gets or sets line spacing value
  72488. */
  72489. get lineSpacing(): string | number;
  72490. /**
  72491. * Gets or sets outlineWidth of the text to display
  72492. */
  72493. get outlineWidth(): number;
  72494. /**
  72495. * Gets or sets outlineWidth of the text to display
  72496. */
  72497. set outlineWidth(value: number);
  72498. /**
  72499. * Gets or sets outlineColor of the text to display
  72500. */
  72501. get outlineColor(): string;
  72502. /**
  72503. * Gets or sets outlineColor of the text to display
  72504. */
  72505. set outlineColor(value: string);
  72506. /**
  72507. * Creates a new TextBlock object
  72508. * @param name defines the name of the control
  72509. * @param text defines the text to display (emptry string by default)
  72510. */
  72511. constructor(
  72512. /**
  72513. * Defines the name of the control
  72514. */
  72515. name?: string | undefined, text?: string);
  72516. protected _getTypeName(): string;
  72517. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72518. private _drawText;
  72519. /** @hidden */
  72520. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72521. protected _applyStates(context: CanvasRenderingContext2D): void;
  72522. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  72523. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  72524. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  72525. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  72526. protected _renderLines(context: CanvasRenderingContext2D): void;
  72527. /**
  72528. * Given a width constraint applied on the text block, find the expected height
  72529. * @returns expected height
  72530. */
  72531. computeExpectedHeight(): number;
  72532. dispose(): void;
  72533. }
  72534. }
  72535. declare module BABYLON.GUI {
  72536. /**
  72537. * Class used to create 2D images
  72538. */
  72539. export class Image extends Control {
  72540. name?: string | undefined;
  72541. private _workingCanvas;
  72542. private _domImage;
  72543. private _imageWidth;
  72544. private _imageHeight;
  72545. private _loaded;
  72546. private _stretch;
  72547. private _source;
  72548. private _autoScale;
  72549. private _sourceLeft;
  72550. private _sourceTop;
  72551. private _sourceWidth;
  72552. private _sourceHeight;
  72553. private _svgAttributesComputationCompleted;
  72554. private _isSVG;
  72555. private _cellWidth;
  72556. private _cellHeight;
  72557. private _cellId;
  72558. private _populateNinePatchSlicesFromImage;
  72559. private _sliceLeft;
  72560. private _sliceRight;
  72561. private _sliceTop;
  72562. private _sliceBottom;
  72563. private _detectPointerOnOpaqueOnly;
  72564. /**
  72565. * BABYLON.Observable notified when the content is loaded
  72566. */
  72567. onImageLoadedObservable: BABYLON.Observable<Image>;
  72568. /**
  72569. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  72570. */
  72571. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  72572. /**
  72573. * Gets a boolean indicating that the content is loaded
  72574. */
  72575. get isLoaded(): boolean;
  72576. /**
  72577. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  72578. */
  72579. get populateNinePatchSlicesFromImage(): boolean;
  72580. set populateNinePatchSlicesFromImage(value: boolean);
  72581. /**
  72582. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  72583. * Beware using this as this will comsume more memory as the image has to be stored twice
  72584. */
  72585. get detectPointerOnOpaqueOnly(): boolean;
  72586. set detectPointerOnOpaqueOnly(value: boolean);
  72587. /**
  72588. * Gets or sets the left value for slicing (9-patch)
  72589. */
  72590. get sliceLeft(): number;
  72591. set sliceLeft(value: number);
  72592. /**
  72593. * Gets or sets the right value for slicing (9-patch)
  72594. */
  72595. get sliceRight(): number;
  72596. set sliceRight(value: number);
  72597. /**
  72598. * Gets or sets the top value for slicing (9-patch)
  72599. */
  72600. get sliceTop(): number;
  72601. set sliceTop(value: number);
  72602. /**
  72603. * Gets or sets the bottom value for slicing (9-patch)
  72604. */
  72605. get sliceBottom(): number;
  72606. set sliceBottom(value: number);
  72607. /**
  72608. * Gets or sets the left coordinate in the source image
  72609. */
  72610. get sourceLeft(): number;
  72611. set sourceLeft(value: number);
  72612. /**
  72613. * Gets or sets the top coordinate in the source image
  72614. */
  72615. get sourceTop(): number;
  72616. set sourceTop(value: number);
  72617. /**
  72618. * Gets or sets the width to capture in the source image
  72619. */
  72620. get sourceWidth(): number;
  72621. set sourceWidth(value: number);
  72622. /**
  72623. * Gets or sets the height to capture in the source image
  72624. */
  72625. get sourceHeight(): number;
  72626. set sourceHeight(value: number);
  72627. /** Indicates if the format of the image is SVG */
  72628. get isSVG(): boolean;
  72629. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  72630. get svgAttributesComputationCompleted(): boolean;
  72631. /**
  72632. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  72633. * @see http://doc.babylonjs.com/how_to/gui#image
  72634. */
  72635. get autoScale(): boolean;
  72636. set autoScale(value: boolean);
  72637. /** Gets or sets the streching mode used by the image */
  72638. get stretch(): number;
  72639. set stretch(value: number);
  72640. /** @hidden */
  72641. _rotate90(n: number, preserveProperties?: boolean): Image;
  72642. private _handleRotationForSVGImage;
  72643. private _rotate90SourceProperties;
  72644. /**
  72645. * Gets or sets the internal DOM image used to render the control
  72646. */
  72647. set domImage(value: HTMLImageElement);
  72648. get domImage(): HTMLImageElement;
  72649. private _onImageLoaded;
  72650. private _extractNinePatchSliceDataFromImage;
  72651. /**
  72652. * Gets or sets image source url
  72653. */
  72654. set source(value: BABYLON.Nullable<string>);
  72655. /**
  72656. * Checks for svg document with icon id present
  72657. */
  72658. private _svgCheck;
  72659. /**
  72660. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  72661. * given external svg file and icon id
  72662. */
  72663. private _getSVGAttribs;
  72664. /**
  72665. * Gets or sets the cell width to use when animation sheet is enabled
  72666. * @see http://doc.babylonjs.com/how_to/gui#image
  72667. */
  72668. get cellWidth(): number;
  72669. set cellWidth(value: number);
  72670. /**
  72671. * Gets or sets the cell height to use when animation sheet is enabled
  72672. * @see http://doc.babylonjs.com/how_to/gui#image
  72673. */
  72674. get cellHeight(): number;
  72675. set cellHeight(value: number);
  72676. /**
  72677. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  72678. * @see http://doc.babylonjs.com/how_to/gui#image
  72679. */
  72680. get cellId(): number;
  72681. set cellId(value: number);
  72682. /**
  72683. * Creates a new Image
  72684. * @param name defines the control name
  72685. * @param url defines the image url
  72686. */
  72687. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  72688. /**
  72689. * Tests if a given coordinates belong to the current control
  72690. * @param x defines x coordinate to test
  72691. * @param y defines y coordinate to test
  72692. * @returns true if the coordinates are inside the control
  72693. */
  72694. contains(x: number, y: number): boolean;
  72695. protected _getTypeName(): string;
  72696. /** Force the control to synchronize with its content */
  72697. synchronizeSizeWithContent(): void;
  72698. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72699. private _prepareWorkingCanvasForOpaqueDetection;
  72700. private _drawImage;
  72701. _draw(context: CanvasRenderingContext2D): void;
  72702. private _renderCornerPatch;
  72703. private _renderNinePatch;
  72704. dispose(): void;
  72705. /** STRETCH_NONE */
  72706. static readonly STRETCH_NONE: number;
  72707. /** STRETCH_FILL */
  72708. static readonly STRETCH_FILL: number;
  72709. /** STRETCH_UNIFORM */
  72710. static readonly STRETCH_UNIFORM: number;
  72711. /** STRETCH_EXTEND */
  72712. static readonly STRETCH_EXTEND: number;
  72713. /** NINE_PATCH */
  72714. static readonly STRETCH_NINE_PATCH: number;
  72715. }
  72716. }
  72717. declare module BABYLON.GUI {
  72718. /**
  72719. * Class used to create 2D buttons
  72720. */
  72721. export class Button extends Rectangle {
  72722. name?: string | undefined;
  72723. /**
  72724. * Function called to generate a pointer enter animation
  72725. */
  72726. pointerEnterAnimation: () => void;
  72727. /**
  72728. * Function called to generate a pointer out animation
  72729. */
  72730. pointerOutAnimation: () => void;
  72731. /**
  72732. * Function called to generate a pointer down animation
  72733. */
  72734. pointerDownAnimation: () => void;
  72735. /**
  72736. * Function called to generate a pointer up animation
  72737. */
  72738. pointerUpAnimation: () => void;
  72739. /**
  72740. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  72741. */
  72742. delegatePickingToChildren: boolean;
  72743. private _image;
  72744. /**
  72745. * Returns the image part of the button (if any)
  72746. */
  72747. get image(): BABYLON.Nullable<Image>;
  72748. private _textBlock;
  72749. /**
  72750. * Returns the image part of the button (if any)
  72751. */
  72752. get textBlock(): BABYLON.Nullable<TextBlock>;
  72753. /**
  72754. * Creates a new Button
  72755. * @param name defines the name of the button
  72756. */
  72757. constructor(name?: string | undefined);
  72758. protected _getTypeName(): string;
  72759. /** @hidden */
  72760. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72761. /** @hidden */
  72762. _onPointerEnter(target: Control): boolean;
  72763. /** @hidden */
  72764. _onPointerOut(target: Control, force?: boolean): void;
  72765. /** @hidden */
  72766. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72767. /** @hidden */
  72768. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72769. /**
  72770. * Creates a new button made with an image and a text
  72771. * @param name defines the name of the button
  72772. * @param text defines the text of the button
  72773. * @param imageUrl defines the url of the image
  72774. * @returns a new Button
  72775. */
  72776. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  72777. /**
  72778. * Creates a new button made with an image
  72779. * @param name defines the name of the button
  72780. * @param imageUrl defines the url of the image
  72781. * @returns a new Button
  72782. */
  72783. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  72784. /**
  72785. * Creates a new button made with a text
  72786. * @param name defines the name of the button
  72787. * @param text defines the text of the button
  72788. * @returns a new Button
  72789. */
  72790. static CreateSimpleButton(name: string, text: string): Button;
  72791. /**
  72792. * Creates a new button made with an image and a centered text
  72793. * @param name defines the name of the button
  72794. * @param text defines the text of the button
  72795. * @param imageUrl defines the url of the image
  72796. * @returns a new Button
  72797. */
  72798. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  72799. }
  72800. }
  72801. declare module BABYLON.GUI {
  72802. /**
  72803. * Class used to create a 2D stack panel container
  72804. */
  72805. export class StackPanel extends Container {
  72806. name?: string | undefined;
  72807. private _isVertical;
  72808. private _manualWidth;
  72809. private _manualHeight;
  72810. private _doNotTrackManualChanges;
  72811. /**
  72812. * Gets or sets a boolean indicating that layou warnings should be ignored
  72813. */
  72814. ignoreLayoutWarnings: boolean;
  72815. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  72816. get isVertical(): boolean;
  72817. set isVertical(value: boolean);
  72818. /**
  72819. * Gets or sets panel width.
  72820. * This value should not be set when in horizontal mode as it will be computed automatically
  72821. */
  72822. set width(value: string | number);
  72823. get width(): string | number;
  72824. /**
  72825. * Gets or sets panel height.
  72826. * This value should not be set when in vertical mode as it will be computed automatically
  72827. */
  72828. set height(value: string | number);
  72829. get height(): string | number;
  72830. /**
  72831. * Creates a new StackPanel
  72832. * @param name defines control name
  72833. */
  72834. constructor(name?: string | undefined);
  72835. protected _getTypeName(): string;
  72836. /** @hidden */
  72837. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72838. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72839. protected _postMeasure(): void;
  72840. }
  72841. }
  72842. declare module BABYLON.GUI {
  72843. /**
  72844. * Class used to represent a 2D checkbox
  72845. */
  72846. export class Checkbox extends Control {
  72847. name?: string | undefined;
  72848. private _isChecked;
  72849. private _background;
  72850. private _checkSizeRatio;
  72851. private _thickness;
  72852. /** Gets or sets border thickness */
  72853. get thickness(): number;
  72854. set thickness(value: number);
  72855. /**
  72856. * BABYLON.Observable raised when isChecked property changes
  72857. */
  72858. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72859. /** Gets or sets a value indicating the ratio between overall size and check size */
  72860. get checkSizeRatio(): number;
  72861. set checkSizeRatio(value: number);
  72862. /** Gets or sets background color */
  72863. get background(): string;
  72864. set background(value: string);
  72865. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72866. get isChecked(): boolean;
  72867. set isChecked(value: boolean);
  72868. /**
  72869. * Creates a new CheckBox
  72870. * @param name defines the control name
  72871. */
  72872. constructor(name?: string | undefined);
  72873. protected _getTypeName(): string;
  72874. /** @hidden */
  72875. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72876. /** @hidden */
  72877. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72878. /**
  72879. * Utility function to easily create a checkbox with a header
  72880. * @param title defines the label to use for the header
  72881. * @param onValueChanged defines the callback to call when value changes
  72882. * @returns a StackPanel containing the checkbox and a textBlock
  72883. */
  72884. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  72885. }
  72886. }
  72887. declare module BABYLON.GUI {
  72888. /**
  72889. * Class used to store key control properties
  72890. */
  72891. export class KeyPropertySet {
  72892. /** Width */
  72893. width?: string;
  72894. /** Height */
  72895. height?: string;
  72896. /** Left padding */
  72897. paddingLeft?: string;
  72898. /** Right padding */
  72899. paddingRight?: string;
  72900. /** Top padding */
  72901. paddingTop?: string;
  72902. /** Bottom padding */
  72903. paddingBottom?: string;
  72904. /** Foreground color */
  72905. color?: string;
  72906. /** Background color */
  72907. background?: string;
  72908. }
  72909. /**
  72910. * Class used to create virtual keyboard
  72911. */
  72912. export class VirtualKeyboard extends StackPanel {
  72913. /** BABYLON.Observable raised when a key is pressed */
  72914. onKeyPressObservable: BABYLON.Observable<string>;
  72915. /** Gets or sets default key button width */
  72916. defaultButtonWidth: string;
  72917. /** Gets or sets default key button height */
  72918. defaultButtonHeight: string;
  72919. /** Gets or sets default key button left padding */
  72920. defaultButtonPaddingLeft: string;
  72921. /** Gets or sets default key button right padding */
  72922. defaultButtonPaddingRight: string;
  72923. /** Gets or sets default key button top padding */
  72924. defaultButtonPaddingTop: string;
  72925. /** Gets or sets default key button bottom padding */
  72926. defaultButtonPaddingBottom: string;
  72927. /** Gets or sets default key button foreground color */
  72928. defaultButtonColor: string;
  72929. /** Gets or sets default key button background color */
  72930. defaultButtonBackground: string;
  72931. /** Gets or sets shift button foreground color */
  72932. shiftButtonColor: string;
  72933. /** Gets or sets shift button thickness*/
  72934. selectedShiftThickness: number;
  72935. /** Gets shift key state */
  72936. shiftState: number;
  72937. protected _getTypeName(): string;
  72938. private _createKey;
  72939. /**
  72940. * Adds a new row of keys
  72941. * @param keys defines the list of keys to add
  72942. * @param propertySets defines the associated property sets
  72943. */
  72944. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  72945. /**
  72946. * Set the shift key to a specific state
  72947. * @param shiftState defines the new shift state
  72948. */
  72949. applyShiftState(shiftState: number): void;
  72950. private _currentlyConnectedInputText;
  72951. private _connectedInputTexts;
  72952. private _onKeyPressObserver;
  72953. /** Gets the input text control currently attached to the keyboard */
  72954. get connectedInputText(): BABYLON.Nullable<InputText>;
  72955. /**
  72956. * Connects the keyboard with an input text control
  72957. *
  72958. * @param input defines the target control
  72959. */
  72960. connect(input: InputText): void;
  72961. /**
  72962. * Disconnects the keyboard from connected InputText controls
  72963. *
  72964. * @param input optionally defines a target control, otherwise all are disconnected
  72965. */
  72966. disconnect(input?: InputText): void;
  72967. private _removeConnectedInputObservables;
  72968. /**
  72969. * Release all resources
  72970. */
  72971. dispose(): void;
  72972. /**
  72973. * Creates a new keyboard using a default layout
  72974. *
  72975. * @param name defines control name
  72976. * @returns a new VirtualKeyboard
  72977. */
  72978. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  72979. }
  72980. }
  72981. declare module BABYLON.GUI {
  72982. /**
  72983. * Class used to create input text control
  72984. */
  72985. export class InputText extends Control implements IFocusableControl {
  72986. name?: string | undefined;
  72987. private _text;
  72988. private _placeholderText;
  72989. private _background;
  72990. private _focusedBackground;
  72991. private _focusedColor;
  72992. private _placeholderColor;
  72993. private _thickness;
  72994. private _margin;
  72995. private _autoStretchWidth;
  72996. private _maxWidth;
  72997. private _isFocused;
  72998. private _blinkTimeout;
  72999. private _blinkIsEven;
  73000. private _cursorOffset;
  73001. private _scrollLeft;
  73002. private _textWidth;
  73003. private _clickedCoordinate;
  73004. private _deadKey;
  73005. private _addKey;
  73006. private _currentKey;
  73007. private _isTextHighlightOn;
  73008. private _textHighlightColor;
  73009. private _highligherOpacity;
  73010. private _highlightedText;
  73011. private _startHighlightIndex;
  73012. private _endHighlightIndex;
  73013. private _cursorIndex;
  73014. private _onFocusSelectAll;
  73015. private _isPointerDown;
  73016. private _onClipboardObserver;
  73017. private _onPointerDblTapObserver;
  73018. /** @hidden */
  73019. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  73020. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  73021. promptMessage: string;
  73022. /** Force disable prompt on mobile device */
  73023. disableMobilePrompt: boolean;
  73024. /** BABYLON.Observable raised when the text changes */
  73025. onTextChangedObservable: BABYLON.Observable<InputText>;
  73026. /** BABYLON.Observable raised just before an entered character is to be added */
  73027. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  73028. /** BABYLON.Observable raised when the control gets the focus */
  73029. onFocusObservable: BABYLON.Observable<InputText>;
  73030. /** BABYLON.Observable raised when the control loses the focus */
  73031. onBlurObservable: BABYLON.Observable<InputText>;
  73032. /**Observable raised when the text is highlighted */
  73033. onTextHighlightObservable: BABYLON.Observable<InputText>;
  73034. /**Observable raised when copy event is triggered */
  73035. onTextCopyObservable: BABYLON.Observable<InputText>;
  73036. /** BABYLON.Observable raised when cut event is triggered */
  73037. onTextCutObservable: BABYLON.Observable<InputText>;
  73038. /** BABYLON.Observable raised when paste event is triggered */
  73039. onTextPasteObservable: BABYLON.Observable<InputText>;
  73040. /** BABYLON.Observable raised when a key event was processed */
  73041. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  73042. /** Gets or sets the maximum width allowed by the control */
  73043. get maxWidth(): string | number;
  73044. /** Gets the maximum width allowed by the control in pixels */
  73045. get maxWidthInPixels(): number;
  73046. set maxWidth(value: string | number);
  73047. /** Gets or sets the text highlighter transparency; default: 0.4 */
  73048. get highligherOpacity(): number;
  73049. set highligherOpacity(value: number);
  73050. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  73051. get onFocusSelectAll(): boolean;
  73052. set onFocusSelectAll(value: boolean);
  73053. /** Gets or sets the text hightlight color */
  73054. get textHighlightColor(): string;
  73055. set textHighlightColor(value: string);
  73056. /** Gets or sets control margin */
  73057. get margin(): string;
  73058. /** Gets control margin in pixels */
  73059. get marginInPixels(): number;
  73060. set margin(value: string);
  73061. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  73062. get autoStretchWidth(): boolean;
  73063. set autoStretchWidth(value: boolean);
  73064. /** Gets or sets border thickness */
  73065. get thickness(): number;
  73066. set thickness(value: number);
  73067. /** Gets or sets the background color when focused */
  73068. get focusedBackground(): string;
  73069. set focusedBackground(value: string);
  73070. /** Gets or sets the background color when focused */
  73071. get focusedColor(): string;
  73072. set focusedColor(value: string);
  73073. /** Gets or sets the background color */
  73074. get background(): string;
  73075. set background(value: string);
  73076. /** Gets or sets the placeholder color */
  73077. get placeholderColor(): string;
  73078. set placeholderColor(value: string);
  73079. /** Gets or sets the text displayed when the control is empty */
  73080. get placeholderText(): string;
  73081. set placeholderText(value: string);
  73082. /** Gets or sets the dead key flag */
  73083. get deadKey(): boolean;
  73084. set deadKey(flag: boolean);
  73085. /** Gets or sets the highlight text */
  73086. get highlightedText(): string;
  73087. set highlightedText(text: string);
  73088. /** Gets or sets if the current key should be added */
  73089. get addKey(): boolean;
  73090. set addKey(flag: boolean);
  73091. /** Gets or sets the value of the current key being entered */
  73092. get currentKey(): string;
  73093. set currentKey(key: string);
  73094. /** Gets or sets the text displayed in the control */
  73095. get text(): string;
  73096. set text(value: string);
  73097. /** Gets or sets control width */
  73098. get width(): string | number;
  73099. set width(value: string | number);
  73100. /**
  73101. * Creates a new InputText
  73102. * @param name defines the control name
  73103. * @param text defines the text of the control
  73104. */
  73105. constructor(name?: string | undefined, text?: string);
  73106. /** @hidden */
  73107. onBlur(): void;
  73108. /** @hidden */
  73109. onFocus(): void;
  73110. protected _getTypeName(): string;
  73111. /**
  73112. * Function called to get the list of controls that should not steal the focus from this control
  73113. * @returns an array of controls
  73114. */
  73115. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  73116. /** @hidden */
  73117. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  73118. /** @hidden */
  73119. private _updateValueFromCursorIndex;
  73120. /** @hidden */
  73121. private _processDblClick;
  73122. /** @hidden */
  73123. private _selectAllText;
  73124. /**
  73125. * Handles the keyboard event
  73126. * @param evt Defines the KeyboardEvent
  73127. */
  73128. processKeyboard(evt: KeyboardEvent): void;
  73129. /** @hidden */
  73130. private _onCopyText;
  73131. /** @hidden */
  73132. private _onCutText;
  73133. /** @hidden */
  73134. private _onPasteText;
  73135. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73136. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73137. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73138. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73139. protected _beforeRenderText(text: string): string;
  73140. dispose(): void;
  73141. }
  73142. }
  73143. declare module BABYLON.GUI {
  73144. /**
  73145. * Class used to create a 2D grid container
  73146. */
  73147. export class Grid extends Container {
  73148. name?: string | undefined;
  73149. private _rowDefinitions;
  73150. private _columnDefinitions;
  73151. private _cells;
  73152. private _childControls;
  73153. /**
  73154. * Gets the number of columns
  73155. */
  73156. get columnCount(): number;
  73157. /**
  73158. * Gets the number of rows
  73159. */
  73160. get rowCount(): number;
  73161. /** Gets the list of children */
  73162. get children(): Control[];
  73163. /** Gets the list of cells (e.g. the containers) */
  73164. get cells(): {
  73165. [key: string]: Container;
  73166. };
  73167. /**
  73168. * Gets the definition of a specific row
  73169. * @param index defines the index of the row
  73170. * @returns the row definition
  73171. */
  73172. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73173. /**
  73174. * Gets the definition of a specific column
  73175. * @param index defines the index of the column
  73176. * @returns the column definition
  73177. */
  73178. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73179. /**
  73180. * Adds a new row to the grid
  73181. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73182. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  73183. * @returns the current grid
  73184. */
  73185. addRowDefinition(height: number, isPixel?: boolean): Grid;
  73186. /**
  73187. * Adds a new column to the grid
  73188. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73189. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73190. * @returns the current grid
  73191. */
  73192. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  73193. /**
  73194. * Update a row definition
  73195. * @param index defines the index of the row to update
  73196. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73197. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  73198. * @returns the current grid
  73199. */
  73200. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  73201. /**
  73202. * Update a column definition
  73203. * @param index defines the index of the column to update
  73204. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73205. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73206. * @returns the current grid
  73207. */
  73208. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  73209. /**
  73210. * Gets the list of children stored in a specific cell
  73211. * @param row defines the row to check
  73212. * @param column defines the column to check
  73213. * @returns the list of controls
  73214. */
  73215. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  73216. /**
  73217. * Gets a string representing the child cell info (row x column)
  73218. * @param child defines the control to get info from
  73219. * @returns a string containing the child cell info (row x column)
  73220. */
  73221. getChildCellInfo(child: Control): string;
  73222. private _removeCell;
  73223. private _offsetCell;
  73224. /**
  73225. * Remove a column definition at specified index
  73226. * @param index defines the index of the column to remove
  73227. * @returns the current grid
  73228. */
  73229. removeColumnDefinition(index: number): Grid;
  73230. /**
  73231. * Remove a row definition at specified index
  73232. * @param index defines the index of the row to remove
  73233. * @returns the current grid
  73234. */
  73235. removeRowDefinition(index: number): Grid;
  73236. /**
  73237. * Adds a new control to the current grid
  73238. * @param control defines the control to add
  73239. * @param row defines the row where to add the control (0 by default)
  73240. * @param column defines the column where to add the control (0 by default)
  73241. * @returns the current grid
  73242. */
  73243. addControl(control: Control, row?: number, column?: number): Grid;
  73244. /**
  73245. * Removes a control from the current container
  73246. * @param control defines the control to remove
  73247. * @returns the current container
  73248. */
  73249. removeControl(control: Control): Container;
  73250. /**
  73251. * Creates a new Grid
  73252. * @param name defines control name
  73253. */
  73254. constructor(name?: string | undefined);
  73255. protected _getTypeName(): string;
  73256. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  73257. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73258. _flagDescendantsAsMatrixDirty(): void;
  73259. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73260. /** Releases associated resources */
  73261. dispose(): void;
  73262. }
  73263. }
  73264. declare module BABYLON.GUI {
  73265. /** Class used to create color pickers */
  73266. export class ColorPicker extends Control {
  73267. name?: string | undefined;
  73268. private static _Epsilon;
  73269. private _colorWheelCanvas;
  73270. private _value;
  73271. private _tmpColor;
  73272. private _pointerStartedOnSquare;
  73273. private _pointerStartedOnWheel;
  73274. private _squareLeft;
  73275. private _squareTop;
  73276. private _squareSize;
  73277. private _h;
  73278. private _s;
  73279. private _v;
  73280. private _lastPointerDownID;
  73281. /**
  73282. * BABYLON.Observable raised when the value changes
  73283. */
  73284. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  73285. /** Gets or sets the color of the color picker */
  73286. get value(): BABYLON.Color3;
  73287. set value(value: BABYLON.Color3);
  73288. /**
  73289. * Gets or sets control width
  73290. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73291. */
  73292. get width(): string | number;
  73293. set width(value: string | number);
  73294. /**
  73295. * Gets or sets control height
  73296. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73297. */
  73298. get height(): string | number;
  73299. /** Gets or sets control height */
  73300. set height(value: string | number);
  73301. /** Gets or sets control size */
  73302. get size(): string | number;
  73303. set size(value: string | number);
  73304. /**
  73305. * Creates a new ColorPicker
  73306. * @param name defines the control name
  73307. */
  73308. constructor(name?: string | undefined);
  73309. protected _getTypeName(): string;
  73310. /** @hidden */
  73311. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73312. private _updateSquareProps;
  73313. private _drawGradientSquare;
  73314. private _drawCircle;
  73315. private _createColorWheelCanvas;
  73316. /** @hidden */
  73317. _draw(context: CanvasRenderingContext2D): void;
  73318. private _pointerIsDown;
  73319. private _updateValueFromPointer;
  73320. private _isPointOnSquare;
  73321. private _isPointOnWheel;
  73322. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73323. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73324. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73325. /**
  73326. * This function expands the color picker by creating a color picker dialog with manual
  73327. * color value input and the ability to save colors into an array to be used later in
  73328. * subsequent launches of the dialogue.
  73329. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  73330. * @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.
  73331. * @returns picked color as a hex string and the saved colors array as hex strings.
  73332. */
  73333. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  73334. pickerWidth?: string;
  73335. pickerHeight?: string;
  73336. headerHeight?: string;
  73337. lastColor?: string;
  73338. swatchLimit?: number;
  73339. numSwatchesPerLine?: number;
  73340. savedColors?: Array<string>;
  73341. }): Promise<{
  73342. savedColors?: string[];
  73343. pickedColor: string;
  73344. }>;
  73345. }
  73346. }
  73347. declare module BABYLON.GUI {
  73348. /** Class used to create 2D ellipse containers */
  73349. export class Ellipse extends Container {
  73350. name?: string | undefined;
  73351. private _thickness;
  73352. /** Gets or sets border thickness */
  73353. get thickness(): number;
  73354. set thickness(value: number);
  73355. /**
  73356. * Creates a new Ellipse
  73357. * @param name defines the control name
  73358. */
  73359. constructor(name?: string | undefined);
  73360. protected _getTypeName(): string;
  73361. protected _localDraw(context: CanvasRenderingContext2D): void;
  73362. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73363. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73364. }
  73365. }
  73366. declare module BABYLON.GUI {
  73367. /**
  73368. * Class used to create a password control
  73369. */
  73370. export class InputPassword extends InputText {
  73371. protected _beforeRenderText(text: string): string;
  73372. }
  73373. }
  73374. declare module BABYLON.GUI {
  73375. /** Class used to render 2D lines */
  73376. export class Line extends Control {
  73377. name?: string | undefined;
  73378. private _lineWidth;
  73379. private _x1;
  73380. private _y1;
  73381. private _x2;
  73382. private _y2;
  73383. private _dash;
  73384. private _connectedControl;
  73385. private _connectedControlDirtyObserver;
  73386. /** Gets or sets the dash pattern */
  73387. get dash(): Array<number>;
  73388. set dash(value: Array<number>);
  73389. /** Gets or sets the control connected with the line end */
  73390. get connectedControl(): Control;
  73391. set connectedControl(value: Control);
  73392. /** Gets or sets start coordinates on X axis */
  73393. get x1(): string | number;
  73394. set x1(value: string | number);
  73395. /** Gets or sets start coordinates on Y axis */
  73396. get y1(): string | number;
  73397. set y1(value: string | number);
  73398. /** Gets or sets end coordinates on X axis */
  73399. get x2(): string | number;
  73400. set x2(value: string | number);
  73401. /** Gets or sets end coordinates on Y axis */
  73402. get y2(): string | number;
  73403. set y2(value: string | number);
  73404. /** Gets or sets line width */
  73405. get lineWidth(): number;
  73406. set lineWidth(value: number);
  73407. /** Gets or sets horizontal alignment */
  73408. set horizontalAlignment(value: number);
  73409. /** Gets or sets vertical alignment */
  73410. set verticalAlignment(value: number);
  73411. private get _effectiveX2();
  73412. private get _effectiveY2();
  73413. /**
  73414. * Creates a new Line
  73415. * @param name defines the control name
  73416. */
  73417. constructor(name?: string | undefined);
  73418. protected _getTypeName(): string;
  73419. _draw(context: CanvasRenderingContext2D): void;
  73420. _measure(): void;
  73421. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73422. /**
  73423. * Move one end of the line given 3D cartesian coordinates.
  73424. * @param position Targeted world position
  73425. * @param scene BABYLON.Scene
  73426. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73427. */
  73428. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  73429. /**
  73430. * Move one end of the line to a position in screen absolute space.
  73431. * @param projectedPosition Position in screen absolute space (X, Y)
  73432. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73433. */
  73434. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  73435. }
  73436. }
  73437. declare module BABYLON.GUI {
  73438. /**
  73439. * Class used to store a point for a MultiLine object.
  73440. * The point can be pure 2D coordinates, a mesh or a control
  73441. */
  73442. export class MultiLinePoint {
  73443. private _multiLine;
  73444. private _x;
  73445. private _y;
  73446. private _control;
  73447. private _mesh;
  73448. private _controlObserver;
  73449. private _meshObserver;
  73450. /** @hidden */
  73451. _point: BABYLON.Vector2;
  73452. /**
  73453. * Creates a new MultiLinePoint
  73454. * @param multiLine defines the source MultiLine object
  73455. */
  73456. constructor(multiLine: MultiLine);
  73457. /** Gets or sets x coordinate */
  73458. get x(): string | number;
  73459. set x(value: string | number);
  73460. /** Gets or sets y coordinate */
  73461. get y(): string | number;
  73462. set y(value: string | number);
  73463. /** Gets or sets the control associated with this point */
  73464. get control(): BABYLON.Nullable<Control>;
  73465. set control(value: BABYLON.Nullable<Control>);
  73466. /** Gets or sets the mesh associated with this point */
  73467. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73468. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  73469. /** Resets links */
  73470. resetLinks(): void;
  73471. /**
  73472. * Gets a translation vector
  73473. * @returns the translation vector
  73474. */
  73475. translate(): BABYLON.Vector2;
  73476. private _translatePoint;
  73477. /** Release associated resources */
  73478. dispose(): void;
  73479. }
  73480. }
  73481. declare module BABYLON.GUI {
  73482. /**
  73483. * Class used to create multi line control
  73484. */
  73485. export class MultiLine extends Control {
  73486. name?: string | undefined;
  73487. private _lineWidth;
  73488. private _dash;
  73489. private _points;
  73490. private _minX;
  73491. private _minY;
  73492. private _maxX;
  73493. private _maxY;
  73494. /**
  73495. * Creates a new MultiLine
  73496. * @param name defines the control name
  73497. */
  73498. constructor(name?: string | undefined);
  73499. /** Gets or sets dash pattern */
  73500. get dash(): Array<number>;
  73501. set dash(value: Array<number>);
  73502. /**
  73503. * Gets point stored at specified index
  73504. * @param index defines the index to look for
  73505. * @returns the requested point if found
  73506. */
  73507. getAt(index: number): MultiLinePoint;
  73508. /** Function called when a point is updated */
  73509. onPointUpdate: () => void;
  73510. /**
  73511. * Adds new points to the point collection
  73512. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  73513. * @returns the list of created MultiLinePoint
  73514. */
  73515. add(...items: (AbstractMesh | Control | {
  73516. x: string | number;
  73517. y: string | number;
  73518. })[]): MultiLinePoint[];
  73519. /**
  73520. * Adds a new point to the point collection
  73521. * @param item defines the item (mesh, control or 2d coordiantes) to add
  73522. * @returns the created MultiLinePoint
  73523. */
  73524. push(item?: (AbstractMesh | Control | {
  73525. x: string | number;
  73526. y: string | number;
  73527. })): MultiLinePoint;
  73528. /**
  73529. * Remove a specific value or point from the active point collection
  73530. * @param value defines the value or point to remove
  73531. */
  73532. remove(value: number | MultiLinePoint): void;
  73533. /**
  73534. * Resets this object to initial state (no point)
  73535. */
  73536. reset(): void;
  73537. /**
  73538. * Resets all links
  73539. */
  73540. resetLinks(): void;
  73541. /** Gets or sets line width */
  73542. get lineWidth(): number;
  73543. set lineWidth(value: number);
  73544. set horizontalAlignment(value: number);
  73545. set verticalAlignment(value: number);
  73546. protected _getTypeName(): string;
  73547. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73548. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73549. _measure(): void;
  73550. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73551. dispose(): void;
  73552. }
  73553. }
  73554. declare module BABYLON.GUI {
  73555. /**
  73556. * Class used to create radio button controls
  73557. */
  73558. export class RadioButton extends Control {
  73559. name?: string | undefined;
  73560. private _isChecked;
  73561. private _background;
  73562. private _checkSizeRatio;
  73563. private _thickness;
  73564. /** Gets or sets border thickness */
  73565. get thickness(): number;
  73566. set thickness(value: number);
  73567. /** Gets or sets group name */
  73568. group: string;
  73569. /** BABYLON.Observable raised when isChecked is changed */
  73570. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  73571. /** Gets or sets a value indicating the ratio between overall size and check size */
  73572. get checkSizeRatio(): number;
  73573. set checkSizeRatio(value: number);
  73574. /** Gets or sets background color */
  73575. get background(): string;
  73576. set background(value: string);
  73577. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  73578. get isChecked(): boolean;
  73579. set isChecked(value: boolean);
  73580. /**
  73581. * Creates a new RadioButton
  73582. * @param name defines the control name
  73583. */
  73584. constructor(name?: string | undefined);
  73585. protected _getTypeName(): string;
  73586. _draw(context: CanvasRenderingContext2D): void;
  73587. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73588. /**
  73589. * Utility function to easily create a radio button with a header
  73590. * @param title defines the label to use for the header
  73591. * @param group defines the group to use for the radio button
  73592. * @param isChecked defines the initial state of the radio button
  73593. * @param onValueChanged defines the callback to call when value changes
  73594. * @returns a StackPanel containing the radio button and a textBlock
  73595. */
  73596. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  73597. }
  73598. }
  73599. declare module BABYLON.GUI {
  73600. /**
  73601. * Class used to create slider controls
  73602. */
  73603. export class BaseSlider extends Control {
  73604. name?: string | undefined;
  73605. protected _thumbWidth: ValueAndUnit;
  73606. private _minimum;
  73607. private _maximum;
  73608. private _value;
  73609. private _isVertical;
  73610. protected _barOffset: ValueAndUnit;
  73611. private _isThumbClamped;
  73612. protected _displayThumb: boolean;
  73613. private _step;
  73614. private _lastPointerDownID;
  73615. protected _effectiveBarOffset: number;
  73616. protected _renderLeft: number;
  73617. protected _renderTop: number;
  73618. protected _renderWidth: number;
  73619. protected _renderHeight: number;
  73620. protected _backgroundBoxLength: number;
  73621. protected _backgroundBoxThickness: number;
  73622. protected _effectiveThumbThickness: number;
  73623. /** BABYLON.Observable raised when the sldier value changes */
  73624. onValueChangedObservable: BABYLON.Observable<number>;
  73625. /** Gets or sets a boolean indicating if the thumb must be rendered */
  73626. get displayThumb(): boolean;
  73627. set displayThumb(value: boolean);
  73628. /** Gets or sets a step to apply to values (0 by default) */
  73629. get step(): number;
  73630. set step(value: number);
  73631. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  73632. get barOffset(): string | number;
  73633. /** Gets main bar offset in pixels*/
  73634. get barOffsetInPixels(): number;
  73635. set barOffset(value: string | number);
  73636. /** Gets or sets thumb width */
  73637. get thumbWidth(): string | number;
  73638. /** Gets thumb width in pixels */
  73639. get thumbWidthInPixels(): number;
  73640. set thumbWidth(value: string | number);
  73641. /** Gets or sets minimum value */
  73642. get minimum(): number;
  73643. set minimum(value: number);
  73644. /** Gets or sets maximum value */
  73645. get maximum(): number;
  73646. set maximum(value: number);
  73647. /** Gets or sets current value */
  73648. get value(): number;
  73649. set value(value: number);
  73650. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  73651. get isVertical(): boolean;
  73652. set isVertical(value: boolean);
  73653. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  73654. get isThumbClamped(): boolean;
  73655. set isThumbClamped(value: boolean);
  73656. /**
  73657. * Creates a new BaseSlider
  73658. * @param name defines the control name
  73659. */
  73660. constructor(name?: string | undefined);
  73661. protected _getTypeName(): string;
  73662. protected _getThumbPosition(): number;
  73663. protected _getThumbThickness(type: string): number;
  73664. protected _prepareRenderingData(type: string): void;
  73665. private _pointerIsDown;
  73666. /** @hidden */
  73667. protected _updateValueFromPointer(x: number, y: number): void;
  73668. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73669. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73670. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73671. }
  73672. }
  73673. declare module BABYLON.GUI {
  73674. /**
  73675. * Class used to create slider controls
  73676. */
  73677. export class Slider extends BaseSlider {
  73678. name?: string | undefined;
  73679. private _background;
  73680. private _borderColor;
  73681. private _isThumbCircle;
  73682. protected _displayValueBar: boolean;
  73683. /** Gets or sets a boolean indicating if the value bar must be rendered */
  73684. get displayValueBar(): boolean;
  73685. set displayValueBar(value: boolean);
  73686. /** Gets or sets border color */
  73687. get borderColor(): string;
  73688. set borderColor(value: string);
  73689. /** Gets or sets background color */
  73690. get background(): string;
  73691. set background(value: string);
  73692. /** Gets or sets a boolean indicating if the thumb should be round or square */
  73693. get isThumbCircle(): boolean;
  73694. set isThumbCircle(value: boolean);
  73695. /**
  73696. * Creates a new Slider
  73697. * @param name defines the control name
  73698. */
  73699. constructor(name?: string | undefined);
  73700. protected _getTypeName(): string;
  73701. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73702. }
  73703. }
  73704. declare module BABYLON.GUI {
  73705. /** Class used to create a RadioGroup
  73706. * which contains groups of radio buttons
  73707. */
  73708. export class SelectorGroup {
  73709. /** name of SelectorGroup */
  73710. name: string;
  73711. private _groupPanel;
  73712. private _selectors;
  73713. private _groupHeader;
  73714. /**
  73715. * Creates a new SelectorGroup
  73716. * @param name of group, used as a group heading
  73717. */
  73718. constructor(
  73719. /** name of SelectorGroup */
  73720. name: string);
  73721. /** Gets the groupPanel of the SelectorGroup */
  73722. get groupPanel(): StackPanel;
  73723. /** Gets the selectors array */
  73724. get selectors(): StackPanel[];
  73725. /** Gets and sets the group header */
  73726. get header(): string;
  73727. set header(label: string);
  73728. /** @hidden */
  73729. private _addGroupHeader;
  73730. /** @hidden*/
  73731. _getSelector(selectorNb: number): StackPanel | undefined;
  73732. /** Removes the selector at the given position
  73733. * @param selectorNb the position of the selector within the group
  73734. */
  73735. removeSelector(selectorNb: number): void;
  73736. }
  73737. /** Class used to create a CheckboxGroup
  73738. * which contains groups of checkbox buttons
  73739. */
  73740. export class CheckboxGroup extends SelectorGroup {
  73741. /** Adds a checkbox as a control
  73742. * @param text is the label for the selector
  73743. * @param func is the function called when the Selector is checked
  73744. * @param checked is true when Selector is checked
  73745. */
  73746. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  73747. /** @hidden */
  73748. _setSelectorLabel(selectorNb: number, label: string): void;
  73749. /** @hidden */
  73750. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73751. /** @hidden */
  73752. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73753. /** @hidden */
  73754. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73755. }
  73756. /** Class used to create a RadioGroup
  73757. * which contains groups of radio buttons
  73758. */
  73759. export class RadioGroup extends SelectorGroup {
  73760. private _selectNb;
  73761. /** Adds a radio button as a control
  73762. * @param label is the label for the selector
  73763. * @param func is the function called when the Selector is checked
  73764. * @param checked is true when Selector is checked
  73765. */
  73766. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  73767. /** @hidden */
  73768. _setSelectorLabel(selectorNb: number, label: string): void;
  73769. /** @hidden */
  73770. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73771. /** @hidden */
  73772. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73773. /** @hidden */
  73774. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73775. }
  73776. /** Class used to create a SliderGroup
  73777. * which contains groups of slider buttons
  73778. */
  73779. export class SliderGroup extends SelectorGroup {
  73780. /**
  73781. * Adds a slider to the SelectorGroup
  73782. * @param label is the label for the SliderBar
  73783. * @param func is the function called when the Slider moves
  73784. * @param unit is a string describing the units used, eg degrees or metres
  73785. * @param min is the minimum value for the Slider
  73786. * @param max is the maximum value for the Slider
  73787. * @param value is the start value for the Slider between min and max
  73788. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  73789. */
  73790. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  73791. /** @hidden */
  73792. _setSelectorLabel(selectorNb: number, label: string): void;
  73793. /** @hidden */
  73794. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73795. /** @hidden */
  73796. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73797. /** @hidden */
  73798. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73799. }
  73800. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  73801. * @see http://doc.babylonjs.com/how_to/selector
  73802. */
  73803. export class SelectionPanel extends Rectangle {
  73804. /** name of SelectionPanel */
  73805. name: string;
  73806. /** an array of SelectionGroups */
  73807. groups: SelectorGroup[];
  73808. private _panel;
  73809. private _buttonColor;
  73810. private _buttonBackground;
  73811. private _headerColor;
  73812. private _barColor;
  73813. private _barHeight;
  73814. private _spacerHeight;
  73815. private _labelColor;
  73816. private _groups;
  73817. private _bars;
  73818. /**
  73819. * Creates a new SelectionPanel
  73820. * @param name of SelectionPanel
  73821. * @param groups is an array of SelectionGroups
  73822. */
  73823. constructor(
  73824. /** name of SelectionPanel */
  73825. name: string,
  73826. /** an array of SelectionGroups */
  73827. groups?: SelectorGroup[]);
  73828. protected _getTypeName(): string;
  73829. /** Gets or sets the headerColor */
  73830. get headerColor(): string;
  73831. set headerColor(color: string);
  73832. private _setHeaderColor;
  73833. /** Gets or sets the button color */
  73834. get buttonColor(): string;
  73835. set buttonColor(color: string);
  73836. private _setbuttonColor;
  73837. /** Gets or sets the label color */
  73838. get labelColor(): string;
  73839. set labelColor(color: string);
  73840. private _setLabelColor;
  73841. /** Gets or sets the button background */
  73842. get buttonBackground(): string;
  73843. set buttonBackground(color: string);
  73844. private _setButtonBackground;
  73845. /** Gets or sets the color of separator bar */
  73846. get barColor(): string;
  73847. set barColor(color: string);
  73848. private _setBarColor;
  73849. /** Gets or sets the height of separator bar */
  73850. get barHeight(): string;
  73851. set barHeight(value: string);
  73852. private _setBarHeight;
  73853. /** Gets or sets the height of spacers*/
  73854. get spacerHeight(): string;
  73855. set spacerHeight(value: string);
  73856. private _setSpacerHeight;
  73857. /** Adds a bar between groups */
  73858. private _addSpacer;
  73859. /** Add a group to the selection panel
  73860. * @param group is the selector group to add
  73861. */
  73862. addGroup(group: SelectorGroup): void;
  73863. /** Remove the group from the given position
  73864. * @param groupNb is the position of the group in the list
  73865. */
  73866. removeGroup(groupNb: number): void;
  73867. /** Change a group header label
  73868. * @param label is the new group header label
  73869. * @param groupNb is the number of the group to relabel
  73870. * */
  73871. setHeaderName(label: string, groupNb: number): void;
  73872. /** Change selector label to the one given
  73873. * @param label is the new selector label
  73874. * @param groupNb is the number of the groupcontaining the selector
  73875. * @param selectorNb is the number of the selector within a group to relabel
  73876. * */
  73877. relabel(label: string, groupNb: number, selectorNb: number): void;
  73878. /** For a given group position remove the selector at the given position
  73879. * @param groupNb is the number of the group to remove the selector from
  73880. * @param selectorNb is the number of the selector within the group
  73881. */
  73882. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  73883. /** For a given group position of correct type add a checkbox button
  73884. * @param groupNb is the number of the group to remove the selector from
  73885. * @param label is the label for the selector
  73886. * @param func is the function called when the Selector is checked
  73887. * @param checked is true when Selector is checked
  73888. */
  73889. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73890. /** For a given group position of correct type add a radio button
  73891. * @param groupNb is the number of the group to remove the selector from
  73892. * @param label is the label for the selector
  73893. * @param func is the function called when the Selector is checked
  73894. * @param checked is true when Selector is checked
  73895. */
  73896. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73897. /**
  73898. * For a given slider group add a slider
  73899. * @param groupNb is the number of the group to add the slider to
  73900. * @param label is the label for the Slider
  73901. * @param func is the function called when the Slider moves
  73902. * @param unit is a string describing the units used, eg degrees or metres
  73903. * @param min is the minimum value for the Slider
  73904. * @param max is the maximum value for the Slider
  73905. * @param value is the start value for the Slider between min and max
  73906. * @param onVal is the function used to format the value displayed, eg radians to degrees
  73907. */
  73908. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  73909. }
  73910. }
  73911. declare module BABYLON.GUI {
  73912. /**
  73913. * Class used to hold a the container for ScrollViewer
  73914. * @hidden
  73915. */
  73916. export class _ScrollViewerWindow extends Container {
  73917. parentClientWidth: number;
  73918. parentClientHeight: number;
  73919. private _freezeControls;
  73920. private _parentMeasure;
  73921. private _oldLeft;
  73922. private _oldTop;
  73923. get freezeControls(): boolean;
  73924. set freezeControls(value: boolean);
  73925. private _bucketWidth;
  73926. private _bucketHeight;
  73927. private _buckets;
  73928. private _bucketLen;
  73929. get bucketWidth(): number;
  73930. get bucketHeight(): number;
  73931. setBucketSizes(width: number, height: number): void;
  73932. private _useBuckets;
  73933. private _makeBuckets;
  73934. private _dispatchInBuckets;
  73935. private _updateMeasures;
  73936. private _updateChildrenMeasures;
  73937. private _restoreMeasures;
  73938. /**
  73939. * Creates a new ScrollViewerWindow
  73940. * @param name of ScrollViewerWindow
  73941. */
  73942. constructor(name?: string);
  73943. protected _getTypeName(): string;
  73944. /** @hidden */
  73945. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73946. /** @hidden */
  73947. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  73948. private _scrollChildren;
  73949. private _scrollChildrenWithBuckets;
  73950. /** @hidden */
  73951. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  73952. protected _postMeasure(): void;
  73953. }
  73954. }
  73955. declare module BABYLON.GUI {
  73956. /**
  73957. * Class used to create slider controls
  73958. */
  73959. export class ScrollBar extends BaseSlider {
  73960. name?: string | undefined;
  73961. private _background;
  73962. private _borderColor;
  73963. private _tempMeasure;
  73964. /** Gets or sets border color */
  73965. get borderColor(): string;
  73966. set borderColor(value: string);
  73967. /** Gets or sets background color */
  73968. get background(): string;
  73969. set background(value: string);
  73970. /**
  73971. * Creates a new Slider
  73972. * @param name defines the control name
  73973. */
  73974. constructor(name?: string | undefined);
  73975. protected _getTypeName(): string;
  73976. protected _getThumbThickness(): number;
  73977. _draw(context: CanvasRenderingContext2D): void;
  73978. private _first;
  73979. private _originX;
  73980. private _originY;
  73981. /** @hidden */
  73982. protected _updateValueFromPointer(x: number, y: number): void;
  73983. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73984. }
  73985. }
  73986. declare module BABYLON.GUI {
  73987. /**
  73988. * Class used to create slider controls
  73989. */
  73990. export class ImageScrollBar extends BaseSlider {
  73991. name?: string | undefined;
  73992. private _backgroundBaseImage;
  73993. private _backgroundImage;
  73994. private _thumbImage;
  73995. private _thumbBaseImage;
  73996. private _thumbLength;
  73997. private _thumbHeight;
  73998. private _barImageHeight;
  73999. private _tempMeasure;
  74000. /** Number of 90° rotation to apply on the images when in vertical mode */
  74001. num90RotationInVerticalMode: number;
  74002. /**
  74003. * Gets or sets the image used to render the background for horizontal bar
  74004. */
  74005. get backgroundImage(): Image;
  74006. set backgroundImage(value: Image);
  74007. /**
  74008. * Gets or sets the image used to render the thumb
  74009. */
  74010. get thumbImage(): Image;
  74011. set thumbImage(value: Image);
  74012. /**
  74013. * Gets or sets the length of the thumb
  74014. */
  74015. get thumbLength(): number;
  74016. set thumbLength(value: number);
  74017. /**
  74018. * Gets or sets the height of the thumb
  74019. */
  74020. get thumbHeight(): number;
  74021. set thumbHeight(value: number);
  74022. /**
  74023. * Gets or sets the height of the bar image
  74024. */
  74025. get barImageHeight(): number;
  74026. set barImageHeight(value: number);
  74027. /**
  74028. * Creates a new ImageScrollBar
  74029. * @param name defines the control name
  74030. */
  74031. constructor(name?: string | undefined);
  74032. protected _getTypeName(): string;
  74033. protected _getThumbThickness(): number;
  74034. _draw(context: CanvasRenderingContext2D): void;
  74035. private _first;
  74036. private _originX;
  74037. private _originY;
  74038. /** @hidden */
  74039. protected _updateValueFromPointer(x: number, y: number): void;
  74040. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74041. }
  74042. }
  74043. declare module BABYLON.GUI {
  74044. /**
  74045. * Class used to hold a viewer window and sliders in a grid
  74046. */
  74047. export class ScrollViewer extends Rectangle {
  74048. private _grid;
  74049. private _horizontalBarSpace;
  74050. private _verticalBarSpace;
  74051. private _dragSpace;
  74052. private _horizontalBar;
  74053. private _verticalBar;
  74054. private _barColor;
  74055. private _barBackground;
  74056. private _barImage;
  74057. private _horizontalBarImage;
  74058. private _verticalBarImage;
  74059. private _barBackgroundImage;
  74060. private _horizontalBarBackgroundImage;
  74061. private _verticalBarBackgroundImage;
  74062. private _barSize;
  74063. private _window;
  74064. private _pointerIsOver;
  74065. private _wheelPrecision;
  74066. private _onWheelObserver;
  74067. private _clientWidth;
  74068. private _clientHeight;
  74069. private _useImageBar;
  74070. private _thumbLength;
  74071. private _thumbHeight;
  74072. private _barImageHeight;
  74073. private _horizontalBarImageHeight;
  74074. private _verticalBarImageHeight;
  74075. /**
  74076. * Gets the horizontal scrollbar
  74077. */
  74078. get horizontalBar(): ScrollBar | ImageScrollBar;
  74079. /**
  74080. * Gets the vertical scrollbar
  74081. */
  74082. get verticalBar(): ScrollBar | ImageScrollBar;
  74083. /**
  74084. * Adds a new control to the current container
  74085. * @param control defines the control to add
  74086. * @returns the current container
  74087. */
  74088. addControl(control: BABYLON.Nullable<Control>): Container;
  74089. /**
  74090. * Removes a control from the current container
  74091. * @param control defines the control to remove
  74092. * @returns the current container
  74093. */
  74094. removeControl(control: Control): Container;
  74095. /** Gets the list of children */
  74096. get children(): Control[];
  74097. _flagDescendantsAsMatrixDirty(): void;
  74098. /**
  74099. * Freezes or unfreezes the controls in the window.
  74100. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  74101. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  74102. */
  74103. get freezeControls(): boolean;
  74104. set freezeControls(value: boolean);
  74105. /** Gets the bucket width */
  74106. get bucketWidth(): number;
  74107. /** Gets the bucket height */
  74108. get bucketHeight(): number;
  74109. /**
  74110. * Sets the bucket sizes.
  74111. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  74112. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  74113. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  74114. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  74115. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  74116. * used), that's why it is not enabled by default.
  74117. * @param width width of the bucket
  74118. * @param height height of the bucket
  74119. */
  74120. setBucketSizes(width: number, height: number): void;
  74121. private _forceHorizontalBar;
  74122. private _forceVerticalBar;
  74123. /**
  74124. * Forces the horizontal scroll bar to be displayed
  74125. */
  74126. get forceHorizontalBar(): boolean;
  74127. set forceHorizontalBar(value: boolean);
  74128. /**
  74129. * Forces the vertical scroll bar to be displayed
  74130. */
  74131. get forceVerticalBar(): boolean;
  74132. set forceVerticalBar(value: boolean);
  74133. /**
  74134. * Creates a new ScrollViewer
  74135. * @param name of ScrollViewer
  74136. */
  74137. constructor(name?: string, isImageBased?: boolean);
  74138. /** Reset the scroll viewer window to initial size */
  74139. resetWindow(): void;
  74140. protected _getTypeName(): string;
  74141. private _buildClientSizes;
  74142. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74143. protected _postMeasure(): void;
  74144. /**
  74145. * Gets or sets the mouse wheel precision
  74146. * from 0 to 1 with a default value of 0.05
  74147. * */
  74148. get wheelPrecision(): number;
  74149. set wheelPrecision(value: number);
  74150. /** Gets or sets the scroll bar container background color */
  74151. get scrollBackground(): string;
  74152. set scrollBackground(color: string);
  74153. /** Gets or sets the bar color */
  74154. get barColor(): string;
  74155. set barColor(color: string);
  74156. /** Gets or sets the bar image */
  74157. get thumbImage(): Image;
  74158. set thumbImage(value: Image);
  74159. /** Gets or sets the horizontal bar image */
  74160. get horizontalThumbImage(): Image;
  74161. set horizontalThumbImage(value: Image);
  74162. /** Gets or sets the vertical bar image */
  74163. get verticalThumbImage(): Image;
  74164. set verticalThumbImage(value: Image);
  74165. /** Gets or sets the size of the bar */
  74166. get barSize(): number;
  74167. set barSize(value: number);
  74168. /** Gets or sets the length of the thumb */
  74169. get thumbLength(): number;
  74170. set thumbLength(value: number);
  74171. /** Gets or sets the height of the thumb */
  74172. get thumbHeight(): number;
  74173. set thumbHeight(value: number);
  74174. /** Gets or sets the height of the bar image */
  74175. get barImageHeight(): number;
  74176. set barImageHeight(value: number);
  74177. /** Gets or sets the height of the horizontal bar image */
  74178. get horizontalBarImageHeight(): number;
  74179. set horizontalBarImageHeight(value: number);
  74180. /** Gets or sets the height of the vertical bar image */
  74181. get verticalBarImageHeight(): number;
  74182. set verticalBarImageHeight(value: number);
  74183. /** Gets or sets the bar background */
  74184. get barBackground(): string;
  74185. set barBackground(color: string);
  74186. /** Gets or sets the bar background image */
  74187. get barImage(): Image;
  74188. set barImage(value: Image);
  74189. /** Gets or sets the horizontal bar background image */
  74190. get horizontalBarImage(): Image;
  74191. set horizontalBarImage(value: Image);
  74192. /** Gets or sets the vertical bar background image */
  74193. get verticalBarImage(): Image;
  74194. set verticalBarImage(value: Image);
  74195. private _setWindowPosition;
  74196. /** @hidden */
  74197. private _updateScroller;
  74198. _link(host: AdvancedDynamicTexture): void;
  74199. /** @hidden */
  74200. private _addBar;
  74201. /** @hidden */
  74202. private _attachWheel;
  74203. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74204. /** Releases associated resources */
  74205. dispose(): void;
  74206. }
  74207. }
  74208. declare module BABYLON.GUI {
  74209. /** Class used to render a grid */
  74210. export class DisplayGrid extends Control {
  74211. name?: string | undefined;
  74212. private _cellWidth;
  74213. private _cellHeight;
  74214. private _minorLineTickness;
  74215. private _minorLineColor;
  74216. private _majorLineTickness;
  74217. private _majorLineColor;
  74218. private _majorLineFrequency;
  74219. private _background;
  74220. private _displayMajorLines;
  74221. private _displayMinorLines;
  74222. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  74223. get displayMinorLines(): boolean;
  74224. set displayMinorLines(value: boolean);
  74225. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  74226. get displayMajorLines(): boolean;
  74227. set displayMajorLines(value: boolean);
  74228. /** Gets or sets background color (Black by default) */
  74229. get background(): string;
  74230. set background(value: string);
  74231. /** Gets or sets the width of each cell (20 by default) */
  74232. get cellWidth(): number;
  74233. set cellWidth(value: number);
  74234. /** Gets or sets the height of each cell (20 by default) */
  74235. get cellHeight(): number;
  74236. set cellHeight(value: number);
  74237. /** Gets or sets the tickness of minor lines (1 by default) */
  74238. get minorLineTickness(): number;
  74239. set minorLineTickness(value: number);
  74240. /** Gets or sets the color of minor lines (DarkGray by default) */
  74241. get minorLineColor(): string;
  74242. set minorLineColor(value: string);
  74243. /** Gets or sets the tickness of major lines (2 by default) */
  74244. get majorLineTickness(): number;
  74245. set majorLineTickness(value: number);
  74246. /** Gets or sets the color of major lines (White by default) */
  74247. get majorLineColor(): string;
  74248. set majorLineColor(value: string);
  74249. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  74250. get majorLineFrequency(): number;
  74251. set majorLineFrequency(value: number);
  74252. /**
  74253. * Creates a new GridDisplayRectangle
  74254. * @param name defines the control name
  74255. */
  74256. constructor(name?: string | undefined);
  74257. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74258. protected _getTypeName(): string;
  74259. }
  74260. }
  74261. declare module BABYLON.GUI {
  74262. /**
  74263. * Class used to create slider controls based on images
  74264. */
  74265. export class ImageBasedSlider extends BaseSlider {
  74266. name?: string | undefined;
  74267. private _backgroundImage;
  74268. private _thumbImage;
  74269. private _valueBarImage;
  74270. private _tempMeasure;
  74271. get displayThumb(): boolean;
  74272. set displayThumb(value: boolean);
  74273. /**
  74274. * Gets or sets the image used to render the background
  74275. */
  74276. get backgroundImage(): Image;
  74277. set backgroundImage(value: Image);
  74278. /**
  74279. * Gets or sets the image used to render the value bar
  74280. */
  74281. get valueBarImage(): Image;
  74282. set valueBarImage(value: Image);
  74283. /**
  74284. * Gets or sets the image used to render the thumb
  74285. */
  74286. get thumbImage(): Image;
  74287. set thumbImage(value: Image);
  74288. /**
  74289. * Creates a new ImageBasedSlider
  74290. * @param name defines the control name
  74291. */
  74292. constructor(name?: string | undefined);
  74293. protected _getTypeName(): string;
  74294. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74295. }
  74296. }
  74297. declare module BABYLON.GUI {
  74298. /**
  74299. * Forcing an export so that this code will execute
  74300. * @hidden
  74301. */
  74302. const name = "Statics";
  74303. }
  74304. declare module BABYLON.GUI {
  74305. /**
  74306. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  74307. */
  74308. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  74309. /**
  74310. * Define the instrumented AdvancedDynamicTexture.
  74311. */
  74312. texture: AdvancedDynamicTexture;
  74313. private _captureRenderTime;
  74314. private _renderTime;
  74315. private _captureLayoutTime;
  74316. private _layoutTime;
  74317. private _onBeginRenderObserver;
  74318. private _onEndRenderObserver;
  74319. private _onBeginLayoutObserver;
  74320. private _onEndLayoutObserver;
  74321. /**
  74322. * Gets the perf counter used to capture render time
  74323. */
  74324. get renderTimeCounter(): BABYLON.PerfCounter;
  74325. /**
  74326. * Gets the perf counter used to capture layout time
  74327. */
  74328. get layoutTimeCounter(): BABYLON.PerfCounter;
  74329. /**
  74330. * Enable or disable the render time capture
  74331. */
  74332. get captureRenderTime(): boolean;
  74333. set captureRenderTime(value: boolean);
  74334. /**
  74335. * Enable or disable the layout time capture
  74336. */
  74337. get captureLayoutTime(): boolean;
  74338. set captureLayoutTime(value: boolean);
  74339. /**
  74340. * Instantiates a new advanced dynamic texture instrumentation.
  74341. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  74342. * @param texture Defines the AdvancedDynamicTexture to instrument
  74343. */
  74344. constructor(
  74345. /**
  74346. * Define the instrumented AdvancedDynamicTexture.
  74347. */
  74348. texture: AdvancedDynamicTexture);
  74349. /**
  74350. * Dispose and release associated resources.
  74351. */
  74352. dispose(): void;
  74353. }
  74354. }
  74355. declare module BABYLON.GUI {
  74356. /**
  74357. * Class used to load GUI via XML.
  74358. */
  74359. export class XmlLoader {
  74360. private _nodes;
  74361. private _nodeTypes;
  74362. private _isLoaded;
  74363. private _objectAttributes;
  74364. private _parentClass;
  74365. /**
  74366. * Create a new xml loader
  74367. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  74368. */
  74369. constructor(parentClass?: null);
  74370. private _getChainElement;
  74371. private _getClassAttribute;
  74372. private _createGuiElement;
  74373. private _parseGrid;
  74374. private _parseElement;
  74375. private _prepareSourceElement;
  74376. private _parseElementsFromSource;
  74377. private _parseXml;
  74378. /**
  74379. * Gets if the loading has finished.
  74380. * @returns whether the loading has finished or not
  74381. */
  74382. isLoaded(): boolean;
  74383. /**
  74384. * Gets a loaded node / control by id.
  74385. * @param id the Controls id set in the xml
  74386. * @returns element of type Control
  74387. */
  74388. getNodeById(id: string): any;
  74389. /**
  74390. * Gets all loaded nodes / controls
  74391. * @returns Array of controls
  74392. */
  74393. getNodes(): any;
  74394. /**
  74395. * Initiates the xml layout loading
  74396. * @param xmlFile defines the xml layout to load
  74397. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  74398. * @param callback defines the callback called on layout load.
  74399. */
  74400. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  74401. }
  74402. }
  74403. declare module BABYLON.GUI {
  74404. /**
  74405. * Class used to create containers for controls
  74406. */
  74407. export class Container3D extends Control3D {
  74408. private _blockLayout;
  74409. /**
  74410. * Gets the list of child controls
  74411. */
  74412. protected _children: Control3D[];
  74413. /**
  74414. * Gets the list of child controls
  74415. */
  74416. get children(): Array<Control3D>;
  74417. /**
  74418. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  74419. * This is helpful to optimize layout operation when adding multiple children in a row
  74420. */
  74421. get blockLayout(): boolean;
  74422. set blockLayout(value: boolean);
  74423. /**
  74424. * Creates a new container
  74425. * @param name defines the container name
  74426. */
  74427. constructor(name?: string);
  74428. /**
  74429. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  74430. * @returns the current container
  74431. */
  74432. updateLayout(): Container3D;
  74433. /**
  74434. * Gets a boolean indicating if the given control is in the children of this control
  74435. * @param control defines the control to check
  74436. * @returns true if the control is in the child list
  74437. */
  74438. containsControl(control: Control3D): boolean;
  74439. /**
  74440. * Adds a control to the children of this control
  74441. * @param control defines the control to add
  74442. * @returns the current container
  74443. */
  74444. addControl(control: Control3D): Container3D;
  74445. /**
  74446. * This function will be called everytime a new control is added
  74447. */
  74448. protected _arrangeChildren(): void;
  74449. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74450. /**
  74451. * Removes a control from the children of this control
  74452. * @param control defines the control to remove
  74453. * @returns the current container
  74454. */
  74455. removeControl(control: Control3D): Container3D;
  74456. protected _getTypeName(): string;
  74457. /**
  74458. * Releases all associated resources
  74459. */
  74460. dispose(): void;
  74461. /** Control rotation will remain unchanged */
  74462. static readonly UNSET_ORIENTATION: number;
  74463. /** Control will rotate to make it look at sphere central axis */
  74464. static readonly FACEORIGIN_ORIENTATION: number;
  74465. /** Control will rotate to make it look back at sphere central axis */
  74466. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  74467. /** Control will rotate to look at z axis (0, 0, 1) */
  74468. static readonly FACEFORWARD_ORIENTATION: number;
  74469. /** Control will rotate to look at negative z axis (0, 0, -1) */
  74470. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  74471. }
  74472. }
  74473. declare module BABYLON.GUI {
  74474. /**
  74475. * Class used to manage 3D user interface
  74476. * @see http://doc.babylonjs.com/how_to/gui3d
  74477. */
  74478. export class GUI3DManager implements BABYLON.IDisposable {
  74479. private _scene;
  74480. private _sceneDisposeObserver;
  74481. private _utilityLayer;
  74482. private _rootContainer;
  74483. private _pointerObserver;
  74484. private _pointerOutObserver;
  74485. /** @hidden */
  74486. _lastPickedControl: Control3D;
  74487. /** @hidden */
  74488. _lastControlOver: {
  74489. [pointerId: number]: Control3D;
  74490. };
  74491. /** @hidden */
  74492. _lastControlDown: {
  74493. [pointerId: number]: Control3D;
  74494. };
  74495. /**
  74496. * BABYLON.Observable raised when the point picked by the pointer events changed
  74497. */
  74498. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  74499. /** @hidden */
  74500. _sharedMaterials: {
  74501. [key: string]: BABYLON.Material;
  74502. };
  74503. /** Gets the hosting scene */
  74504. get scene(): BABYLON.Scene;
  74505. /** Gets associated utility layer */
  74506. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  74507. /**
  74508. * Creates a new GUI3DManager
  74509. * @param scene
  74510. */
  74511. constructor(scene?: BABYLON.Scene);
  74512. private _handlePointerOut;
  74513. private _doPicking;
  74514. /**
  74515. * Gets the root container
  74516. */
  74517. get rootContainer(): Container3D;
  74518. /**
  74519. * Gets a boolean indicating if the given control is in the root child list
  74520. * @param control defines the control to check
  74521. * @returns true if the control is in the root child list
  74522. */
  74523. containsControl(control: Control3D): boolean;
  74524. /**
  74525. * Adds a control to the root child list
  74526. * @param control defines the control to add
  74527. * @returns the current manager
  74528. */
  74529. addControl(control: Control3D): GUI3DManager;
  74530. /**
  74531. * Removes a control from the root child list
  74532. * @param control defines the control to remove
  74533. * @returns the current container
  74534. */
  74535. removeControl(control: Control3D): GUI3DManager;
  74536. /**
  74537. * Releases all associated resources
  74538. */
  74539. dispose(): void;
  74540. }
  74541. }
  74542. declare module BABYLON.GUI {
  74543. /**
  74544. * Class used to transport BABYLON.Vector3 information for pointer events
  74545. */
  74546. export class Vector3WithInfo extends BABYLON.Vector3 {
  74547. /** defines the current mouse button index */
  74548. buttonIndex: number;
  74549. /**
  74550. * Creates a new Vector3WithInfo
  74551. * @param source defines the vector3 data to transport
  74552. * @param buttonIndex defines the current mouse button index
  74553. */
  74554. constructor(source: BABYLON.Vector3,
  74555. /** defines the current mouse button index */
  74556. buttonIndex?: number);
  74557. }
  74558. }
  74559. declare module BABYLON.GUI {
  74560. /**
  74561. * Class used as base class for controls
  74562. */
  74563. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  74564. /** Defines the control name */
  74565. name?: string | undefined;
  74566. /** @hidden */
  74567. _host: GUI3DManager;
  74568. private _node;
  74569. private _downCount;
  74570. private _enterCount;
  74571. private _downPointerIds;
  74572. private _isVisible;
  74573. /** Gets or sets the control position in world space */
  74574. get position(): BABYLON.Vector3;
  74575. set position(value: BABYLON.Vector3);
  74576. /** Gets or sets the control scaling in world space */
  74577. get scaling(): BABYLON.Vector3;
  74578. set scaling(value: BABYLON.Vector3);
  74579. /** Callback used to start pointer enter animation */
  74580. pointerEnterAnimation: () => void;
  74581. /** Callback used to start pointer out animation */
  74582. pointerOutAnimation: () => void;
  74583. /** Callback used to start pointer down animation */
  74584. pointerDownAnimation: () => void;
  74585. /** Callback used to start pointer up animation */
  74586. pointerUpAnimation: () => void;
  74587. /**
  74588. * An event triggered when the pointer move over the control
  74589. */
  74590. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  74591. /**
  74592. * An event triggered when the pointer move out of the control
  74593. */
  74594. onPointerOutObservable: BABYLON.Observable<Control3D>;
  74595. /**
  74596. * An event triggered when the pointer taps the control
  74597. */
  74598. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  74599. /**
  74600. * An event triggered when pointer is up
  74601. */
  74602. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  74603. /**
  74604. * An event triggered when a control is clicked on (with a mouse)
  74605. */
  74606. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  74607. /**
  74608. * An event triggered when pointer enters the control
  74609. */
  74610. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  74611. /**
  74612. * Gets or sets the parent container
  74613. */
  74614. parent: BABYLON.Nullable<Container3D>;
  74615. private _behaviors;
  74616. /**
  74617. * Gets the list of attached behaviors
  74618. * @see http://doc.babylonjs.com/features/behaviour
  74619. */
  74620. get behaviors(): BABYLON.Behavior<Control3D>[];
  74621. /**
  74622. * Attach a behavior to the control
  74623. * @see http://doc.babylonjs.com/features/behaviour
  74624. * @param behavior defines the behavior to attach
  74625. * @returns the current control
  74626. */
  74627. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74628. /**
  74629. * Remove an attached behavior
  74630. * @see http://doc.babylonjs.com/features/behaviour
  74631. * @param behavior defines the behavior to attach
  74632. * @returns the current control
  74633. */
  74634. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74635. /**
  74636. * Gets an attached behavior by name
  74637. * @param name defines the name of the behavior to look for
  74638. * @see http://doc.babylonjs.com/features/behaviour
  74639. * @returns null if behavior was not found else the requested behavior
  74640. */
  74641. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  74642. /** Gets or sets a boolean indicating if the control is visible */
  74643. get isVisible(): boolean;
  74644. set isVisible(value: boolean);
  74645. /**
  74646. * Creates a new control
  74647. * @param name defines the control name
  74648. */
  74649. constructor(
  74650. /** Defines the control name */
  74651. name?: string | undefined);
  74652. /**
  74653. * Gets a string representing the class name
  74654. */
  74655. get typeName(): string;
  74656. /**
  74657. * Get the current class name of the control.
  74658. * @returns current class name
  74659. */
  74660. getClassName(): string;
  74661. protected _getTypeName(): string;
  74662. /**
  74663. * Gets the transform node used by this control
  74664. */
  74665. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  74666. /**
  74667. * Gets the mesh used to render this control
  74668. */
  74669. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74670. /**
  74671. * Link the control as child of the given node
  74672. * @param node defines the node to link to. Use null to unlink the control
  74673. * @returns the current control
  74674. */
  74675. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  74676. /** @hidden **/
  74677. _prepareNode(scene: BABYLON.Scene): void;
  74678. /**
  74679. * Node creation.
  74680. * Can be overriden by children
  74681. * @param scene defines the scene where the node must be attached
  74682. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  74683. */
  74684. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74685. /**
  74686. * Affect a material to the given mesh
  74687. * @param mesh defines the mesh which will represent the control
  74688. */
  74689. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74690. /** @hidden */
  74691. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  74692. /** @hidden */
  74693. _onPointerEnter(target: Control3D): boolean;
  74694. /** @hidden */
  74695. _onPointerOut(target: Control3D): void;
  74696. /** @hidden */
  74697. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74698. /** @hidden */
  74699. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74700. /** @hidden */
  74701. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74702. /** @hidden */
  74703. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74704. /** @hidden */
  74705. _disposeNode(): void;
  74706. /**
  74707. * Releases all associated resources
  74708. */
  74709. dispose(): void;
  74710. }
  74711. }
  74712. declare module BABYLON.GUI {
  74713. /**
  74714. * Class used as a root to all buttons
  74715. */
  74716. export class AbstractButton3D extends Control3D {
  74717. /**
  74718. * Creates a new button
  74719. * @param name defines the control name
  74720. */
  74721. constructor(name?: string);
  74722. protected _getTypeName(): string;
  74723. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74724. }
  74725. }
  74726. declare module BABYLON.GUI {
  74727. /**
  74728. * Class used to create a button in 3D
  74729. */
  74730. export class Button3D extends AbstractButton3D {
  74731. /** @hidden */
  74732. protected _currentMaterial: BABYLON.Material;
  74733. private _facadeTexture;
  74734. private _content;
  74735. private _contentResolution;
  74736. private _contentScaleRatio;
  74737. /**
  74738. * Gets or sets the texture resolution used to render content (512 by default)
  74739. */
  74740. get contentResolution(): BABYLON.int;
  74741. set contentResolution(value: BABYLON.int);
  74742. /**
  74743. * Gets or sets the texture scale ratio used to render content (2 by default)
  74744. */
  74745. get contentScaleRatio(): number;
  74746. set contentScaleRatio(value: number);
  74747. protected _disposeFacadeTexture(): void;
  74748. protected _resetContent(): void;
  74749. /**
  74750. * Creates a new button
  74751. * @param name defines the control name
  74752. */
  74753. constructor(name?: string);
  74754. /**
  74755. * Gets or sets the GUI 2D content used to display the button's facade
  74756. */
  74757. get content(): Control;
  74758. set content(value: Control);
  74759. /**
  74760. * Apply the facade texture (created from the content property).
  74761. * This function can be overloaded by child classes
  74762. * @param facadeTexture defines the AdvancedDynamicTexture to use
  74763. */
  74764. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74765. protected _getTypeName(): string;
  74766. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74767. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74768. /**
  74769. * Releases all associated resources
  74770. */
  74771. dispose(): void;
  74772. }
  74773. }
  74774. declare module BABYLON.GUI {
  74775. /**
  74776. * Abstract class used to create a container panel deployed on the surface of a volume
  74777. */
  74778. export abstract class VolumeBasedPanel extends Container3D {
  74779. private _columns;
  74780. private _rows;
  74781. private _rowThenColum;
  74782. private _orientation;
  74783. protected _cellWidth: number;
  74784. protected _cellHeight: number;
  74785. /**
  74786. * Gets or sets the distance between elements
  74787. */
  74788. margin: number;
  74789. /**
  74790. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  74791. * | Value | Type | Description |
  74792. * | ----- | ----------------------------------- | ----------- |
  74793. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  74794. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  74795. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  74796. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  74797. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  74798. */
  74799. get orientation(): number;
  74800. set orientation(value: number);
  74801. /**
  74802. * Gets or sets the number of columns requested (10 by default).
  74803. * The panel will automatically compute the number of rows based on number of child controls.
  74804. */
  74805. get columns(): BABYLON.int;
  74806. set columns(value: BABYLON.int);
  74807. /**
  74808. * Gets or sets a the number of rows requested.
  74809. * The panel will automatically compute the number of columns based on number of child controls.
  74810. */
  74811. get rows(): BABYLON.int;
  74812. set rows(value: BABYLON.int);
  74813. /**
  74814. * Creates new VolumeBasedPanel
  74815. */
  74816. constructor();
  74817. protected _arrangeChildren(): void;
  74818. /** Child classes must implement this function to provide correct control positioning */
  74819. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74820. /** Child classes can implement this function to provide additional processing */
  74821. protected _finalProcessing(): void;
  74822. }
  74823. }
  74824. declare module BABYLON.GUI {
  74825. /**
  74826. * Class used to create a container panel deployed on the surface of a cylinder
  74827. */
  74828. export class CylinderPanel extends VolumeBasedPanel {
  74829. private _radius;
  74830. /**
  74831. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  74832. */
  74833. get radius(): BABYLON.float;
  74834. set radius(value: BABYLON.float);
  74835. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74836. private _cylindricalMapping;
  74837. }
  74838. }
  74839. declare module BABYLON.GUI {
  74840. /** @hidden */
  74841. export var fluentVertexShader: {
  74842. name: string;
  74843. shader: string;
  74844. };
  74845. }
  74846. declare module BABYLON.GUI {
  74847. /** @hidden */
  74848. export var fluentPixelShader: {
  74849. name: string;
  74850. shader: string;
  74851. };
  74852. }
  74853. declare module BABYLON.GUI {
  74854. /** @hidden */
  74855. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  74856. INNERGLOW: boolean;
  74857. BORDER: boolean;
  74858. HOVERLIGHT: boolean;
  74859. TEXTURE: boolean;
  74860. constructor();
  74861. }
  74862. /**
  74863. * Class used to render controls with fluent desgin
  74864. */
  74865. export class FluentMaterial extends BABYLON.PushMaterial {
  74866. /**
  74867. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  74868. */
  74869. innerGlowColorIntensity: number;
  74870. /**
  74871. * Gets or sets the inner glow color (white by default)
  74872. */
  74873. innerGlowColor: BABYLON.Color3;
  74874. /**
  74875. * Gets or sets alpha value (default is 1.0)
  74876. */
  74877. alpha: number;
  74878. /**
  74879. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  74880. */
  74881. albedoColor: BABYLON.Color3;
  74882. /**
  74883. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  74884. */
  74885. renderBorders: boolean;
  74886. /**
  74887. * Gets or sets border width (default is 0.5)
  74888. */
  74889. borderWidth: number;
  74890. /**
  74891. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  74892. */
  74893. edgeSmoothingValue: number;
  74894. /**
  74895. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  74896. */
  74897. borderMinValue: number;
  74898. /**
  74899. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  74900. */
  74901. renderHoverLight: boolean;
  74902. /**
  74903. * Gets or sets the radius used to render the hover light (default is 1.0)
  74904. */
  74905. hoverRadius: number;
  74906. /**
  74907. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  74908. */
  74909. hoverColor: BABYLON.Color4;
  74910. /**
  74911. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  74912. */
  74913. hoverPosition: BABYLON.Vector3;
  74914. private _albedoTexture;
  74915. /** Gets or sets the texture to use for albedo color */
  74916. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  74917. /**
  74918. * Creates a new Fluent material
  74919. * @param name defines the name of the material
  74920. * @param scene defines the hosting scene
  74921. */
  74922. constructor(name: string, scene: BABYLON.Scene);
  74923. needAlphaBlending(): boolean;
  74924. needAlphaTesting(): boolean;
  74925. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74926. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74927. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74928. getActiveTextures(): BABYLON.BaseTexture[];
  74929. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74930. dispose(forceDisposeEffect?: boolean): void;
  74931. clone(name: string): FluentMaterial;
  74932. serialize(): any;
  74933. getClassName(): string;
  74934. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  74935. }
  74936. }
  74937. declare module BABYLON.GUI {
  74938. /**
  74939. * Class used to create a holographic button in 3D
  74940. */
  74941. export class HolographicButton extends Button3D {
  74942. private _backPlate;
  74943. private _textPlate;
  74944. private _frontPlate;
  74945. private _text;
  74946. private _imageUrl;
  74947. private _shareMaterials;
  74948. private _frontMaterial;
  74949. private _backMaterial;
  74950. private _plateMaterial;
  74951. private _pickedPointObserver;
  74952. private _tooltipFade;
  74953. private _tooltipTextBlock;
  74954. private _tooltipTexture;
  74955. private _tooltipMesh;
  74956. private _tooltipHoverObserver;
  74957. private _tooltipOutObserver;
  74958. private _disposeTooltip;
  74959. /**
  74960. * Rendering ground id of all the mesh in the button
  74961. */
  74962. set renderingGroupId(id: number);
  74963. get renderingGroupId(): number;
  74964. /**
  74965. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  74966. */
  74967. set tooltipText(text: BABYLON.Nullable<string>);
  74968. get tooltipText(): BABYLON.Nullable<string>;
  74969. /**
  74970. * Gets or sets text for the button
  74971. */
  74972. get text(): string;
  74973. set text(value: string);
  74974. /**
  74975. * Gets or sets the image url for the button
  74976. */
  74977. get imageUrl(): string;
  74978. set imageUrl(value: string);
  74979. /**
  74980. * Gets the back material used by this button
  74981. */
  74982. get backMaterial(): FluentMaterial;
  74983. /**
  74984. * Gets the front material used by this button
  74985. */
  74986. get frontMaterial(): FluentMaterial;
  74987. /**
  74988. * Gets the plate material used by this button
  74989. */
  74990. get plateMaterial(): BABYLON.StandardMaterial;
  74991. /**
  74992. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  74993. */
  74994. get shareMaterials(): boolean;
  74995. /**
  74996. * Creates a new button
  74997. * @param name defines the control name
  74998. */
  74999. constructor(name?: string, shareMaterials?: boolean);
  75000. protected _getTypeName(): string;
  75001. private _rebuildContent;
  75002. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75003. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  75004. private _createBackMaterial;
  75005. private _createFrontMaterial;
  75006. private _createPlateMaterial;
  75007. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  75008. /**
  75009. * Releases all associated resources
  75010. */
  75011. dispose(): void;
  75012. }
  75013. }
  75014. declare module BABYLON.GUI {
  75015. /**
  75016. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  75017. */
  75018. export class MeshButton3D extends Button3D {
  75019. /** @hidden */
  75020. protected _currentMesh: BABYLON.Mesh;
  75021. /**
  75022. * Creates a new 3D button based on a mesh
  75023. * @param mesh mesh to become a 3D button
  75024. * @param name defines the control name
  75025. */
  75026. constructor(mesh: BABYLON.Mesh, name?: string);
  75027. protected _getTypeName(): string;
  75028. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75029. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  75030. }
  75031. }
  75032. declare module BABYLON.GUI {
  75033. /**
  75034. * Class used to create a container panel deployed on the surface of a plane
  75035. */
  75036. export class PlanePanel extends VolumeBasedPanel {
  75037. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75038. }
  75039. }
  75040. declare module BABYLON.GUI {
  75041. /**
  75042. * Class used to create a container panel where items get randomized planar mapping
  75043. */
  75044. export class ScatterPanel extends VolumeBasedPanel {
  75045. private _iteration;
  75046. /**
  75047. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  75048. */
  75049. get iteration(): BABYLON.float;
  75050. set iteration(value: BABYLON.float);
  75051. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75052. private _scatterMapping;
  75053. protected _finalProcessing(): void;
  75054. }
  75055. }
  75056. declare module BABYLON.GUI {
  75057. /**
  75058. * Class used to create a container panel deployed on the surface of a sphere
  75059. */
  75060. export class SpherePanel extends VolumeBasedPanel {
  75061. private _radius;
  75062. /**
  75063. * Gets or sets the radius of the sphere where to project controls (5 by default)
  75064. */
  75065. get radius(): BABYLON.float;
  75066. set radius(value: BABYLON.float);
  75067. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75068. private _sphericalMapping;
  75069. }
  75070. }
  75071. declare module BABYLON.GUI {
  75072. /**
  75073. * Class used to create a stack panel in 3D on XY plane
  75074. */
  75075. export class StackPanel3D extends Container3D {
  75076. private _isVertical;
  75077. /**
  75078. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  75079. */
  75080. get isVertical(): boolean;
  75081. set isVertical(value: boolean);
  75082. /**
  75083. * Gets or sets the distance between elements
  75084. */
  75085. margin: number;
  75086. /**
  75087. * Creates new StackPanel
  75088. * @param isVertical
  75089. */
  75090. constructor(isVertical?: boolean);
  75091. protected _arrangeChildren(): void;
  75092. }
  75093. }
  75094. declare module BABYLON {
  75095. /**
  75096. * Configuration for glTF validation
  75097. */
  75098. export interface IGLTFValidationConfiguration {
  75099. /**
  75100. * The url of the glTF validator.
  75101. */
  75102. url: string;
  75103. }
  75104. /**
  75105. * glTF validation
  75106. */
  75107. export class GLTFValidation {
  75108. /**
  75109. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  75110. */
  75111. static Configuration: IGLTFValidationConfiguration;
  75112. private static _LoadScriptPromise;
  75113. /**
  75114. * Validate a glTF asset using the glTF-Validator.
  75115. * @param data The JSON of a glTF or the array buffer of a binary glTF
  75116. * @param rootUrl The root url for the glTF
  75117. * @param fileName The file name for the glTF
  75118. * @param getExternalResource The callback to get external resources for the glTF validator
  75119. * @returns A promise that resolves with the glTF validation results once complete
  75120. */
  75121. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  75122. }
  75123. }
  75124. declare module BABYLON {
  75125. /**
  75126. * Mode that determines the coordinate system to use.
  75127. */
  75128. export enum GLTFLoaderCoordinateSystemMode {
  75129. /**
  75130. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  75131. */
  75132. AUTO = 0,
  75133. /**
  75134. * Sets the useRightHandedSystem flag on the scene.
  75135. */
  75136. FORCE_RIGHT_HANDED = 1
  75137. }
  75138. /**
  75139. * Mode that determines what animations will start.
  75140. */
  75141. export enum GLTFLoaderAnimationStartMode {
  75142. /**
  75143. * No animation will start.
  75144. */
  75145. NONE = 0,
  75146. /**
  75147. * The first animation will start.
  75148. */
  75149. FIRST = 1,
  75150. /**
  75151. * All animations will start.
  75152. */
  75153. ALL = 2
  75154. }
  75155. /**
  75156. * Interface that contains the data for the glTF asset.
  75157. */
  75158. export interface IGLTFLoaderData {
  75159. /**
  75160. * The object that represents the glTF JSON.
  75161. */
  75162. json: Object;
  75163. /**
  75164. * The BIN chunk of a binary glTF.
  75165. */
  75166. bin: Nullable<IDataBuffer>;
  75167. }
  75168. /**
  75169. * Interface for extending the loader.
  75170. */
  75171. export interface IGLTFLoaderExtension {
  75172. /**
  75173. * The name of this extension.
  75174. */
  75175. readonly name: string;
  75176. /**
  75177. * Defines whether this extension is enabled.
  75178. */
  75179. enabled: boolean;
  75180. /**
  75181. * Defines the order of this extension.
  75182. * The loader sorts the extensions using these values when loading.
  75183. */
  75184. order?: number;
  75185. }
  75186. /**
  75187. * Loader state.
  75188. */
  75189. export enum GLTFLoaderState {
  75190. /**
  75191. * The asset is loading.
  75192. */
  75193. LOADING = 0,
  75194. /**
  75195. * The asset is ready for rendering.
  75196. */
  75197. READY = 1,
  75198. /**
  75199. * The asset is completely loaded.
  75200. */
  75201. COMPLETE = 2
  75202. }
  75203. /** @hidden */
  75204. export interface IImportMeshAsyncOutput {
  75205. meshes: AbstractMesh[];
  75206. particleSystems: IParticleSystem[];
  75207. skeletons: Skeleton[];
  75208. animationGroups: AnimationGroup[];
  75209. lights: Light[];
  75210. transformNodes: TransformNode[];
  75211. }
  75212. /** @hidden */
  75213. export interface IGLTFLoader extends IDisposable {
  75214. readonly state: Nullable<GLTFLoaderState>;
  75215. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  75216. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  75217. }
  75218. /**
  75219. * File loader for loading glTF files into a scene.
  75220. */
  75221. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  75222. /** @hidden */
  75223. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75224. /** @hidden */
  75225. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75226. /**
  75227. * Raised when the asset has been parsed
  75228. */
  75229. onParsedObservable: Observable<IGLTFLoaderData>;
  75230. private _onParsedObserver;
  75231. /**
  75232. * Raised when the asset has been parsed
  75233. */
  75234. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  75235. /**
  75236. * 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.
  75237. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  75238. * Defaults to true.
  75239. * @hidden
  75240. */
  75241. static IncrementalLoading: boolean;
  75242. /**
  75243. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  75244. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  75245. * @hidden
  75246. */
  75247. static HomogeneousCoordinates: boolean;
  75248. /**
  75249. * The coordinate system mode. Defaults to AUTO.
  75250. */
  75251. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  75252. /**
  75253. * The animation start mode. Defaults to FIRST.
  75254. */
  75255. animationStartMode: GLTFLoaderAnimationStartMode;
  75256. /**
  75257. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  75258. */
  75259. compileMaterials: boolean;
  75260. /**
  75261. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  75262. */
  75263. useClipPlane: boolean;
  75264. /**
  75265. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  75266. */
  75267. compileShadowGenerators: boolean;
  75268. /**
  75269. * Defines if the Alpha blended materials are only applied as coverage.
  75270. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  75271. * If true, no extra effects are applied to transparent pixels.
  75272. */
  75273. transparencyAsCoverage: boolean;
  75274. /**
  75275. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  75276. * Enabling will disable offline support and glTF validator.
  75277. * Defaults to false.
  75278. */
  75279. useRangeRequests: boolean;
  75280. /**
  75281. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  75282. */
  75283. createInstances: boolean;
  75284. /**
  75285. * Function called before loading a url referenced by the asset.
  75286. */
  75287. preprocessUrlAsync: (url: string) => Promise<string>;
  75288. /**
  75289. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75290. */
  75291. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  75292. private _onMeshLoadedObserver;
  75293. /**
  75294. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75295. */
  75296. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  75297. /**
  75298. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  75299. */
  75300. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  75301. private _onTextureLoadedObserver;
  75302. /**
  75303. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  75304. */
  75305. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  75306. /**
  75307. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  75308. */
  75309. readonly onMaterialLoadedObservable: Observable<Material>;
  75310. private _onMaterialLoadedObserver;
  75311. /**
  75312. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  75313. */
  75314. set onMaterialLoaded(callback: (material: Material) => void);
  75315. /**
  75316. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  75317. */
  75318. readonly onCameraLoadedObservable: Observable<Camera>;
  75319. private _onCameraLoadedObserver;
  75320. /**
  75321. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  75322. */
  75323. set onCameraLoaded(callback: (camera: Camera) => void);
  75324. /**
  75325. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  75326. * For assets with LODs, raised when all of the LODs are complete.
  75327. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75328. */
  75329. readonly onCompleteObservable: Observable<void>;
  75330. private _onCompleteObserver;
  75331. /**
  75332. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  75333. * For assets with LODs, raised when all of the LODs are complete.
  75334. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75335. */
  75336. set onComplete(callback: () => void);
  75337. /**
  75338. * Observable raised when an error occurs.
  75339. */
  75340. readonly onErrorObservable: Observable<any>;
  75341. private _onErrorObserver;
  75342. /**
  75343. * Callback raised when an error occurs.
  75344. */
  75345. set onError(callback: (reason: any) => void);
  75346. /**
  75347. * Observable raised after the loader is disposed.
  75348. */
  75349. readonly onDisposeObservable: Observable<void>;
  75350. private _onDisposeObserver;
  75351. /**
  75352. * Callback raised after the loader is disposed.
  75353. */
  75354. set onDispose(callback: () => void);
  75355. /**
  75356. * Observable raised after a loader extension is created.
  75357. * Set additional options for a loader extension in this event.
  75358. */
  75359. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  75360. private _onExtensionLoadedObserver;
  75361. /**
  75362. * Callback raised after a loader extension is created.
  75363. */
  75364. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  75365. /**
  75366. * Defines if the loader logging is enabled.
  75367. */
  75368. get loggingEnabled(): boolean;
  75369. set loggingEnabled(value: boolean);
  75370. /**
  75371. * Defines if the loader should capture performance counters.
  75372. */
  75373. get capturePerformanceCounters(): boolean;
  75374. set capturePerformanceCounters(value: boolean);
  75375. /**
  75376. * Defines if the loader should validate the asset.
  75377. */
  75378. validate: boolean;
  75379. /**
  75380. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  75381. */
  75382. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  75383. private _onValidatedObserver;
  75384. /**
  75385. * Callback raised after a loader extension is created.
  75386. */
  75387. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  75388. private _loader;
  75389. /**
  75390. * Name of the loader ("gltf")
  75391. */
  75392. name: string;
  75393. /** @hidden */
  75394. extensions: ISceneLoaderPluginExtensions;
  75395. /**
  75396. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  75397. */
  75398. dispose(): void;
  75399. /** @hidden */
  75400. _clear(): void;
  75401. /** @hidden */
  75402. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75403. /** @hidden */
  75404. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75405. /** @hidden */
  75406. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75407. meshes: AbstractMesh[];
  75408. particleSystems: IParticleSystem[];
  75409. skeletons: Skeleton[];
  75410. animationGroups: AnimationGroup[];
  75411. }>;
  75412. /** @hidden */
  75413. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75414. /** @hidden */
  75415. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  75416. /** @hidden */
  75417. canDirectLoad(data: string): boolean;
  75418. /** @hidden */
  75419. directLoad(scene: Scene, data: string): any;
  75420. /**
  75421. * The callback that allows custom handling of the root url based on the response url.
  75422. * @param rootUrl the original root url
  75423. * @param responseURL the response url if available
  75424. * @returns the new root url
  75425. */
  75426. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  75427. /** @hidden */
  75428. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  75429. /**
  75430. * The loader state or null if the loader is not active.
  75431. */
  75432. get loaderState(): Nullable<GLTFLoaderState>;
  75433. /**
  75434. * Returns a promise that resolves when the asset is completely loaded.
  75435. * @returns a promise that resolves when the asset is completely loaded.
  75436. */
  75437. whenCompleteAsync(): Promise<void>;
  75438. private _validate;
  75439. private _getLoader;
  75440. private _parseJson;
  75441. private _unpackBinaryAsync;
  75442. private _unpackBinaryV1Async;
  75443. private _unpackBinaryV2Async;
  75444. private static _parseVersion;
  75445. private static _compareVersion;
  75446. private static readonly _logSpaces;
  75447. private _logIndentLevel;
  75448. private _loggingEnabled;
  75449. /** @hidden */
  75450. _log: (message: string) => void;
  75451. /** @hidden */
  75452. _logOpen(message: string): void;
  75453. /** @hidden */
  75454. _logClose(): void;
  75455. private _logEnabled;
  75456. private _logDisabled;
  75457. private _capturePerformanceCounters;
  75458. /** @hidden */
  75459. _startPerformanceCounter: (counterName: string) => void;
  75460. /** @hidden */
  75461. _endPerformanceCounter: (counterName: string) => void;
  75462. private _startPerformanceCounterEnabled;
  75463. private _startPerformanceCounterDisabled;
  75464. private _endPerformanceCounterEnabled;
  75465. private _endPerformanceCounterDisabled;
  75466. }
  75467. }
  75468. declare module BABYLON.GLTF1 {
  75469. /**
  75470. * Enums
  75471. * @hidden
  75472. */
  75473. export enum EComponentType {
  75474. BYTE = 5120,
  75475. UNSIGNED_BYTE = 5121,
  75476. SHORT = 5122,
  75477. UNSIGNED_SHORT = 5123,
  75478. FLOAT = 5126
  75479. }
  75480. /** @hidden */
  75481. export enum EShaderType {
  75482. FRAGMENT = 35632,
  75483. VERTEX = 35633
  75484. }
  75485. /** @hidden */
  75486. export enum EParameterType {
  75487. BYTE = 5120,
  75488. UNSIGNED_BYTE = 5121,
  75489. SHORT = 5122,
  75490. UNSIGNED_SHORT = 5123,
  75491. INT = 5124,
  75492. UNSIGNED_INT = 5125,
  75493. FLOAT = 5126,
  75494. FLOAT_VEC2 = 35664,
  75495. FLOAT_VEC3 = 35665,
  75496. FLOAT_VEC4 = 35666,
  75497. INT_VEC2 = 35667,
  75498. INT_VEC3 = 35668,
  75499. INT_VEC4 = 35669,
  75500. BOOL = 35670,
  75501. BOOL_VEC2 = 35671,
  75502. BOOL_VEC3 = 35672,
  75503. BOOL_VEC4 = 35673,
  75504. FLOAT_MAT2 = 35674,
  75505. FLOAT_MAT3 = 35675,
  75506. FLOAT_MAT4 = 35676,
  75507. SAMPLER_2D = 35678
  75508. }
  75509. /** @hidden */
  75510. export enum ETextureWrapMode {
  75511. CLAMP_TO_EDGE = 33071,
  75512. MIRRORED_REPEAT = 33648,
  75513. REPEAT = 10497
  75514. }
  75515. /** @hidden */
  75516. export enum ETextureFilterType {
  75517. NEAREST = 9728,
  75518. LINEAR = 9728,
  75519. NEAREST_MIPMAP_NEAREST = 9984,
  75520. LINEAR_MIPMAP_NEAREST = 9985,
  75521. NEAREST_MIPMAP_LINEAR = 9986,
  75522. LINEAR_MIPMAP_LINEAR = 9987
  75523. }
  75524. /** @hidden */
  75525. export enum ETextureFormat {
  75526. ALPHA = 6406,
  75527. RGB = 6407,
  75528. RGBA = 6408,
  75529. LUMINANCE = 6409,
  75530. LUMINANCE_ALPHA = 6410
  75531. }
  75532. /** @hidden */
  75533. export enum ECullingType {
  75534. FRONT = 1028,
  75535. BACK = 1029,
  75536. FRONT_AND_BACK = 1032
  75537. }
  75538. /** @hidden */
  75539. export enum EBlendingFunction {
  75540. ZERO = 0,
  75541. ONE = 1,
  75542. SRC_COLOR = 768,
  75543. ONE_MINUS_SRC_COLOR = 769,
  75544. DST_COLOR = 774,
  75545. ONE_MINUS_DST_COLOR = 775,
  75546. SRC_ALPHA = 770,
  75547. ONE_MINUS_SRC_ALPHA = 771,
  75548. DST_ALPHA = 772,
  75549. ONE_MINUS_DST_ALPHA = 773,
  75550. CONSTANT_COLOR = 32769,
  75551. ONE_MINUS_CONSTANT_COLOR = 32770,
  75552. CONSTANT_ALPHA = 32771,
  75553. ONE_MINUS_CONSTANT_ALPHA = 32772,
  75554. SRC_ALPHA_SATURATE = 776
  75555. }
  75556. /** @hidden */
  75557. export interface IGLTFProperty {
  75558. extensions?: {
  75559. [key: string]: any;
  75560. };
  75561. extras?: Object;
  75562. }
  75563. /** @hidden */
  75564. export interface IGLTFChildRootProperty extends IGLTFProperty {
  75565. name?: string;
  75566. }
  75567. /** @hidden */
  75568. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  75569. bufferView: string;
  75570. byteOffset: number;
  75571. byteStride: number;
  75572. count: number;
  75573. type: string;
  75574. componentType: EComponentType;
  75575. max?: number[];
  75576. min?: number[];
  75577. name?: string;
  75578. }
  75579. /** @hidden */
  75580. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  75581. buffer: string;
  75582. byteOffset: number;
  75583. byteLength: number;
  75584. byteStride: number;
  75585. target?: number;
  75586. }
  75587. /** @hidden */
  75588. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  75589. uri: string;
  75590. byteLength?: number;
  75591. type?: string;
  75592. }
  75593. /** @hidden */
  75594. export interface IGLTFShader extends IGLTFChildRootProperty {
  75595. uri: string;
  75596. type: EShaderType;
  75597. }
  75598. /** @hidden */
  75599. export interface IGLTFProgram extends IGLTFChildRootProperty {
  75600. attributes: string[];
  75601. fragmentShader: string;
  75602. vertexShader: string;
  75603. }
  75604. /** @hidden */
  75605. export interface IGLTFTechniqueParameter {
  75606. type: number;
  75607. count?: number;
  75608. semantic?: string;
  75609. node?: string;
  75610. value?: number | boolean | string | Array<any>;
  75611. source?: string;
  75612. babylonValue?: any;
  75613. }
  75614. /** @hidden */
  75615. export interface IGLTFTechniqueCommonProfile {
  75616. lightingModel: string;
  75617. texcoordBindings: Object;
  75618. parameters?: Array<any>;
  75619. }
  75620. /** @hidden */
  75621. export interface IGLTFTechniqueStatesFunctions {
  75622. blendColor?: number[];
  75623. blendEquationSeparate?: number[];
  75624. blendFuncSeparate?: number[];
  75625. colorMask: boolean[];
  75626. cullFace: number[];
  75627. }
  75628. /** @hidden */
  75629. export interface IGLTFTechniqueStates {
  75630. enable: number[];
  75631. functions: IGLTFTechniqueStatesFunctions;
  75632. }
  75633. /** @hidden */
  75634. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  75635. parameters: {
  75636. [key: string]: IGLTFTechniqueParameter;
  75637. };
  75638. program: string;
  75639. attributes: {
  75640. [key: string]: string;
  75641. };
  75642. uniforms: {
  75643. [key: string]: string;
  75644. };
  75645. states: IGLTFTechniqueStates;
  75646. }
  75647. /** @hidden */
  75648. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  75649. technique?: string;
  75650. values: string[];
  75651. }
  75652. /** @hidden */
  75653. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  75654. attributes: {
  75655. [key: string]: string;
  75656. };
  75657. indices: string;
  75658. material: string;
  75659. mode?: number;
  75660. }
  75661. /** @hidden */
  75662. export interface IGLTFMesh extends IGLTFChildRootProperty {
  75663. primitives: IGLTFMeshPrimitive[];
  75664. }
  75665. /** @hidden */
  75666. export interface IGLTFImage extends IGLTFChildRootProperty {
  75667. uri: string;
  75668. }
  75669. /** @hidden */
  75670. export interface IGLTFSampler extends IGLTFChildRootProperty {
  75671. magFilter?: number;
  75672. minFilter?: number;
  75673. wrapS?: number;
  75674. wrapT?: number;
  75675. }
  75676. /** @hidden */
  75677. export interface IGLTFTexture extends IGLTFChildRootProperty {
  75678. sampler: string;
  75679. source: string;
  75680. format?: ETextureFormat;
  75681. internalFormat?: ETextureFormat;
  75682. target?: number;
  75683. type?: number;
  75684. babylonTexture?: Texture;
  75685. }
  75686. /** @hidden */
  75687. export interface IGLTFAmbienLight {
  75688. color?: number[];
  75689. }
  75690. /** @hidden */
  75691. export interface IGLTFDirectionalLight {
  75692. color?: number[];
  75693. }
  75694. /** @hidden */
  75695. export interface IGLTFPointLight {
  75696. color?: number[];
  75697. constantAttenuation?: number;
  75698. linearAttenuation?: number;
  75699. quadraticAttenuation?: number;
  75700. }
  75701. /** @hidden */
  75702. export interface IGLTFSpotLight {
  75703. color?: number[];
  75704. constantAttenuation?: number;
  75705. fallOfAngle?: number;
  75706. fallOffExponent?: number;
  75707. linearAttenuation?: number;
  75708. quadraticAttenuation?: number;
  75709. }
  75710. /** @hidden */
  75711. export interface IGLTFLight extends IGLTFChildRootProperty {
  75712. type: string;
  75713. }
  75714. /** @hidden */
  75715. export interface IGLTFCameraOrthographic {
  75716. xmag: number;
  75717. ymag: number;
  75718. zfar: number;
  75719. znear: number;
  75720. }
  75721. /** @hidden */
  75722. export interface IGLTFCameraPerspective {
  75723. aspectRatio: number;
  75724. yfov: number;
  75725. zfar: number;
  75726. znear: number;
  75727. }
  75728. /** @hidden */
  75729. export interface IGLTFCamera extends IGLTFChildRootProperty {
  75730. type: string;
  75731. }
  75732. /** @hidden */
  75733. export interface IGLTFAnimationChannelTarget {
  75734. id: string;
  75735. path: string;
  75736. }
  75737. /** @hidden */
  75738. export interface IGLTFAnimationChannel {
  75739. sampler: string;
  75740. target: IGLTFAnimationChannelTarget;
  75741. }
  75742. /** @hidden */
  75743. export interface IGLTFAnimationSampler {
  75744. input: string;
  75745. output: string;
  75746. interpolation?: string;
  75747. }
  75748. /** @hidden */
  75749. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  75750. channels?: IGLTFAnimationChannel[];
  75751. parameters?: {
  75752. [key: string]: string;
  75753. };
  75754. samplers?: {
  75755. [key: string]: IGLTFAnimationSampler;
  75756. };
  75757. }
  75758. /** @hidden */
  75759. export interface IGLTFNodeInstanceSkin {
  75760. skeletons: string[];
  75761. skin: string;
  75762. meshes: string[];
  75763. }
  75764. /** @hidden */
  75765. export interface IGLTFSkins extends IGLTFChildRootProperty {
  75766. bindShapeMatrix: number[];
  75767. inverseBindMatrices: string;
  75768. jointNames: string[];
  75769. babylonSkeleton?: Skeleton;
  75770. }
  75771. /** @hidden */
  75772. export interface IGLTFNode extends IGLTFChildRootProperty {
  75773. camera?: string;
  75774. children: string[];
  75775. skin?: string;
  75776. jointName?: string;
  75777. light?: string;
  75778. matrix: number[];
  75779. mesh?: string;
  75780. meshes?: string[];
  75781. rotation?: number[];
  75782. scale?: number[];
  75783. translation?: number[];
  75784. babylonNode?: Node;
  75785. }
  75786. /** @hidden */
  75787. export interface IGLTFScene extends IGLTFChildRootProperty {
  75788. nodes: string[];
  75789. }
  75790. /** @hidden */
  75791. export interface IGLTFRuntime {
  75792. extensions: {
  75793. [key: string]: any;
  75794. };
  75795. accessors: {
  75796. [key: string]: IGLTFAccessor;
  75797. };
  75798. buffers: {
  75799. [key: string]: IGLTFBuffer;
  75800. };
  75801. bufferViews: {
  75802. [key: string]: IGLTFBufferView;
  75803. };
  75804. meshes: {
  75805. [key: string]: IGLTFMesh;
  75806. };
  75807. lights: {
  75808. [key: string]: IGLTFLight;
  75809. };
  75810. cameras: {
  75811. [key: string]: IGLTFCamera;
  75812. };
  75813. nodes: {
  75814. [key: string]: IGLTFNode;
  75815. };
  75816. images: {
  75817. [key: string]: IGLTFImage;
  75818. };
  75819. textures: {
  75820. [key: string]: IGLTFTexture;
  75821. };
  75822. shaders: {
  75823. [key: string]: IGLTFShader;
  75824. };
  75825. programs: {
  75826. [key: string]: IGLTFProgram;
  75827. };
  75828. samplers: {
  75829. [key: string]: IGLTFSampler;
  75830. };
  75831. techniques: {
  75832. [key: string]: IGLTFTechnique;
  75833. };
  75834. materials: {
  75835. [key: string]: IGLTFMaterial;
  75836. };
  75837. animations: {
  75838. [key: string]: IGLTFAnimation;
  75839. };
  75840. skins: {
  75841. [key: string]: IGLTFSkins;
  75842. };
  75843. currentScene?: Object;
  75844. scenes: {
  75845. [key: string]: IGLTFScene;
  75846. };
  75847. extensionsUsed: string[];
  75848. extensionsRequired?: string[];
  75849. buffersCount: number;
  75850. shaderscount: number;
  75851. scene: Scene;
  75852. rootUrl: string;
  75853. loadedBufferCount: number;
  75854. loadedBufferViews: {
  75855. [name: string]: ArrayBufferView;
  75856. };
  75857. loadedShaderCount: number;
  75858. importOnlyMeshes: boolean;
  75859. importMeshesNames?: string[];
  75860. dummyNodes: Node[];
  75861. forAssetContainer: boolean;
  75862. }
  75863. /** @hidden */
  75864. export interface INodeToRoot {
  75865. bone: Bone;
  75866. node: IGLTFNode;
  75867. id: string;
  75868. }
  75869. /** @hidden */
  75870. export interface IJointNode {
  75871. node: IGLTFNode;
  75872. id: string;
  75873. }
  75874. }
  75875. declare module BABYLON.GLTF1 {
  75876. /**
  75877. * Utils functions for GLTF
  75878. * @hidden
  75879. */
  75880. export class GLTFUtils {
  75881. /**
  75882. * Sets the given "parameter" matrix
  75883. * @param scene: the Scene object
  75884. * @param source: the source node where to pick the matrix
  75885. * @param parameter: the GLTF technique parameter
  75886. * @param uniformName: the name of the shader's uniform
  75887. * @param shaderMaterial: the shader material
  75888. */
  75889. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  75890. /**
  75891. * Sets the given "parameter" matrix
  75892. * @param shaderMaterial: the shader material
  75893. * @param uniform: the name of the shader's uniform
  75894. * @param value: the value of the uniform
  75895. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  75896. */
  75897. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  75898. /**
  75899. * Returns the wrap mode of the texture
  75900. * @param mode: the mode value
  75901. */
  75902. static GetWrapMode(mode: number): number;
  75903. /**
  75904. * Returns the byte stride giving an accessor
  75905. * @param accessor: the GLTF accessor objet
  75906. */
  75907. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  75908. /**
  75909. * Returns the texture filter mode giving a mode value
  75910. * @param mode: the filter mode value
  75911. */
  75912. static GetTextureFilterMode(mode: number): ETextureFilterType;
  75913. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  75914. /**
  75915. * Returns a buffer from its accessor
  75916. * @param gltfRuntime: the GLTF runtime
  75917. * @param accessor: the GLTF accessor
  75918. */
  75919. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  75920. /**
  75921. * Decodes a buffer view into a string
  75922. * @param view: the buffer view
  75923. */
  75924. static DecodeBufferToText(view: ArrayBufferView): string;
  75925. /**
  75926. * Returns the default material of gltf. Related to
  75927. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  75928. * @param scene: the Babylon.js scene
  75929. */
  75930. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  75931. private static _DefaultMaterial;
  75932. }
  75933. }
  75934. declare module BABYLON.GLTF1 {
  75935. /**
  75936. * Implementation of the base glTF spec
  75937. * @hidden
  75938. */
  75939. export class GLTFLoaderBase {
  75940. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  75941. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75942. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  75943. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75944. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  75945. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75946. }
  75947. /**
  75948. * glTF V1 Loader
  75949. * @hidden
  75950. */
  75951. export class GLTFLoader implements IGLTFLoader {
  75952. static Extensions: {
  75953. [name: string]: GLTFLoaderExtension;
  75954. };
  75955. static RegisterExtension(extension: GLTFLoaderExtension): void;
  75956. state: Nullable<GLTFLoaderState>;
  75957. dispose(): void;
  75958. private _importMeshAsync;
  75959. /**
  75960. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  75961. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  75962. * @param scene the scene the meshes should be added to
  75963. * @param forAssetContainer defines if the entities must be stored in the scene
  75964. * @param data gltf data containing information of the meshes in a loaded file
  75965. * @param rootUrl root url to load from
  75966. * @param onProgress event that fires when loading progress has occured
  75967. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  75968. */
  75969. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  75970. private _loadAsync;
  75971. /**
  75972. * Imports all objects from a loaded gltf file and adds them to the scene
  75973. * @param scene the scene the objects should be added to
  75974. * @param data gltf data containing information of the meshes in a loaded file
  75975. * @param rootUrl root url to load from
  75976. * @param onProgress event that fires when loading progress has occured
  75977. * @returns a promise which completes when objects have been loaded to the scene
  75978. */
  75979. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  75980. private _loadShadersAsync;
  75981. private _loadBuffersAsync;
  75982. private _createNodes;
  75983. }
  75984. /** @hidden */
  75985. export abstract class GLTFLoaderExtension {
  75986. private _name;
  75987. constructor(name: string);
  75988. get name(): string;
  75989. /**
  75990. * Defines an override for loading the runtime
  75991. * Return true to stop further extensions from loading the runtime
  75992. */
  75993. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  75994. /**
  75995. * Defines an onverride for creating gltf runtime
  75996. * Return true to stop further extensions from creating the runtime
  75997. */
  75998. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  75999. /**
  76000. * Defines an override for loading buffers
  76001. * Return true to stop further extensions from loading this buffer
  76002. */
  76003. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  76004. /**
  76005. * Defines an override for loading texture buffers
  76006. * Return true to stop further extensions from loading this texture data
  76007. */
  76008. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76009. /**
  76010. * Defines an override for creating textures
  76011. * Return true to stop further extensions from loading this texture
  76012. */
  76013. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  76014. /**
  76015. * Defines an override for loading shader strings
  76016. * Return true to stop further extensions from loading this shader data
  76017. */
  76018. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76019. /**
  76020. * Defines an override for loading materials
  76021. * Return true to stop further extensions from loading this material
  76022. */
  76023. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76024. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  76025. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  76026. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  76027. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  76028. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  76029. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  76030. private static LoadTextureBufferAsync;
  76031. private static CreateTextureAsync;
  76032. private static ApplyExtensions;
  76033. }
  76034. }
  76035. declare module BABYLON.GLTF1 {
  76036. /** @hidden */
  76037. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  76038. private _bin;
  76039. constructor();
  76040. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  76041. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76042. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76043. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76044. }
  76045. }
  76046. declare module BABYLON.GLTF1 {
  76047. /** @hidden */
  76048. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  76049. constructor();
  76050. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  76051. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76052. private _loadTexture;
  76053. }
  76054. }
  76055. declare module BABYLON.GLTF2.Loader {
  76056. /**
  76057. * Loader interface with an index field.
  76058. */
  76059. export interface IArrayItem {
  76060. /**
  76061. * The index of this item in the array.
  76062. */
  76063. index: number;
  76064. }
  76065. /**
  76066. * Loader interface with additional members.
  76067. */
  76068. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  76069. /** @hidden */
  76070. _data?: Promise<ArrayBufferView>;
  76071. /** @hidden */
  76072. _babylonVertexBuffer?: Promise<VertexBuffer>;
  76073. }
  76074. /**
  76075. * Loader interface with additional members.
  76076. */
  76077. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  76078. }
  76079. /** @hidden */
  76080. export interface _IAnimationSamplerData {
  76081. input: Float32Array;
  76082. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  76083. output: Float32Array;
  76084. }
  76085. /**
  76086. * Loader interface with additional members.
  76087. */
  76088. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  76089. /** @hidden */
  76090. _data?: Promise<_IAnimationSamplerData>;
  76091. }
  76092. /**
  76093. * Loader interface with additional members.
  76094. */
  76095. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  76096. channels: IAnimationChannel[];
  76097. samplers: IAnimationSampler[];
  76098. /** @hidden */
  76099. _babylonAnimationGroup?: AnimationGroup;
  76100. }
  76101. /**
  76102. * Loader interface with additional members.
  76103. */
  76104. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  76105. /** @hidden */
  76106. _data?: Promise<ArrayBufferView>;
  76107. }
  76108. /**
  76109. * Loader interface with additional members.
  76110. */
  76111. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  76112. /** @hidden */
  76113. _data?: Promise<ArrayBufferView>;
  76114. /** @hidden */
  76115. _babylonBuffer?: Promise<Buffer>;
  76116. }
  76117. /**
  76118. * Loader interface with additional members.
  76119. */
  76120. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  76121. }
  76122. /**
  76123. * Loader interface with additional members.
  76124. */
  76125. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  76126. /** @hidden */
  76127. _data?: Promise<ArrayBufferView>;
  76128. }
  76129. /**
  76130. * Loader interface with additional members.
  76131. */
  76132. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  76133. }
  76134. /**
  76135. * Loader interface with additional members.
  76136. */
  76137. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  76138. }
  76139. /**
  76140. * Loader interface with additional members.
  76141. */
  76142. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  76143. baseColorTexture?: ITextureInfo;
  76144. metallicRoughnessTexture?: ITextureInfo;
  76145. }
  76146. /**
  76147. * Loader interface with additional members.
  76148. */
  76149. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  76150. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  76151. normalTexture?: IMaterialNormalTextureInfo;
  76152. occlusionTexture?: IMaterialOcclusionTextureInfo;
  76153. emissiveTexture?: ITextureInfo;
  76154. /** @hidden */
  76155. _data?: {
  76156. [babylonDrawMode: number]: {
  76157. babylonMaterial: Material;
  76158. babylonMeshes: AbstractMesh[];
  76159. promise: Promise<void>;
  76160. };
  76161. };
  76162. }
  76163. /**
  76164. * Loader interface with additional members.
  76165. */
  76166. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  76167. primitives: IMeshPrimitive[];
  76168. }
  76169. /**
  76170. * Loader interface with additional members.
  76171. */
  76172. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  76173. /** @hidden */
  76174. _instanceData?: {
  76175. babylonSourceMesh: Mesh;
  76176. promise: Promise<any>;
  76177. };
  76178. }
  76179. /**
  76180. * Loader interface with additional members.
  76181. */
  76182. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  76183. /**
  76184. * The parent glTF node.
  76185. */
  76186. parent?: INode;
  76187. /** @hidden */
  76188. _babylonTransformNode?: TransformNode;
  76189. /** @hidden */
  76190. _primitiveBabylonMeshes?: AbstractMesh[];
  76191. /** @hidden */
  76192. _babylonBones?: Bone[];
  76193. /** @hidden */
  76194. _numMorphTargets?: number;
  76195. }
  76196. /** @hidden */
  76197. export interface _ISamplerData {
  76198. noMipMaps: boolean;
  76199. samplingMode: number;
  76200. wrapU: number;
  76201. wrapV: number;
  76202. }
  76203. /**
  76204. * Loader interface with additional members.
  76205. */
  76206. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  76207. /** @hidden */
  76208. _data?: _ISamplerData;
  76209. }
  76210. /**
  76211. * Loader interface with additional members.
  76212. */
  76213. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  76214. }
  76215. /**
  76216. * Loader interface with additional members.
  76217. */
  76218. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  76219. /** @hidden */
  76220. _data?: {
  76221. babylonSkeleton: Skeleton;
  76222. promise: Promise<void>;
  76223. };
  76224. }
  76225. /**
  76226. * Loader interface with additional members.
  76227. */
  76228. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  76229. }
  76230. /**
  76231. * Loader interface with additional members.
  76232. */
  76233. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  76234. }
  76235. /**
  76236. * Loader interface with additional members.
  76237. */
  76238. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  76239. accessors?: IAccessor[];
  76240. animations?: IAnimation[];
  76241. buffers?: IBuffer[];
  76242. bufferViews?: IBufferView[];
  76243. cameras?: ICamera[];
  76244. images?: IImage[];
  76245. materials?: IMaterial[];
  76246. meshes?: IMesh[];
  76247. nodes?: INode[];
  76248. samplers?: ISampler[];
  76249. scenes?: IScene[];
  76250. skins?: ISkin[];
  76251. textures?: ITexture[];
  76252. }
  76253. }
  76254. declare module BABYLON.GLTF2 {
  76255. /**
  76256. * Interface for a glTF loader extension.
  76257. */
  76258. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  76259. /**
  76260. * Called after the loader state changes to LOADING.
  76261. */
  76262. onLoading?(): void;
  76263. /**
  76264. * Called after the loader state changes to READY.
  76265. */
  76266. onReady?(): void;
  76267. /**
  76268. * Define this method to modify the default behavior when loading scenes.
  76269. * @param context The context when loading the asset
  76270. * @param scene The glTF scene property
  76271. * @returns A promise that resolves when the load is complete or null if not handled
  76272. */
  76273. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  76274. /**
  76275. * Define this method to modify the default behavior when loading nodes.
  76276. * @param context The context when loading the asset
  76277. * @param node The glTF node property
  76278. * @param assign A function called synchronously after parsing the glTF properties
  76279. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  76280. */
  76281. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76282. /**
  76283. * Define this method to modify the default behavior when loading cameras.
  76284. * @param context The context when loading the asset
  76285. * @param camera The glTF camera property
  76286. * @param assign A function called synchronously after parsing the glTF properties
  76287. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  76288. */
  76289. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76290. /**
  76291. * @hidden
  76292. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  76293. * @param context The context when loading the asset
  76294. * @param primitive The glTF mesh primitive property
  76295. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  76296. */
  76297. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76298. /**
  76299. * @hidden
  76300. * Define this method to modify the default behavior when loading data for mesh primitives.
  76301. * @param context The context when loading the asset
  76302. * @param name The mesh name when loading the asset
  76303. * @param node The glTF node when loading the asset
  76304. * @param mesh The glTF mesh when loading the asset
  76305. * @param primitive The glTF mesh primitive property
  76306. * @param assign A function called synchronously after parsing the glTF properties
  76307. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76308. */
  76309. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76310. /**
  76311. * @hidden
  76312. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  76313. * @param context The context when loading the asset
  76314. * @param material The glTF material property
  76315. * @param assign A function called synchronously after parsing the glTF properties
  76316. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  76317. */
  76318. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76319. /**
  76320. * Define this method to modify the default behavior when creating materials.
  76321. * @param context The context when loading the asset
  76322. * @param material The glTF material property
  76323. * @param babylonDrawMode The draw mode for the Babylon material
  76324. * @returns The Babylon material or null if not handled
  76325. */
  76326. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76327. /**
  76328. * Define this method to modify the default behavior when loading material properties.
  76329. * @param context The context when loading the asset
  76330. * @param material The glTF material property
  76331. * @param babylonMaterial The Babylon material
  76332. * @returns A promise that resolves when the load is complete or null if not handled
  76333. */
  76334. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76335. /**
  76336. * Define this method to modify the default behavior when loading texture infos.
  76337. * @param context The context when loading the asset
  76338. * @param textureInfo The glTF texture info property
  76339. * @param assign A function called synchronously after parsing the glTF properties
  76340. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76341. */
  76342. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76343. /**
  76344. * @hidden
  76345. * Define this method to modify the default behavior when loading textures.
  76346. * @param context The context when loading the asset
  76347. * @param texture The glTF texture property
  76348. * @param assign A function called synchronously after parsing the glTF properties
  76349. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76350. */
  76351. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76352. /**
  76353. * Define this method to modify the default behavior when loading animations.
  76354. * @param context The context when loading the asset
  76355. * @param animation The glTF animation property
  76356. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  76357. */
  76358. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76359. /**
  76360. * @hidden
  76361. * Define this method to modify the default behavior when loading skins.
  76362. * @param context The context when loading the asset
  76363. * @param node The glTF node property
  76364. * @param skin The glTF skin property
  76365. * @returns A promise that resolves when the load is complete or null if not handled
  76366. */
  76367. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  76368. /**
  76369. * @hidden
  76370. * Define this method to modify the default behavior when loading uris.
  76371. * @param context The context when loading the asset
  76372. * @param property The glTF property associated with the uri
  76373. * @param uri The uri to load
  76374. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76375. */
  76376. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76377. /**
  76378. * Define this method to modify the default behavior when loading buffer views.
  76379. * @param context The context when loading the asset
  76380. * @param bufferView The glTF buffer view property
  76381. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76382. */
  76383. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  76384. /**
  76385. * Define this method to modify the default behavior when loading buffers.
  76386. * @param context The context when loading the asset
  76387. * @param buffer The glTF buffer property
  76388. * @param byteOffset The byte offset to load
  76389. * @param byteLength The byte length to load
  76390. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76391. */
  76392. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76393. }
  76394. }
  76395. declare module BABYLON.GLTF2 {
  76396. /**
  76397. * Helper class for working with arrays when loading the glTF asset
  76398. */
  76399. export class ArrayItem {
  76400. /**
  76401. * Gets an item from the given array.
  76402. * @param context The context when loading the asset
  76403. * @param array The array to get the item from
  76404. * @param index The index to the array
  76405. * @returns The array item
  76406. */
  76407. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  76408. /**
  76409. * Assign an `index` field to each item of the given array.
  76410. * @param array The array of items
  76411. */
  76412. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  76413. }
  76414. /**
  76415. * The glTF 2.0 loader
  76416. */
  76417. export class GLTFLoader implements IGLTFLoader {
  76418. /** @hidden */
  76419. _completePromises: Promise<any>[];
  76420. /** @hidden */
  76421. _forAssetContainer: boolean;
  76422. /** Storage */
  76423. _babylonLights: Light[];
  76424. private _disposed;
  76425. private _parent;
  76426. private _state;
  76427. private _extensions;
  76428. private _rootUrl;
  76429. private _fileName;
  76430. private _uniqueRootUrl;
  76431. private _gltf;
  76432. private _bin;
  76433. private _babylonScene;
  76434. private _rootBabylonMesh;
  76435. private _defaultBabylonMaterialData;
  76436. private _progressCallback?;
  76437. private _requests;
  76438. private static _RegisteredExtensions;
  76439. /**
  76440. * The default glTF sampler.
  76441. */
  76442. static readonly DefaultSampler: ISampler;
  76443. /**
  76444. * Registers a loader extension.
  76445. * @param name The name of the loader extension.
  76446. * @param factory The factory function that creates the loader extension.
  76447. */
  76448. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  76449. /**
  76450. * Unregisters a loader extension.
  76451. * @param name The name of the loader extension.
  76452. * @returns A boolean indicating whether the extension has been unregistered
  76453. */
  76454. static UnregisterExtension(name: string): boolean;
  76455. /**
  76456. * The loader state.
  76457. */
  76458. get state(): Nullable<GLTFLoaderState>;
  76459. /**
  76460. * The object that represents the glTF JSON.
  76461. */
  76462. get gltf(): IGLTF;
  76463. /**
  76464. * The BIN chunk of a binary glTF.
  76465. */
  76466. get bin(): Nullable<IDataBuffer>;
  76467. /**
  76468. * The parent file loader.
  76469. */
  76470. get parent(): GLTFFileLoader;
  76471. /**
  76472. * The Babylon scene when loading the asset.
  76473. */
  76474. get babylonScene(): Scene;
  76475. /**
  76476. * The root Babylon mesh when loading the asset.
  76477. */
  76478. get rootBabylonMesh(): Mesh;
  76479. /** @hidden */
  76480. constructor(parent: GLTFFileLoader);
  76481. /** @hidden */
  76482. dispose(): void;
  76483. /** @hidden */
  76484. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  76485. /** @hidden */
  76486. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76487. private _loadAsync;
  76488. private _loadData;
  76489. private _setupData;
  76490. private _loadExtensions;
  76491. private _checkExtensions;
  76492. private _setState;
  76493. private _createRootNode;
  76494. /**
  76495. * Loads a glTF scene.
  76496. * @param context The context when loading the asset
  76497. * @param scene The glTF scene property
  76498. * @returns A promise that resolves when the load is complete
  76499. */
  76500. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  76501. private _forEachPrimitive;
  76502. private _getMeshes;
  76503. private _getTransformNodes;
  76504. private _getSkeletons;
  76505. private _getAnimationGroups;
  76506. private _startAnimations;
  76507. /**
  76508. * Loads a glTF node.
  76509. * @param context The context when loading the asset
  76510. * @param node The glTF node property
  76511. * @param assign A function called synchronously after parsing the glTF properties
  76512. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  76513. */
  76514. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  76515. private _loadMeshAsync;
  76516. /**
  76517. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  76518. * @param context The context when loading the asset
  76519. * @param name The mesh name when loading the asset
  76520. * @param node The glTF node when loading the asset
  76521. * @param mesh The glTF mesh when loading the asset
  76522. * @param primitive The glTF mesh primitive property
  76523. * @param assign A function called synchronously after parsing the glTF properties
  76524. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76525. */
  76526. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76527. private _loadVertexDataAsync;
  76528. private _createMorphTargets;
  76529. private _loadMorphTargetsAsync;
  76530. private _loadMorphTargetVertexDataAsync;
  76531. private static _LoadTransform;
  76532. private _loadSkinAsync;
  76533. private _loadBones;
  76534. private _loadBone;
  76535. private _loadSkinInverseBindMatricesDataAsync;
  76536. private _updateBoneMatrices;
  76537. private _getNodeMatrix;
  76538. /**
  76539. * Loads a glTF camera.
  76540. * @param context The context when loading the asset
  76541. * @param camera The glTF camera property
  76542. * @param assign A function called synchronously after parsing the glTF properties
  76543. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  76544. */
  76545. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  76546. private _loadAnimationsAsync;
  76547. /**
  76548. * Loads a glTF animation.
  76549. * @param context The context when loading the asset
  76550. * @param animation The glTF animation property
  76551. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  76552. */
  76553. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  76554. /**
  76555. * @hidden Loads a glTF animation channel.
  76556. * @param context The context when loading the asset
  76557. * @param animationContext The context of the animation when loading the asset
  76558. * @param animation The glTF animation property
  76559. * @param channel The glTF animation channel property
  76560. * @param babylonAnimationGroup The babylon animation group property
  76561. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  76562. * @returns A void promise when the channel load is complete
  76563. */
  76564. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  76565. private _loadAnimationSamplerAsync;
  76566. private _loadBufferAsync;
  76567. /**
  76568. * Loads a glTF buffer view.
  76569. * @param context The context when loading the asset
  76570. * @param bufferView The glTF buffer view property
  76571. * @returns A promise that resolves with the loaded data when the load is complete
  76572. */
  76573. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  76574. private _loadAccessorAsync;
  76575. /** @hidden */
  76576. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  76577. private _loadIndicesAccessorAsync;
  76578. private _loadVertexBufferViewAsync;
  76579. private _loadVertexAccessorAsync;
  76580. private _loadMaterialMetallicRoughnessPropertiesAsync;
  76581. /** @hidden */
  76582. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  76583. private _createDefaultMaterial;
  76584. /**
  76585. * Creates a Babylon material from a glTF material.
  76586. * @param context The context when loading the asset
  76587. * @param material The glTF material property
  76588. * @param babylonDrawMode The draw mode for the Babylon material
  76589. * @returns The Babylon material
  76590. */
  76591. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  76592. /**
  76593. * Loads properties from a glTF material into a Babylon material.
  76594. * @param context The context when loading the asset
  76595. * @param material The glTF material property
  76596. * @param babylonMaterial The Babylon material
  76597. * @returns A promise that resolves when the load is complete
  76598. */
  76599. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76600. /**
  76601. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  76602. * @param context The context when loading the asset
  76603. * @param material The glTF material property
  76604. * @param babylonMaterial The Babylon material
  76605. * @returns A promise that resolves when the load is complete
  76606. */
  76607. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76608. /**
  76609. * Loads the alpha properties from a glTF material into a Babylon material.
  76610. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  76611. * @param context The context when loading the asset
  76612. * @param material The glTF material property
  76613. * @param babylonMaterial The Babylon material
  76614. */
  76615. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  76616. /**
  76617. * Loads a glTF texture info.
  76618. * @param context The context when loading the asset
  76619. * @param textureInfo The glTF texture info property
  76620. * @param assign A function called synchronously after parsing the glTF properties
  76621. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  76622. */
  76623. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76624. /** @hidden */
  76625. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76626. /** @hidden */
  76627. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76628. private _loadSampler;
  76629. /**
  76630. * Loads a glTF image.
  76631. * @param context The context when loading the asset
  76632. * @param image The glTF image property
  76633. * @returns A promise that resolves with the loaded data when the load is complete
  76634. */
  76635. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  76636. /**
  76637. * Loads a glTF uri.
  76638. * @param context The context when loading the asset
  76639. * @param property The glTF property associated with the uri
  76640. * @param uri The base64 or relative uri
  76641. * @returns A promise that resolves with the loaded data when the load is complete
  76642. */
  76643. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  76644. private _onProgress;
  76645. /**
  76646. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  76647. * @param babylonObject the Babylon object with metadata
  76648. * @param pointer the JSON pointer
  76649. */
  76650. static AddPointerMetadata(babylonObject: {
  76651. metadata: any;
  76652. }, pointer: string): void;
  76653. private static _GetTextureWrapMode;
  76654. private static _GetTextureSamplingMode;
  76655. private static _GetTypedArrayConstructor;
  76656. private static _GetTypedArray;
  76657. private static _GetNumComponents;
  76658. private static _ValidateUri;
  76659. private static _GetDrawMode;
  76660. private _compileMaterialsAsync;
  76661. private _compileShadowGeneratorsAsync;
  76662. private _forEachExtensions;
  76663. private _applyExtensions;
  76664. private _extensionsOnLoading;
  76665. private _extensionsOnReady;
  76666. private _extensionsLoadSceneAsync;
  76667. private _extensionsLoadNodeAsync;
  76668. private _extensionsLoadCameraAsync;
  76669. private _extensionsLoadVertexDataAsync;
  76670. private _extensionsLoadMeshPrimitiveAsync;
  76671. private _extensionsLoadMaterialAsync;
  76672. private _extensionsCreateMaterial;
  76673. private _extensionsLoadMaterialPropertiesAsync;
  76674. private _extensionsLoadTextureInfoAsync;
  76675. private _extensionsLoadTextureAsync;
  76676. private _extensionsLoadAnimationAsync;
  76677. private _extensionsLoadSkinAsync;
  76678. private _extensionsLoadUriAsync;
  76679. private _extensionsLoadBufferViewAsync;
  76680. private _extensionsLoadBufferAsync;
  76681. /**
  76682. * Helper method called by a loader extension to load an glTF extension.
  76683. * @param context The context when loading the asset
  76684. * @param property The glTF property to load the extension from
  76685. * @param extensionName The name of the extension to load
  76686. * @param actionAsync The action to run
  76687. * @returns The promise returned by actionAsync or null if the extension does not exist
  76688. */
  76689. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76690. /**
  76691. * Helper method called by a loader extension to load a glTF extra.
  76692. * @param context The context when loading the asset
  76693. * @param property The glTF property to load the extra from
  76694. * @param extensionName The name of the extension to load
  76695. * @param actionAsync The action to run
  76696. * @returns The promise returned by actionAsync or null if the extra does not exist
  76697. */
  76698. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76699. /**
  76700. * Checks for presence of an extension.
  76701. * @param name The name of the extension to check
  76702. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  76703. */
  76704. isExtensionUsed(name: string): boolean;
  76705. /**
  76706. * Increments the indentation level and logs a message.
  76707. * @param message The message to log
  76708. */
  76709. logOpen(message: string): void;
  76710. /**
  76711. * Decrements the indentation level.
  76712. */
  76713. logClose(): void;
  76714. /**
  76715. * Logs a message
  76716. * @param message The message to log
  76717. */
  76718. log(message: string): void;
  76719. /**
  76720. * Starts a performance counter.
  76721. * @param counterName The name of the performance counter
  76722. */
  76723. startPerformanceCounter(counterName: string): void;
  76724. /**
  76725. * Ends a performance counter.
  76726. * @param counterName The name of the performance counter
  76727. */
  76728. endPerformanceCounter(counterName: string): void;
  76729. }
  76730. }
  76731. declare module BABYLON.GLTF2.Loader.Extensions {
  76732. /**
  76733. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  76734. */
  76735. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  76736. /**
  76737. * The name of this extension.
  76738. */
  76739. readonly name: string;
  76740. /**
  76741. * Defines whether this extension is enabled.
  76742. */
  76743. enabled: boolean;
  76744. private _loader;
  76745. private _lights?;
  76746. /** @hidden */
  76747. constructor(loader: GLTFLoader);
  76748. /** @hidden */
  76749. dispose(): void;
  76750. /** @hidden */
  76751. onLoading(): void;
  76752. /** @hidden */
  76753. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76754. private _loadLightAsync;
  76755. }
  76756. }
  76757. declare module BABYLON.GLTF2.Loader.Extensions {
  76758. /**
  76759. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  76760. */
  76761. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  76762. /**
  76763. * The name of this extension.
  76764. */
  76765. readonly name: string;
  76766. /**
  76767. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  76768. */
  76769. dracoCompression?: DracoCompression;
  76770. /**
  76771. * Defines whether this extension is enabled.
  76772. */
  76773. enabled: boolean;
  76774. private _loader;
  76775. /** @hidden */
  76776. constructor(loader: GLTFLoader);
  76777. /** @hidden */
  76778. dispose(): void;
  76779. /** @hidden */
  76780. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76781. }
  76782. }
  76783. declare module BABYLON.GLTF2.Loader.Extensions {
  76784. /**
  76785. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  76786. */
  76787. export class KHR_lights implements IGLTFLoaderExtension {
  76788. /**
  76789. * The name of this extension.
  76790. */
  76791. readonly name: string;
  76792. /**
  76793. * Defines whether this extension is enabled.
  76794. */
  76795. enabled: boolean;
  76796. private _loader;
  76797. private _lights?;
  76798. /** @hidden */
  76799. constructor(loader: GLTFLoader);
  76800. /** @hidden */
  76801. dispose(): void;
  76802. /** @hidden */
  76803. onLoading(): void;
  76804. /** @hidden */
  76805. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76806. }
  76807. }
  76808. declare module BABYLON.GLTF2.Loader.Extensions {
  76809. /**
  76810. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  76811. */
  76812. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  76813. /**
  76814. * The name of this extension.
  76815. */
  76816. readonly name: string;
  76817. /**
  76818. * Defines whether this extension is enabled.
  76819. */
  76820. enabled: boolean;
  76821. /**
  76822. * Defines a number that determines the order the extensions are applied.
  76823. */
  76824. order: number;
  76825. private _loader;
  76826. /** @hidden */
  76827. constructor(loader: GLTFLoader);
  76828. /** @hidden */
  76829. dispose(): void;
  76830. /** @hidden */
  76831. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76832. private _loadSpecularGlossinessPropertiesAsync;
  76833. }
  76834. }
  76835. declare module BABYLON.GLTF2.Loader.Extensions {
  76836. /**
  76837. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  76838. */
  76839. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  76840. /**
  76841. * The name of this extension.
  76842. */
  76843. readonly name: string;
  76844. /**
  76845. * Defines whether this extension is enabled.
  76846. */
  76847. enabled: boolean;
  76848. /**
  76849. * Defines a number that determines the order the extensions are applied.
  76850. */
  76851. order: number;
  76852. private _loader;
  76853. /** @hidden */
  76854. constructor(loader: GLTFLoader);
  76855. /** @hidden */
  76856. dispose(): void;
  76857. /** @hidden */
  76858. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76859. private _loadUnlitPropertiesAsync;
  76860. }
  76861. }
  76862. declare module BABYLON.GLTF2.Loader.Extensions {
  76863. /**
  76864. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76865. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  76866. * !!! Experimental Extension Subject to Changes !!!
  76867. */
  76868. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  76869. /**
  76870. * The name of this extension.
  76871. */
  76872. readonly name: string;
  76873. /**
  76874. * Defines whether this extension is enabled.
  76875. */
  76876. enabled: boolean;
  76877. /**
  76878. * Defines a number that determines the order the extensions are applied.
  76879. */
  76880. order: number;
  76881. private _loader;
  76882. /** @hidden */
  76883. constructor(loader: GLTFLoader);
  76884. /** @hidden */
  76885. dispose(): void;
  76886. /** @hidden */
  76887. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76888. private _loadClearCoatPropertiesAsync;
  76889. }
  76890. }
  76891. declare module BABYLON.GLTF2.Loader.Extensions {
  76892. /**
  76893. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  76894. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76895. * !!! Experimental Extension Subject to Changes !!!
  76896. */
  76897. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  76898. /**
  76899. * The name of this extension.
  76900. */
  76901. readonly name: string;
  76902. /**
  76903. * Defines whether this extension is enabled.
  76904. */
  76905. enabled: boolean;
  76906. /**
  76907. * Defines a number that determines the order the extensions are applied.
  76908. */
  76909. order: number;
  76910. private _loader;
  76911. /** @hidden */
  76912. constructor(loader: GLTFLoader);
  76913. /** @hidden */
  76914. dispose(): void;
  76915. /** @hidden */
  76916. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76917. private _loadSheenPropertiesAsync;
  76918. }
  76919. }
  76920. declare module BABYLON.GLTF2.Loader.Extensions {
  76921. /**
  76922. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76923. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76924. * !!! Experimental Extension Subject to Changes !!!
  76925. */
  76926. export class KHR_materials_specular implements IGLTFLoaderExtension {
  76927. /**
  76928. * The name of this extension.
  76929. */
  76930. readonly name: string;
  76931. /**
  76932. * Defines whether this extension is enabled.
  76933. */
  76934. enabled: boolean;
  76935. /**
  76936. * Defines a number that determines the order the extensions are applied.
  76937. */
  76938. order: number;
  76939. private _loader;
  76940. /** @hidden */
  76941. constructor(loader: GLTFLoader);
  76942. /** @hidden */
  76943. dispose(): void;
  76944. /** @hidden */
  76945. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76946. private _loadSpecularPropertiesAsync;
  76947. }
  76948. }
  76949. declare module BABYLON.GLTF2.Loader.Extensions {
  76950. /**
  76951. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  76952. * [Playground Sample](//TODO)
  76953. * !!! Experimental Extension Subject to Changes !!!
  76954. */
  76955. export class KHR_mesh_instancing implements IGLTFLoaderExtension {
  76956. /**
  76957. * The name of this extension.
  76958. */
  76959. readonly name: string;
  76960. /**
  76961. * Defines whether this extension is enabled.
  76962. */
  76963. enabled: boolean;
  76964. private _loader;
  76965. /** @hidden */
  76966. constructor(loader: GLTFLoader);
  76967. /** @hidden */
  76968. dispose(): void;
  76969. /** @hidden */
  76970. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76971. }
  76972. }
  76973. declare module BABYLON.GLTF2.Loader.Extensions {
  76974. /**
  76975. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  76976. */
  76977. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  76978. /**
  76979. * The name of this extension.
  76980. */
  76981. readonly name: string;
  76982. /**
  76983. * Defines whether this extension is enabled.
  76984. */
  76985. enabled: boolean;
  76986. /** @hidden */
  76987. constructor(loader: GLTFLoader);
  76988. /** @hidden */
  76989. dispose(): void;
  76990. }
  76991. }
  76992. declare module BABYLON.GLTF2.Loader.Extensions {
  76993. /**
  76994. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  76995. * !!! Experimental Extension Subject to Changes !!!
  76996. */
  76997. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  76998. /** The name of this extension. */
  76999. readonly name: string;
  77000. /** Defines whether this extension is enabled. */
  77001. enabled: boolean;
  77002. private _loader;
  77003. /** @hidden */
  77004. constructor(loader: GLTFLoader);
  77005. /** @hidden */
  77006. dispose(): void;
  77007. /** @hidden */
  77008. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77009. }
  77010. }
  77011. declare module BABYLON.GLTF2.Loader.Extensions {
  77012. /**
  77013. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  77014. */
  77015. export class KHR_texture_transform implements IGLTFLoaderExtension {
  77016. /**
  77017. * The name of this extension.
  77018. */
  77019. readonly name: string;
  77020. /**
  77021. * Defines whether this extension is enabled.
  77022. */
  77023. enabled: boolean;
  77024. private _loader;
  77025. /** @hidden */
  77026. constructor(loader: GLTFLoader);
  77027. /** @hidden */
  77028. dispose(): void;
  77029. /** @hidden */
  77030. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77031. }
  77032. }
  77033. declare module BABYLON.GLTF2.Loader.Extensions {
  77034. /**
  77035. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  77036. */
  77037. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  77038. /**
  77039. * The name of this extension.
  77040. */
  77041. readonly name: string;
  77042. /**
  77043. * Defines whether this extension is enabled.
  77044. */
  77045. enabled: boolean;
  77046. private _loader;
  77047. private _clips;
  77048. private _emitters;
  77049. /** @hidden */
  77050. constructor(loader: GLTFLoader);
  77051. /** @hidden */
  77052. dispose(): void;
  77053. /** @hidden */
  77054. onLoading(): void;
  77055. /** @hidden */
  77056. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77057. /** @hidden */
  77058. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77059. /** @hidden */
  77060. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  77061. private _loadClipAsync;
  77062. private _loadEmitterAsync;
  77063. private _getEventAction;
  77064. private _loadAnimationEventAsync;
  77065. }
  77066. }
  77067. declare module BABYLON.GLTF2.Loader.Extensions {
  77068. /**
  77069. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  77070. */
  77071. export class MSFT_lod implements IGLTFLoaderExtension {
  77072. /**
  77073. * The name of this extension.
  77074. */
  77075. readonly name: string;
  77076. /**
  77077. * Defines whether this extension is enabled.
  77078. */
  77079. enabled: boolean;
  77080. /**
  77081. * Defines a number that determines the order the extensions are applied.
  77082. */
  77083. order: number;
  77084. /**
  77085. * Maximum number of LODs to load, starting from the lowest LOD.
  77086. */
  77087. maxLODsToLoad: number;
  77088. /**
  77089. * Observable raised when all node LODs of one level are loaded.
  77090. * The event data is the index of the loaded LOD starting from zero.
  77091. * Dispose the loader to cancel the loading of the next level of LODs.
  77092. */
  77093. onNodeLODsLoadedObservable: Observable<number>;
  77094. /**
  77095. * Observable raised when all material LODs of one level are loaded.
  77096. * The event data is the index of the loaded LOD starting from zero.
  77097. * Dispose the loader to cancel the loading of the next level of LODs.
  77098. */
  77099. onMaterialLODsLoadedObservable: Observable<number>;
  77100. private _loader;
  77101. private _nodeIndexLOD;
  77102. private _nodeSignalLODs;
  77103. private _nodePromiseLODs;
  77104. private _materialIndexLOD;
  77105. private _materialSignalLODs;
  77106. private _materialPromiseLODs;
  77107. private _indexLOD;
  77108. private _bufferLODs;
  77109. /** @hidden */
  77110. constructor(loader: GLTFLoader);
  77111. /** @hidden */
  77112. dispose(): void;
  77113. /** @hidden */
  77114. onReady(): void;
  77115. /** @hidden */
  77116. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77117. /** @hidden */
  77118. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77119. /** @hidden */
  77120. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  77121. /** @hidden */
  77122. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  77123. /** @hidden */
  77124. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  77125. private _loadBufferLOD;
  77126. /**
  77127. * Gets an array of LOD properties from lowest to highest.
  77128. */
  77129. private _getLODs;
  77130. private _disposeTransformNode;
  77131. private _disposeMaterials;
  77132. }
  77133. }
  77134. declare module BABYLON.GLTF2.Loader.Extensions {
  77135. /** @hidden */
  77136. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  77137. readonly name: string;
  77138. enabled: boolean;
  77139. private _loader;
  77140. constructor(loader: GLTFLoader);
  77141. dispose(): void;
  77142. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77143. }
  77144. }
  77145. declare module BABYLON.GLTF2.Loader.Extensions {
  77146. /** @hidden */
  77147. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  77148. readonly name: string;
  77149. enabled: boolean;
  77150. private _loader;
  77151. constructor(loader: GLTFLoader);
  77152. dispose(): void;
  77153. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77154. }
  77155. }
  77156. declare module BABYLON.GLTF2.Loader.Extensions {
  77157. /**
  77158. * Store glTF extras (if present) in BJS objects' metadata
  77159. */
  77160. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  77161. /**
  77162. * The name of this extension.
  77163. */
  77164. readonly name: string;
  77165. /**
  77166. * Defines whether this extension is enabled.
  77167. */
  77168. enabled: boolean;
  77169. private _loader;
  77170. private _assignExtras;
  77171. /** @hidden */
  77172. constructor(loader: GLTFLoader);
  77173. /** @hidden */
  77174. dispose(): void;
  77175. /** @hidden */
  77176. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77177. /** @hidden */
  77178. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  77179. /** @hidden */
  77180. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  77181. }
  77182. }
  77183. declare module BABYLON {
  77184. /**
  77185. * Class reading and parsing the MTL file bundled with the obj file.
  77186. */
  77187. export class MTLFileLoader {
  77188. /**
  77189. * Invert Y-Axis of referenced textures on load
  77190. */
  77191. static INVERT_TEXTURE_Y: boolean;
  77192. /**
  77193. * All material loaded from the mtl will be set here
  77194. */
  77195. materials: StandardMaterial[];
  77196. /**
  77197. * This function will read the mtl file and create each material described inside
  77198. * This function could be improve by adding :
  77199. * -some component missing (Ni, Tf...)
  77200. * -including the specific options available
  77201. *
  77202. * @param scene defines the scene the material will be created in
  77203. * @param data defines the mtl data to parse
  77204. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  77205. * @param forAssetContainer defines if the material should be registered in the scene
  77206. */
  77207. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  77208. /**
  77209. * Gets the texture for the material.
  77210. *
  77211. * If the material is imported from input file,
  77212. * We sanitize the url to ensure it takes the textre from aside the material.
  77213. *
  77214. * @param rootUrl The root url to load from
  77215. * @param value The value stored in the mtl
  77216. * @return The Texture
  77217. */
  77218. private static _getTexture;
  77219. }
  77220. }
  77221. declare module BABYLON {
  77222. /**
  77223. * Options for loading OBJ/MTL files
  77224. */
  77225. type MeshLoadOptions = {
  77226. /**
  77227. * Defines if UVs are optimized by default during load.
  77228. */
  77229. OptimizeWithUV: boolean;
  77230. /**
  77231. * Defines custom scaling of UV coordinates of loaded meshes.
  77232. */
  77233. UVScaling: Vector2;
  77234. /**
  77235. * Invert model on y-axis (does a model scaling inversion)
  77236. */
  77237. InvertY: boolean;
  77238. /**
  77239. * Invert Y-Axis of referenced textures on load
  77240. */
  77241. InvertTextureY: boolean;
  77242. /**
  77243. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77244. */
  77245. ImportVertexColors: boolean;
  77246. /**
  77247. * Compute the normals for the model, even if normals are present in the file.
  77248. */
  77249. ComputeNormals: boolean;
  77250. /**
  77251. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77252. */
  77253. SkipMaterials: boolean;
  77254. /**
  77255. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77256. */
  77257. MaterialLoadingFailsSilently: boolean;
  77258. };
  77259. /**
  77260. * OBJ file type loader.
  77261. * This is a babylon scene loader plugin.
  77262. */
  77263. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77264. /**
  77265. * Defines if UVs are optimized by default during load.
  77266. */
  77267. static OPTIMIZE_WITH_UV: boolean;
  77268. /**
  77269. * Invert model on y-axis (does a model scaling inversion)
  77270. */
  77271. static INVERT_Y: boolean;
  77272. /**
  77273. * Invert Y-Axis of referenced textures on load
  77274. */
  77275. static get INVERT_TEXTURE_Y(): boolean;
  77276. static set INVERT_TEXTURE_Y(value: boolean);
  77277. /**
  77278. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77279. */
  77280. static IMPORT_VERTEX_COLORS: boolean;
  77281. /**
  77282. * Compute the normals for the model, even if normals are present in the file.
  77283. */
  77284. static COMPUTE_NORMALS: boolean;
  77285. /**
  77286. * Defines custom scaling of UV coordinates of loaded meshes.
  77287. */
  77288. static UV_SCALING: Vector2;
  77289. /**
  77290. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77291. */
  77292. static SKIP_MATERIALS: boolean;
  77293. /**
  77294. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77295. *
  77296. * Defaults to true for backwards compatibility.
  77297. */
  77298. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  77299. /**
  77300. * Defines the name of the plugin.
  77301. */
  77302. name: string;
  77303. /**
  77304. * Defines the extension the plugin is able to load.
  77305. */
  77306. extensions: string;
  77307. /** @hidden */
  77308. obj: RegExp;
  77309. /** @hidden */
  77310. group: RegExp;
  77311. /** @hidden */
  77312. mtllib: RegExp;
  77313. /** @hidden */
  77314. usemtl: RegExp;
  77315. /** @hidden */
  77316. smooth: RegExp;
  77317. /** @hidden */
  77318. vertexPattern: RegExp;
  77319. /** @hidden */
  77320. normalPattern: RegExp;
  77321. /** @hidden */
  77322. uvPattern: RegExp;
  77323. /** @hidden */
  77324. facePattern1: RegExp;
  77325. /** @hidden */
  77326. facePattern2: RegExp;
  77327. /** @hidden */
  77328. facePattern3: RegExp;
  77329. /** @hidden */
  77330. facePattern4: RegExp;
  77331. /** @hidden */
  77332. facePattern5: RegExp;
  77333. private _forAssetContainer;
  77334. private _meshLoadOptions;
  77335. /**
  77336. * Creates loader for .OBJ files
  77337. *
  77338. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  77339. */
  77340. constructor(meshLoadOptions?: MeshLoadOptions);
  77341. private static get currentMeshLoadOptions();
  77342. /**
  77343. * Calls synchronously the MTL file attached to this obj.
  77344. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  77345. * Without this function materials are not displayed in the first frame (but displayed after).
  77346. * In consequence it is impossible to get material information in your HTML file
  77347. *
  77348. * @param url The URL of the MTL file
  77349. * @param rootUrl
  77350. * @param onSuccess Callback function to be called when the MTL file is loaded
  77351. * @private
  77352. */
  77353. private _loadMTL;
  77354. /**
  77355. * Instantiates a OBJ file loader plugin.
  77356. * @returns the created plugin
  77357. */
  77358. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  77359. /**
  77360. * If the data string can be loaded directly.
  77361. *
  77362. * @param data string containing the file data
  77363. * @returns if the data can be loaded directly
  77364. */
  77365. canDirectLoad(data: string): boolean;
  77366. /**
  77367. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  77368. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  77369. * @param scene the scene the meshes should be added to
  77370. * @param data the OBJ data to load
  77371. * @param rootUrl root url to load from
  77372. * @param onProgress event that fires when loading progress has occured
  77373. * @param fileName Defines the name of the file to load
  77374. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  77375. */
  77376. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  77377. meshes: AbstractMesh[];
  77378. particleSystems: IParticleSystem[];
  77379. skeletons: Skeleton[];
  77380. animationGroups: AnimationGroup[];
  77381. }>;
  77382. /**
  77383. * Imports all objects from the loaded OBJ data and adds them to the scene
  77384. * @param scene the scene the objects should be added to
  77385. * @param data the OBJ data to load
  77386. * @param rootUrl root url to load from
  77387. * @param onProgress event that fires when loading progress has occured
  77388. * @param fileName Defines the name of the file to load
  77389. * @returns a promise which completes when objects have been loaded to the scene
  77390. */
  77391. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77392. /**
  77393. * Load into an asset container.
  77394. * @param scene The scene to load into
  77395. * @param data The data to import
  77396. * @param rootUrl The root url for scene and resources
  77397. * @param onProgress The callback when the load progresses
  77398. * @param fileName Defines the name of the file to load
  77399. * @returns The loaded asset container
  77400. */
  77401. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  77402. /**
  77403. * Read the OBJ file and create an Array of meshes.
  77404. * Each mesh contains all information given by the OBJ and the MTL file.
  77405. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  77406. *
  77407. * @param meshesNames
  77408. * @param scene Scene The scene where are displayed the data
  77409. * @param data String The content of the obj file
  77410. * @param rootUrl String The path to the folder
  77411. * @returns Array<AbstractMesh>
  77412. * @private
  77413. */
  77414. private _parseSolid;
  77415. }
  77416. }
  77417. declare module BABYLON {
  77418. /**
  77419. * STL file type loader.
  77420. * This is a babylon scene loader plugin.
  77421. */
  77422. export class STLFileLoader implements ISceneLoaderPlugin {
  77423. /** @hidden */
  77424. solidPattern: RegExp;
  77425. /** @hidden */
  77426. facetsPattern: RegExp;
  77427. /** @hidden */
  77428. normalPattern: RegExp;
  77429. /** @hidden */
  77430. vertexPattern: RegExp;
  77431. /**
  77432. * Defines the name of the plugin.
  77433. */
  77434. name: string;
  77435. /**
  77436. * Defines the extensions the stl loader is able to load.
  77437. * force data to come in as an ArrayBuffer
  77438. * we'll convert to string if it looks like it's an ASCII .stl
  77439. */
  77440. extensions: ISceneLoaderPluginExtensions;
  77441. /**
  77442. * Import meshes into a scene.
  77443. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  77444. * @param scene The scene to import into
  77445. * @param data The data to import
  77446. * @param rootUrl The root url for scene and resources
  77447. * @param meshes The meshes array to import into
  77448. * @param particleSystems The particle systems array to import into
  77449. * @param skeletons The skeletons array to import into
  77450. * @param onError The callback when import fails
  77451. * @returns True if successful or false otherwise
  77452. */
  77453. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  77454. /**
  77455. * Load into a scene.
  77456. * @param scene The scene to load into
  77457. * @param data The data to import
  77458. * @param rootUrl The root url for scene and resources
  77459. * @param onError The callback when import fails
  77460. * @returns true if successful or false otherwise
  77461. */
  77462. load(scene: Scene, data: any, rootUrl: string): boolean;
  77463. /**
  77464. * Load into an asset container.
  77465. * @param scene The scene to load into
  77466. * @param data The data to import
  77467. * @param rootUrl The root url for scene and resources
  77468. * @param onError The callback when import fails
  77469. * @returns The loaded asset container
  77470. */
  77471. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  77472. private _isBinary;
  77473. private _parseBinary;
  77474. private _parseASCII;
  77475. }
  77476. }
  77477. declare module BABYLON {
  77478. /**
  77479. * Class for generating OBJ data from a Babylon scene.
  77480. */
  77481. export class OBJExport {
  77482. /**
  77483. * Exports the geometry of a Mesh array in .OBJ file format (text)
  77484. * @param mesh defines the list of meshes to serialize
  77485. * @param materials defines if materials should be exported
  77486. * @param matlibname defines the name of the associated mtl file
  77487. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  77488. * @returns the OBJ content
  77489. */
  77490. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  77491. /**
  77492. * Exports the material(s) of a mesh in .MTL file format (text)
  77493. * @param mesh defines the mesh to extract the material from
  77494. * @returns the mtl content
  77495. */
  77496. static MTL(mesh: Mesh): string;
  77497. }
  77498. }
  77499. declare module BABYLON {
  77500. /** @hidden */
  77501. export var __IGLTFExporterExtension: number;
  77502. /**
  77503. * Interface for extending the exporter
  77504. * @hidden
  77505. */
  77506. export interface IGLTFExporterExtension {
  77507. /**
  77508. * The name of this extension
  77509. */
  77510. readonly name: string;
  77511. /**
  77512. * Defines whether this extension is enabled
  77513. */
  77514. enabled: boolean;
  77515. /**
  77516. * Defines whether this extension is required
  77517. */
  77518. required: boolean;
  77519. }
  77520. }
  77521. declare module BABYLON.GLTF2.Exporter {
  77522. /** @hidden */
  77523. export var __IGLTFExporterExtensionV2: number;
  77524. /**
  77525. * Interface for a glTF exporter extension
  77526. * @hidden
  77527. */
  77528. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  77529. /**
  77530. * Define this method to modify the default behavior before exporting a texture
  77531. * @param context The context when loading the asset
  77532. * @param babylonTexture The Babylon.js texture
  77533. * @param mimeType The mime-type of the generated image
  77534. * @returns A promise that resolves with the exported texture
  77535. */
  77536. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  77537. /**
  77538. * Define this method to get notified when a texture info is created
  77539. * @param context The context when loading the asset
  77540. * @param textureInfo The glTF texture info
  77541. * @param babylonTexture The Babylon.js texture
  77542. */
  77543. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77544. /**
  77545. * Define this method to modify the default behavior when exporting texture info
  77546. * @param context The context when loading the asset
  77547. * @param meshPrimitive glTF mesh primitive
  77548. * @param babylonSubMesh Babylon submesh
  77549. * @param binaryWriter glTF serializer binary writer instance
  77550. * @returns nullable IMeshPrimitive promise
  77551. */
  77552. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  77553. /**
  77554. * Define this method to modify the default behavior when exporting a node
  77555. * @param context The context when exporting the node
  77556. * @param node glTF node
  77557. * @param babylonNode BabylonJS node
  77558. * @returns nullable INode promise
  77559. */
  77560. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77561. [key: number]: number;
  77562. }): Promise<Nullable<INode>>;
  77563. /**
  77564. * Define this method to modify the default behavior when exporting a material
  77565. * @param material glTF material
  77566. * @param babylonMaterial BabylonJS material
  77567. * @returns nullable IMaterial promise
  77568. */
  77569. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  77570. /**
  77571. * Define this method to return additional textures to export from a material
  77572. * @param material glTF material
  77573. * @param babylonMaterial BabylonJS material
  77574. * @returns List of textures
  77575. */
  77576. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77577. /** Gets a boolean indicating that this extension was used */
  77578. wasUsed: boolean;
  77579. /** Gets a boolean indicating that this extension is required for the file to work */
  77580. required: boolean;
  77581. /**
  77582. * Called after the exporter state changes to EXPORTING
  77583. */
  77584. onExporting?(): void;
  77585. }
  77586. }
  77587. declare module BABYLON.GLTF2.Exporter {
  77588. /**
  77589. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  77590. * @hidden
  77591. */
  77592. export class _GLTFMaterialExporter {
  77593. /**
  77594. * Represents the dielectric specular values for R, G and B
  77595. */
  77596. private static readonly _DielectricSpecular;
  77597. /**
  77598. * Allows the maximum specular power to be defined for material calculations
  77599. */
  77600. private static readonly _MaxSpecularPower;
  77601. /**
  77602. * Mapping to store textures
  77603. */
  77604. private _textureMap;
  77605. /**
  77606. * Numeric tolerance value
  77607. */
  77608. private static readonly _Epsilon;
  77609. /**
  77610. * Reference to the glTF Exporter
  77611. */
  77612. private _exporter;
  77613. constructor(exporter: _Exporter);
  77614. /**
  77615. * Specifies if two colors are approximately equal in value
  77616. * @param color1 first color to compare to
  77617. * @param color2 second color to compare to
  77618. * @param epsilon threshold value
  77619. */
  77620. private static FuzzyEquals;
  77621. /**
  77622. * Gets the materials from a Babylon scene and converts them to glTF materials
  77623. * @param scene babylonjs scene
  77624. * @param mimeType texture mime type
  77625. * @param images array of images
  77626. * @param textures array of textures
  77627. * @param materials array of materials
  77628. * @param imageData mapping of texture names to base64 textures
  77629. * @param hasTextureCoords specifies if texture coordinates are present on the material
  77630. */
  77631. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  77632. /**
  77633. * Makes a copy of the glTF material without the texture parameters
  77634. * @param originalMaterial original glTF material
  77635. * @returns glTF material without texture parameters
  77636. */
  77637. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  77638. /**
  77639. * Specifies if the material has any texture parameters present
  77640. * @param material glTF Material
  77641. * @returns boolean specifying if texture parameters are present
  77642. */
  77643. _hasTexturesPresent(material: IMaterial): boolean;
  77644. /**
  77645. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  77646. * @param babylonStandardMaterial
  77647. * @returns glTF Metallic Roughness Material representation
  77648. */
  77649. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  77650. /**
  77651. * Computes the metallic factor
  77652. * @param diffuse diffused value
  77653. * @param specular specular value
  77654. * @param oneMinusSpecularStrength one minus the specular strength
  77655. * @returns metallic value
  77656. */
  77657. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  77658. /**
  77659. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  77660. * @param glTFMaterial glTF material
  77661. * @param babylonMaterial Babylon material
  77662. */
  77663. private static _SetAlphaMode;
  77664. /**
  77665. * Converts a Babylon Standard Material to a glTF Material
  77666. * @param babylonStandardMaterial BJS Standard Material
  77667. * @param mimeType mime type to use for the textures
  77668. * @param images array of glTF image interfaces
  77669. * @param textures array of glTF texture interfaces
  77670. * @param materials array of glTF material interfaces
  77671. * @param imageData map of image file name to data
  77672. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77673. */
  77674. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77675. private _finishMaterial;
  77676. /**
  77677. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77678. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  77679. * @param mimeType mime type to use for the textures
  77680. * @param images array of glTF image interfaces
  77681. * @param textures array of glTF texture interfaces
  77682. * @param materials array of glTF material interfaces
  77683. * @param imageData map of image file name to data
  77684. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77685. */
  77686. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77687. /**
  77688. * Converts an image typed array buffer to a base64 image
  77689. * @param buffer typed array buffer
  77690. * @param width width of the image
  77691. * @param height height of the image
  77692. * @param mimeType mimetype of the image
  77693. * @returns base64 image string
  77694. */
  77695. private _createBase64FromCanvasAsync;
  77696. /**
  77697. * Generates a white texture based on the specified width and height
  77698. * @param width width of the texture in pixels
  77699. * @param height height of the texture in pixels
  77700. * @param scene babylonjs scene
  77701. * @returns white texture
  77702. */
  77703. private _createWhiteTexture;
  77704. /**
  77705. * 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
  77706. * @param texture1 first texture to resize
  77707. * @param texture2 second texture to resize
  77708. * @param scene babylonjs scene
  77709. * @returns resized textures or null
  77710. */
  77711. private _resizeTexturesToSameDimensions;
  77712. /**
  77713. * Converts an array of pixels to a Float32Array
  77714. * Throws an error if the pixel format is not supported
  77715. * @param pixels - array buffer containing pixel values
  77716. * @returns Float32 of pixels
  77717. */
  77718. private _convertPixelArrayToFloat32;
  77719. /**
  77720. * Convert Specular Glossiness Textures to Metallic Roughness
  77721. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  77722. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  77723. * @param diffuseTexture texture used to store diffuse information
  77724. * @param specularGlossinessTexture texture used to store specular and glossiness information
  77725. * @param factors specular glossiness material factors
  77726. * @param mimeType the mime type to use for the texture
  77727. * @returns pbr metallic roughness interface or null
  77728. */
  77729. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  77730. /**
  77731. * Converts specular glossiness material properties to metallic roughness
  77732. * @param specularGlossiness interface with specular glossiness material properties
  77733. * @returns interface with metallic roughness material properties
  77734. */
  77735. private _convertSpecularGlossinessToMetallicRoughness;
  77736. /**
  77737. * Calculates the surface reflectance, independent of lighting conditions
  77738. * @param color Color source to calculate brightness from
  77739. * @returns number representing the perceived brightness, or zero if color is undefined
  77740. */
  77741. private _getPerceivedBrightness;
  77742. /**
  77743. * Returns the maximum color component value
  77744. * @param color
  77745. * @returns maximum color component value, or zero if color is null or undefined
  77746. */
  77747. private _getMaxComponent;
  77748. /**
  77749. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  77750. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77751. * @param mimeType mime type to use for the textures
  77752. * @param images array of glTF image interfaces
  77753. * @param textures array of glTF texture interfaces
  77754. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77755. * @param imageData map of image file name to data
  77756. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77757. * @returns glTF PBR Metallic Roughness factors
  77758. */
  77759. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  77760. private _getGLTFTextureSampler;
  77761. private _getGLTFTextureWrapMode;
  77762. private _getGLTFTextureWrapModesSampler;
  77763. /**
  77764. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  77765. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77766. * @param mimeType mime type to use for the textures
  77767. * @param images array of glTF image interfaces
  77768. * @param textures array of glTF texture interfaces
  77769. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77770. * @param imageData map of image file name to data
  77771. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77772. * @returns glTF PBR Metallic Roughness factors
  77773. */
  77774. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  77775. /**
  77776. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77777. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77778. * @param mimeType mime type to use for the textures
  77779. * @param images array of glTF image interfaces
  77780. * @param textures array of glTF texture interfaces
  77781. * @param materials array of glTF material interfaces
  77782. * @param imageData map of image file name to data
  77783. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77784. */
  77785. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77786. private setMetallicRoughnessPbrMaterial;
  77787. private getPixelsFromTexture;
  77788. /**
  77789. * Extracts a texture from a Babylon texture into file data and glTF data
  77790. * @param babylonTexture Babylon texture to extract
  77791. * @param mimeType Mime Type of the babylonTexture
  77792. * @return glTF texture info, or null if the texture format is not supported
  77793. */
  77794. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77795. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77796. /**
  77797. * Builds a texture from base64 string
  77798. * @param base64Texture base64 texture string
  77799. * @param baseTextureName Name to use for the texture
  77800. * @param mimeType image mime type for the texture
  77801. * @param images array of images
  77802. * @param textures array of textures
  77803. * @param imageData map of image data
  77804. * @returns glTF texture info, or null if the texture format is not supported
  77805. */
  77806. private _getTextureInfoFromBase64;
  77807. }
  77808. }
  77809. declare module BABYLON {
  77810. /**
  77811. * Class for holding and downloading glTF file data
  77812. */
  77813. export class GLTFData {
  77814. /**
  77815. * Object which contains the file name as the key and its data as the value
  77816. */
  77817. glTFFiles: {
  77818. [fileName: string]: string | Blob;
  77819. };
  77820. /**
  77821. * Initializes the glTF file object
  77822. */
  77823. constructor();
  77824. /**
  77825. * Downloads the glTF data as files based on their names and data
  77826. */
  77827. downloadFiles(): void;
  77828. }
  77829. }
  77830. declare module BABYLON {
  77831. /**
  77832. * Holds a collection of exporter options and parameters
  77833. */
  77834. export interface IExportOptions {
  77835. /**
  77836. * Function which indicates whether a babylon node should be exported or not
  77837. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  77838. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  77839. */
  77840. shouldExportNode?(node: Node): boolean;
  77841. /**
  77842. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  77843. * @param metadata source metadata to read from
  77844. * @returns the data to store to glTF node extras
  77845. */
  77846. metadataSelector?(metadata: any): any;
  77847. /**
  77848. * The sample rate to bake animation curves
  77849. */
  77850. animationSampleRate?: number;
  77851. /**
  77852. * Begin serialization without waiting for the scene to be ready
  77853. */
  77854. exportWithoutWaitingForScene?: boolean;
  77855. /**
  77856. * Indicates if coordinate system swapping root nodes should be included in export
  77857. */
  77858. includeCoordinateSystemConversionNodes?: boolean;
  77859. }
  77860. /**
  77861. * Class for generating glTF data from a Babylon scene.
  77862. */
  77863. export class GLTF2Export {
  77864. /**
  77865. * Exports the geometry of the scene to .gltf file format asynchronously
  77866. * @param scene Babylon scene with scene hierarchy information
  77867. * @param filePrefix File prefix to use when generating the glTF file
  77868. * @param options Exporter options
  77869. * @returns Returns an object with a .gltf file and associates texture names
  77870. * as keys and their data and paths as values
  77871. */
  77872. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77873. private static _PreExportAsync;
  77874. private static _PostExportAsync;
  77875. /**
  77876. * Exports the geometry of the scene to .glb file format asychronously
  77877. * @param scene Babylon scene with scene hierarchy information
  77878. * @param filePrefix File prefix to use when generating glb file
  77879. * @param options Exporter options
  77880. * @returns Returns an object with a .glb filename as key and data as value
  77881. */
  77882. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77883. }
  77884. }
  77885. declare module BABYLON.GLTF2.Exporter {
  77886. /**
  77887. * @hidden
  77888. */
  77889. export class _GLTFUtilities {
  77890. /**
  77891. * Creates a buffer view based on the supplied arguments
  77892. * @param bufferIndex index value of the specified buffer
  77893. * @param byteOffset byte offset value
  77894. * @param byteLength byte length of the bufferView
  77895. * @param byteStride byte distance between conequential elements
  77896. * @param name name of the buffer view
  77897. * @returns bufferView for glTF
  77898. */
  77899. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  77900. /**
  77901. * Creates an accessor based on the supplied arguments
  77902. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  77903. * @param name The name of the accessor
  77904. * @param type The type of the accessor
  77905. * @param componentType The datatype of components in the attribute
  77906. * @param count The number of attributes referenced by this accessor
  77907. * @param byteOffset The offset relative to the start of the bufferView in bytes
  77908. * @param min Minimum value of each component in this attribute
  77909. * @param max Maximum value of each component in this attribute
  77910. * @returns accessor for glTF
  77911. */
  77912. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  77913. /**
  77914. * Calculates the minimum and maximum values of an array of position floats
  77915. * @param positions Positions array of a mesh
  77916. * @param vertexStart Starting vertex offset to calculate min and max values
  77917. * @param vertexCount Number of vertices to check for min and max values
  77918. * @returns min number array and max number array
  77919. */
  77920. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  77921. min: number[];
  77922. max: number[];
  77923. };
  77924. /**
  77925. * Converts a new right-handed Vector3
  77926. * @param vector vector3 array
  77927. * @returns right-handed Vector3
  77928. */
  77929. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  77930. /**
  77931. * Converts a Vector3 to right-handed
  77932. * @param vector Vector3 to convert to right-handed
  77933. */
  77934. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  77935. /**
  77936. * Converts a three element number array to right-handed
  77937. * @param vector number array to convert to right-handed
  77938. */
  77939. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  77940. /**
  77941. * Converts a new right-handed Vector3
  77942. * @param vector vector3 array
  77943. * @returns right-handed Vector3
  77944. */
  77945. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  77946. /**
  77947. * Converts a Vector3 to right-handed
  77948. * @param vector Vector3 to convert to right-handed
  77949. */
  77950. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  77951. /**
  77952. * Converts a three element number array to right-handed
  77953. * @param vector number array to convert to right-handed
  77954. */
  77955. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  77956. /**
  77957. * Converts a Vector4 to right-handed
  77958. * @param vector Vector4 to convert to right-handed
  77959. */
  77960. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  77961. /**
  77962. * Converts a Vector4 to right-handed
  77963. * @param vector Vector4 to convert to right-handed
  77964. */
  77965. static _GetRightHandedArray4FromRef(vector: number[]): void;
  77966. /**
  77967. * Converts a Quaternion to right-handed
  77968. * @param quaternion Source quaternion to convert to right-handed
  77969. */
  77970. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  77971. /**
  77972. * Converts a Quaternion to right-handed
  77973. * @param quaternion Source quaternion to convert to right-handed
  77974. */
  77975. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  77976. static _NormalizeTangentFromRef(tangent: Vector4): void;
  77977. }
  77978. }
  77979. declare module BABYLON.GLTF2.Exporter {
  77980. /**
  77981. * Converts Babylon Scene into glTF 2.0.
  77982. * @hidden
  77983. */
  77984. export class _Exporter {
  77985. /**
  77986. * Stores the glTF to export
  77987. */
  77988. _glTF: IGLTF;
  77989. /**
  77990. * Stores all generated buffer views, which represents views into the main glTF buffer data
  77991. */
  77992. _bufferViews: IBufferView[];
  77993. /**
  77994. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  77995. */
  77996. _accessors: IAccessor[];
  77997. /**
  77998. * Stores all the generated nodes, which contains transform and/or mesh information per node
  77999. */
  78000. _nodes: INode[];
  78001. /**
  78002. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  78003. */
  78004. private _scenes;
  78005. /**
  78006. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  78007. */
  78008. private _meshes;
  78009. /**
  78010. * Stores all the generated material information, which represents the appearance of each primitive
  78011. */
  78012. _materials: IMaterial[];
  78013. _materialMap: {
  78014. [materialID: number]: number;
  78015. };
  78016. /**
  78017. * Stores all the generated texture information, which is referenced by glTF materials
  78018. */
  78019. _textures: ITexture[];
  78020. /**
  78021. * Stores all the generated image information, which is referenced by glTF textures
  78022. */
  78023. _images: IImage[];
  78024. /**
  78025. * Stores all the texture samplers
  78026. */
  78027. _samplers: ISampler[];
  78028. /**
  78029. * Stores all the generated animation samplers, which is referenced by glTF animations
  78030. */
  78031. /**
  78032. * Stores the animations for glTF models
  78033. */
  78034. private _animations;
  78035. /**
  78036. * Stores the total amount of bytes stored in the glTF buffer
  78037. */
  78038. private _totalByteLength;
  78039. /**
  78040. * Stores a reference to the Babylon scene containing the source geometry and material information
  78041. */
  78042. _babylonScene: Scene;
  78043. /**
  78044. * Stores a map of the image data, where the key is the file name and the value
  78045. * is the image data
  78046. */
  78047. _imageData: {
  78048. [fileName: string]: {
  78049. data: Uint8Array;
  78050. mimeType: ImageMimeType;
  78051. };
  78052. };
  78053. /**
  78054. * Stores a map of the unique id of a node to its index in the node array
  78055. */
  78056. _nodeMap: {
  78057. [key: number]: number;
  78058. };
  78059. /**
  78060. * Specifies if the source Babylon scene was left handed, and needed conversion.
  78061. */
  78062. _convertToRightHandedSystem: boolean;
  78063. /**
  78064. * Specifies if a Babylon node should be converted to right-handed on export
  78065. */
  78066. _convertToRightHandedSystemMap: {
  78067. [nodeId: number]: boolean;
  78068. };
  78069. _includeCoordinateSystemConversionNodes: boolean;
  78070. /**
  78071. * Baked animation sample rate
  78072. */
  78073. private _animationSampleRate;
  78074. private _options;
  78075. private _localEngine;
  78076. _glTFMaterialExporter: _GLTFMaterialExporter;
  78077. private _extensions;
  78078. private static _ExtensionNames;
  78079. private static _ExtensionFactories;
  78080. private _applyExtension;
  78081. private _applyExtensions;
  78082. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  78083. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  78084. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78085. [key: number]: number;
  78086. }): Promise<Nullable<INode>>;
  78087. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  78088. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  78089. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  78090. private _forEachExtensions;
  78091. private _extensionsOnExporting;
  78092. /**
  78093. * Load glTF serializer extensions
  78094. */
  78095. private _loadExtensions;
  78096. /**
  78097. * Creates a glTF Exporter instance, which can accept optional exporter options
  78098. * @param babylonScene Babylon scene object
  78099. * @param options Options to modify the behavior of the exporter
  78100. */
  78101. constructor(babylonScene: Scene, options?: IExportOptions);
  78102. dispose(): void;
  78103. /**
  78104. * Registers a glTF exporter extension
  78105. * @param name Name of the extension to export
  78106. * @param factory The factory function that creates the exporter extension
  78107. */
  78108. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  78109. /**
  78110. * Un-registers an exporter extension
  78111. * @param name The name fo the exporter extension
  78112. * @returns A boolean indicating whether the extension has been un-registered
  78113. */
  78114. static UnregisterExtension(name: string): boolean;
  78115. /**
  78116. * Lazy load a local engine
  78117. */
  78118. _getLocalEngine(): Engine;
  78119. private reorderIndicesBasedOnPrimitiveMode;
  78120. /**
  78121. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  78122. * clock-wise during export to glTF
  78123. * @param submesh BabylonJS submesh
  78124. * @param primitiveMode Primitive mode of the mesh
  78125. * @param sideOrientation the winding order of the submesh
  78126. * @param vertexBufferKind The type of vertex attribute
  78127. * @param meshAttributeArray The vertex attribute data
  78128. * @param byteOffset The offset to the binary data
  78129. * @param binaryWriter The binary data for the glTF file
  78130. * @param convertToRightHandedSystem Converts the values to right-handed
  78131. */
  78132. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  78133. /**
  78134. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  78135. * clock-wise during export to glTF
  78136. * @param submesh BabylonJS submesh
  78137. * @param primitiveMode Primitive mode of the mesh
  78138. * @param sideOrientation the winding order of the submesh
  78139. * @param vertexBufferKind The type of vertex attribute
  78140. * @param meshAttributeArray The vertex attribute data
  78141. * @param byteOffset The offset to the binary data
  78142. * @param binaryWriter The binary data for the glTF file
  78143. * @param convertToRightHandedSystem Converts the values to right-handed
  78144. */
  78145. private reorderTriangleFillMode;
  78146. /**
  78147. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  78148. * clock-wise during export to glTF
  78149. * @param submesh BabylonJS submesh
  78150. * @param primitiveMode Primitive mode of the mesh
  78151. * @param sideOrientation the winding order of the submesh
  78152. * @param vertexBufferKind The type of vertex attribute
  78153. * @param meshAttributeArray The vertex attribute data
  78154. * @param byteOffset The offset to the binary data
  78155. * @param binaryWriter The binary data for the glTF file
  78156. * @param convertToRightHandedSystem Converts the values to right-handed
  78157. */
  78158. private reorderTriangleStripDrawMode;
  78159. /**
  78160. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  78161. * clock-wise during export to glTF
  78162. * @param submesh BabylonJS submesh
  78163. * @param primitiveMode Primitive mode of the mesh
  78164. * @param sideOrientation the winding order of the submesh
  78165. * @param vertexBufferKind The type of vertex attribute
  78166. * @param meshAttributeArray The vertex attribute data
  78167. * @param byteOffset The offset to the binary data
  78168. * @param binaryWriter The binary data for the glTF file
  78169. * @param convertToRightHandedSystem Converts the values to right-handed
  78170. */
  78171. private reorderTriangleFanMode;
  78172. /**
  78173. * Writes the vertex attribute data to binary
  78174. * @param vertices The vertices to write to the binary writer
  78175. * @param byteOffset The offset into the binary writer to overwrite binary data
  78176. * @param vertexAttributeKind The vertex attribute type
  78177. * @param meshAttributeArray The vertex attribute data
  78178. * @param binaryWriter The writer containing the binary data
  78179. * @param convertToRightHandedSystem Converts the values to right-handed
  78180. */
  78181. private writeVertexAttributeData;
  78182. /**
  78183. * Writes mesh attribute data to a data buffer
  78184. * Returns the bytelength of the data
  78185. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  78186. * @param meshAttributeArray Array containing the attribute data
  78187. * @param binaryWriter The buffer to write the binary data to
  78188. * @param indices Used to specify the order of the vertex data
  78189. * @param convertToRightHandedSystem Converts the values to right-handed
  78190. */
  78191. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  78192. /**
  78193. * Generates glTF json data
  78194. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  78195. * @param glTFPrefix Text to use when prefixing a glTF file
  78196. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  78197. * @returns json data as string
  78198. */
  78199. private generateJSON;
  78200. /**
  78201. * Generates data for .gltf and .bin files based on the glTF prefix string
  78202. * @param glTFPrefix Text to use when prefixing a glTF file
  78203. * @param dispose Dispose the exporter
  78204. * @returns GLTFData with glTF file data
  78205. */
  78206. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78207. /**
  78208. * Creates a binary buffer for glTF
  78209. * @returns array buffer for binary data
  78210. */
  78211. private _generateBinaryAsync;
  78212. /**
  78213. * Pads the number to a multiple of 4
  78214. * @param num number to pad
  78215. * @returns padded number
  78216. */
  78217. private _getPadding;
  78218. /**
  78219. * @hidden
  78220. */
  78221. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78222. /**
  78223. * Sets the TRS for each node
  78224. * @param node glTF Node for storing the transformation data
  78225. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  78226. * @param convertToRightHandedSystem Converts the values to right-handed
  78227. */
  78228. private setNodeTransformation;
  78229. private getVertexBufferFromMesh;
  78230. /**
  78231. * Creates a bufferview based on the vertices type for the Babylon mesh
  78232. * @param kind Indicates the type of vertices data
  78233. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  78234. * @param binaryWriter The buffer to write the bufferview data to
  78235. * @param convertToRightHandedSystem Converts the values to right-handed
  78236. */
  78237. private createBufferViewKind;
  78238. /**
  78239. * The primitive mode of the Babylon mesh
  78240. * @param babylonMesh The BabylonJS mesh
  78241. */
  78242. private getMeshPrimitiveMode;
  78243. /**
  78244. * Sets the primitive mode of the glTF mesh primitive
  78245. * @param meshPrimitive glTF mesh primitive
  78246. * @param primitiveMode The primitive mode
  78247. */
  78248. private setPrimitiveMode;
  78249. /**
  78250. * Sets the vertex attribute accessor based of the glTF mesh primitive
  78251. * @param meshPrimitive glTF mesh primitive
  78252. * @param attributeKind vertex attribute
  78253. * @returns boolean specifying if uv coordinates are present
  78254. */
  78255. private setAttributeKind;
  78256. /**
  78257. * Sets data for the primitive attributes of each submesh
  78258. * @param mesh glTF Mesh object to store the primitive attribute information
  78259. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  78260. * @param binaryWriter Buffer to write the attribute data to
  78261. * @param convertToRightHandedSystem Converts the values to right-handed
  78262. */
  78263. private setPrimitiveAttributesAsync;
  78264. /**
  78265. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  78266. * @param node The node to check
  78267. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  78268. */
  78269. private isBabylonCoordinateSystemConvertingNode;
  78270. /**
  78271. * Creates a glTF scene based on the array of meshes
  78272. * Returns the the total byte offset
  78273. * @param babylonScene Babylon scene to get the mesh data from
  78274. * @param binaryWriter Buffer to write binary data to
  78275. */
  78276. private createSceneAsync;
  78277. /**
  78278. * Creates a mapping of Node unique id to node index and handles animations
  78279. * @param babylonScene Babylon Scene
  78280. * @param nodes Babylon transform nodes
  78281. * @param binaryWriter Buffer to write binary data to
  78282. * @returns Node mapping of unique id to index
  78283. */
  78284. private createNodeMapAndAnimationsAsync;
  78285. /**
  78286. * Creates a glTF node from a Babylon mesh
  78287. * @param babylonMesh Source Babylon mesh
  78288. * @param binaryWriter Buffer for storing geometry data
  78289. * @param convertToRightHandedSystem Converts the values to right-handed
  78290. * @param nodeMap Node mapping of unique id to glTF node index
  78291. * @returns glTF node
  78292. */
  78293. private createNodeAsync;
  78294. }
  78295. /**
  78296. * @hidden
  78297. *
  78298. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  78299. */
  78300. export class _BinaryWriter {
  78301. /**
  78302. * Array buffer which stores all binary data
  78303. */
  78304. private _arrayBuffer;
  78305. /**
  78306. * View of the array buffer
  78307. */
  78308. private _dataView;
  78309. /**
  78310. * byte offset of data in array buffer
  78311. */
  78312. private _byteOffset;
  78313. /**
  78314. * Initialize binary writer with an initial byte length
  78315. * @param byteLength Initial byte length of the array buffer
  78316. */
  78317. constructor(byteLength: number);
  78318. /**
  78319. * Resize the array buffer to the specified byte length
  78320. * @param byteLength
  78321. */
  78322. private resizeBuffer;
  78323. /**
  78324. * Get an array buffer with the length of the byte offset
  78325. * @returns ArrayBuffer resized to the byte offset
  78326. */
  78327. getArrayBuffer(): ArrayBuffer;
  78328. /**
  78329. * Get the byte offset of the array buffer
  78330. * @returns byte offset
  78331. */
  78332. getByteOffset(): number;
  78333. /**
  78334. * Stores an UInt8 in the array buffer
  78335. * @param entry
  78336. * @param byteOffset If defined, specifies where to set the value as an offset.
  78337. */
  78338. setUInt8(entry: number, byteOffset?: number): void;
  78339. /**
  78340. * Gets an UInt32 in the array buffer
  78341. * @param entry
  78342. * @param byteOffset If defined, specifies where to set the value as an offset.
  78343. */
  78344. getUInt32(byteOffset: number): number;
  78345. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78346. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78347. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78348. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78349. /**
  78350. * Stores a Float32 in the array buffer
  78351. * @param entry
  78352. */
  78353. setFloat32(entry: number, byteOffset?: number): void;
  78354. /**
  78355. * Stores an UInt32 in the array buffer
  78356. * @param entry
  78357. * @param byteOffset If defined, specifies where to set the value as an offset.
  78358. */
  78359. setUInt32(entry: number, byteOffset?: number): void;
  78360. }
  78361. }
  78362. declare module BABYLON.GLTF2.Exporter {
  78363. /**
  78364. * @hidden
  78365. * Interface to store animation data.
  78366. */
  78367. export interface _IAnimationData {
  78368. /**
  78369. * Keyframe data.
  78370. */
  78371. inputs: number[];
  78372. /**
  78373. * Value data.
  78374. */
  78375. outputs: number[][];
  78376. /**
  78377. * Animation interpolation data.
  78378. */
  78379. samplerInterpolation: AnimationSamplerInterpolation;
  78380. /**
  78381. * Minimum keyframe value.
  78382. */
  78383. inputsMin: number;
  78384. /**
  78385. * Maximum keyframe value.
  78386. */
  78387. inputsMax: number;
  78388. }
  78389. /**
  78390. * @hidden
  78391. */
  78392. export interface _IAnimationInfo {
  78393. /**
  78394. * The target channel for the animation
  78395. */
  78396. animationChannelTargetPath: AnimationChannelTargetPath;
  78397. /**
  78398. * The glTF accessor type for the data.
  78399. */
  78400. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  78401. /**
  78402. * Specifies if quaternions should be used.
  78403. */
  78404. useQuaternion: boolean;
  78405. }
  78406. /**
  78407. * @hidden
  78408. * Utility class for generating glTF animation data from BabylonJS.
  78409. */
  78410. export class _GLTFAnimation {
  78411. /**
  78412. * @ignore
  78413. *
  78414. * Creates glTF channel animation from BabylonJS animation.
  78415. * @param babylonTransformNode - BabylonJS mesh.
  78416. * @param animation - animation.
  78417. * @param animationChannelTargetPath - The target animation channel.
  78418. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  78419. * @param useQuaternion - Specifies if quaternions are used.
  78420. * @returns nullable IAnimationData
  78421. */
  78422. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  78423. private static _DeduceAnimationInfo;
  78424. /**
  78425. * @ignore
  78426. * Create node animations from the transform node animations
  78427. * @param babylonNode
  78428. * @param runtimeGLTFAnimation
  78429. * @param idleGLTFAnimations
  78430. * @param nodeMap
  78431. * @param nodes
  78432. * @param binaryWriter
  78433. * @param bufferViews
  78434. * @param accessors
  78435. * @param convertToRightHandedSystem
  78436. * @param animationSampleRate
  78437. */
  78438. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  78439. [key: number]: number;
  78440. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  78441. /**
  78442. * @ignore
  78443. * Create node animations from the animation groups
  78444. * @param babylonScene
  78445. * @param glTFAnimations
  78446. * @param nodeMap
  78447. * @param nodes
  78448. * @param binaryWriter
  78449. * @param bufferViews
  78450. * @param accessors
  78451. * @param convertToRightHandedSystemMap
  78452. * @param animationSampleRate
  78453. */
  78454. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  78455. [key: number]: number;
  78456. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  78457. [nodeId: number]: boolean;
  78458. }, animationSampleRate: number): void;
  78459. private static AddAnimation;
  78460. /**
  78461. * Create a baked animation
  78462. * @param babylonTransformNode BabylonJS mesh
  78463. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  78464. * @param animationChannelTargetPath animation target channel
  78465. * @param minFrame minimum animation frame
  78466. * @param maxFrame maximum animation frame
  78467. * @param fps frames per second of the animation
  78468. * @param inputs input key frames of the animation
  78469. * @param outputs output key frame data of the animation
  78470. * @param convertToRightHandedSystem converts the values to right-handed
  78471. * @param useQuaternion specifies if quaternions should be used
  78472. */
  78473. private static _CreateBakedAnimation;
  78474. private static _ConvertFactorToVector3OrQuaternion;
  78475. private static _SetInterpolatedValue;
  78476. /**
  78477. * Creates linear animation from the animation key frames
  78478. * @param babylonTransformNode BabylonJS mesh
  78479. * @param animation BabylonJS animation
  78480. * @param animationChannelTargetPath The target animation channel
  78481. * @param frameDelta The difference between the last and first frame of the animation
  78482. * @param inputs Array to store the key frame times
  78483. * @param outputs Array to store the key frame data
  78484. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78485. * @param useQuaternion Specifies if quaternions are used in the animation
  78486. */
  78487. private static _CreateLinearOrStepAnimation;
  78488. /**
  78489. * Creates cubic spline animation from the animation key frames
  78490. * @param babylonTransformNode BabylonJS mesh
  78491. * @param animation BabylonJS animation
  78492. * @param animationChannelTargetPath The target animation channel
  78493. * @param frameDelta The difference between the last and first frame of the animation
  78494. * @param inputs Array to store the key frame times
  78495. * @param outputs Array to store the key frame data
  78496. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78497. * @param useQuaternion Specifies if quaternions are used in the animation
  78498. */
  78499. private static _CreateCubicSplineAnimation;
  78500. private static _GetBasePositionRotationOrScale;
  78501. /**
  78502. * Adds a key frame value
  78503. * @param keyFrame
  78504. * @param animation
  78505. * @param outputs
  78506. * @param animationChannelTargetPath
  78507. * @param basePositionRotationOrScale
  78508. * @param convertToRightHandedSystem
  78509. * @param useQuaternion
  78510. */
  78511. private static _AddKeyframeValue;
  78512. /**
  78513. * Determine the interpolation based on the key frames
  78514. * @param keyFrames
  78515. * @param animationChannelTargetPath
  78516. * @param useQuaternion
  78517. */
  78518. private static _DeduceInterpolation;
  78519. /**
  78520. * Adds an input tangent or output tangent to the output data
  78521. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  78522. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  78523. * @param outputs The animation data by keyframe
  78524. * @param animationChannelTargetPath The target animation channel
  78525. * @param interpolation The interpolation type
  78526. * @param keyFrame The key frame with the animation data
  78527. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  78528. * @param useQuaternion Specifies if quaternions are used
  78529. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  78530. */
  78531. private static AddSplineTangent;
  78532. /**
  78533. * Get the minimum and maximum key frames' frame values
  78534. * @param keyFrames animation key frames
  78535. * @returns the minimum and maximum key frame value
  78536. */
  78537. private static calculateMinMaxKeyFrames;
  78538. }
  78539. }
  78540. declare module BABYLON.GLTF2.Exporter {
  78541. /** @hidden */
  78542. export var textureTransformPixelShader: {
  78543. name: string;
  78544. shader: string;
  78545. };
  78546. }
  78547. declare module BABYLON.GLTF2.Exporter.Extensions {
  78548. /**
  78549. * @hidden
  78550. */
  78551. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  78552. private _recordedTextures;
  78553. /** Name of this extension */
  78554. readonly name: string;
  78555. /** Defines whether this extension is enabled */
  78556. enabled: boolean;
  78557. /** Defines whether this extension is required */
  78558. required: boolean;
  78559. /** Reference to the glTF exporter */
  78560. private _wasUsed;
  78561. constructor(exporter: _Exporter);
  78562. dispose(): void;
  78563. /** @hidden */
  78564. get wasUsed(): boolean;
  78565. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78566. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  78567. /**
  78568. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  78569. * @param babylonTexture
  78570. * @param offset
  78571. * @param rotation
  78572. * @param scale
  78573. * @param scene
  78574. */
  78575. private _textureTransformTextureAsync;
  78576. }
  78577. }
  78578. declare module BABYLON.GLTF2.Exporter.Extensions {
  78579. /**
  78580. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  78581. */
  78582. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  78583. /** The name of this extension. */
  78584. readonly name: string;
  78585. /** Defines whether this extension is enabled. */
  78586. enabled: boolean;
  78587. /** Defines whether this extension is required */
  78588. required: boolean;
  78589. /** Reference to the glTF exporter */
  78590. private _exporter;
  78591. private _lights;
  78592. /** @hidden */
  78593. constructor(exporter: _Exporter);
  78594. /** @hidden */
  78595. dispose(): void;
  78596. /** @hidden */
  78597. get wasUsed(): boolean;
  78598. /** @hidden */
  78599. onExporting(): void;
  78600. /**
  78601. * Define this method to modify the default behavior when exporting a node
  78602. * @param context The context when exporting the node
  78603. * @param node glTF node
  78604. * @param babylonNode BabylonJS node
  78605. * @param nodeMap Node mapping of unique id to glTF node index
  78606. * @returns nullable INode promise
  78607. */
  78608. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78609. [key: number]: number;
  78610. }): Promise<Nullable<INode>>;
  78611. }
  78612. }
  78613. declare module BABYLON.GLTF2.Exporter.Extensions {
  78614. /**
  78615. * @hidden
  78616. */
  78617. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  78618. /** Name of this extension */
  78619. readonly name: string;
  78620. /** Defines whether this extension is enabled */
  78621. enabled: boolean;
  78622. /** Defines whether this extension is required */
  78623. required: boolean;
  78624. /** Reference to the glTF exporter */
  78625. private _textureInfos;
  78626. private _exportedTextures;
  78627. private _wasUsed;
  78628. constructor(exporter: _Exporter);
  78629. dispose(): void;
  78630. /** @hidden */
  78631. get wasUsed(): boolean;
  78632. private _getTextureIndex;
  78633. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78634. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  78635. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  78636. }
  78637. }
  78638. declare module BABYLON {
  78639. /**
  78640. * Class for generating STL data from a Babylon scene.
  78641. */
  78642. export class STLExport {
  78643. /**
  78644. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  78645. * @param meshes list defines the mesh to serialize
  78646. * @param download triggers the automatic download of the file.
  78647. * @param fileName changes the downloads fileName.
  78648. * @param binary changes the STL to a binary type.
  78649. * @param isLittleEndian toggle for binary type exporter.
  78650. * @returns the STL as UTF8 string
  78651. */
  78652. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  78653. }
  78654. }
  78655. declare module "babylonjs-gltf2interface" {
  78656. export = BABYLON.GLTF2;
  78657. }
  78658. /**
  78659. * Module for glTF 2.0 Interface
  78660. */
  78661. declare module BABYLON.GLTF2 {
  78662. /**
  78663. * The datatype of the components in the attribute
  78664. */
  78665. const enum AccessorComponentType {
  78666. /**
  78667. * Byte
  78668. */
  78669. BYTE = 5120,
  78670. /**
  78671. * Unsigned Byte
  78672. */
  78673. UNSIGNED_BYTE = 5121,
  78674. /**
  78675. * Short
  78676. */
  78677. SHORT = 5122,
  78678. /**
  78679. * Unsigned Short
  78680. */
  78681. UNSIGNED_SHORT = 5123,
  78682. /**
  78683. * Unsigned Int
  78684. */
  78685. UNSIGNED_INT = 5125,
  78686. /**
  78687. * Float
  78688. */
  78689. FLOAT = 5126,
  78690. }
  78691. /**
  78692. * Specifies if the attirbute is a scalar, vector, or matrix
  78693. */
  78694. const enum AccessorType {
  78695. /**
  78696. * Scalar
  78697. */
  78698. SCALAR = "SCALAR",
  78699. /**
  78700. * Vector2
  78701. */
  78702. VEC2 = "VEC2",
  78703. /**
  78704. * Vector3
  78705. */
  78706. VEC3 = "VEC3",
  78707. /**
  78708. * Vector4
  78709. */
  78710. VEC4 = "VEC4",
  78711. /**
  78712. * Matrix2x2
  78713. */
  78714. MAT2 = "MAT2",
  78715. /**
  78716. * Matrix3x3
  78717. */
  78718. MAT3 = "MAT3",
  78719. /**
  78720. * Matrix4x4
  78721. */
  78722. MAT4 = "MAT4",
  78723. }
  78724. /**
  78725. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78726. */
  78727. const enum AnimationChannelTargetPath {
  78728. /**
  78729. * Translation
  78730. */
  78731. TRANSLATION = "translation",
  78732. /**
  78733. * Rotation
  78734. */
  78735. ROTATION = "rotation",
  78736. /**
  78737. * Scale
  78738. */
  78739. SCALE = "scale",
  78740. /**
  78741. * Weights
  78742. */
  78743. WEIGHTS = "weights",
  78744. }
  78745. /**
  78746. * Interpolation algorithm
  78747. */
  78748. const enum AnimationSamplerInterpolation {
  78749. /**
  78750. * The animated values are linearly interpolated between keyframes
  78751. */
  78752. LINEAR = "LINEAR",
  78753. /**
  78754. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  78755. */
  78756. STEP = "STEP",
  78757. /**
  78758. * The animation's interpolation is computed using a cubic spline with specified tangents
  78759. */
  78760. CUBICSPLINE = "CUBICSPLINE",
  78761. }
  78762. /**
  78763. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78764. */
  78765. const enum CameraType {
  78766. /**
  78767. * A perspective camera containing properties to create a perspective projection matrix
  78768. */
  78769. PERSPECTIVE = "perspective",
  78770. /**
  78771. * An orthographic camera containing properties to create an orthographic projection matrix
  78772. */
  78773. ORTHOGRAPHIC = "orthographic",
  78774. }
  78775. /**
  78776. * The mime-type of the image
  78777. */
  78778. const enum ImageMimeType {
  78779. /**
  78780. * JPEG Mime-type
  78781. */
  78782. JPEG = "image/jpeg",
  78783. /**
  78784. * PNG Mime-type
  78785. */
  78786. PNG = "image/png",
  78787. }
  78788. /**
  78789. * The alpha rendering mode of the material
  78790. */
  78791. const enum MaterialAlphaMode {
  78792. /**
  78793. * The alpha value is ignored and the rendered output is fully opaque
  78794. */
  78795. OPAQUE = "OPAQUE",
  78796. /**
  78797. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  78798. */
  78799. MASK = "MASK",
  78800. /**
  78801. * 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)
  78802. */
  78803. BLEND = "BLEND",
  78804. }
  78805. /**
  78806. * The type of the primitives to render
  78807. */
  78808. const enum MeshPrimitiveMode {
  78809. /**
  78810. * Points
  78811. */
  78812. POINTS = 0,
  78813. /**
  78814. * Lines
  78815. */
  78816. LINES = 1,
  78817. /**
  78818. * Line Loop
  78819. */
  78820. LINE_LOOP = 2,
  78821. /**
  78822. * Line Strip
  78823. */
  78824. LINE_STRIP = 3,
  78825. /**
  78826. * Triangles
  78827. */
  78828. TRIANGLES = 4,
  78829. /**
  78830. * Triangle Strip
  78831. */
  78832. TRIANGLE_STRIP = 5,
  78833. /**
  78834. * Triangle Fan
  78835. */
  78836. TRIANGLE_FAN = 6,
  78837. }
  78838. /**
  78839. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78840. */
  78841. const enum TextureMagFilter {
  78842. /**
  78843. * Nearest
  78844. */
  78845. NEAREST = 9728,
  78846. /**
  78847. * Linear
  78848. */
  78849. LINEAR = 9729,
  78850. }
  78851. /**
  78852. * Minification filter. All valid values correspond to WebGL enums
  78853. */
  78854. const enum TextureMinFilter {
  78855. /**
  78856. * Nearest
  78857. */
  78858. NEAREST = 9728,
  78859. /**
  78860. * Linear
  78861. */
  78862. LINEAR = 9729,
  78863. /**
  78864. * Nearest Mip-Map Nearest
  78865. */
  78866. NEAREST_MIPMAP_NEAREST = 9984,
  78867. /**
  78868. * Linear Mipmap Nearest
  78869. */
  78870. LINEAR_MIPMAP_NEAREST = 9985,
  78871. /**
  78872. * Nearest Mipmap Linear
  78873. */
  78874. NEAREST_MIPMAP_LINEAR = 9986,
  78875. /**
  78876. * Linear Mipmap Linear
  78877. */
  78878. LINEAR_MIPMAP_LINEAR = 9987,
  78879. }
  78880. /**
  78881. * S (U) wrapping mode. All valid values correspond to WebGL enums
  78882. */
  78883. const enum TextureWrapMode {
  78884. /**
  78885. * Clamp to Edge
  78886. */
  78887. CLAMP_TO_EDGE = 33071,
  78888. /**
  78889. * Mirrored Repeat
  78890. */
  78891. MIRRORED_REPEAT = 33648,
  78892. /**
  78893. * Repeat
  78894. */
  78895. REPEAT = 10497,
  78896. }
  78897. /**
  78898. * glTF Property
  78899. */
  78900. interface IProperty {
  78901. /**
  78902. * Dictionary object with extension-specific objects
  78903. */
  78904. extensions?: {
  78905. [key: string]: any;
  78906. };
  78907. /**
  78908. * Application-Specific data
  78909. */
  78910. extras?: any;
  78911. }
  78912. /**
  78913. * glTF Child of Root Property
  78914. */
  78915. interface IChildRootProperty extends IProperty {
  78916. /**
  78917. * The user-defined name of this object
  78918. */
  78919. name?: string;
  78920. }
  78921. /**
  78922. * Indices of those attributes that deviate from their initialization value
  78923. */
  78924. interface IAccessorSparseIndices extends IProperty {
  78925. /**
  78926. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78927. */
  78928. bufferView: number;
  78929. /**
  78930. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78931. */
  78932. byteOffset?: number;
  78933. /**
  78934. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  78935. */
  78936. componentType: AccessorComponentType;
  78937. }
  78938. /**
  78939. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  78940. */
  78941. interface IAccessorSparseValues extends IProperty {
  78942. /**
  78943. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78944. */
  78945. bufferView: number;
  78946. /**
  78947. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78948. */
  78949. byteOffset?: number;
  78950. }
  78951. /**
  78952. * Sparse storage of attributes that deviate from their initialization value
  78953. */
  78954. interface IAccessorSparse extends IProperty {
  78955. /**
  78956. * The number of attributes encoded in this sparse accessor
  78957. */
  78958. count: number;
  78959. /**
  78960. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  78961. */
  78962. indices: IAccessorSparseIndices;
  78963. /**
  78964. * 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
  78965. */
  78966. values: IAccessorSparseValues;
  78967. }
  78968. /**
  78969. * 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
  78970. */
  78971. interface IAccessor extends IChildRootProperty {
  78972. /**
  78973. * The index of the bufferview
  78974. */
  78975. bufferView?: number;
  78976. /**
  78977. * The offset relative to the start of the bufferView in bytes
  78978. */
  78979. byteOffset?: number;
  78980. /**
  78981. * The datatype of components in the attribute
  78982. */
  78983. componentType: AccessorComponentType;
  78984. /**
  78985. * Specifies whether integer data values should be normalized
  78986. */
  78987. normalized?: boolean;
  78988. /**
  78989. * The number of attributes referenced by this accessor
  78990. */
  78991. count: number;
  78992. /**
  78993. * Specifies if the attribute is a scalar, vector, or matrix
  78994. */
  78995. type: AccessorType;
  78996. /**
  78997. * Maximum value of each component in this attribute
  78998. */
  78999. max?: number[];
  79000. /**
  79001. * Minimum value of each component in this attribute
  79002. */
  79003. min?: number[];
  79004. /**
  79005. * Sparse storage of attributes that deviate from their initialization value
  79006. */
  79007. sparse?: IAccessorSparse;
  79008. }
  79009. /**
  79010. * Targets an animation's sampler at a node's property
  79011. */
  79012. interface IAnimationChannel extends IProperty {
  79013. /**
  79014. * The index of a sampler in this animation used to compute the value for the target
  79015. */
  79016. sampler: number;
  79017. /**
  79018. * The index of the node and TRS property to target
  79019. */
  79020. target: IAnimationChannelTarget;
  79021. }
  79022. /**
  79023. * The index of the node and TRS property that an animation channel targets
  79024. */
  79025. interface IAnimationChannelTarget extends IProperty {
  79026. /**
  79027. * The index of the node to target
  79028. */
  79029. node: number;
  79030. /**
  79031. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  79032. */
  79033. path: AnimationChannelTargetPath;
  79034. }
  79035. /**
  79036. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79037. */
  79038. interface IAnimationSampler extends IProperty {
  79039. /**
  79040. * The index of an accessor containing keyframe input values, e.g., time
  79041. */
  79042. input: number;
  79043. /**
  79044. * Interpolation algorithm
  79045. */
  79046. interpolation?: AnimationSamplerInterpolation;
  79047. /**
  79048. * The index of an accessor, containing keyframe output values
  79049. */
  79050. output: number;
  79051. }
  79052. /**
  79053. * A keyframe animation
  79054. */
  79055. interface IAnimation extends IChildRootProperty {
  79056. /**
  79057. * An array of channels, each of which targets an animation's sampler at a node's property
  79058. */
  79059. channels: IAnimationChannel[];
  79060. /**
  79061. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79062. */
  79063. samplers: IAnimationSampler[];
  79064. }
  79065. /**
  79066. * Metadata about the glTF asset
  79067. */
  79068. interface IAsset extends IChildRootProperty {
  79069. /**
  79070. * A copyright message suitable for display to credit the content creator
  79071. */
  79072. copyright?: string;
  79073. /**
  79074. * Tool that generated this glTF model. Useful for debugging
  79075. */
  79076. generator?: string;
  79077. /**
  79078. * The glTF version that this asset targets
  79079. */
  79080. version: string;
  79081. /**
  79082. * The minimum glTF version that this asset targets
  79083. */
  79084. minVersion?: string;
  79085. }
  79086. /**
  79087. * A buffer points to binary geometry, animation, or skins
  79088. */
  79089. interface IBuffer extends IChildRootProperty {
  79090. /**
  79091. * 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
  79092. */
  79093. uri?: string;
  79094. /**
  79095. * The length of the buffer in bytes
  79096. */
  79097. byteLength: number;
  79098. }
  79099. /**
  79100. * A view into a buffer generally representing a subset of the buffer
  79101. */
  79102. interface IBufferView extends IChildRootProperty {
  79103. /**
  79104. * The index of the buffer
  79105. */
  79106. buffer: number;
  79107. /**
  79108. * The offset into the buffer in bytes
  79109. */
  79110. byteOffset?: number;
  79111. /**
  79112. * The lenth of the bufferView in bytes
  79113. */
  79114. byteLength: number;
  79115. /**
  79116. * The stride, in bytes
  79117. */
  79118. byteStride?: number;
  79119. }
  79120. /**
  79121. * An orthographic camera containing properties to create an orthographic projection matrix
  79122. */
  79123. interface ICameraOrthographic extends IProperty {
  79124. /**
  79125. * The floating-point horizontal magnification of the view. Must not be zero
  79126. */
  79127. xmag: number;
  79128. /**
  79129. * The floating-point vertical magnification of the view. Must not be zero
  79130. */
  79131. ymag: number;
  79132. /**
  79133. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  79134. */
  79135. zfar: number;
  79136. /**
  79137. * The floating-point distance to the near clipping plane
  79138. */
  79139. znear: number;
  79140. }
  79141. /**
  79142. * A perspective camera containing properties to create a perspective projection matrix
  79143. */
  79144. interface ICameraPerspective extends IProperty {
  79145. /**
  79146. * The floating-point aspect ratio of the field of view
  79147. */
  79148. aspectRatio?: number;
  79149. /**
  79150. * The floating-point vertical field of view in radians
  79151. */
  79152. yfov: number;
  79153. /**
  79154. * The floating-point distance to the far clipping plane
  79155. */
  79156. zfar?: number;
  79157. /**
  79158. * The floating-point distance to the near clipping plane
  79159. */
  79160. znear: number;
  79161. }
  79162. /**
  79163. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  79164. */
  79165. interface ICamera extends IChildRootProperty {
  79166. /**
  79167. * An orthographic camera containing properties to create an orthographic projection matrix
  79168. */
  79169. orthographic?: ICameraOrthographic;
  79170. /**
  79171. * A perspective camera containing properties to create a perspective projection matrix
  79172. */
  79173. perspective?: ICameraPerspective;
  79174. /**
  79175. * Specifies if the camera uses a perspective or orthographic projection
  79176. */
  79177. type: CameraType;
  79178. }
  79179. /**
  79180. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  79181. */
  79182. interface IImage extends IChildRootProperty {
  79183. /**
  79184. * 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
  79185. */
  79186. uri?: string;
  79187. /**
  79188. * The image's MIME type
  79189. */
  79190. mimeType?: ImageMimeType;
  79191. /**
  79192. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  79193. */
  79194. bufferView?: number;
  79195. }
  79196. /**
  79197. * Material Normal Texture Info
  79198. */
  79199. interface IMaterialNormalTextureInfo extends ITextureInfo {
  79200. /**
  79201. * The scalar multiplier applied to each normal vector of the normal texture
  79202. */
  79203. scale?: number;
  79204. }
  79205. /**
  79206. * Material Occlusion Texture Info
  79207. */
  79208. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  79209. /**
  79210. * A scalar multiplier controlling the amount of occlusion applied
  79211. */
  79212. strength?: number;
  79213. }
  79214. /**
  79215. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  79216. */
  79217. interface IMaterialPbrMetallicRoughness {
  79218. /**
  79219. * The material's base color factor
  79220. */
  79221. baseColorFactor?: number[];
  79222. /**
  79223. * The base color texture
  79224. */
  79225. baseColorTexture?: ITextureInfo;
  79226. /**
  79227. * The metalness of the material
  79228. */
  79229. metallicFactor?: number;
  79230. /**
  79231. * The roughness of the material
  79232. */
  79233. roughnessFactor?: number;
  79234. /**
  79235. * The metallic-roughness texture
  79236. */
  79237. metallicRoughnessTexture?: ITextureInfo;
  79238. }
  79239. /**
  79240. * The material appearance of a primitive
  79241. */
  79242. interface IMaterial extends IChildRootProperty {
  79243. /**
  79244. * 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
  79245. */
  79246. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79247. /**
  79248. * The normal map texture
  79249. */
  79250. normalTexture?: IMaterialNormalTextureInfo;
  79251. /**
  79252. * The occlusion map texture
  79253. */
  79254. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79255. /**
  79256. * The emissive map texture
  79257. */
  79258. emissiveTexture?: ITextureInfo;
  79259. /**
  79260. * 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
  79261. */
  79262. emissiveFactor?: number[];
  79263. /**
  79264. * The alpha rendering mode of the material
  79265. */
  79266. alphaMode?: MaterialAlphaMode;
  79267. /**
  79268. * The alpha cutoff value of the material
  79269. */
  79270. alphaCutoff?: number;
  79271. /**
  79272. * Specifies whether the material is double sided
  79273. */
  79274. doubleSided?: boolean;
  79275. }
  79276. /**
  79277. * Geometry to be rendered with the given material
  79278. */
  79279. interface IMeshPrimitive extends IProperty {
  79280. /**
  79281. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  79282. */
  79283. attributes: {
  79284. [name: string]: number;
  79285. };
  79286. /**
  79287. * The index of the accessor that contains the indices
  79288. */
  79289. indices?: number;
  79290. /**
  79291. * The index of the material to apply to this primitive when rendering
  79292. */
  79293. material?: number;
  79294. /**
  79295. * The type of primitives to render. All valid values correspond to WebGL enums
  79296. */
  79297. mode?: MeshPrimitiveMode;
  79298. /**
  79299. * 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
  79300. */
  79301. targets?: {
  79302. [name: string]: number;
  79303. }[];
  79304. }
  79305. /**
  79306. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  79307. */
  79308. interface IMesh extends IChildRootProperty {
  79309. /**
  79310. * An array of primitives, each defining geometry to be rendered with a material
  79311. */
  79312. primitives: IMeshPrimitive[];
  79313. /**
  79314. * Array of weights to be applied to the Morph Targets
  79315. */
  79316. weights?: number[];
  79317. }
  79318. /**
  79319. * A node in the node hierarchy
  79320. */
  79321. interface INode extends IChildRootProperty {
  79322. /**
  79323. * The index of the camera referenced by this node
  79324. */
  79325. camera?: number;
  79326. /**
  79327. * The indices of this node's children
  79328. */
  79329. children?: number[];
  79330. /**
  79331. * The index of the skin referenced by this node
  79332. */
  79333. skin?: number;
  79334. /**
  79335. * A floating-point 4x4 transformation matrix stored in column-major order
  79336. */
  79337. matrix?: number[];
  79338. /**
  79339. * The index of the mesh in this node
  79340. */
  79341. mesh?: number;
  79342. /**
  79343. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  79344. */
  79345. rotation?: number[];
  79346. /**
  79347. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  79348. */
  79349. scale?: number[];
  79350. /**
  79351. * The node's translation along the x, y, and z axes
  79352. */
  79353. translation?: number[];
  79354. /**
  79355. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  79356. */
  79357. weights?: number[];
  79358. }
  79359. /**
  79360. * Texture sampler properties for filtering and wrapping modes
  79361. */
  79362. interface ISampler extends IChildRootProperty {
  79363. /**
  79364. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  79365. */
  79366. magFilter?: TextureMagFilter;
  79367. /**
  79368. * Minification filter. All valid values correspond to WebGL enums
  79369. */
  79370. minFilter?: TextureMinFilter;
  79371. /**
  79372. * S (U) wrapping mode. All valid values correspond to WebGL enums
  79373. */
  79374. wrapS?: TextureWrapMode;
  79375. /**
  79376. * T (V) wrapping mode. All valid values correspond to WebGL enums
  79377. */
  79378. wrapT?: TextureWrapMode;
  79379. }
  79380. /**
  79381. * The root nodes of a scene
  79382. */
  79383. interface IScene extends IChildRootProperty {
  79384. /**
  79385. * The indices of each root node
  79386. */
  79387. nodes: number[];
  79388. }
  79389. /**
  79390. * Joints and matrices defining a skin
  79391. */
  79392. interface ISkin extends IChildRootProperty {
  79393. /**
  79394. * 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
  79395. */
  79396. inverseBindMatrices?: number;
  79397. /**
  79398. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  79399. */
  79400. skeleton?: number;
  79401. /**
  79402. * 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)
  79403. */
  79404. joints: number[];
  79405. }
  79406. /**
  79407. * A texture and its sampler
  79408. */
  79409. interface ITexture extends IChildRootProperty {
  79410. /**
  79411. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  79412. */
  79413. sampler?: number;
  79414. /**
  79415. * The index of the image used by this texture
  79416. */
  79417. source: number;
  79418. }
  79419. /**
  79420. * Reference to a texture
  79421. */
  79422. interface ITextureInfo extends IProperty {
  79423. /**
  79424. * The index of the texture
  79425. */
  79426. index: number;
  79427. /**
  79428. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  79429. */
  79430. texCoord?: number;
  79431. }
  79432. /**
  79433. * The root object for a glTF asset
  79434. */
  79435. interface IGLTF extends IProperty {
  79436. /**
  79437. * An array of accessors. An accessor is a typed view into a bufferView
  79438. */
  79439. accessors?: IAccessor[];
  79440. /**
  79441. * An array of keyframe animations
  79442. */
  79443. animations?: IAnimation[];
  79444. /**
  79445. * Metadata about the glTF asset
  79446. */
  79447. asset: IAsset;
  79448. /**
  79449. * An array of buffers. A buffer points to binary geometry, animation, or skins
  79450. */
  79451. buffers?: IBuffer[];
  79452. /**
  79453. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  79454. */
  79455. bufferViews?: IBufferView[];
  79456. /**
  79457. * An array of cameras
  79458. */
  79459. cameras?: ICamera[];
  79460. /**
  79461. * Names of glTF extensions used somewhere in this asset
  79462. */
  79463. extensionsUsed?: string[];
  79464. /**
  79465. * Names of glTF extensions required to properly load this asset
  79466. */
  79467. extensionsRequired?: string[];
  79468. /**
  79469. * An array of images. An image defines data used to create a texture
  79470. */
  79471. images?: IImage[];
  79472. /**
  79473. * An array of materials. A material defines the appearance of a primitive
  79474. */
  79475. materials?: IMaterial[];
  79476. /**
  79477. * An array of meshes. A mesh is a set of primitives to be rendered
  79478. */
  79479. meshes?: IMesh[];
  79480. /**
  79481. * An array of nodes
  79482. */
  79483. nodes?: INode[];
  79484. /**
  79485. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  79486. */
  79487. samplers?: ISampler[];
  79488. /**
  79489. * The index of the default scene
  79490. */
  79491. scene?: number;
  79492. /**
  79493. * An array of scenes
  79494. */
  79495. scenes?: IScene[];
  79496. /**
  79497. * An array of skins. A skin is defined by joints and matrices
  79498. */
  79499. skins?: ISkin[];
  79500. /**
  79501. * An array of textures
  79502. */
  79503. textures?: ITexture[];
  79504. }
  79505. /**
  79506. * The glTF validation results
  79507. * @ignore
  79508. */
  79509. interface IGLTFValidationResults {
  79510. info: {
  79511. generator: string;
  79512. hasAnimations: boolean;
  79513. hasDefaultScene: boolean;
  79514. hasMaterials: boolean;
  79515. hasMorphTargets: boolean;
  79516. hasSkins: boolean;
  79517. hasTextures: boolean;
  79518. maxAttributesUsed: number;
  79519. primitivesCount: number
  79520. };
  79521. issues: {
  79522. messages: Array<string>;
  79523. numErrors: number;
  79524. numHints: number;
  79525. numInfos: number;
  79526. numWarnings: number;
  79527. truncated: boolean
  79528. };
  79529. mimeType: string;
  79530. uri: string;
  79531. validatedAt: string;
  79532. validatorVersion: string;
  79533. }
  79534. /**
  79535. * The glTF validation options
  79536. */
  79537. interface IGLTFValidationOptions {
  79538. /** Uri to use */
  79539. uri?: string;
  79540. /** Function used to load external resources */
  79541. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  79542. /** Boolean indicating that we need to validate accessor data */
  79543. validateAccessorData?: boolean;
  79544. /** max number of issues allowed */
  79545. maxIssues?: number;
  79546. /** Ignored issues */
  79547. ignoredIssues?: Array<string>;
  79548. /** Value to override severy settings */
  79549. severityOverrides?: Object;
  79550. }
  79551. /**
  79552. * The glTF validator object
  79553. * @ignore
  79554. */
  79555. interface IGLTFValidator {
  79556. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79557. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79558. }
  79559. }
  79560. declare module BABYLON {
  79561. /** @hidden */
  79562. export var cellPixelShader: {
  79563. name: string;
  79564. shader: string;
  79565. };
  79566. }
  79567. declare module BABYLON {
  79568. /** @hidden */
  79569. export var cellVertexShader: {
  79570. name: string;
  79571. shader: string;
  79572. };
  79573. }
  79574. declare module BABYLON {
  79575. export class CellMaterial extends BABYLON.PushMaterial {
  79576. private _diffuseTexture;
  79577. diffuseTexture: BABYLON.BaseTexture;
  79578. diffuseColor: BABYLON.Color3;
  79579. _computeHighLevel: boolean;
  79580. computeHighLevel: boolean;
  79581. private _disableLighting;
  79582. disableLighting: boolean;
  79583. private _maxSimultaneousLights;
  79584. maxSimultaneousLights: number;
  79585. private _renderId;
  79586. constructor(name: string, scene: BABYLON.Scene);
  79587. needAlphaBlending(): boolean;
  79588. needAlphaTesting(): boolean;
  79589. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79590. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79591. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79592. getAnimatables(): BABYLON.IAnimatable[];
  79593. getActiveTextures(): BABYLON.BaseTexture[];
  79594. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79595. dispose(forceDisposeEffect?: boolean): void;
  79596. getClassName(): string;
  79597. clone(name: string): CellMaterial;
  79598. serialize(): any;
  79599. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  79600. }
  79601. }
  79602. declare module BABYLON {
  79603. export class CustomShaderStructure {
  79604. FragmentStore: string;
  79605. VertexStore: string;
  79606. constructor();
  79607. }
  79608. export class ShaderSpecialParts {
  79609. constructor();
  79610. Fragment_Begin: string;
  79611. Fragment_Definitions: string;
  79612. Fragment_MainBegin: string;
  79613. Fragment_Custom_Diffuse: string;
  79614. Fragment_Before_Lights: string;
  79615. Fragment_Before_Fog: string;
  79616. Fragment_Custom_Alpha: string;
  79617. Fragment_Before_FragColor: string;
  79618. Vertex_Begin: string;
  79619. Vertex_Definitions: string;
  79620. Vertex_MainBegin: string;
  79621. Vertex_Before_PositionUpdated: string;
  79622. Vertex_Before_NormalUpdated: string;
  79623. Vertex_MainEnd: string;
  79624. }
  79625. export class CustomMaterial extends BABYLON.StandardMaterial {
  79626. static ShaderIndexer: number;
  79627. CustomParts: ShaderSpecialParts;
  79628. _isCreatedShader: boolean;
  79629. _createdShaderName: string;
  79630. _customUniform: string[];
  79631. _newUniforms: string[];
  79632. _newUniformInstances: any[];
  79633. _newSamplerInstances: BABYLON.Texture[];
  79634. _customAttributes: string[];
  79635. FragmentShader: string;
  79636. VertexShader: string;
  79637. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79638. ReviewUniform(name: string, arr: string[]): string[];
  79639. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines, attributes?: string[]): string;
  79640. constructor(name: string, scene: BABYLON.Scene);
  79641. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  79642. AddAttribute(name: string): CustomMaterial;
  79643. Fragment_Begin(shaderPart: string): CustomMaterial;
  79644. Fragment_Definitions(shaderPart: string): CustomMaterial;
  79645. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  79646. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  79647. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  79648. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  79649. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  79650. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  79651. Vertex_Begin(shaderPart: string): CustomMaterial;
  79652. Vertex_Definitions(shaderPart: string): CustomMaterial;
  79653. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  79654. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  79655. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  79656. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  79657. }
  79658. }
  79659. declare module BABYLON {
  79660. export class ShaderAlebdoParts {
  79661. constructor();
  79662. Fragment_Begin: string;
  79663. Fragment_Definitions: string;
  79664. Fragment_MainBegin: string;
  79665. Fragment_Custom_Albedo: string;
  79666. Fragment_Before_Lights: string;
  79667. Fragment_Custom_MetallicRoughness: string;
  79668. Fragment_Custom_MicroSurface: string;
  79669. Fragment_Before_Fog: string;
  79670. Fragment_Custom_Alpha: string;
  79671. Fragment_Before_FragColor: string;
  79672. Vertex_Begin: string;
  79673. Vertex_Definitions: string;
  79674. Vertex_MainBegin: string;
  79675. Vertex_Before_PositionUpdated: string;
  79676. Vertex_Before_NormalUpdated: string;
  79677. Vertex_MainEnd: string;
  79678. }
  79679. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  79680. static ShaderIndexer: number;
  79681. CustomParts: ShaderAlebdoParts;
  79682. _isCreatedShader: boolean;
  79683. _createdShaderName: string;
  79684. _customUniform: string[];
  79685. _newUniforms: string[];
  79686. _newUniformInstances: any[];
  79687. _newSamplerInstances: BABYLON.Texture[];
  79688. _customAttributes: string[];
  79689. FragmentShader: string;
  79690. VertexShader: string;
  79691. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79692. ReviewUniform(name: string, arr: string[]): string[];
  79693. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines, attributes?: string[]): string;
  79694. constructor(name: string, scene: BABYLON.Scene);
  79695. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  79696. AddAttribute(name: string): PBRCustomMaterial;
  79697. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  79698. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  79699. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  79700. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  79701. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  79702. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  79703. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  79704. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  79705. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  79706. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  79707. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  79708. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  79709. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  79710. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  79711. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  79712. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  79713. }
  79714. }
  79715. declare module BABYLON {
  79716. /** @hidden */
  79717. export var firePixelShader: {
  79718. name: string;
  79719. shader: string;
  79720. };
  79721. }
  79722. declare module BABYLON {
  79723. /** @hidden */
  79724. export var fireVertexShader: {
  79725. name: string;
  79726. shader: string;
  79727. };
  79728. }
  79729. declare module BABYLON {
  79730. export class FireMaterial extends BABYLON.PushMaterial {
  79731. private _diffuseTexture;
  79732. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79733. private _distortionTexture;
  79734. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79735. private _opacityTexture;
  79736. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79737. diffuseColor: BABYLON.Color3;
  79738. speed: number;
  79739. private _scaledDiffuse;
  79740. private _renderId;
  79741. private _lastTime;
  79742. constructor(name: string, scene: BABYLON.Scene);
  79743. needAlphaBlending(): boolean;
  79744. needAlphaTesting(): boolean;
  79745. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79746. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79747. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79748. getAnimatables(): BABYLON.IAnimatable[];
  79749. getActiveTextures(): BABYLON.BaseTexture[];
  79750. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79751. getClassName(): string;
  79752. dispose(forceDisposeEffect?: boolean): void;
  79753. clone(name: string): FireMaterial;
  79754. serialize(): any;
  79755. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  79756. }
  79757. }
  79758. declare module BABYLON {
  79759. /** @hidden */
  79760. export var furPixelShader: {
  79761. name: string;
  79762. shader: string;
  79763. };
  79764. }
  79765. declare module BABYLON {
  79766. /** @hidden */
  79767. export var furVertexShader: {
  79768. name: string;
  79769. shader: string;
  79770. };
  79771. }
  79772. declare module BABYLON {
  79773. export class FurMaterial extends BABYLON.PushMaterial {
  79774. private _diffuseTexture;
  79775. diffuseTexture: BABYLON.BaseTexture;
  79776. private _heightTexture;
  79777. heightTexture: BABYLON.BaseTexture;
  79778. diffuseColor: BABYLON.Color3;
  79779. furLength: number;
  79780. furAngle: number;
  79781. furColor: BABYLON.Color3;
  79782. furOffset: number;
  79783. furSpacing: number;
  79784. furGravity: BABYLON.Vector3;
  79785. furSpeed: number;
  79786. furDensity: number;
  79787. furOcclusion: number;
  79788. furTexture: BABYLON.DynamicTexture;
  79789. private _disableLighting;
  79790. disableLighting: boolean;
  79791. private _maxSimultaneousLights;
  79792. maxSimultaneousLights: number;
  79793. highLevelFur: boolean;
  79794. _meshes: BABYLON.AbstractMesh[];
  79795. private _renderId;
  79796. private _furTime;
  79797. constructor(name: string, scene: BABYLON.Scene);
  79798. get furTime(): number;
  79799. set furTime(furTime: number);
  79800. needAlphaBlending(): boolean;
  79801. needAlphaTesting(): boolean;
  79802. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79803. updateFur(): void;
  79804. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79805. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79806. getAnimatables(): BABYLON.IAnimatable[];
  79807. getActiveTextures(): BABYLON.BaseTexture[];
  79808. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79809. dispose(forceDisposeEffect?: boolean): void;
  79810. clone(name: string): FurMaterial;
  79811. serialize(): any;
  79812. getClassName(): string;
  79813. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  79814. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  79815. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  79816. }
  79817. }
  79818. declare module BABYLON {
  79819. /** @hidden */
  79820. export var gradientPixelShader: {
  79821. name: string;
  79822. shader: string;
  79823. };
  79824. }
  79825. declare module BABYLON {
  79826. /** @hidden */
  79827. export var gradientVertexShader: {
  79828. name: string;
  79829. shader: string;
  79830. };
  79831. }
  79832. declare module BABYLON {
  79833. export class GradientMaterial extends BABYLON.PushMaterial {
  79834. private _maxSimultaneousLights;
  79835. maxSimultaneousLights: number;
  79836. topColor: BABYLON.Color3;
  79837. topColorAlpha: number;
  79838. bottomColor: BABYLON.Color3;
  79839. bottomColorAlpha: number;
  79840. offset: number;
  79841. scale: number;
  79842. smoothness: number;
  79843. private _disableLighting;
  79844. disableLighting: boolean;
  79845. private _renderId;
  79846. constructor(name: string, scene: BABYLON.Scene);
  79847. needAlphaBlending(): boolean;
  79848. needAlphaTesting(): boolean;
  79849. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79850. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79851. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79852. getAnimatables(): BABYLON.IAnimatable[];
  79853. dispose(forceDisposeEffect?: boolean): void;
  79854. clone(name: string): GradientMaterial;
  79855. serialize(): any;
  79856. getClassName(): string;
  79857. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  79858. }
  79859. }
  79860. declare module BABYLON {
  79861. /** @hidden */
  79862. export var gridPixelShader: {
  79863. name: string;
  79864. shader: string;
  79865. };
  79866. }
  79867. declare module BABYLON {
  79868. /** @hidden */
  79869. export var gridVertexShader: {
  79870. name: string;
  79871. shader: string;
  79872. };
  79873. }
  79874. declare module BABYLON {
  79875. /**
  79876. * The grid materials allows you to wrap any shape with a grid.
  79877. * Colors are customizable.
  79878. */
  79879. export class GridMaterial extends BABYLON.PushMaterial {
  79880. /**
  79881. * Main color of the grid (e.g. between lines)
  79882. */
  79883. mainColor: BABYLON.Color3;
  79884. /**
  79885. * Color of the grid lines.
  79886. */
  79887. lineColor: BABYLON.Color3;
  79888. /**
  79889. * The scale of the grid compared to unit.
  79890. */
  79891. gridRatio: number;
  79892. /**
  79893. * Allows setting an offset for the grid lines.
  79894. */
  79895. gridOffset: BABYLON.Vector3;
  79896. /**
  79897. * The frequency of thicker lines.
  79898. */
  79899. majorUnitFrequency: number;
  79900. /**
  79901. * The visibility of minor units in the grid.
  79902. */
  79903. minorUnitVisibility: number;
  79904. /**
  79905. * The grid opacity outside of the lines.
  79906. */
  79907. opacity: number;
  79908. /**
  79909. * Determine RBG output is premultiplied by alpha value.
  79910. */
  79911. preMultiplyAlpha: boolean;
  79912. private _opacityTexture;
  79913. opacityTexture: BABYLON.BaseTexture;
  79914. private _gridControl;
  79915. private _renderId;
  79916. /**
  79917. * constructor
  79918. * @param name The name given to the material in order to identify it afterwards.
  79919. * @param scene The scene the material is used in.
  79920. */
  79921. constructor(name: string, scene: BABYLON.Scene);
  79922. /**
  79923. * Returns wehter or not the grid requires alpha blending.
  79924. */
  79925. needAlphaBlending(): boolean;
  79926. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79927. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79928. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79929. /**
  79930. * Dispose the material and its associated resources.
  79931. * @param forceDisposeEffect will also dispose the used effect when true
  79932. */
  79933. dispose(forceDisposeEffect?: boolean): void;
  79934. clone(name: string): GridMaterial;
  79935. serialize(): any;
  79936. getClassName(): string;
  79937. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  79938. }
  79939. }
  79940. declare module BABYLON {
  79941. /** @hidden */
  79942. export var lavaPixelShader: {
  79943. name: string;
  79944. shader: string;
  79945. };
  79946. }
  79947. declare module BABYLON {
  79948. /** @hidden */
  79949. export var lavaVertexShader: {
  79950. name: string;
  79951. shader: string;
  79952. };
  79953. }
  79954. declare module BABYLON {
  79955. export class LavaMaterial extends BABYLON.PushMaterial {
  79956. private _diffuseTexture;
  79957. diffuseTexture: BABYLON.BaseTexture;
  79958. noiseTexture: BABYLON.BaseTexture;
  79959. fogColor: BABYLON.Color3;
  79960. speed: number;
  79961. movingSpeed: number;
  79962. lowFrequencySpeed: number;
  79963. fogDensity: number;
  79964. private _lastTime;
  79965. diffuseColor: BABYLON.Color3;
  79966. private _disableLighting;
  79967. disableLighting: boolean;
  79968. private _unlit;
  79969. unlit: boolean;
  79970. private _maxSimultaneousLights;
  79971. maxSimultaneousLights: number;
  79972. private _scaledDiffuse;
  79973. private _renderId;
  79974. constructor(name: string, scene: BABYLON.Scene);
  79975. needAlphaBlending(): boolean;
  79976. needAlphaTesting(): boolean;
  79977. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79978. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79979. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79980. getAnimatables(): BABYLON.IAnimatable[];
  79981. getActiveTextures(): BABYLON.BaseTexture[];
  79982. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79983. dispose(forceDisposeEffect?: boolean): void;
  79984. clone(name: string): LavaMaterial;
  79985. serialize(): any;
  79986. getClassName(): string;
  79987. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  79988. }
  79989. }
  79990. declare module BABYLON {
  79991. /** @hidden */
  79992. export var mixPixelShader: {
  79993. name: string;
  79994. shader: string;
  79995. };
  79996. }
  79997. declare module BABYLON {
  79998. /** @hidden */
  79999. export var mixVertexShader: {
  80000. name: string;
  80001. shader: string;
  80002. };
  80003. }
  80004. declare module BABYLON {
  80005. export class MixMaterial extends BABYLON.PushMaterial {
  80006. /**
  80007. * Mix textures
  80008. */
  80009. private _mixTexture1;
  80010. mixTexture1: BABYLON.BaseTexture;
  80011. private _mixTexture2;
  80012. mixTexture2: BABYLON.BaseTexture;
  80013. /**
  80014. * Diffuse textures
  80015. */
  80016. private _diffuseTexture1;
  80017. diffuseTexture1: BABYLON.Texture;
  80018. private _diffuseTexture2;
  80019. diffuseTexture2: BABYLON.Texture;
  80020. private _diffuseTexture3;
  80021. diffuseTexture3: BABYLON.Texture;
  80022. private _diffuseTexture4;
  80023. diffuseTexture4: BABYLON.Texture;
  80024. private _diffuseTexture5;
  80025. diffuseTexture5: BABYLON.Texture;
  80026. private _diffuseTexture6;
  80027. diffuseTexture6: BABYLON.Texture;
  80028. private _diffuseTexture7;
  80029. diffuseTexture7: BABYLON.Texture;
  80030. private _diffuseTexture8;
  80031. diffuseTexture8: BABYLON.Texture;
  80032. /**
  80033. * Uniforms
  80034. */
  80035. diffuseColor: BABYLON.Color3;
  80036. specularColor: BABYLON.Color3;
  80037. specularPower: number;
  80038. private _disableLighting;
  80039. disableLighting: boolean;
  80040. private _maxSimultaneousLights;
  80041. maxSimultaneousLights: number;
  80042. private _renderId;
  80043. constructor(name: string, scene: BABYLON.Scene);
  80044. needAlphaBlending(): boolean;
  80045. needAlphaTesting(): boolean;
  80046. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80047. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80048. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80049. getAnimatables(): BABYLON.IAnimatable[];
  80050. getActiveTextures(): BABYLON.BaseTexture[];
  80051. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80052. dispose(forceDisposeEffect?: boolean): void;
  80053. clone(name: string): MixMaterial;
  80054. serialize(): any;
  80055. getClassName(): string;
  80056. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  80057. }
  80058. }
  80059. declare module BABYLON {
  80060. /** @hidden */
  80061. export var normalPixelShader: {
  80062. name: string;
  80063. shader: string;
  80064. };
  80065. }
  80066. declare module BABYLON {
  80067. /** @hidden */
  80068. export var normalVertexShader: {
  80069. name: string;
  80070. shader: string;
  80071. };
  80072. }
  80073. declare module BABYLON {
  80074. export class NormalMaterial extends BABYLON.PushMaterial {
  80075. private _diffuseTexture;
  80076. diffuseTexture: BABYLON.BaseTexture;
  80077. diffuseColor: BABYLON.Color3;
  80078. private _disableLighting;
  80079. disableLighting: boolean;
  80080. private _maxSimultaneousLights;
  80081. maxSimultaneousLights: number;
  80082. private _renderId;
  80083. constructor(name: string, scene: BABYLON.Scene);
  80084. needAlphaBlending(): boolean;
  80085. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  80086. needAlphaTesting(): boolean;
  80087. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80088. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80089. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80090. getAnimatables(): BABYLON.IAnimatable[];
  80091. getActiveTextures(): BABYLON.BaseTexture[];
  80092. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80093. dispose(forceDisposeEffect?: boolean): void;
  80094. clone(name: string): NormalMaterial;
  80095. serialize(): any;
  80096. getClassName(): string;
  80097. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  80098. }
  80099. }
  80100. declare module BABYLON {
  80101. /** @hidden */
  80102. export var shadowOnlyPixelShader: {
  80103. name: string;
  80104. shader: string;
  80105. };
  80106. }
  80107. declare module BABYLON {
  80108. /** @hidden */
  80109. export var shadowOnlyVertexShader: {
  80110. name: string;
  80111. shader: string;
  80112. };
  80113. }
  80114. declare module BABYLON {
  80115. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  80116. private _renderId;
  80117. private _activeLight;
  80118. constructor(name: string, scene: BABYLON.Scene);
  80119. shadowColor: BABYLON.Color3;
  80120. needAlphaBlending(): boolean;
  80121. needAlphaTesting(): boolean;
  80122. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80123. get activeLight(): BABYLON.IShadowLight;
  80124. set activeLight(light: BABYLON.IShadowLight);
  80125. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80126. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80127. clone(name: string): ShadowOnlyMaterial;
  80128. serialize(): any;
  80129. getClassName(): string;
  80130. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  80131. }
  80132. }
  80133. declare module BABYLON {
  80134. /** @hidden */
  80135. export var simplePixelShader: {
  80136. name: string;
  80137. shader: string;
  80138. };
  80139. }
  80140. declare module BABYLON {
  80141. /** @hidden */
  80142. export var simpleVertexShader: {
  80143. name: string;
  80144. shader: string;
  80145. };
  80146. }
  80147. declare module BABYLON {
  80148. export class SimpleMaterial extends BABYLON.PushMaterial {
  80149. private _diffuseTexture;
  80150. diffuseTexture: BABYLON.BaseTexture;
  80151. diffuseColor: BABYLON.Color3;
  80152. private _disableLighting;
  80153. disableLighting: boolean;
  80154. private _maxSimultaneousLights;
  80155. maxSimultaneousLights: number;
  80156. private _renderId;
  80157. constructor(name: string, scene: BABYLON.Scene);
  80158. needAlphaBlending(): boolean;
  80159. needAlphaTesting(): boolean;
  80160. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80161. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80162. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80163. getAnimatables(): BABYLON.IAnimatable[];
  80164. getActiveTextures(): BABYLON.BaseTexture[];
  80165. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80166. dispose(forceDisposeEffect?: boolean): void;
  80167. clone(name: string): SimpleMaterial;
  80168. serialize(): any;
  80169. getClassName(): string;
  80170. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  80171. }
  80172. }
  80173. declare module BABYLON {
  80174. /** @hidden */
  80175. export var skyPixelShader: {
  80176. name: string;
  80177. shader: string;
  80178. };
  80179. }
  80180. declare module BABYLON {
  80181. /** @hidden */
  80182. export var skyVertexShader: {
  80183. name: string;
  80184. shader: string;
  80185. };
  80186. }
  80187. declare module BABYLON {
  80188. /**
  80189. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  80190. * @see https://doc.babylonjs.com/extensions/sky
  80191. */
  80192. export class SkyMaterial extends BABYLON.PushMaterial {
  80193. /**
  80194. * Defines the overall luminance of sky in interval ]0, 1[.
  80195. */
  80196. luminance: number;
  80197. /**
  80198. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  80199. */
  80200. turbidity: number;
  80201. /**
  80202. * Defines the sky appearance (light intensity).
  80203. */
  80204. rayleigh: number;
  80205. /**
  80206. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  80207. */
  80208. mieCoefficient: number;
  80209. /**
  80210. * Defines the amount of haze particles following the Mie scattering theory.
  80211. */
  80212. mieDirectionalG: number;
  80213. /**
  80214. * Defines the distance of the sun according to the active scene camera.
  80215. */
  80216. distance: number;
  80217. /**
  80218. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  80219. * "inclined".
  80220. */
  80221. inclination: number;
  80222. /**
  80223. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  80224. * an object direction and a reference direction.
  80225. */
  80226. azimuth: number;
  80227. /**
  80228. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  80229. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  80230. */
  80231. sunPosition: BABYLON.Vector3;
  80232. /**
  80233. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  80234. * .sunPosition property.
  80235. */
  80236. useSunPosition: boolean;
  80237. /**
  80238. * Defines an offset vector used to get a horizon offset.
  80239. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  80240. */
  80241. cameraOffset: BABYLON.Vector3;
  80242. private _cameraPosition;
  80243. private _renderId;
  80244. /**
  80245. * Instantiates a new sky material.
  80246. * This material allows to create dynamic and texture free
  80247. * effects for skyboxes by taking care of the atmosphere state.
  80248. * @see https://doc.babylonjs.com/extensions/sky
  80249. * @param name Define the name of the material in the scene
  80250. * @param scene Define the scene the material belong to
  80251. */
  80252. constructor(name: string, scene: BABYLON.Scene);
  80253. /**
  80254. * Specifies if the material will require alpha blending
  80255. * @returns a boolean specifying if alpha blending is needed
  80256. */
  80257. needAlphaBlending(): boolean;
  80258. /**
  80259. * Specifies if this material should be rendered in alpha test mode
  80260. * @returns false as the sky material doesn't need alpha testing.
  80261. */
  80262. needAlphaTesting(): boolean;
  80263. /**
  80264. * Get the texture used for alpha test purpose.
  80265. * @returns null as the sky material has no texture.
  80266. */
  80267. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80268. /**
  80269. * Get if the submesh is ready to be used and all its information available.
  80270. * Child classes can use it to update shaders
  80271. * @param mesh defines the mesh to check
  80272. * @param subMesh defines which submesh to check
  80273. * @param useInstances specifies that instances should be used
  80274. * @returns a boolean indicating that the submesh is ready or not
  80275. */
  80276. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80277. /**
  80278. * Binds the submesh to this material by preparing the effect and shader to draw
  80279. * @param world defines the world transformation matrix
  80280. * @param mesh defines the mesh containing the submesh
  80281. * @param subMesh defines the submesh to bind the material to
  80282. */
  80283. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80284. /**
  80285. * Get the list of animatables in the material.
  80286. * @returns the list of animatables object used in the material
  80287. */
  80288. getAnimatables(): BABYLON.IAnimatable[];
  80289. /**
  80290. * Disposes the material
  80291. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  80292. */
  80293. dispose(forceDisposeEffect?: boolean): void;
  80294. /**
  80295. * Makes a duplicate of the material, and gives it a new name
  80296. * @param name defines the new name for the duplicated material
  80297. * @returns the cloned material
  80298. */
  80299. clone(name: string): SkyMaterial;
  80300. /**
  80301. * Serializes this material in a JSON representation
  80302. * @returns the serialized material object
  80303. */
  80304. serialize(): any;
  80305. /**
  80306. * Gets the current class name of the material e.g. "SkyMaterial"
  80307. * Mainly use in serialization.
  80308. * @returns the class name
  80309. */
  80310. getClassName(): string;
  80311. /**
  80312. * Creates a sky material from parsed material data
  80313. * @param source defines the JSON representation of the material
  80314. * @param scene defines the hosting scene
  80315. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  80316. * @returns a new sky material
  80317. */
  80318. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  80319. }
  80320. }
  80321. declare module BABYLON {
  80322. /** @hidden */
  80323. export var terrainPixelShader: {
  80324. name: string;
  80325. shader: string;
  80326. };
  80327. }
  80328. declare module BABYLON {
  80329. /** @hidden */
  80330. export var terrainVertexShader: {
  80331. name: string;
  80332. shader: string;
  80333. };
  80334. }
  80335. declare module BABYLON {
  80336. export class TerrainMaterial extends BABYLON.PushMaterial {
  80337. private _mixTexture;
  80338. mixTexture: BABYLON.BaseTexture;
  80339. private _diffuseTexture1;
  80340. diffuseTexture1: BABYLON.Texture;
  80341. private _diffuseTexture2;
  80342. diffuseTexture2: BABYLON.Texture;
  80343. private _diffuseTexture3;
  80344. diffuseTexture3: BABYLON.Texture;
  80345. private _bumpTexture1;
  80346. bumpTexture1: BABYLON.Texture;
  80347. private _bumpTexture2;
  80348. bumpTexture2: BABYLON.Texture;
  80349. private _bumpTexture3;
  80350. bumpTexture3: BABYLON.Texture;
  80351. diffuseColor: BABYLON.Color3;
  80352. specularColor: BABYLON.Color3;
  80353. specularPower: number;
  80354. private _disableLighting;
  80355. disableLighting: boolean;
  80356. private _maxSimultaneousLights;
  80357. maxSimultaneousLights: number;
  80358. private _renderId;
  80359. constructor(name: string, scene: BABYLON.Scene);
  80360. needAlphaBlending(): boolean;
  80361. needAlphaTesting(): boolean;
  80362. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80363. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80364. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80365. getAnimatables(): BABYLON.IAnimatable[];
  80366. getActiveTextures(): BABYLON.BaseTexture[];
  80367. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80368. dispose(forceDisposeEffect?: boolean): void;
  80369. clone(name: string): TerrainMaterial;
  80370. serialize(): any;
  80371. getClassName(): string;
  80372. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  80373. }
  80374. }
  80375. declare module BABYLON {
  80376. /** @hidden */
  80377. export var triplanarPixelShader: {
  80378. name: string;
  80379. shader: string;
  80380. };
  80381. }
  80382. declare module BABYLON {
  80383. /** @hidden */
  80384. export var triplanarVertexShader: {
  80385. name: string;
  80386. shader: string;
  80387. };
  80388. }
  80389. declare module BABYLON {
  80390. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  80391. mixTexture: BABYLON.BaseTexture;
  80392. private _diffuseTextureX;
  80393. diffuseTextureX: BABYLON.BaseTexture;
  80394. private _diffuseTextureY;
  80395. diffuseTextureY: BABYLON.BaseTexture;
  80396. private _diffuseTextureZ;
  80397. diffuseTextureZ: BABYLON.BaseTexture;
  80398. private _normalTextureX;
  80399. normalTextureX: BABYLON.BaseTexture;
  80400. private _normalTextureY;
  80401. normalTextureY: BABYLON.BaseTexture;
  80402. private _normalTextureZ;
  80403. normalTextureZ: BABYLON.BaseTexture;
  80404. tileSize: number;
  80405. diffuseColor: BABYLON.Color3;
  80406. specularColor: BABYLON.Color3;
  80407. specularPower: number;
  80408. private _disableLighting;
  80409. disableLighting: boolean;
  80410. private _maxSimultaneousLights;
  80411. maxSimultaneousLights: number;
  80412. private _renderId;
  80413. constructor(name: string, scene: BABYLON.Scene);
  80414. needAlphaBlending(): boolean;
  80415. needAlphaTesting(): boolean;
  80416. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80417. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80418. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80419. getAnimatables(): BABYLON.IAnimatable[];
  80420. getActiveTextures(): BABYLON.BaseTexture[];
  80421. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80422. dispose(forceDisposeEffect?: boolean): void;
  80423. clone(name: string): TriPlanarMaterial;
  80424. serialize(): any;
  80425. getClassName(): string;
  80426. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  80427. }
  80428. }
  80429. declare module BABYLON {
  80430. /** @hidden */
  80431. export var waterPixelShader: {
  80432. name: string;
  80433. shader: string;
  80434. };
  80435. }
  80436. declare module BABYLON {
  80437. /** @hidden */
  80438. export var waterVertexShader: {
  80439. name: string;
  80440. shader: string;
  80441. };
  80442. }
  80443. declare module BABYLON {
  80444. export class WaterMaterial extends BABYLON.PushMaterial {
  80445. renderTargetSize: BABYLON.Vector2;
  80446. private _bumpTexture;
  80447. bumpTexture: BABYLON.BaseTexture;
  80448. diffuseColor: BABYLON.Color3;
  80449. specularColor: BABYLON.Color3;
  80450. specularPower: number;
  80451. private _disableLighting;
  80452. disableLighting: boolean;
  80453. private _maxSimultaneousLights;
  80454. maxSimultaneousLights: number;
  80455. /**
  80456. * @param {number}: Represents the wind force
  80457. */
  80458. windForce: number;
  80459. /**
  80460. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  80461. */
  80462. windDirection: BABYLON.Vector2;
  80463. /**
  80464. * @param {number}: Wave height, represents the height of the waves
  80465. */
  80466. waveHeight: number;
  80467. /**
  80468. * @param {number}: Bump height, represents the bump height related to the bump map
  80469. */
  80470. bumpHeight: number;
  80471. /**
  80472. * @param {boolean}: Add a smaller moving bump to less steady waves.
  80473. */
  80474. private _bumpSuperimpose;
  80475. bumpSuperimpose: boolean;
  80476. /**
  80477. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  80478. */
  80479. private _fresnelSeparate;
  80480. fresnelSeparate: boolean;
  80481. /**
  80482. * @param {boolean}: bump Waves modify the reflection.
  80483. */
  80484. private _bumpAffectsReflection;
  80485. bumpAffectsReflection: boolean;
  80486. /**
  80487. * @param {number}: The water color blended with the refraction (near)
  80488. */
  80489. waterColor: BABYLON.Color3;
  80490. /**
  80491. * @param {number}: The blend factor related to the water color
  80492. */
  80493. colorBlendFactor: number;
  80494. /**
  80495. * @param {number}: The water color blended with the reflection (far)
  80496. */
  80497. waterColor2: BABYLON.Color3;
  80498. /**
  80499. * @param {number}: The blend factor related to the water color (reflection, far)
  80500. */
  80501. colorBlendFactor2: number;
  80502. /**
  80503. * @param {number}: Represents the maximum length of a wave
  80504. */
  80505. waveLength: number;
  80506. /**
  80507. * @param {number}: Defines the waves speed
  80508. */
  80509. waveSpeed: number;
  80510. /**
  80511. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  80512. * will avoid calculating useless pixels in the pixel shader of the water material.
  80513. */
  80514. disableClipPlane: boolean;
  80515. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  80516. private _mesh;
  80517. private _refractionRTT;
  80518. private _reflectionRTT;
  80519. private _reflectionTransform;
  80520. private _lastTime;
  80521. private _lastDeltaTime;
  80522. private _renderId;
  80523. private _useLogarithmicDepth;
  80524. private _waitingRenderList;
  80525. private _imageProcessingConfiguration;
  80526. private _imageProcessingObserver;
  80527. /**
  80528. * Gets a boolean indicating that current material needs to register RTT
  80529. */
  80530. get hasRenderTargetTextures(): boolean;
  80531. /**
  80532. * Constructor
  80533. */
  80534. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  80535. get useLogarithmicDepth(): boolean;
  80536. set useLogarithmicDepth(value: boolean);
  80537. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80538. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80539. addToRenderList(node: any): void;
  80540. enableRenderTargets(enable: boolean): void;
  80541. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  80542. get renderTargetsEnabled(): boolean;
  80543. needAlphaBlending(): boolean;
  80544. needAlphaTesting(): boolean;
  80545. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80546. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80547. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80548. private _createRenderTargets;
  80549. getAnimatables(): BABYLON.IAnimatable[];
  80550. getActiveTextures(): BABYLON.BaseTexture[];
  80551. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80552. dispose(forceDisposeEffect?: boolean): void;
  80553. clone(name: string): WaterMaterial;
  80554. serialize(): any;
  80555. getClassName(): string;
  80556. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  80557. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  80558. }
  80559. }
  80560. declare module BABYLON {
  80561. /** @hidden */
  80562. export var asciiartPixelShader: {
  80563. name: string;
  80564. shader: string;
  80565. };
  80566. }
  80567. declare module BABYLON {
  80568. /**
  80569. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  80570. *
  80571. * It basically takes care rendering the font front the given font size to a texture.
  80572. * This is used later on in the postprocess.
  80573. */
  80574. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  80575. private _font;
  80576. private _text;
  80577. private _charSize;
  80578. /**
  80579. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80580. */
  80581. get charSize(): number;
  80582. /**
  80583. * Create a new instance of the Ascii Art FontTexture class
  80584. * @param name the name of the texture
  80585. * @param font the font to use, use the W3C CSS notation
  80586. * @param text the caracter set to use in the rendering.
  80587. * @param scene the scene that owns the texture
  80588. */
  80589. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80590. /**
  80591. * Gets the max char width of a font.
  80592. * @param font the font to use, use the W3C CSS notation
  80593. * @return the max char width
  80594. */
  80595. private getFontWidth;
  80596. /**
  80597. * Gets the max char height of a font.
  80598. * @param font the font to use, use the W3C CSS notation
  80599. * @return the max char height
  80600. */
  80601. private getFontHeight;
  80602. /**
  80603. * Clones the current AsciiArtTexture.
  80604. * @return the clone of the texture.
  80605. */
  80606. clone(): AsciiArtFontTexture;
  80607. /**
  80608. * Parses a json object representing the texture and returns an instance of it.
  80609. * @param source the source JSON representation
  80610. * @param scene the scene to create the texture for
  80611. * @return the parsed texture
  80612. */
  80613. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  80614. }
  80615. /**
  80616. * Option available in the Ascii Art Post Process.
  80617. */
  80618. export interface IAsciiArtPostProcessOptions {
  80619. /**
  80620. * The font to use following the w3c font definition.
  80621. */
  80622. font?: string;
  80623. /**
  80624. * The character set to use in the postprocess.
  80625. */
  80626. characterSet?: string;
  80627. /**
  80628. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80629. * This number is defined between 0 and 1;
  80630. */
  80631. mixToTile?: number;
  80632. /**
  80633. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80634. * This number is defined between 0 and 1;
  80635. */
  80636. mixToNormal?: number;
  80637. }
  80638. /**
  80639. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  80640. *
  80641. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80642. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  80643. */
  80644. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  80645. /**
  80646. * The font texture used to render the char in the post process.
  80647. */
  80648. private _asciiArtFontTexture;
  80649. /**
  80650. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80651. * This number is defined between 0 and 1;
  80652. */
  80653. mixToTile: number;
  80654. /**
  80655. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80656. * This number is defined between 0 and 1;
  80657. */
  80658. mixToNormal: number;
  80659. /**
  80660. * Instantiates a new Ascii Art Post Process.
  80661. * @param name the name to give to the postprocess
  80662. * @camera the camera to apply the post process to.
  80663. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  80664. */
  80665. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  80666. }
  80667. }
  80668. declare module BABYLON {
  80669. /** @hidden */
  80670. export var digitalrainPixelShader: {
  80671. name: string;
  80672. shader: string;
  80673. };
  80674. }
  80675. declare module BABYLON {
  80676. /**
  80677. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  80678. *
  80679. * It basically takes care rendering the font front the given font size to a texture.
  80680. * This is used later on in the postprocess.
  80681. */
  80682. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  80683. private _font;
  80684. private _text;
  80685. private _charSize;
  80686. /**
  80687. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80688. */
  80689. get charSize(): number;
  80690. /**
  80691. * Create a new instance of the Digital Rain FontTexture class
  80692. * @param name the name of the texture
  80693. * @param font the font to use, use the W3C CSS notation
  80694. * @param text the caracter set to use in the rendering.
  80695. * @param scene the scene that owns the texture
  80696. */
  80697. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80698. /**
  80699. * Gets the max char width of a font.
  80700. * @param font the font to use, use the W3C CSS notation
  80701. * @return the max char width
  80702. */
  80703. private getFontWidth;
  80704. /**
  80705. * Gets the max char height of a font.
  80706. * @param font the font to use, use the W3C CSS notation
  80707. * @return the max char height
  80708. */
  80709. private getFontHeight;
  80710. /**
  80711. * Clones the current DigitalRainFontTexture.
  80712. * @return the clone of the texture.
  80713. */
  80714. clone(): DigitalRainFontTexture;
  80715. /**
  80716. * Parses a json object representing the texture and returns an instance of it.
  80717. * @param source the source JSON representation
  80718. * @param scene the scene to create the texture for
  80719. * @return the parsed texture
  80720. */
  80721. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  80722. }
  80723. /**
  80724. * Option available in the Digital Rain Post Process.
  80725. */
  80726. export interface IDigitalRainPostProcessOptions {
  80727. /**
  80728. * The font to use following the w3c font definition.
  80729. */
  80730. font?: string;
  80731. /**
  80732. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80733. * This number is defined between 0 and 1;
  80734. */
  80735. mixToTile?: number;
  80736. /**
  80737. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80738. * This number is defined between 0 and 1;
  80739. */
  80740. mixToNormal?: number;
  80741. }
  80742. /**
  80743. * DigitalRainPostProcess helps rendering everithing in digital rain.
  80744. *
  80745. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80746. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  80747. */
  80748. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  80749. /**
  80750. * The font texture used to render the char in the post process.
  80751. */
  80752. private _digitalRainFontTexture;
  80753. /**
  80754. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80755. * This number is defined between 0 and 1;
  80756. */
  80757. mixToTile: number;
  80758. /**
  80759. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80760. * This number is defined between 0 and 1;
  80761. */
  80762. mixToNormal: number;
  80763. /**
  80764. * Instantiates a new Digital Rain Post Process.
  80765. * @param name the name to give to the postprocess
  80766. * @camera the camera to apply the post process to.
  80767. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  80768. */
  80769. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  80770. }
  80771. }
  80772. declare module BABYLON {
  80773. /** @hidden */
  80774. export var brickProceduralTexturePixelShader: {
  80775. name: string;
  80776. shader: string;
  80777. };
  80778. }
  80779. declare module BABYLON {
  80780. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  80781. private _numberOfBricksHeight;
  80782. private _numberOfBricksWidth;
  80783. private _jointColor;
  80784. private _brickColor;
  80785. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80786. updateShaderUniforms(): void;
  80787. get numberOfBricksHeight(): number;
  80788. set numberOfBricksHeight(value: number);
  80789. get numberOfBricksWidth(): number;
  80790. set numberOfBricksWidth(value: number);
  80791. get jointColor(): BABYLON.Color3;
  80792. set jointColor(value: BABYLON.Color3);
  80793. get brickColor(): BABYLON.Color3;
  80794. set brickColor(value: BABYLON.Color3);
  80795. /**
  80796. * Serializes this brick procedural texture
  80797. * @returns a serialized brick procedural texture object
  80798. */
  80799. serialize(): any;
  80800. /**
  80801. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  80802. * @param parsedTexture defines parsed texture data
  80803. * @param scene defines the current scene
  80804. * @param rootUrl defines the root URL containing brick procedural texture information
  80805. * @returns a parsed Brick Procedural BABYLON.Texture
  80806. */
  80807. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  80808. }
  80809. }
  80810. declare module BABYLON {
  80811. /** @hidden */
  80812. export var cloudProceduralTexturePixelShader: {
  80813. name: string;
  80814. shader: string;
  80815. };
  80816. }
  80817. declare module BABYLON {
  80818. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  80819. private _skyColor;
  80820. private _cloudColor;
  80821. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80822. updateShaderUniforms(): void;
  80823. get skyColor(): BABYLON.Color4;
  80824. set skyColor(value: BABYLON.Color4);
  80825. get cloudColor(): BABYLON.Color4;
  80826. set cloudColor(value: BABYLON.Color4);
  80827. /**
  80828. * Serializes this cloud procedural texture
  80829. * @returns a serialized cloud procedural texture object
  80830. */
  80831. serialize(): any;
  80832. /**
  80833. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  80834. * @param parsedTexture defines parsed texture data
  80835. * @param scene defines the current scene
  80836. * @param rootUrl defines the root URL containing cloud procedural texture information
  80837. * @returns a parsed Cloud Procedural BABYLON.Texture
  80838. */
  80839. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  80840. }
  80841. }
  80842. declare module BABYLON {
  80843. /** @hidden */
  80844. export var fireProceduralTexturePixelShader: {
  80845. name: string;
  80846. shader: string;
  80847. };
  80848. }
  80849. declare module BABYLON {
  80850. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  80851. private _time;
  80852. private _speed;
  80853. private _autoGenerateTime;
  80854. private _fireColors;
  80855. private _alphaThreshold;
  80856. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80857. updateShaderUniforms(): void;
  80858. render(useCameraPostProcess?: boolean): void;
  80859. static get PurpleFireColors(): BABYLON.Color3[];
  80860. static get GreenFireColors(): BABYLON.Color3[];
  80861. static get RedFireColors(): BABYLON.Color3[];
  80862. static get BlueFireColors(): BABYLON.Color3[];
  80863. get autoGenerateTime(): boolean;
  80864. set autoGenerateTime(value: boolean);
  80865. get fireColors(): BABYLON.Color3[];
  80866. set fireColors(value: BABYLON.Color3[]);
  80867. get time(): number;
  80868. set time(value: number);
  80869. get speed(): BABYLON.Vector2;
  80870. set speed(value: BABYLON.Vector2);
  80871. get alphaThreshold(): number;
  80872. set alphaThreshold(value: number);
  80873. /**
  80874. * Serializes this fire procedural texture
  80875. * @returns a serialized fire procedural texture object
  80876. */
  80877. serialize(): any;
  80878. /**
  80879. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  80880. * @param parsedTexture defines parsed texture data
  80881. * @param scene defines the current scene
  80882. * @param rootUrl defines the root URL containing fire procedural texture information
  80883. * @returns a parsed Fire Procedural BABYLON.Texture
  80884. */
  80885. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  80886. }
  80887. }
  80888. declare module BABYLON {
  80889. /** @hidden */
  80890. export var grassProceduralTexturePixelShader: {
  80891. name: string;
  80892. shader: string;
  80893. };
  80894. }
  80895. declare module BABYLON {
  80896. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  80897. private _grassColors;
  80898. private _groundColor;
  80899. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80900. updateShaderUniforms(): void;
  80901. get grassColors(): BABYLON.Color3[];
  80902. set grassColors(value: BABYLON.Color3[]);
  80903. get groundColor(): BABYLON.Color3;
  80904. set groundColor(value: BABYLON.Color3);
  80905. /**
  80906. * Serializes this grass procedural texture
  80907. * @returns a serialized grass procedural texture object
  80908. */
  80909. serialize(): any;
  80910. /**
  80911. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  80912. * @param parsedTexture defines parsed texture data
  80913. * @param scene defines the current scene
  80914. * @param rootUrl defines the root URL containing grass procedural texture information
  80915. * @returns a parsed Grass Procedural BABYLON.Texture
  80916. */
  80917. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  80918. }
  80919. }
  80920. declare module BABYLON {
  80921. /** @hidden */
  80922. export var marbleProceduralTexturePixelShader: {
  80923. name: string;
  80924. shader: string;
  80925. };
  80926. }
  80927. declare module BABYLON {
  80928. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  80929. private _numberOfTilesHeight;
  80930. private _numberOfTilesWidth;
  80931. private _amplitude;
  80932. private _jointColor;
  80933. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80934. updateShaderUniforms(): void;
  80935. get numberOfTilesHeight(): number;
  80936. set numberOfTilesHeight(value: number);
  80937. get amplitude(): number;
  80938. set amplitude(value: number);
  80939. get numberOfTilesWidth(): number;
  80940. set numberOfTilesWidth(value: number);
  80941. get jointColor(): BABYLON.Color3;
  80942. set jointColor(value: BABYLON.Color3);
  80943. /**
  80944. * Serializes this marble procedural texture
  80945. * @returns a serialized marble procedural texture object
  80946. */
  80947. serialize(): any;
  80948. /**
  80949. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  80950. * @param parsedTexture defines parsed texture data
  80951. * @param scene defines the current scene
  80952. * @param rootUrl defines the root URL containing marble procedural texture information
  80953. * @returns a parsed Marble Procedural BABYLON.Texture
  80954. */
  80955. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  80956. }
  80957. }
  80958. declare module BABYLON {
  80959. /** @hidden */
  80960. export var normalMapProceduralTexturePixelShader: {
  80961. name: string;
  80962. shader: string;
  80963. };
  80964. }
  80965. declare module BABYLON {
  80966. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  80967. private _baseTexture;
  80968. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80969. updateShaderUniforms(): void;
  80970. render(useCameraPostProcess?: boolean): void;
  80971. resize(size: any, generateMipMaps: any): void;
  80972. get baseTexture(): BABYLON.Texture;
  80973. set baseTexture(texture: BABYLON.Texture);
  80974. /**
  80975. * Serializes this normal map procedural texture
  80976. * @returns a serialized normal map procedural texture object
  80977. */
  80978. serialize(): any;
  80979. /**
  80980. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  80981. * @param parsedTexture defines parsed texture data
  80982. * @param scene defines the current scene
  80983. * @param rootUrl defines the root URL containing normal map procedural texture information
  80984. * @returns a parsed Normal Map Procedural BABYLON.Texture
  80985. */
  80986. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  80987. }
  80988. }
  80989. declare module BABYLON {
  80990. /** @hidden */
  80991. export var perlinNoiseProceduralTexturePixelShader: {
  80992. name: string;
  80993. shader: string;
  80994. };
  80995. }
  80996. declare module BABYLON {
  80997. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  80998. time: number;
  80999. timeScale: number;
  81000. translationSpeed: number;
  81001. private _currentTranslation;
  81002. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81003. updateShaderUniforms(): void;
  81004. render(useCameraPostProcess?: boolean): void;
  81005. resize(size: any, generateMipMaps: any): void;
  81006. /**
  81007. * Serializes this perlin noise procedural texture
  81008. * @returns a serialized perlin noise procedural texture object
  81009. */
  81010. serialize(): any;
  81011. /**
  81012. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  81013. * @param parsedTexture defines parsed texture data
  81014. * @param scene defines the current scene
  81015. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  81016. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  81017. */
  81018. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  81019. }
  81020. }
  81021. declare module BABYLON {
  81022. /** @hidden */
  81023. export var roadProceduralTexturePixelShader: {
  81024. name: string;
  81025. shader: string;
  81026. };
  81027. }
  81028. declare module BABYLON {
  81029. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  81030. private _roadColor;
  81031. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81032. updateShaderUniforms(): void;
  81033. get roadColor(): BABYLON.Color3;
  81034. set roadColor(value: BABYLON.Color3);
  81035. /**
  81036. * Serializes this road procedural texture
  81037. * @returns a serialized road procedural texture object
  81038. */
  81039. serialize(): any;
  81040. /**
  81041. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  81042. * @param parsedTexture defines parsed texture data
  81043. * @param scene defines the current scene
  81044. * @param rootUrl defines the root URL containing road procedural texture information
  81045. * @returns a parsed Road Procedural BABYLON.Texture
  81046. */
  81047. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  81048. }
  81049. }
  81050. declare module BABYLON {
  81051. /** @hidden */
  81052. export var starfieldProceduralTexturePixelShader: {
  81053. name: string;
  81054. shader: string;
  81055. };
  81056. }
  81057. declare module BABYLON {
  81058. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  81059. private _time;
  81060. private _alpha;
  81061. private _beta;
  81062. private _zoom;
  81063. private _formuparam;
  81064. private _stepsize;
  81065. private _tile;
  81066. private _brightness;
  81067. private _darkmatter;
  81068. private _distfading;
  81069. private _saturation;
  81070. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81071. updateShaderUniforms(): void;
  81072. get time(): number;
  81073. set time(value: number);
  81074. get alpha(): number;
  81075. set alpha(value: number);
  81076. get beta(): number;
  81077. set beta(value: number);
  81078. get formuparam(): number;
  81079. set formuparam(value: number);
  81080. get stepsize(): number;
  81081. set stepsize(value: number);
  81082. get zoom(): number;
  81083. set zoom(value: number);
  81084. get tile(): number;
  81085. set tile(value: number);
  81086. get brightness(): number;
  81087. set brightness(value: number);
  81088. get darkmatter(): number;
  81089. set darkmatter(value: number);
  81090. get distfading(): number;
  81091. set distfading(value: number);
  81092. get saturation(): number;
  81093. set saturation(value: number);
  81094. /**
  81095. * Serializes this starfield procedural texture
  81096. * @returns a serialized starfield procedural texture object
  81097. */
  81098. serialize(): any;
  81099. /**
  81100. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  81101. * @param parsedTexture defines parsed texture data
  81102. * @param scene defines the current scene
  81103. * @param rootUrl defines the root URL containing startfield procedural texture information
  81104. * @returns a parsed Starfield Procedural BABYLON.Texture
  81105. */
  81106. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  81107. }
  81108. }
  81109. declare module BABYLON {
  81110. /** @hidden */
  81111. export var woodProceduralTexturePixelShader: {
  81112. name: string;
  81113. shader: string;
  81114. };
  81115. }
  81116. declare module BABYLON {
  81117. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  81118. private _ampScale;
  81119. private _woodColor;
  81120. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81121. updateShaderUniforms(): void;
  81122. get ampScale(): number;
  81123. set ampScale(value: number);
  81124. get woodColor(): BABYLON.Color3;
  81125. set woodColor(value: BABYLON.Color3);
  81126. /**
  81127. * Serializes this wood procedural texture
  81128. * @returns a serialized wood procedural texture object
  81129. */
  81130. serialize(): any;
  81131. /**
  81132. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  81133. * @param parsedTexture defines parsed texture data
  81134. * @param scene defines the current scene
  81135. * @param rootUrl defines the root URL containing wood procedural texture information
  81136. * @returns a parsed Wood Procedural BABYLON.Texture
  81137. */
  81138. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  81139. }
  81140. }